libjboss-classloader-java-2.0.6.GA.orig/0000755000175000017500000000000011620043421017713 5ustar twernertwernerlibjboss-classloader-java-2.0.6.GA.orig/classloading-vfs/0000755000175000017500000000000011620043416023156 5ustar twernertwernerlibjboss-classloader-java-2.0.6.GA.orig/classloading-vfs/.classpath0000644000175000017500000001132711155514315025151 0ustar twernertwerner libjboss-classloader-java-2.0.6.GA.orig/classloading-vfs/pom.xml0000644000175000017500000000755711202514647024516 0ustar twernertwerner org.jboss.cl jboss-cl 2.0.6.GA ../build 4.0.0 jboss-classloading-vfs jar JBoss ClassLoading VFS http://www.jboss.org/jbossmc JBoss ClassLoading VFS org.jboss jboss-common-core org.jboss.logging jboss-logging-spi org.jboss.cl jboss-classloading org.jboss.microcontainer jboss-kernel org.jboss.microcontainer jboss-kernel org.jboss jboss-common-core jboss jboss-common-logging-spi org.jboss jbossxb org.jboss jbossxb true org.jboss jboss-reflect org.jboss jboss-common-core jboss jboss-common-logging-spi org.jboss.man jboss-managed true org.jboss jboss-reflect org.jboss jboss-common-core jboss jboss-common-logging-spi org.jboss jboss-vfs org.jboss jboss-common-core jboss jboss-common-logging-spi org.jboss.test jboss-test test junit junit test libjboss-classloader-java-2.0.6.GA.orig/classloading-vfs/src/0000755000175000017500000000000011620043416023745 5ustar twernertwernerlibjboss-classloader-java-2.0.6.GA.orig/classloading-vfs/src/test/0000755000175000017500000000000011620043415024723 5ustar twernertwernerlibjboss-classloader-java-2.0.6.GA.orig/classloading-vfs/src/test/resources/0000755000175000017500000000000011620043416026736 5ustar twernertwernerlibjboss-classloader-java-2.0.6.GA.orig/classloading-vfs/src/test/resources/classloader/0000755000175000017500000000000011620043416031232 5ustar twernertwerner././@LongLink0000000000000000000000000000014600000000000011566 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloading-vfs/src/test/resources/classloader/testwar1.war/libjboss-classloader-java-2.0.6.GA.orig/classloading-vfs/src/test/resources/classloader/testwar1.war0000755000175000017500000000000011620043416033515 5ustar twernertwerner././@LongLink0000000000000000000000000000015700000000000011570 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloading-vfs/src/test/resources/classloader/testwar1.war/META-INF/libjboss-classloader-java-2.0.6.GA.orig/classloading-vfs/src/test/resources/classloader/testwar1.war0000755000175000017500000000000011620043416033515 5ustar twernertwerner././@LongLink0000000000000000000000000000017200000000000011565 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloading-vfs/src/test/resources/classloader/testwar1.war/META-INF/MANIFEST.MFlibjboss-classloader-java-2.0.6.GA.orig/classloading-vfs/src/test/resources/classloader/testwar1.war0000644000175000017500000000007010756304615033526 0ustar twernertwernerManifest-Version: 1.0 Class-Path: testjar1 lib/util.jar ././@LongLink0000000000000000000000000000015600000000000011567 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloading-vfs/src/test/resources/classloader/testwar1.war/WEB-INF/libjboss-classloader-java-2.0.6.GA.orig/classloading-vfs/src/test/resources/classloader/testwar1.war0000755000175000017500000000000011620043416033515 5ustar twernertwerner././@LongLink0000000000000000000000000000017700000000000011572 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloading-vfs/src/test/resources/classloader/testwar1.war/WEB-INF/test-resource.txtlibjboss-classloader-java-2.0.6.GA.orig/classloading-vfs/src/test/resources/classloader/testwar1.war0000644000175000017500000000002210756304615033523 0ustar twernertwernerA WEB-INF resource././@LongLink0000000000000000000000000000016600000000000011570 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloading-vfs/src/test/resources/classloader/testwar1.war/WEB-INF/classes/libjboss-classloader-java-2.0.6.GA.orig/classloading-vfs/src/test/resources/classloader/testwar1.war0000755000175000017500000000000011620043416033515 5ustar twernertwerner././@LongLink0000000000000000000000000000017300000000000011566 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloading-vfs/src/test/resources/classloader/testwar1.war/WEB-INF/classes/test/libjboss-classloader-java-2.0.6.GA.orig/classloading-vfs/src/test/resources/classloader/testwar1.war0000755000175000017500000000000011620043416033515 5ustar twernertwerner././@LongLink0000000000000000000000000000021000000000000011556 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloading-vfs/src/test/resources/classloader/testwar1.war/WEB-INF/classes/test/Servlet.classlibjboss-classloader-java-2.0.6.GA.orig/classloading-vfs/src/test/resources/classloader/testwar1.war0000644000175000017500000000001710756304615033527 0ustar twernertwernerA servlet classlibjboss-classloader-java-2.0.6.GA.orig/classloading-vfs/src/test/resources/classloader/testjar2/0000755000175000017500000000000011620043416032770 5ustar twernertwerner././@LongLink0000000000000000000000000000015300000000000011564 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloading-vfs/src/test/resources/classloader/testjar2/package1/libjboss-classloader-java-2.0.6.GA.orig/classloading-vfs/src/test/resources/classloader/testjar2/pac0000755000175000017500000000000011620043416033454 5ustar twernertwerner././@LongLink0000000000000000000000000000016300000000000011565 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloading-vfs/src/test/resources/classloader/testjar2/package1/notemptylibjboss-classloader-java-2.0.6.GA.orig/classloading-vfs/src/test/resources/classloader/testjar2/pac0000644000175000017500000000002110756304615033461 0ustar twernertwernertestjar2.package1libjboss-classloader-java-2.0.6.GA.orig/classloading-vfs/src/test/resources/classloader/testjar3/0000755000175000017500000000000011620043416032771 5ustar twernertwerner././@LongLink0000000000000000000000000000015300000000000011564 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloading-vfs/src/test/resources/classloader/testjar3/package1/libjboss-classloader-java-2.0.6.GA.orig/classloading-vfs/src/test/resources/classloader/testjar3/pac0000755000175000017500000000000011620043416033455 5ustar twernertwerner././@LongLink0000000000000000000000000000016300000000000011565 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloading-vfs/src/test/resources/classloader/testjar3/package1/notemptylibjboss-classloader-java-2.0.6.GA.orig/classloading-vfs/src/test/resources/classloader/testjar3/pac0000644000175000017500000000002110767534621033466 0ustar twernertwernertestjar3.package1././@LongLink0000000000000000000000000000015600000000000011567 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloading-vfs/src/test/resources/classloader/testjar3/subjar1.jar/libjboss-classloader-java-2.0.6.GA.orig/classloading-vfs/src/test/resources/classloader/testjar3/sub0000755000175000017500000000000011620043416033503 5ustar twernertwerner././@LongLink0000000000000000000000000000016600000000000011570 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloading-vfs/src/test/resources/classloader/testjar3/subjar1.jar/notemptylibjboss-classloader-java-2.0.6.GA.orig/classloading-vfs/src/test/resources/classloader/testjar3/sub0000644000175000017500000000001110767534621033513 0ustar twernertwernertestjar3.././@LongLink0000000000000000000000000000016700000000000011571 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloading-vfs/src/test/resources/classloader/testjar3/subjar1.jar/package2/libjboss-classloader-java-2.0.6.GA.orig/classloading-vfs/src/test/resources/classloader/testjar3/sub0000755000175000017500000000000011620043416033503 5ustar twernertwerner././@LongLink0000000000000000000000000000017700000000000011572 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloading-vfs/src/test/resources/classloader/testjar3/subjar1.jar/package2/notemptylibjboss-classloader-java-2.0.6.GA.orig/classloading-vfs/src/test/resources/classloader/testjar3/sub0000644000175000017500000000002110767534621033514 0ustar twernertwernertestjar3.package2libjboss-classloader-java-2.0.6.GA.orig/classloading-vfs/src/test/resources/classloader/lib/0000755000175000017500000000000011620043416032000 5ustar twernertwerner././@LongLink0000000000000000000000000000014600000000000011566 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloading-vfs/src/test/resources/classloader/lib/util.jar/libjboss-classloader-java-2.0.6.GA.orig/classloading-vfs/src/test/resources/classloader/lib/util.jar0000755000175000017500000000000011620043416033451 5ustar twernertwernerlibjboss-classloader-java-2.0.6.GA.orig/classloading-vfs/src/test/resources/classloader/testjar1/0000755000175000017500000000000011620043416032767 5ustar twernertwerner././@LongLink0000000000000000000000000000015300000000000011564 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloading-vfs/src/test/resources/classloader/testjar1/package1/libjboss-classloader-java-2.0.6.GA.orig/classloading-vfs/src/test/resources/classloader/testjar1/pac0000755000175000017500000000000011620043416033453 5ustar twernertwerner././@LongLink0000000000000000000000000000016300000000000011565 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloading-vfs/src/test/resources/classloader/testjar1/package1/notemptylibjboss-classloader-java-2.0.6.GA.orig/classloading-vfs/src/test/resources/classloader/testjar1/pac0000644000175000017500000000002110756304615033460 0ustar twernertwernertestjar1.package1././@LongLink0000000000000000000000000000015200000000000011563 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloading-vfs/src/test/resources/classloader/testjar1/notemptylibjboss-classloader-java-2.0.6.GA.orig/classloading-vfs/src/test/resources/classloader/testjar1/not0000644000175000017500000000001110756304615033514 0ustar twernertwernertestjar1.././@LongLink0000000000000000000000000000015300000000000011564 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloading-vfs/src/test/resources/classloader/testjar1/package2/libjboss-classloader-java-2.0.6.GA.orig/classloading-vfs/src/test/resources/classloader/testjar1/pac0000755000175000017500000000000011620043416033453 5ustar twernertwerner././@LongLink0000000000000000000000000000016700000000000011571 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloading-vfs/src/test/resources/classloader/testjar1/package2/subpackage3/libjboss-classloader-java-2.0.6.GA.orig/classloading-vfs/src/test/resources/classloader/testjar1/pac0000755000175000017500000000000011620043416033453 5ustar twernertwerner././@LongLink0000000000000000000000000000017700000000000011572 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloading-vfs/src/test/resources/classloader/testjar1/package2/subpackage3/notemptylibjboss-classloader-java-2.0.6.GA.orig/classloading-vfs/src/test/resources/classloader/testjar1/pac0000644000175000017500000000003510756304615033465 0ustar twernertwernertestjar1.package2.subpackage3././@LongLink0000000000000000000000000000016300000000000011565 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloading-vfs/src/test/resources/classloader/testjar1/package2/notemptylibjboss-classloader-java-2.0.6.GA.orig/classloading-vfs/src/test/resources/classloader/testjar1/pac0000644000175000017500000000002110756304615033460 0ustar twernertwernertestjar1.package2././@LongLink0000000000000000000000000000016700000000000011571 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloading-vfs/src/test/resources/classloader/testjar1/package2/subpackage1/libjboss-classloader-java-2.0.6.GA.orig/classloading-vfs/src/test/resources/classloader/testjar1/pac0000755000175000017500000000000011620043416033453 5ustar twernertwerner././@LongLink0000000000000000000000000000017700000000000011572 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloading-vfs/src/test/resources/classloader/testjar1/package2/subpackage1/notemptylibjboss-classloader-java-2.0.6.GA.orig/classloading-vfs/src/test/resources/classloader/testjar1/pac0000644000175000017500000000003510756304615033465 0ustar twernertwernertestjar1.package2.subpackage1././@LongLink0000000000000000000000000000016700000000000011571 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloading-vfs/src/test/resources/classloader/testjar1/package2/subpackage2/libjboss-classloader-java-2.0.6.GA.orig/classloading-vfs/src/test/resources/classloader/testjar1/pac0000755000175000017500000000000011620043416033453 5ustar twernertwerner././@LongLink0000000000000000000000000000017700000000000011572 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloading-vfs/src/test/resources/classloader/testjar1/package2/subpackage2/notemptylibjboss-classloader-java-2.0.6.GA.orig/classloading-vfs/src/test/resources/classloader/testjar1/pac0000644000175000017500000000003510756304615033465 0ustar twernertwernertestjar1.package2.subpackage2././@LongLink0000000000000000000000000000014600000000000011566 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloading-vfs/src/test/resources/classloader/testear1x.earlibjboss-classloader-java-2.0.6.GA.orig/classloading-vfs/src/test/resources/classloader/testear1x.ea0000644000175000017500000000416411063454005033467 0ustar twernertwernerPKít68iëÔE„ejb1.jarUT žp–Gƒ—ÌHUxõP ðffáb363 $ÀÊ ÊPn¨ÂÉÀ¬±nªû¼‚iî¡, _¿0Àõ%¢éã‚éKÍJ*†h.Å©Yp¿)ŠfiÍÁ©ÅÅ™ùyN©‰yºÉ9‰ÅÅ`Ó6.œê®ž‰Í´t4§ðÀLËLKLN…:¦ §cú˜PµK¡i÷„ºÉ->Ëq¹eënS ‹³÷¬¥À10 +-N-*Ö+(Ê/H-*ÉL…‘6Õˆ‚Ä’ Û’Ôâ’ÔÄ"C=  C½¬Ä¢oF&qf\±Å e 0üuÑиc…Ä]h²~ÌXCÖoÓCVH¢‚{¼pö–ÆRC°Ä%+$.ÑMÅŒEd§†™ SVHœ¢ƒ›ÈŽcbdÀ·¬¸E73V!†2‚ õR˜qÌ ‰cˆQ¬l ål@x¨x HPK m®-9lib/UT M˜ÌH[˜ÌHUxõPPKüp/9è§d¾êF lib/jar1.jarUT PÎH"PÎHUxôô ðffaàÂ?ú– H€“…Á×5ÄQ×ÓÏMÿß)f†ovTINÍ"@ ×ìëèç鿢çëÖÛïïØ€çèû©¿dkîðyŠ)¶¼XûØ ëFê=ßÈÇ›|b…–еæ÷k«}\îsë褷ßï“z/õÆca©Þ¦-sžÞt>rËtÙã/Veê(͘T7=&ôõ¶¬ósŸLJ7çä](ú¹_ñaÐ9³_Nµ¼“މ-ü´uγȗõNe¼’e:£È4a5s6ÿ‹—âßóävñÍ[[]Ü,èĬ½e{[Ü?¹]nùÎVVÇN¿ç_:­»èÈïMݧÄ6(wµÕÞ?ýwÚáõ¯äWN<ÞÝ6aâ£ÌÒz¡ééóAAóZ«ñ&Ðã !AÊN´ aâÒ’Ì}„’£^fÈJaJ‚3‹RSô’s‹‹=ÃU¹HyqjQ±^AQ~AjQIfj±¶‡ÎÉ ºžºzž¾:FW˜…~YÎôü©À7‹§o\Ù( Ô&ŽEF&Ôx„Å0( ”$®9DP´ÙâH ¸p‡D0Âà ¡[È!@5#ÖpD¸’ÈA!€¢}#f¸x³²AÜÆÊ  ”g‡PK«s68E*$«lwar1.warUT Bn–Gƒ—ÌHUxõP ðffáb363 $ÀÉ Êàëâ¨ëéç¦ÂÉÀ¬±nª»SÞ4÷Ð †/Œ_àzö›Z0ý9}RÈad½¾Ž~žn®Á!z¾n`c8MuŸ—0Æ71/3-µ¸D7,µ¨83?ÏJÁPÏ€Ë9'±¸X7 ±$ÃJ!'3I?+±ÈPHpàt1ÐÖpW'ü+|¼ÛÔâWŽÀ=y O ˆ%´–Ý¡WP”_ZT’™Z 6jçlTGk{èœÜ ë©«çé«ct…Yè×S7± ‚ï^-yýò9‘Ü9¦[·ë¤ Ù ,‰dS È×E©Åù¥EÉ©z%%`«RùQ­rT€ªW€)ÅH¦'ƒB0µ˜PÜ¡!‚ňòÔ$\Æ02‰3ãJ@¼pWýuÑHɉbVh²˜ b#oi´A6%Y±B’ºq˜)ÙI›€4"½`¸WJAvÑ[$#0Ó +$Ý » 3I ÎÈ€/°B!Ÿ  øt+’™ˆd#0²Q?°I(Ʊ²4°¡8ƒ=ˆPKh«-9]©?H– lib/jar2.jarUT £’ÌHƒ—ÌHUxõP ðffaàÂôÕº– H€“…Á×5ÄQ×ÓÏMÿß)f†ovTINÍ"@ ×ìëèç鿢çëöÙ÷Ìio]½‹¼ÞºZçΜßdpÅøÁÓ"=/_Oß‹¥«X8g¼’<"-¥a!&òd‰VÅ3Õ×™ŸŠ>1‚mïñœÿÕh¶ Ôv.°máh¶³qiIfŽ>BIš˜’âÒ¤‚ÄäìÄôT<ªe±¨vÌË/ÉH-ÒMÎI,.ðfda@ X( +ºVd/Š h³Å¨ ¸pìF B ¶ A€{X ·nYÝ<ŒŽ• âNVK bwFPKít68iëÔE„ ¤ejb1.jarUTžp–GUxPK m®-9 ýA€lib/UTM˜ÌHUxPKüp/9è§d¾êF ´·lib/jar1.jarUTPÎHUxPK«s68E*$«l ¤àwar1.warUTBn–GUxPKh«-9]©?H– ¤Ælib/jar2.jarUT£’ÌHUxPKS libjboss-classloader-java-2.0.6.GA.orig/classloading-vfs/src/test/resources/org/0000755000175000017500000000000011620043415027524 5ustar twernertwernerlibjboss-classloader-java-2.0.6.GA.orig/classloading-vfs/src/test/resources/org/jboss/0000755000175000017500000000000011620043415030644 5ustar twernertwernerlibjboss-classloader-java-2.0.6.GA.orig/classloading-vfs/src/test/resources/org/jboss/test/0000755000175000017500000000000011620043415031623 5ustar twernertwerner././@LongLink0000000000000000000000000000015100000000000011562 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloading-vfs/src/test/resources/org/jboss/test/classloading/libjboss-classloader-java-2.0.6.GA.orig/classloading-vfs/src/test/resources/org/jboss/test/classload0000755000175000017500000000000011620043415033511 5ustar twernertwerner././@LongLink0000000000000000000000000000015500000000000011566 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloading-vfs/src/test/resources/org/jboss/test/classloading/vfs/libjboss-classloader-java-2.0.6.GA.orig/classloading-vfs/src/test/resources/org/jboss/test/classload0000755000175000017500000000000011620043416033512 5ustar twernertwerner././@LongLink0000000000000000000000000000017000000000000011563 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloading-vfs/src/test/resources/org/jboss/test/classloading/vfs/client.jar/libjboss-classloader-java-2.0.6.GA.orig/classloading-vfs/src/test/resources/org/jboss/test/classload0000755000175000017500000000000011620043416033512 5ustar twernertwerner././@LongLink0000000000000000000000000000020100000000000011556 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloading-vfs/src/test/resources/org/jboss/test/classloading/vfs/client.jar/META-INF/libjboss-classloader-java-2.0.6.GA.orig/classloading-vfs/src/test/resources/org/jboss/test/classload0000755000175000017500000000000011620043416033512 5ustar twernertwerner././@LongLink0000000000000000000000000000021400000000000011562 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloading-vfs/src/test/resources/org/jboss/test/classloading/vfs/client.jar/META-INF/MANIFEST.MFlibjboss-classloader-java-2.0.6.GA.orig/classloading-vfs/src/test/resources/org/jboss/test/classload0000644000175000017500000000020111042271742033510 0ustar twernertwernerManifest-Version: 1.0 Main-Class: org.jboss.test.classloading.vfs.client.support.main.Client Class-Path: lib.jar ../../../../../ ././@LongLink0000000000000000000000000000016600000000000011570 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloading-vfs/src/test/resources/org/jboss/test/classloading/vfs/metadata/libjboss-classloader-java-2.0.6.GA.orig/classloading-vfs/src/test/resources/org/jboss/test/classload0000755000175000017500000000000011620043416033512 5ustar twernertwerner././@LongLink0000000000000000000000000000017300000000000011566 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloading-vfs/src/test/resources/org/jboss/test/classloading/vfs/metadata/test/libjboss-classloader-java-2.0.6.GA.orig/classloading-vfs/src/test/resources/org/jboss/test/classload0000755000175000017500000000000011620043416033512 5ustar twernertwerner././@LongLink0000000000000000000000000000023300000000000011563 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloading-vfs/src/test/resources/org/jboss/test/classloading/vfs/metadata/test/GeneratedClassesUnitTestCase.xmllibjboss-classloader-java-2.0.6.GA.orig/classloading-vfs/src/test/resources/org/jboss/test/classload0000644000175000017500000000065711173151646033534 0ustar twernertwerner ././@LongLink0000000000000000000000000000020500000000000011562 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloading-vfs/src/test/resources/org/jboss/test/classloading/vfs/metadata/test/B1.0.0.xmllibjboss-classloader-java-2.0.6.GA.orig/classloading-vfs/src/test/resources/org/jboss/test/classload0000644000175000017500000000043610756304615033531 0ustar twernertwerner ././@LongLink0000000000000000000000000000021000000000000011556 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloading-vfs/src/test/resources/org/jboss/test/classloading/vfs/metadata/test/SmokeTest.xmllibjboss-classloader-java-2.0.6.GA.orig/classloading-vfs/src/test/resources/org/jboss/test/classload0000644000175000017500000000025710756304615033532 0ustar twernertwerner ././@LongLink0000000000000000000000000000020500000000000011562 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloading-vfs/src/test/resources/org/jboss/test/classloading/vfs/metadata/test/A1.0.0.xmllibjboss-classloader-java-2.0.6.GA.orig/classloading-vfs/src/test/resources/org/jboss/test/classload0000644000175000017500000000027410756304615033531 0ustar twernertwerner ././@LongLink0000000000000000000000000000022500000000000011564 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloading-vfs/src/test/resources/org/jboss/test/classloading/vfs/metadata/test/VFSResourceVisitorTest.xmllibjboss-classloader-java-2.0.6.GA.orig/classloading-vfs/src/test/resources/org/jboss/test/classload0000644000175000017500000000040411005334164033512 0ustar twernertwerner ${test.dir}/support/ ././@LongLink0000000000000000000000000000017200000000000011565 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloading-vfs/src/test/resources/org/jboss/test/classloading/vfs/metadata/xml/libjboss-classloader-java-2.0.6.GA.orig/classloading-vfs/src/test/resources/org/jboss/test/classload0000755000175000017500000000000011620043416033512 5ustar twernertwerner././@LongLink0000000000000000000000000000017700000000000011572 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloading-vfs/src/test/resources/org/jboss/test/classloading/vfs/metadata/xml/test/libjboss-classloader-java-2.0.6.GA.orig/classloading-vfs/src/test/resources/org/jboss/test/classload0000755000175000017500000000000011620043416033512 5ustar twernertwerner././@LongLink0000000000000000000000000000022100000000000011560 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloading-vfs/src/test/resources/org/jboss/test/classloading/vfs/metadata/xml/test/ModuleExcluded.xmllibjboss-classloader-java-2.0.6.GA.orig/classloading-vfs/src/test/resources/org/jboss/test/classload0000644000175000017500000000022510756304615033525 0ustar twernertwerner ././@LongLink0000000000000000000000000000022500000000000011564 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloading-vfs/src/test/resources/org/jboss/test/classloading/vfs/metadata/xml/test/ImportVersionRange.xmllibjboss-classloader-java-2.0.6.GA.orig/classloading-vfs/src/test/resources/org/jboss/test/classload0000644000175000017500000000133210756304615033525 0ustar twernertwerner ././@LongLink0000000000000000000000000000023400000000000011564 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloading-vfs/src/test/resources/org/jboss/test/classloading/vfs/metadata/xml/test/ImportOnePackageVersioned.xmllibjboss-classloader-java-2.0.6.GA.orig/classloading-vfs/src/test/resources/org/jboss/test/classload0000644000175000017500000000033610756304615033530 0ustar twernertwerner ././@LongLink0000000000000000000000000000022600000000000011565 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloading-vfs/src/test/resources/org/jboss/test/classloading/vfs/metadata/xml/test/ImportThreePackages.xmllibjboss-classloader-java-2.0.6.GA.orig/classloading-vfs/src/test/resources/org/jboss/test/classload0000644000175000017500000000051610756304615033530 0ustar twernertwerner ././@LongLink0000000000000000000000000000023300000000000011563 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloading-vfs/src/test/resources/org/jboss/test/classloading/vfs/metadata/xml/test/ExportOneModuleVersioned.xmllibjboss-classloader-java-2.0.6.GA.orig/classloading-vfs/src/test/resources/org/jboss/test/classload0000644000175000017500000000032510756304615033526 0ustar twernertwerner ././@LongLink0000000000000000000000000000022000000000000011557 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloading-vfs/src/test/resources/org/jboss/test/classloading/vfs/metadata/xml/test/ModuleVersion.xmllibjboss-classloader-java-2.0.6.GA.orig/classloading-vfs/src/test/resources/org/jboss/test/classload0000644000175000017500000000023710756304615033530 0ustar twernertwerner ././@LongLink0000000000000000000000000000023300000000000011563 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloading-vfs/src/test/resources/org/jboss/test/classloading/vfs/metadata/xml/test/ExportOneModuleNoVersion.xmllibjboss-classloader-java-2.0.6.GA.orig/classloading-vfs/src/test/resources/org/jboss/test/classload0000644000175000017500000000030510756304615033524 0ustar twernertwerner ././@LongLink0000000000000000000000000000022500000000000011564 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloading-vfs/src/test/resources/org/jboss/test/classloading/vfs/metadata/xml/test/ImportThreeModules.xmllibjboss-classloader-java-2.0.6.GA.orig/classloading-vfs/src/test/resources/org/jboss/test/classload0000644000175000017500000000051310756304615033525 0ustar twernertwerner ././@LongLink0000000000000000000000000000022200000000000011561 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloading-vfs/src/test/resources/org/jboss/test/classloading/vfs/metadata/xml/test/UsesRequirement.xmllibjboss-classloader-java-2.0.6.GA.orig/classloading-vfs/src/test/resources/org/jboss/test/classload0000644000175000017500000000031610756304615033526 0ustar twernertwerner ././@LongLink0000000000000000000000000000023400000000000011564 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloading-vfs/src/test/resources/org/jboss/test/classloading/vfs/metadata/xml/test/ImportOnePackageNoVersion.xmllibjboss-classloader-java-2.0.6.GA.orig/classloading-vfs/src/test/resources/org/jboss/test/classload0000644000175000017500000000030610756304615033525 0ustar twernertwerner ././@LongLink0000000000000000000000000000022000000000000011557 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloading-vfs/src/test/resources/org/jboss/test/classloading/vfs/metadata/xml/test/ModuleContext.xmllibjboss-classloader-java-2.0.6.GA.orig/classloading-vfs/src/test/resources/org/jboss/test/classload0000644000175000017500000000024110756304615033523 0ustar twernertwerner ././@LongLink0000000000000000000000000000022200000000000011561 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloading-vfs/src/test/resources/org/jboss/test/classloading/vfs/metadata/xml/test/ModuleBlackList.xmllibjboss-classloader-java-2.0.6.GA.orig/classloading-vfs/src/test/resources/org/jboss/test/classload0000644000175000017500000000024110756304615033523 0ustar twernertwerner ././@LongLink0000000000000000000000000000022500000000000011564 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloading-vfs/src/test/resources/org/jboss/test/classloading/vfs/metadata/xml/test/ModuleParentDomain.xmllibjboss-classloader-java-2.0.6.GA.orig/classloading-vfs/src/test/resources/org/jboss/test/classload0000644000175000017500000000026010756304615033524 0ustar twernertwerner ././@LongLink0000000000000000000000000000022500000000000011564 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloading-vfs/src/test/resources/org/jboss/test/classloading/vfs/metadata/xml/test/WildcardCapability.xmllibjboss-classloader-java-2.0.6.GA.orig/classloading-vfs/src/test/resources/org/jboss/test/classload0000644000175000017500000000053510756304615033531 0ustar twernertwerner ././@LongLink0000000000000000000000000000021700000000000011565 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloading-vfs/src/test/resources/org/jboss/test/classloading/vfs/metadata/xml/test/ModuleDomain.xmllibjboss-classloader-java-2.0.6.GA.orig/classloading-vfs/src/test/resources/org/jboss/test/classload0000644000175000017500000000024310756304615033525 0ustar twernertwerner ././@LongLink0000000000000000000000000000022100000000000011560 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloading-vfs/src/test/resources/org/jboss/test/classloading/vfs/metadata/xml/test/ModuleIncluded.xmllibjboss-classloader-java-2.0.6.GA.orig/classloading-vfs/src/test/resources/org/jboss/test/classload0000644000175000017500000000022510756304615033525 0ustar twernertwerner ././@LongLink0000000000000000000000000000022600000000000011565 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloading-vfs/src/test/resources/org/jboss/test/classloading/vfs/metadata/xml/test/ReExportRequirement.xmllibjboss-classloader-java-2.0.6.GA.orig/classloading-vfs/src/test/resources/org/jboss/test/classload0000644000175000017500000000043310756304615033526 0ustar twernertwerner ././@LongLink0000000000000000000000000000021700000000000011565 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloading-vfs/src/test/resources/org/jboss/test/classloading/vfs/metadata/xml/test/ModuleSystem.xmllibjboss-classloader-java-2.0.6.GA.orig/classloading-vfs/src/test/resources/org/jboss/test/classload0000644000175000017500000000023710756304615033530 0ustar twernertwerner ././@LongLink0000000000000000000000000000023400000000000011564 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloading-vfs/src/test/resources/org/jboss/test/classloading/vfs/metadata/xml/test/ExportOnePackageVersioned.xmllibjboss-classloader-java-2.0.6.GA.orig/classloading-vfs/src/test/resources/org/jboss/test/classload0000644000175000017500000000032610756304615033527 0ustar twernertwerner ././@LongLink0000000000000000000000000000023300000000000011563 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloading-vfs/src/test/resources/org/jboss/test/classloading/vfs/metadata/xml/test/ImportOneModuleNoVersion.xmllibjboss-classloader-java-2.0.6.GA.orig/classloading-vfs/src/test/resources/org/jboss/test/classload0000644000175000017500000000030510756304615033524 0ustar twernertwerner ././@LongLink0000000000000000000000000000022600000000000011565 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloading-vfs/src/test/resources/org/jboss/test/classloading/vfs/metadata/xml/test/OptionalRequirement.xmllibjboss-classloader-java-2.0.6.GA.orig/classloading-vfs/src/test/resources/org/jboss/test/classload0000644000175000017500000000043310756304615033526 0ustar twernertwerner ././@LongLink0000000000000000000000000000021600000000000011564 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloading-vfs/src/test/resources/org/jboss/test/classloading/vfs/metadata/xml/test/ModuleCache.xmllibjboss-classloader-java-2.0.6.GA.orig/classloading-vfs/src/test/resources/org/jboss/test/classload0000644000175000017500000000023510756304615033526 0ustar twernertwerner ././@LongLink0000000000000000000000000000021500000000000011563 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloading-vfs/src/test/resources/org/jboss/test/classloading/vfs/metadata/xml/test/ModuleName.xmllibjboss-classloader-java-2.0.6.GA.orig/classloading-vfs/src/test/resources/org/jboss/test/classload0000644000175000017500000000020110756304615033517 0ustar twernertwerner ././@LongLink0000000000000000000000000000022400000000000011563 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloading-vfs/src/test/resources/org/jboss/test/classloading/vfs/metadata/xml/test/ExportImportMixed.xmllibjboss-classloader-java-2.0.6.GA.orig/classloading-vfs/src/test/resources/org/jboss/test/classload0000644000175000017500000000105311173151646033523 0ustar twernertwerner ././@LongLink0000000000000000000000000000022200000000000011561 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloading-vfs/src/test/resources/org/jboss/test/classloading/vfs/metadata/xml/test/ModuleImportAll.xmllibjboss-classloader-java-2.0.6.GA.orig/classloading-vfs/src/test/resources/org/jboss/test/classload0000644000175000017500000000024110756304615033523 0ustar twernertwerner ././@LongLink0000000000000000000000000000024300000000000011564 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloading-vfs/src/test/resources/org/jboss/test/classloading/vfs/metadata/xml/test/ModuleJ2seClassLoadingCompliance.xmllibjboss-classloader-java-2.0.6.GA.orig/classloading-vfs/src/test/resources/org/jboss/test/classload0000644000175000017500000000024410756304615033526 0ustar twernertwerner ././@LongLink0000000000000000000000000000023300000000000011563 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloading-vfs/src/test/resources/org/jboss/test/classloading/vfs/metadata/xml/test/ImportOneModuleVersioned.xmllibjboss-classloader-java-2.0.6.GA.orig/classloading-vfs/src/test/resources/org/jboss/test/classload0000644000175000017500000000033510756304615033527 0ustar twernertwerner ././@LongLink0000000000000000000000000000022600000000000011565 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloading-vfs/src/test/resources/org/jboss/test/classloading/vfs/metadata/xml/test/WildcardRequirement.xmllibjboss-classloader-java-2.0.6.GA.orig/classloading-vfs/src/test/resources/org/jboss/test/classload0000644000175000017500000000052510756304615033530 0ustar twernertwerner ././@LongLink0000000000000000000000000000023400000000000011564 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloading-vfs/src/test/resources/org/jboss/test/classloading/vfs/metadata/xml/test/ExportOnePackageNoVersion.xmllibjboss-classloader-java-2.0.6.GA.orig/classloading-vfs/src/test/resources/org/jboss/test/classload0000644000175000017500000000030610756304615033525 0ustar twernertwerner ././@LongLink0000000000000000000000000000022200000000000011561 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloading-vfs/src/test/resources/org/jboss/test/classloading/vfs/metadata/xml/test/ModuleExportAll.xmllibjboss-classloader-java-2.0.6.GA.orig/classloading-vfs/src/test/resources/org/jboss/test/classload0000644000175000017500000000024010756304615033522 0ustar twernertwerner ././@LongLink0000000000000000000000000000021600000000000011564 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloading-vfs/src/test/resources/org/jboss/test/classloading/vfs/metadata/xml/test/ModuleRoots.xmllibjboss-classloader-java-2.0.6.GA.orig/classloading-vfs/src/test/resources/org/jboss/test/classload0000644000175000017500000000030310756304615033522 0ustar twernertwerner root1 root2 root3 ././@LongLink0000000000000000000000000000022500000000000011564 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloading-vfs/src/test/resources/org/jboss/test/classloading/vfs/metadata/xml/test/DynamicRequirement.xmllibjboss-classloader-java-2.0.6.GA.orig/classloading-vfs/src/test/resources/org/jboss/test/classload0000644000175000017500000000043110761314167033523 0ustar twernertwerner ././@LongLink0000000000000000000000000000022700000000000011566 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloading-vfs/src/test/resources/org/jboss/test/classloading/vfs/metadata/xml/test/ModuleExcludedExport.xmllibjboss-classloader-java-2.0.6.GA.orig/classloading-vfs/src/test/resources/org/jboss/test/classload0000644000175000017500000000024110756304615033523 0ustar twernertwerner ././@LongLink0000000000000000000000000000022600000000000011565 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloading-vfs/src/test/resources/org/jboss/test/classloading/vfs/metadata/xml/test/ExportThreePackages.xmllibjboss-classloader-java-2.0.6.GA.orig/classloading-vfs/src/test/resources/org/jboss/test/classload0000644000175000017500000000046610756304615033534 0ustar twernertwerner ././@LongLink0000000000000000000000000000022500000000000011564 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloading-vfs/src/test/resources/org/jboss/test/classloading/vfs/metadata/xml/test/ExportThreeModules.xmllibjboss-classloader-java-2.0.6.GA.orig/classloading-vfs/src/test/resources/org/jboss/test/classload0000644000175000017500000000046310756304615033531 0ustar twernertwerner ././@LongLink0000000000000000000000000000020000000000000011555 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloading-vfs/src/test/resources/org/jboss/test/classloading/vfs/metadata/Common.xmllibjboss-classloader-java-2.0.6.GA.orig/classloading-vfs/src/test/resources/org/jboss/test/classload0000644000175000017500000000252711173151646033532 0ustar twernertwerner urn:jboss:classloader:1.0 org.jboss.classloading.spi.vfs.metadata.VFSClassLoaderFactory10 urn:jboss:classloading:1.0 org.jboss.classloading.spi.metadata.ClassLoadingMetaData10 ././@LongLink0000000000000000000000000000016500000000000011567 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloading-vfs/src/test/resources/org/jboss/test/classloading/vfs/lib.jar/libjboss-classloader-java-2.0.6.GA.orig/classloading-vfs/src/test/resources/org/jboss/test/classload0000755000175000017500000000000011620043416033512 5ustar twernertwerner././@LongLink0000000000000000000000000000017200000000000011565 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloading-vfs/src/test/resources/org/jboss/test/classloading/vfs/lib.jar/emptylibjboss-classloader-java-2.0.6.GA.orig/classloading-vfs/src/test/resources/org/jboss/test/classload0000644000175000017500000000000511042334447033514 0ustar twernertwerneremptylibjboss-classloader-java-2.0.6.GA.orig/classloading-vfs/src/test/resources/classes/0000755000175000017500000000000011620043416030373 5ustar twernertwernerlibjboss-classloader-java-2.0.6.GA.orig/classloading-vfs/src/test/resources/classes/newpackage/0000755000175000017500000000000011620043416032500 5ustar twernertwerner././@LongLink0000000000000000000000000000016400000000000011566 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloading-vfs/src/test/resources/classes/newpackage/GeneratedClass.classlibjboss-classloader-java-2.0.6.GA.orig/classloading-vfs/src/test/resources/classes/newpackage/Gener0000644000175000017500000000044111137575176033502 0ustar twernertwernerÊþº¾1newpackage/GeneratedClassjava/lang/Object()VCode  LineNumberTableLocalVariableTablethisLnewpackage/GeneratedClass; SourceFileGeneratedClass.java!/*·±   libjboss-classloader-java-2.0.6.GA.orig/classloading-vfs/src/test/resources/classes/org/0000755000175000017500000000000011620043416031162 5ustar twernertwernerlibjboss-classloader-java-2.0.6.GA.orig/classloading-vfs/src/test/resources/classes/org/jboss/0000755000175000017500000000000011620043416032302 5ustar twernertwernerlibjboss-classloader-java-2.0.6.GA.orig/classloading-vfs/src/test/resources/classes/org/jboss/test/0000755000175000017500000000000011620043416033261 5ustar twernertwerner././@LongLink0000000000000000000000000000016100000000000011563 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloading-vfs/src/test/resources/classes/org/jboss/test/classloading/libjboss-classloader-java-2.0.6.GA.orig/classloading-vfs/src/test/resources/classes/org/jboss/test/c0000755000175000017500000000000011620043416033424 5ustar twernertwerner././@LongLink0000000000000000000000000000016500000000000011567 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloading-vfs/src/test/resources/classes/org/jboss/test/classloading/vfs/libjboss-classloader-java-2.0.6.GA.orig/classloading-vfs/src/test/resources/classes/org/jboss/test/c0000755000175000017500000000000011620043416033424 5ustar twernertwerner././@LongLink0000000000000000000000000000017600000000000011571 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloading-vfs/src/test/resources/classes/org/jboss/test/classloading/vfs/metadata/libjboss-classloader-java-2.0.6.GA.orig/classloading-vfs/src/test/resources/classes/org/jboss/test/c0000755000175000017500000000000011620043416033424 5ustar twernertwerner././@LongLink0000000000000000000000000000020600000000000011563 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloading-vfs/src/test/resources/classes/org/jboss/test/classloading/vfs/metadata/support/libjboss-classloader-java-2.0.6.GA.orig/classloading-vfs/src/test/resources/classes/org/jboss/test/c0000755000175000017500000000000011620043416033424 5ustar twernertwerner././@LongLink0000000000000000000000000000021000000000000011556 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloading-vfs/src/test/resources/classes/org/jboss/test/classloading/vfs/metadata/support/a/libjboss-classloader-java-2.0.6.GA.orig/classloading-vfs/src/test/resources/classes/org/jboss/test/c0000755000175000017500000000000011620043416033424 5ustar twernertwerner././@LongLink0000000000000000000000000000023400000000000011564 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloading-vfs/src/test/resources/classes/org/jboss/test/classloading/vfs/metadata/support/a/GeneratedClass.classlibjboss-classloader-java-2.0.6.GA.orig/classloading-vfs/src/test/resources/classes/org/jboss/test/c0000644000175000017500000000056111137575176033450 0ustar twernertwernerÊþº¾1Aorg/jboss/test/classloading/vfs/metadata/support/a/GeneratedClassjava/lang/Object()VCode  LineNumberTableLocalVariableTablethisCLorg/jboss/test/classloading/vfs/metadata/support/a/GeneratedClass; SourceFileGeneratedClass.java!/*·±   libjboss-classloader-java-2.0.6.GA.orig/classloading-vfs/src/test/resources/classes/otherpackage/0000755000175000017500000000000011620043416033030 5ustar twernertwerner././@LongLink0000000000000000000000000000016600000000000011570 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloading-vfs/src/test/resources/classes/otherpackage/GeneratedClass.classlibjboss-classloader-java-2.0.6.GA.orig/classloading-vfs/src/test/resources/classes/otherpackage/Gen0000644000175000017500000000044511173151646033477 0ustar twernertwernerÊþº¾1otherpackage/GeneratedClassjava/lang/Object()VCode  LineNumberTableLocalVariableTablethisLotherpackage/GeneratedClass; SourceFileGeneratedClass.java!/*·±   ././@LongLink0000000000000000000000000000016000000000000011562 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloading-vfs/src/test/resources/classes/DefaultGeneratedClass.classlibjboss-classloader-java-2.0.6.GA.orig/classloading-vfs/src/test/resources/classes/DefaultGenerated0000644000175000017500000000044011137575176033537 0ustar twernertwernerÊþº¾1DefaultGeneratedClassjava/lang/Object()VCode  LineNumberTableLocalVariableTablethisLDefaultGeneratedClass; SourceFileDefaultGeneratedClass.java!/*·±   libjboss-classloader-java-2.0.6.GA.orig/classloading-vfs/src/test/java/0000755000175000017500000000000011620043414025643 5ustar twernertwernerlibjboss-classloader-java-2.0.6.GA.orig/classloading-vfs/src/test/java/org/0000755000175000017500000000000011620043414026432 5ustar twernertwernerlibjboss-classloader-java-2.0.6.GA.orig/classloading-vfs/src/test/java/org/jboss/0000755000175000017500000000000011620043415027553 5ustar twernertwernerlibjboss-classloader-java-2.0.6.GA.orig/classloading-vfs/src/test/java/org/jboss/test/0000755000175000017500000000000011620043415030532 5ustar twernertwernerlibjboss-classloader-java-2.0.6.GA.orig/classloading-vfs/src/test/java/org/jboss/test/classloading/0000755000175000017500000000000011620043415033175 5ustar twernertwerner././@LongLink0000000000000000000000000000020100000000000011556 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloading-vfs/src/test/java/org/jboss/test/classloading/ClassLoadingVFSTestSuite.javalibjboss-classloader-java-2.0.6.GA.orig/classloading-vfs/src/test/java/org/jboss/test/classloading/C0000644000175000017500000000771311173151646033323 0ustar twernertwerner/* * JBoss, Home of Professional Open Source. * Copyright 2008, Red Hat Middleware LLC, and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.test.classloading; import junit.framework.Test; import junit.framework.TestSuite; import junit.textui.TestRunner; import org.jboss.test.classloading.vfs.client.test.ClientClassPathUnitTestCase; import org.jboss.test.classloading.vfs.metadata.test.DomainUnitTestCase; import org.jboss.test.classloading.vfs.metadata.test.GeneratedClassesUnitTestCase; import org.jboss.test.classloading.vfs.metadata.test.ImportAllUnitTestCase; import org.jboss.test.classloading.vfs.metadata.test.ManagedObjectVFSClassLoaderFactoryUnitTestCase; import org.jboss.test.classloading.vfs.metadata.test.ModuleDependencyUnitTestCase; import org.jboss.test.classloading.vfs.metadata.test.PackageDependencyUnitTestCase; import org.jboss.test.classloading.vfs.metadata.test.ReExportModuleUnitTestCase; import org.jboss.test.classloading.vfs.metadata.test.ReExportPackageUnitTestCase; import org.jboss.test.classloading.vfs.metadata.test.UsesPackageUnitTestCase; import org.jboss.test.classloading.vfs.metadata.test.VFSClassLoaderFactoryUnitTestCase; import org.jboss.test.classloading.vfs.metadata.test.VFSResourceVisitorUnitTestCase; import org.jboss.test.classloading.vfs.metadata.xml.test.VFSClassLoaderFactoryXMLUnitTestCase; import org.jboss.test.classloading.vfs.metadata.xml.test.NoopClassLoaderFactoryXMLUnitTestCase; import org.jboss.test.classloading.vfs.policy.test.ExportAllUnitTestCase; import org.jboss.test.classloading.vfs.policy.test.PackageInfoUnitTestCase; /** * ClassLoading VFS Test Suite. * * @author Adrian Brock * @version $Revision: 37459 $ */ public class ClassLoadingVFSTestSuite extends TestSuite { /** * For running the testsuite from the command line * * @param args the command line args */ public static void main(String[] args) { TestRunner.run(suite()); } /** * Create the testsuite * * @return the testsuite */ public static Test suite() { TestSuite suite = new TestSuite("ClassLoading VFS Tests"); suite.addTest(ExportAllUnitTestCase.suite()); suite.addTest(VFSClassLoaderFactoryXMLUnitTestCase.suite()); suite.addTest(NoopClassLoaderFactoryXMLUnitTestCase.suite()); suite.addTest(DomainUnitTestCase.suite()); suite.addTest(ImportAllUnitTestCase.suite()); suite.addTest(ModuleDependencyUnitTestCase.suite()); suite.addTest(PackageDependencyUnitTestCase.suite()); suite.addTest(VFSClassLoaderFactoryUnitTestCase.suite()); suite.addTest(ManagedObjectVFSClassLoaderFactoryUnitTestCase.suite()); suite.addTest(ReExportModuleUnitTestCase.suite()); suite.addTest(ReExportPackageUnitTestCase.suite()); suite.addTest(UsesPackageUnitTestCase.suite()); suite.addTest(VFSResourceVisitorUnitTestCase.suite()); suite.addTest(ClientClassPathUnitTestCase.suite()); suite.addTest(PackageInfoUnitTestCase.suite()); suite.addTest(GeneratedClassesUnitTestCase.suite()); return suite; } } ././@LongLink0000000000000000000000000000015000000000000011561 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloading-vfs/src/test/java/org/jboss/test/classloading/vfs/libjboss-classloader-java-2.0.6.GA.orig/classloading-vfs/src/test/java/org/jboss/test/classloading/v0000755000175000017500000000000011620043415033363 5ustar twernertwerner././@LongLink0000000000000000000000000000015700000000000011570 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloading-vfs/src/test/java/org/jboss/test/classloading/vfs/policy/libjboss-classloader-java-2.0.6.GA.orig/classloading-vfs/src/test/java/org/jboss/test/classloading/v0000755000175000017500000000000011620043415033363 5ustar twernertwerner././@LongLink0000000000000000000000000000016400000000000011566 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloading-vfs/src/test/java/org/jboss/test/classloading/vfs/policy/test/libjboss-classloader-java-2.0.6.GA.orig/classloading-vfs/src/test/java/org/jboss/test/classloading/v0000755000175000017500000000000011620043415033363 5ustar twernertwerner././@LongLink0000000000000000000000000000022000000000000011557 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloading-vfs/src/test/java/org/jboss/test/classloading/vfs/policy/test/PackageInfoUnitTestCase.javalibjboss-classloader-java-2.0.6.GA.orig/classloading-vfs/src/test/java/org/jboss/test/classloading/v0000644000175000017500000000563611071406374033406 0ustar twernertwerner/* * JBoss, Home of Professional Open Source * Copyright 2008, Red Hat Middleware LLC, and individual contributors * by the @authors tag. See the copyright.txt in the distribution for a * full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.test.classloading.vfs.policy.test; import java.net.URL; import junit.framework.Test; import junit.framework.TestSuite; import org.jboss.classloader.spi.PackageInformation; import org.jboss.classloading.spi.metadata.ExportAll; import org.jboss.classloading.spi.vfs.policy.VFSClassLoaderPolicy; import org.jboss.test.BaseTestCase; import org.jboss.virtual.VFS; import org.jboss.virtual.VirtualFile; /** * Package related tests of VFSClassLoaderPolicy * @author Scott.Stark@jboss.org * @version $Revision: 79077 $ */ public class PackageInfoUnitTestCase extends BaseTestCase { public PackageInfoUnitTestCase(String name) { super(name); } public void testCorrectPackage() throws Exception { URL testear1xURL = getResource("/classloader/testear1x.ear"); VirtualFile testear1x = VFS.getRoot(testear1xURL); VirtualFile jar1 = testear1x.getChild("lib/jar1.jar"); assertNotNull(jar1); VirtualFile jar2 = testear1x.getChild("lib/jar2.jar"); assertNotNull(jar2); VFSClassLoaderPolicy policy = VFSClassLoaderPolicy.createVFSClassLoaderPolicy("testCorrectPackage", testear1x, jar2, jar1); policy.setExportAll(ExportAll.NON_EMPTY); policy.setImportAll(true); PackageInformation utilInfo = policy.getClassPackageInformation("util.Shared", "util"); /* Specification-Title: testear1x.ear/lib/jar1.jar Specification-Version: 1.0.1.GA Specification-Vendor: JBoss Implementation-Title: JBoss [division of RedHat] Implementation-URL: http://www.jboss.org/ Implementation-Version: 1.0.1.GA Implementation-Vendor: JBoss.org Implementation-Vendor-Id: http://www.jboss.org/ */ assertEquals("testear1x.ear/lib/jar1.jar", utilInfo.specTitle); assertEquals("1.0.1.GA", utilInfo.specVersion); } public static Test suite() { return new TestSuite(PackageInfoUnitTestCase.class); } } ././@LongLink0000000000000000000000000000021600000000000011564 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloading-vfs/src/test/java/org/jboss/test/classloading/vfs/policy/test/ExportAllUnitTestCase.javalibjboss-classloader-java-2.0.6.GA.orig/classloading-vfs/src/test/java/org/jboss/test/classloading/v0000644000175000017500000003501511044122414033366 0ustar twernertwerner/* * JBoss, Home of Professional Open Source * Copyright 2007, JBoss Inc., and individual contributors as indicated * by the @authors tag. See the copyright.txt in the distribution for a * full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.test.classloading.vfs.policy.test; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.net.URL; import java.util.Arrays; import java.util.Collections; import java.util.HashMap; import java.util.HashSet; import java.util.Map; import java.util.Set; import junit.framework.Test; import junit.framework.TestSuite; import org.jboss.classloader.plugins.system.DefaultClassLoaderSystem; import org.jboss.classloader.spi.ClassLoaderSystem; import org.jboss.classloading.spi.metadata.ExportAll; import org.jboss.classloading.spi.vfs.policy.VFSClassLoaderPolicy; import org.jboss.test.BaseTestCase; import org.jboss.virtual.VFS; import org.jboss.virtual.VirtualFile; /** * ExportAllUnitTestCase. * * @author Adrian Brock * @version $Revision: 1.1 $ */ public class ExportAllUnitTestCase extends BaseTestCase { protected void testExportAll(ExportAll exportAll, Map expected, String... urls) throws Exception { testExportAll(exportAll, expected, urls, null); } protected void testExportAll(ExportAll exportAll, Map expected, Set empty, String... urls) throws Exception { testExportAll(exportAll, expected, empty, urls, null); } protected void testExportAll(ExportAll exportAll, Map expected, String[] urls, String[] excluded) throws Exception { Set empty = Collections.emptySet(); testExportAll(exportAll, expected, empty, urls, excluded); } protected void testExportAll(ExportAll exportAll, Map expected, Set empty, String[] urls, String[] excluded) throws Exception { testExportAllAbsolute(exportAll, expected, empty, urls, excluded); testExportAllFromBase(exportAll, expected, empty, urls, excluded); } protected void testExportAllCommon(ExportAll exportAll, Map expected, Set empty, VirtualFile[] files, VirtualFile[] excluded) throws Exception { VFSClassLoaderPolicy policy = VFSClassLoaderPolicy.createVFSClassLoaderPolicy(files, excluded); policy.setExportAll(exportAll); String[] packageNames = policy.getPackageNames(); Set actual = makeSet(packageNames); assertEquals(expected.keySet(), actual); ClassLoaderSystem system = new DefaultClassLoaderSystem(); ClassLoader classLoader = system.registerClassLoaderPolicy(policy); for (Map.Entry entry : expected.entrySet()) { String packageName = entry.getKey(); String resource = packageName.replace('.', '/') + "/notempty"; InputStream is = classLoader.getResourceAsStream(resource); if (empty.contains(packageName)) assertNull("Did not expect resource: " + resource, is); else { assertNotNull("Did not find resource: " + resource, is); String contents = getContents(is); assertEquals(entry.getValue(), contents); } } } protected void testExportAllFromBase(ExportAll exportAll, Map expected, Set empty, String[] urls, String[] excluded) throws Exception { URL baseURL = getResource("/classloader"); assertNotNull(baseURL); VirtualFile base = VFS.getRoot(baseURL); VirtualFile[] files = new VirtualFile[urls.length]; for (int i = 0; i < urls.length; ++i) { try { files[i] = base.getChild(urls[i]); } catch (IOException ignored) { } if (files[i] == null && i > 0) { try { files[i] = files[0].getChild(urls[i]); } catch (IOException ignored) { } } if (files[i] == null) fail("Can't find " + urls[i]); } VirtualFile[] excludedFiles = null; if (excluded != null) { excludedFiles = new VirtualFile[excluded.length]; for (int i = 0; i < excluded.length; ++i) { try { excludedFiles[i] = base.getChild(excluded[i]); } catch (IOException ignored) { } if (excludedFiles[i] == null) { try { excludedFiles[i] = files[0].getChild(excluded[i]); } catch (IOException ignored) { } } if (excludedFiles[i] == null) fail("Can't find " + excluded[i]); } } testExportAllCommon(exportAll, expected, empty, files, excludedFiles); } protected void testExportAllAbsolute(ExportAll exportAll, Map expected, Set empty, String[] urls, String[] excluded) throws Exception { VirtualFile[] files = new VirtualFile[urls.length]; for (int i = 0; i < urls.length; ++i) { String urlString = "/classloader/" + urls[i]; URL url = getResource(urlString); if (url != null) { files[i]= VFS.getRoot(url); } else { if (i > 0) files[i] = files[0].getChild(urls[i]); if (files[i] == null) fail("Expected to find resource: " + urlString); } } VirtualFile[] excludedFiles = null; if (excluded != null) { excludedFiles = new VirtualFile[excluded.length]; for (int i = 0; i < excluded.length; ++i) { String urlString = "/classloader/" + excluded[i]; URL url = getResource(urlString); if (url != null) { excludedFiles[i]= VFS.getRoot(url); } else { excludedFiles[i] = files[0].getChild(excluded[i]); if (excludedFiles[i] == null) fail("Expected to find resource: " + files[0].getName() + "/" + excluded[i]); } } } testExportAllCommon(exportAll, expected, empty, files, excludedFiles); } public void testExportAllJar1() throws Exception { Map expected = makeSimpleMap("testjar1", "", "package1", "package2", "package2.subpackage1", "package2.subpackage2", "package2.subpackage3" ); testExportAll(ExportAll.ALL, expected, "testjar1"); } public void testJar1Resources() throws Exception { URL testjar1URL = getResource("/classloader/testjar1"); VirtualFile testjar1 = VFS.getRoot(testjar1URL); VFSClassLoaderPolicy policy = VFSClassLoaderPolicy.createVFSClassLoaderPolicy(testjar1); policy.setExportAll(ExportAll.ALL); ClassLoaderSystem system = new DefaultClassLoaderSystem(); ClassLoader classLoader = system.registerClassLoaderPolicy(policy); URL notempty = classLoader.getResource("notempty"); assertNotNull(notempty); } public void testWar1Resources() throws Exception { URL testwar1URL = getResource("/classloader/testwar1.war"); VirtualFile testwar1 = VFS.getRoot(testwar1URL); VFSClassLoaderPolicy policy = VFSClassLoaderPolicy.createVFSClassLoaderPolicy(testwar1); policy.setExportAll(ExportAll.NON_EMPTY); policy.setImportAll(true); ClassLoaderSystem system = new DefaultClassLoaderSystem(); ClassLoader classLoader = system.registerClassLoaderPolicy(policy); URL resURL = classLoader.getResource("test-resource.txt"); assertNull(resURL); resURL = classLoader.getResource("WEB-INF/test-resource.txt"); assertNotNull(resURL); } public void testExportAllJar1NonEmpty() throws Exception { Map expected = makeSimpleMap("testjar1", "", "package1", "package2", "package2.subpackage1", "package2.subpackage2", "package2.subpackage3" ); testExportAll(ExportAll.NON_EMPTY, expected, "testjar1"); } public void testExportAllJar2() throws Exception { Map expected = makeSimpleMap("testjar2", "", "package1" ); Set empty = makeSet(""); testExportAll(ExportAll.ALL, expected, empty, "testjar2"); } public void testExportAllJar2NonEmpty() throws Exception { Map expected = makeSimpleMap("testjar2", "package1" ); testExportAll(ExportAll.NON_EMPTY, expected, "testjar2"); } public void testExportAllJar1And2() throws Exception { Map expected = makeSimpleMap("testjar1", "", "package1", "package2", "package2.subpackage1", "package2.subpackage2", "package2.subpackage3" ); testExportAll(ExportAll.ALL, expected, "testjar1", "testjar2"); } public void testExportAllJar1And2NonEmpty() throws Exception { Map expected = makeSimpleMap("testjar1", "", "package1", "package2", "package2.subpackage1", "package2.subpackage2", "package2.subpackage3" ); testExportAll(ExportAll.NON_EMPTY, expected, "testjar1", "testjar2"); } public void testExportAllJar2And1() throws Exception { Map expected = makeComplexMap( "", "testjar1", "package1", "testjar2", "package2", "testjar1", "package2.subpackage1", "testjar1", "package2.subpackage2", "testjar1", "package2.subpackage3", "testjar1" ); testExportAll(ExportAll.ALL, expected, "testjar2", "testjar1"); } public void testExportAllJar2And1NonEmpty() throws Exception { Map expected = makeComplexMap( "", "testjar1", "package1", "testjar2", "package2", "testjar1", "package2.subpackage1", "testjar1", "package2.subpackage2", "testjar1", "package2.subpackage3", "testjar1" ); testExportAll(ExportAll.NON_EMPTY, expected, "testjar2", "testjar1"); } public void testExportAllJar3() throws Exception { Map expected = makeSimpleMap("testjar3", "", "package1", "package2" ); testExportAll(ExportAll.ALL, expected, "testjar3", "subjar1.jar"); } public void testExportAllSimpleExcluded() throws Exception { Map expected = makeSimpleMap("testjar1", "", "package1" ); testExportAll(ExportAll.ALL, expected, new String[] { "testjar1" } , new String[] { "package2" }); } public void testExportAllMultipleRootsExcluded() throws Exception { Map expected = makeSimpleMap("testjar1", "", "package1" ); testExportAll(ExportAll.ALL, expected, new String[] { "testjar1", "testjar2" } , new String[] { "package2" }); } public void testExportAllMultipleExcluded() throws Exception { Map expected = makeSimpleMap("testjar1", "" ); testExportAll(ExportAll.ALL, expected, new String[] { "testjar1" } , new String[] { "package1", "package2" }); } public void testJar3Resources() throws Exception { URL testjar3URL = getResource("/classloader/testjar3"); VirtualFile testjar3 = VFS.getRoot(testjar3URL); VirtualFile testjar3subjar = testjar3.getChild("subjar1.jar"); assertNotNull(testjar3subjar); VFSClassLoaderPolicy policy = VFSClassLoaderPolicy.createVFSClassLoaderPolicy(testjar3, testjar3subjar); policy.setExportAll(ExportAll.NON_EMPTY); ClassLoaderSystem system = new DefaultClassLoaderSystem(); ClassLoader classLoader = system.registerClassLoaderPolicy(policy); URL notempty = classLoader.getResource("notempty"); assertNotNull(notempty); notempty = classLoader.getResource("package1/notempty"); assertNotNull(notempty); notempty = classLoader.getResource("package2/notempty"); assertNotNull(notempty); } protected String getContents(InputStream is) throws Exception { StringBuilder builder = new StringBuilder(); InputStreamReader reader = new InputStreamReader(is); int character = reader.read(); while (character != -1) { builder.append((char) character); character = reader.read(); } return builder.toString(); } protected Set makeSet(String... elements) { assertNotNull(elements); return new HashSet(Arrays.asList(elements)); } protected Map makeSimpleMap(String prefix, String... elements) { assertNotNull(prefix); assertNotNull(elements); Map result = new HashMap(); for (String string : elements) result.put(string, prefix + "." + string); return result; } protected Map makeComplexMap(String... elements) { assertNotNull(elements); Map result = new HashMap(); for (int i = 0; i < elements.length; i += 2) result.put(elements[i], elements[i+1] + '.' + elements[i]); return result; } public static Test suite() { return new TestSuite(ExportAllUnitTestCase.class); } public ExportAllUnitTestCase(String name) throws Throwable { super(name); } } ././@LongLink0000000000000000000000000000015700000000000011570 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloading-vfs/src/test/java/org/jboss/test/classloading/vfs/client/libjboss-classloader-java-2.0.6.GA.orig/classloading-vfs/src/test/java/org/jboss/test/classloading/v0000755000175000017500000000000011620043415033363 5ustar twernertwerner././@LongLink0000000000000000000000000000016400000000000011566 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloading-vfs/src/test/java/org/jboss/test/classloading/vfs/client/test/libjboss-classloader-java-2.0.6.GA.orig/classloading-vfs/src/test/java/org/jboss/test/classloading/v0000755000175000017500000000000011620043415033363 5ustar twernertwerner././@LongLink0000000000000000000000000000022400000000000011563 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloading-vfs/src/test/java/org/jboss/test/classloading/vfs/client/test/ClientClassPathUnitTestCase.javalibjboss-classloader-java-2.0.6.GA.orig/classloading-vfs/src/test/java/org/jboss/test/classloading/v0000644000175000017500000001167011042333404033370 0ustar twernertwerner/* * JBoss, Home of Professional Open Source * Copyright 2008, Red Hat Middleware LLC, and individual contributors * by the @authors tag. See the copyright.txt in the distribution for a * full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.test.classloading.vfs.client.test; import java.io.InputStream; import java.net.URL; import java.util.ArrayList; import java.util.jar.Attributes; import java.util.jar.Manifest; import junit.framework.Test; import org.jboss.test.classloading.vfs.client.support.launcher.ClientLauncher; import org.jboss.test.classloading.vfs.metadata.VFSClassLoadingMicrocontainerTest; /** * Tests of vfs class loading that affect a client application type of env. * * @author Scott.Stark@jboss.org * @version $Revision:$ */ public class ClientClassPathUnitTestCase extends VFSClassLoadingMicrocontainerTest { public static Test suite() { return suite(ClientClassPathUnitTestCase.class); } public ClientClassPathUnitTestCase(String name) { super(name); } /* public void testClientVFSClassLoaderFactory() throws Exception { URL clientJar = super.getResource("/org/jboss/test/classloading/vfs/client.jar"); VFSClassLoaderFactory factory = new VFSClassLoaderFactory("ClientLauncher"); ClassLoadingMetaDataFactory cfactory = ClassLoadingMetaDataFactory.getInstance(); String clientClassName = "org.jboss.test.classloading.vfs.client.support.main.Client"; //factory.getCapabilities().addCapability(cfactory.createPackage("org.jboss.test.classloading.vfs.client.support.main")); factory.getRoots().add(clientJar.toString()); // This would be handled by the structure deployer URL mfURL = super.getResource("/org/jboss/test/classloading/vfs/client.jar/META-INF/MANIFEST.MF"); InputStream mfIS = mfURL.openStream(); Manifest mf = new Manifest(mfIS); mfIS.close(); String pathValue = mf.getMainAttributes().getValue(Attributes.Name.CLASS_PATH); String[] paths = pathValue.split(" "); for(String path : paths) { URL pathURL = new URL(clientJar, path); factory.getRoots().add(pathURL.toString()); } getLog().debug("VFSClassLoaderFactory.roots : "+factory.getRoots()); // factory.setIncludedPackages("org.jboss.test.classloading.vfs.client.support.main"); KernelDeployment depA = install(factory); try { ClassLoader clA = assertClassLoader(factory); assertLoadClass(clientClassName, clA); assertLoadClassFail("org.jboss.test.classloading.vfs.client.support.launcher.ClientLauncher", clA); } finally { undeploy(depA); } assertNoClassLoader(factory); } */ /** * Test an application client launcher mock up that uses the mc, vfs, * class loaders to launch the application client environment and call its * main method. * @throws Throwable */ public void testClientMainClassPath() throws Throwable { URL clientJar = super.getResource("/org/jboss/test/classloading/vfs/client.jar/"); // This would be handled by the structure deployer URL mfURL = new URL(clientJar, "META-INF/MANIFEST.MF"); InputStream mfIS = mfURL.openStream(); Manifest mf = new Manifest(mfIS); mfIS.close(); String pathValue = mf.getMainAttributes().getValue(Attributes.Name.CLASS_PATH); String[] paths = pathValue.split(" "); ArrayList pathList = new ArrayList(); pathList.add(clientJar.toString()); for(String path : paths) { URL pathURL = new URL(clientJar, "../" + path); pathList.add(pathURL.toString()); } String[] clientCP = new String[pathList.size()]; pathList.toArray(clientCP); String[] args = {clientJar.toString()}; String clientClassName = "org.jboss.test.classloading.vfs.client.support.main.Client"; ClientLauncher.launch(clientClassName, "testClientMainClassPath", clientCP, args); if(ClientLauncher.getException() != null) { Exception ex = ClientLauncher.getException(); getLog().error("ClientLauncher.exception: ", ex); fail("ClientLauncher saw an exception, "+ex); } } } ././@LongLink0000000000000000000000000000016700000000000011571 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloading-vfs/src/test/java/org/jboss/test/classloading/vfs/client/support/libjboss-classloader-java-2.0.6.GA.orig/classloading-vfs/src/test/java/org/jboss/test/classloading/v0000755000175000017500000000000011620043415033363 5ustar twernertwerner././@LongLink0000000000000000000000000000020000000000000011555 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloading-vfs/src/test/java/org/jboss/test/classloading/vfs/client/support/launcher/libjboss-classloader-java-2.0.6.GA.orig/classloading-vfs/src/test/java/org/jboss/test/classloading/v0000755000175000017500000000000011620043415033363 5ustar twernertwerner././@LongLink0000000000000000000000000000022300000000000011562 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloading-vfs/src/test/java/org/jboss/test/classloading/vfs/client/support/launcher/ClientLauncher.javalibjboss-classloader-java-2.0.6.GA.orig/classloading-vfs/src/test/java/org/jboss/test/classloading/v0000644000175000017500000003261011063447574033406 0ustar twernertwerner/* * JBoss, Home of Professional Open Source * Copyright 2008, Red Hat Middleware LLC, and individual contributors * by the @authors tag. See the copyright.txt in the distribution for a * full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.test.classloading.vfs.client.support.launcher; import java.lang.reflect.Method; import java.net.URL; import java.util.ArrayList; import org.jboss.beans.metadata.plugins.builder.BeanMetaDataBuilderFactory; import org.jboss.beans.metadata.spi.BeanMetaData; import org.jboss.beans.metadata.spi.BeanMetaDataFactory; import org.jboss.beans.metadata.spi.ValueMetaData; import org.jboss.beans.metadata.spi.builder.BeanMetaDataBuilder; import org.jboss.classloader.plugins.ClassLoaderUtils; import org.jboss.classloading.spi.metadata.ClassLoadingMetaDataFactory; import org.jboss.classloading.spi.vfs.metadata.VFSClassLoaderFactory; import org.jboss.dependency.spi.Controller; import org.jboss.dependency.spi.ControllerMode; import org.jboss.dependency.spi.ControllerState; import org.jboss.kernel.Kernel; import org.jboss.kernel.plugins.bootstrap.AbstractBootstrap; import org.jboss.kernel.plugins.bootstrap.basic.BasicBootstrap; import org.jboss.kernel.plugins.deployment.AbstractKernelDeployment; import org.jboss.kernel.plugins.deployment.xml.BasicXMLDeployer; import org.jboss.kernel.spi.dependency.KernelController; import org.jboss.kernel.spi.dependency.KernelControllerContext; import org.jboss.kernel.spi.deployment.KernelDeployment; import org.jboss.logging.Logger; /** * An application client launcher mock up that uses the mc, vfs, class loaders * to launch the application client environment and call its main method. * * @author Scott.Stark@jboss.org * @version $Revision:$ */ public class ClientLauncher { private static Logger log = Logger.getLogger(ClientLauncher.class); private static Exception exception; /** The kernel */ private static Kernel kernel; /** The deployer */ private static BasicXMLDeployer deployer; /** The default mode */ private static ControllerMode defaultMode = ControllerMode.AUTOMATIC; private static void init() throws Throwable { // Bootstrap the kernel AbstractBootstrap bootstrap = getBootstrap(); bootstrap.run(); kernel = bootstrap.getKernel(); // Create the deployer deployer = createDeployer(); } private static BasicXMLDeployer createDeployer() { return new BasicXMLDeployer(kernel, defaultMode); } /** * Get the defaultMode. * * @return the defaultMode. */ public ControllerMode getDefaultMode() { return defaultMode; } /** * Set the defaultMode. * * @param defaultMode the defaultMode. */ public void setDefaultMode(ControllerMode defaultMode) { this.defaultMode = defaultMode; } /** * Get the kernel bootstrap * * @return the bootstrap * @throws Exception for any error */ private static AbstractBootstrap getBootstrap() throws Exception { return new BasicBootstrap(); } /** * Get a bean * * @param name the name of the bean * @param state the state of the bean * @return the bean * @throws IllegalStateException when the bean does not exist at that state */ private static Object getBean(final Object name, final ControllerState state) { KernelControllerContext context = getControllerContext(name, state); return context.getTarget(); } /** * Get a bean * * @param the expected type * @param name the name of the bean * @param state the state of the bean * @param expected the expected type * @return the bean * @throws IllegalStateException when the bean does not exist at that state */ private static T getBean(final Object name, final ControllerState state, final Class expected) { if (expected == null) throw new IllegalArgumentException("Null expected"); Object bean = getBean(name, state); if (expected.isInstance(bean) == false) throw new ClassCastException(ClassLoaderUtils.classToString(bean.getClass()) + " is not an instanceof " + ClassLoaderUtils.classToString(expected)); return expected.cast(bean); } /** * Get a context * * @param name the name of the bean * @param state the state of the bean * @return the context * @throws IllegalStateException when the context does not exist at that state */ private static KernelControllerContext getControllerContext(final Object name, final ControllerState state) { KernelController controller = kernel.getController(); KernelControllerContext context = (KernelControllerContext) controller.getContext(name, state); if (context == null) return handleNotFoundContext(controller, name, state); return context; } /** * Handle not found context. * * @param controller the controller * @param name the name of the bean * @param state the state of the bean * @return the context * @throws IllegalStateException when the context does not exist at that state */ private static KernelControllerContext handleNotFoundContext(Controller controller, Object name, ControllerState state) { throw new IllegalStateException("Bean not found: '" + name + "' at state " + state); } /** * Validate * * @throws Exception for any error */ private static void validate() throws Exception { try { deployer.validate(); } catch (RuntimeException e) { throw e; } catch (Exception e) { throw e; } catch (Error e) { throw e; } catch (Throwable t) { throw new RuntimeException(t); } } /** * Deploy a url * * @param url the deployment url * @return the deployment * @throws Exception for any error */ private static KernelDeployment deploy(URL url) throws Exception { try { log.debug("Deploying " + url); KernelDeployment deployment = deployer.deploy(url); log.trace("Deployed " + url); return deployment; } catch (RuntimeException e) { throw e; } catch (Exception e) { throw e; } catch (Error e) { throw e; } catch (Throwable t) { throw new RuntimeException(t); } } /** * Deploy a deployment * * @param deployment the deployment * @throws Exception for any error */ private static void deploy(KernelDeployment deployment) throws Exception { log.debug("Deploying " + deployment); try { deployer.deploy(deployment); log.debug("Deployed " + deployment); } catch (Exception e) { throw e; } catch (Error e) { throw e; } catch (Throwable t) { throw new RuntimeException("Error deploying deployment: " + deployment, t); } } /** * Undeploy a deployment * * @param deployment the deployment */ private static void undeploy(KernelDeployment deployment) { log.debug("Undeploying " + deployment.getName()); try { deployer.undeploy(deployment); log.trace("Undeployed " + deployment.getName()); } catch (Throwable t) { log.warn("Error during undeployment: " + deployment.getName(), t); } } /** * Undeploy a deployment * * @param url the url */ protected void undeploy(URL url) { log.debug("Undeploying " + url); try { deployer.undeploy(url); log.trace("Undeployed " + url); } catch (Throwable t) { log.warn("Error during undeployment: " + url, t); } } @SuppressWarnings("unused") private static void shutdown() { kernel.getController().shutdown(); } /** * Undeploy all */ @SuppressWarnings("unused") private static void undeploy() { log.debug("Undeploying " + deployer.getDeploymentNames()); deployer.shutdown(); } public static Exception getException() { return exception; } /** * The client launcher entry point that create an mc to launch the client container. * @param clientClass * @param clientName * @param cp * @param args * @throws Throwable */ @SuppressWarnings({"unchecked", "deprecation"}) public static void launch(String clientClass, String clientName, String[] cp, String[] args) throws Throwable { // Init the kernel and deployers init(); // Deploy the common launcher beans String common = "/org/jboss/test/classloading/vfs/metadata/Common.xml"; URL url = ClientLauncher.class.getResource(common); if (url == null) throw new IllegalStateException(common + " not found"); deploy(url); validate(); try { VFSClassLoaderFactory factory = new VFSClassLoaderFactory("ClientLauncherClassLoader"); ArrayList roots = new ArrayList(); // This will come from the client metadata for(String path : cp) roots.add(path); factory.setRoots(roots); // Do we have to export all packages? Not going to know them... int lastDot = clientClass.lastIndexOf('.'); if(lastDot > 0) { String clientPackage = clientClass.substring(0, lastDot); ClassLoadingMetaDataFactory cfactory = ClassLoadingMetaDataFactory.getInstance(); factory.getCapabilities().addCapability(cfactory.createModule(clientPackage)); factory.getCapabilities().addCapability(cfactory.createPackage(clientPackage)); } //factory.setIncluded(ClassFilter.JAVA_ONLY); ArrayList beanFactories = new ArrayList(); beanFactories.add(factory); BeanMetaDataBuilder builder = BeanMetaDataBuilderFactory.createBuilder("ClientContainer", ClientContainer.class.getName()); // ClientContainer(Object metaData, String mainClass, String applicationClientName) Object metaData = null; builder.addConstructorParameter(Object.class.getName(), metaData); builder.addConstructorParameter(Class.class.getName(), clientClass); builder.addConstructorParameter(String.class.getName(), clientName); String classLoaderName = factory.getContextName(); if(classLoaderName == null) classLoaderName = factory.getName() + ":" + factory.getVersion(); ValueMetaData classLoader = builder.createInject(classLoaderName); builder.setClassLoader(classLoader); BeanMetaData clientContainerMD = builder.getBeanMetaData(); AbstractKernelDeployment deployment = new AbstractKernelDeployment(); deployment.setName(factory.getName() + ":" + factory.getVersion()); if(clientContainerMD instanceof BeanMetaDataFactory) { BeanMetaDataFactory bmdf = (BeanMetaDataFactory) clientContainerMD; beanFactories.add(bmdf); } else { // Have to use the deprecated beans ArrayList beans = new ArrayList(); beans.add(clientContainerMD); deployment.setBeans(beans); } deployment.setBeanFactories(beanFactories); deploy(deployment); validate(); ClassLoader ccLoader = getBean(classLoaderName, ControllerState.INSTALLED, ClassLoader.class); if(ccLoader == null ) throw new Exception(classLoaderName+" bean was not created"); Class clientContainerClass = ccLoader.loadClass(ClientContainer.class.getName()); Object client = getBean("ClientContainer", ControllerState.INSTALLED, clientContainerClass); if(client == null ) throw new Exception("ClientContainer bean was not created"); Method method = clientContainerClass.getMethod("getMainClass"); Class mainClass = (Class) method.invoke(client); ClassLoader mainClassLoader = mainClass.getClassLoader(); if(ccLoader != mainClassLoader) throw new Exception(ccLoader+" != "+mainClassLoader); // Invoke main on the underlying client main class Class parameterTypes[] = { args.getClass() }; method = clientContainerClass.getDeclaredMethod("invokeMain", parameterTypes); method.invoke(client, (Object) args); undeploy(deployment); } catch(Exception e) { exception = e; } } } ././@LongLink0000000000000000000000000000022400000000000011563 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloading-vfs/src/test/java/org/jboss/test/classloading/vfs/client/support/launcher/ClientContainer.javalibjboss-classloader-java-2.0.6.GA.orig/classloading-vfs/src/test/java/org/jboss/test/classloading/v0000644000175000017500000000405211042331441033363 0ustar twernertwerner/* * JBoss, Home of Professional Open Source * Copyright 2008, Red Hat Middleware LLC, and individual contributors * by the @authors tag. See the copyright.txt in the distribution for a * full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.test.classloading.vfs.client.support.launcher; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; /** * @author Scott.Stark@jboss.org * @version $Revision:$ */ public class ClientContainer { private Class mainClass; @SuppressWarnings("unused") private Object metaData; @SuppressWarnings("unused") private String applicationClientName; public ClientContainer(Object metaData, Class mainClass, String applicationClientName) { this.metaData = metaData; this.mainClass = mainClass; this.applicationClientName = applicationClientName; } public Class getMainClass() { return mainClass; } public void invokeMain(String args[]) throws SecurityException, NoSuchMethodException, IllegalArgumentException, IllegalAccessException, InvocationTargetException { Class parameterTypes[] = { args.getClass() }; Method method = mainClass.getDeclaredMethod("main", parameterTypes); method.invoke(null, (Object) args); } } ././@LongLink0000000000000000000000000000017400000000000011567 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloading-vfs/src/test/java/org/jboss/test/classloading/vfs/client/support/main/libjboss-classloader-java-2.0.6.GA.orig/classloading-vfs/src/test/java/org/jboss/test/classloading/v0000755000175000017500000000000011620043415033363 5ustar twernertwerner././@LongLink0000000000000000000000000000020700000000000011564 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloading-vfs/src/test/java/org/jboss/test/classloading/vfs/client/support/main/Client.javalibjboss-classloader-java-2.0.6.GA.orig/classloading-vfs/src/test/java/org/jboss/test/classloading/v0000644000175000017500000000275111042271742033376 0ustar twernertwerner/* * JBoss, Home of Professional Open Source * Copyright 2008, Red Hat Middleware LLC, and individual contributors * by the @authors tag. See the copyright.txt in the distribution for a * full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.test.classloading.vfs.client.support.main; import java.util.Arrays; /** * @author Scott.Stark@jboss.org * @version $Revision:$ */ public class Client { /** * @param args */ public static void main(String[] args) { System.out.println("Client.main, args="+Arrays.asList(args)); System.out.println("Client.ClassLoader: "+Client.class.getClassLoader()); System.out.println("Client.ProtectionDomain"+ Client.class.getProtectionDomain()); } } ././@LongLink0000000000000000000000000000016100000000000011563 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloading-vfs/src/test/java/org/jboss/test/classloading/vfs/metadata/libjboss-classloader-java-2.0.6.GA.orig/classloading-vfs/src/test/java/org/jboss/test/classloading/v0000755000175000017500000000000011620043415033363 5ustar twernertwerner././@LongLink0000000000000000000000000000016600000000000011570 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloading-vfs/src/test/java/org/jboss/test/classloading/vfs/metadata/test/libjboss-classloader-java-2.0.6.GA.orig/classloading-vfs/src/test/java/org/jboss/test/classloading/v0000755000175000017500000000000011620043415033363 5ustar twernertwerner././@LongLink0000000000000000000000000000022500000000000011564 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloading-vfs/src/test/java/org/jboss/test/classloading/vfs/metadata/test/ReExportModuleUnitTestCase.javalibjboss-classloader-java-2.0.6.GA.orig/classloading-vfs/src/test/java/org/jboss/test/classloading/v0000644000175000017500000002005410756304615033401 0ustar twernertwerner/* * JBoss, Home of Professional Open Source. * Copyright 2008, Red Hat Middleware LLC, and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.test.classloading.vfs.metadata.test; import junit.framework.Test; import org.jboss.classloading.spi.metadata.ClassLoadingMetaDataFactory; import org.jboss.classloading.spi.vfs.metadata.VFSClassLoaderFactory; import org.jboss.kernel.spi.deployment.KernelDeployment; import org.jboss.test.classloading.vfs.metadata.VFSClassLoadingMicrocontainerTest; import org.jboss.test.classloading.vfs.metadata.support.a.A; import org.jboss.test.classloading.vfs.metadata.support.b.B; import org.jboss.test.classloading.vfs.metadata.support.c.C; /** * ReExportModuleUnitTestCase. * * @author Adrian Brock * @version $Revision: 1.1 $ */ public class ReExportModuleUnitTestCase extends VFSClassLoadingMicrocontainerTest { public static Test suite() { return suite(ReExportModuleUnitTestCase.class); } public ReExportModuleUnitTestCase(String name) { super(name); } public void testReExport() throws Exception { ClassLoadingMetaDataFactory factory = ClassLoadingMetaDataFactory.getInstance(); VFSClassLoaderFactory a = new VFSClassLoaderFactory("a"); a.getRoots().add(getRoot(A.class)); a.setIncludedPackages(A.class.getPackage().getName()); a.getCapabilities().addCapability(factory.createModule("a")); a.getCapabilities().addCapability(factory.createPackage(A.class.getPackage().getName())); KernelDeployment depA = install(a); try { ClassLoader clA = assertClassLoader(a); assertLoadClass(A.class, clA); assertLoadClassFail(B.class, clA); assertLoadClassFail(C.class, clA); VFSClassLoaderFactory b = new VFSClassLoaderFactory("b"); b.getRoots().add(getRoot(B.class)); b.setIncludedPackages(B.class.getPackage().getName()); b.getCapabilities().addCapability(factory.createModule("b")); b.getCapabilities().addCapability(factory.createPackage(B.class.getPackage().getName())); b.getRequirements().addRequirement(factory.createReExportModule("a")); KernelDeployment depB = install(b); try { assertLoadClass(A.class, clA); assertLoadClassFail(B.class, clA); assertLoadClassFail(C.class, clA); ClassLoader clB = assertClassLoader(b); assertLoadClass(A.class, clB, clA); assertLoadClass(B.class, clB); assertLoadClassFail(C.class, clB); VFSClassLoaderFactory c = new VFSClassLoaderFactory("c"); c.getRoots().add(getRoot(C.class)); c.setIncludedPackages(C.class.getPackage().getName()); c.getRequirements().addRequirement(factory.createRequireModule("b")); KernelDeployment depC = install(c); try { assertLoadClass(A.class, clA); assertLoadClassFail(B.class, clA); assertLoadClassFail(C.class, clA); assertLoadClass(A.class, clB, clA); assertLoadClass(B.class, clB); assertLoadClassFail(C.class, clB); ClassLoader clC = assertClassLoader(c); assertLoadClass(A.class, clC, clA); assertLoadClass(B.class, clC, clB); assertLoadClass(C.class, clC); } finally { undeploy(depC); } assertNoClassLoader(c); assertLoadClass(A.class, clA); assertLoadClassFail(B.class, clA); assertLoadClassFail(C.class, clA); assertLoadClass(A.class, clB, clA); assertLoadClass(B.class, clB); assertLoadClassFail(C.class, clB); } finally { undeploy(depB); } assertNoClassLoader(b); assertLoadClass(A.class, clA); assertLoadClassFail(B.class, clA); assertLoadClassFail(C.class, clA); } finally { undeploy(depA); } assertNoClassLoader(a); } public void testNoReExport() throws Exception { ClassLoadingMetaDataFactory factory = ClassLoadingMetaDataFactory.getInstance(); VFSClassLoaderFactory a = new VFSClassLoaderFactory("a"); a.getRoots().add(getRoot(A.class)); a.setIncludedPackages(A.class.getPackage().getName()); a.getCapabilities().addCapability(factory.createModule("a")); a.getCapabilities().addCapability(factory.createPackage(A.class.getPackage().getName())); KernelDeployment depA = install(a); try { ClassLoader clA = assertClassLoader(a); assertLoadClass(A.class, clA); assertLoadClassFail(B.class, clA); assertLoadClassFail(C.class, clA); VFSClassLoaderFactory b = new VFSClassLoaderFactory("b"); b.getRoots().add(getRoot(B.class)); b.setIncludedPackages(B.class.getPackage().getName()); b.getCapabilities().addCapability(factory.createModule("b")); b.getCapabilities().addCapability(factory.createPackage(B.class.getPackage().getName())); b.getRequirements().addRequirement(factory.createReExportModule("a")); KernelDeployment depB = install(b); try { assertLoadClass(A.class, clA); assertLoadClassFail(B.class, clA); assertLoadClassFail(C.class, clA); ClassLoader clB = assertClassLoader(b); assertLoadClass(A.class, clB, clA); assertLoadClass(B.class, clB); assertLoadClassFail(C.class, clB); VFSClassLoaderFactory c = new VFSClassLoaderFactory("c"); c.getRoots().add(getRoot(C.class)); c.setIncludedPackages(C.class.getPackage().getName()); c.getRequirements().addRequirement(factory.createRequirePackage(B.class.getPackage().getName())); KernelDeployment depC = install(c); try { assertLoadClass(A.class, clA); assertLoadClassFail(B.class, clA); assertLoadClassFail(C.class, clA); assertLoadClass(A.class, clB, clA); assertLoadClass(B.class, clB); assertLoadClassFail(C.class, clB); ClassLoader clC = assertClassLoader(c); assertLoadClassFail(A.class, clC); assertLoadClass(B.class, clC, clB); assertLoadClass(C.class, clC); } finally { undeploy(depC); } assertNoClassLoader(c); assertLoadClass(A.class, clA); assertLoadClassFail(B.class, clA); assertLoadClassFail(C.class, clA); assertLoadClass(A.class, clB, clA); assertLoadClass(B.class, clB); assertLoadClassFail(C.class, clB); } finally { undeploy(depB); } assertNoClassLoader(b); assertLoadClass(A.class, clA); assertLoadClassFail(B.class, clA); assertLoadClassFail(C.class, clA); } finally { undeploy(depA); } assertNoClassLoader(a); } } ././@LongLink0000000000000000000000000000022700000000000011566 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloading-vfs/src/test/java/org/jboss/test/classloading/vfs/metadata/test/GeneratedClassesUnitTestCase.javalibjboss-classloader-java-2.0.6.GA.orig/classloading-vfs/src/test/java/org/jboss/test/classloading/v0000644000175000017500000001672511173151646033411 0ustar twernertwerner/* * JBoss, Home of Professional Open Source. * Copyright 2008, Red Hat Middleware LLC, and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.test.classloading.vfs.metadata.test; import java.io.ByteArrayOutputStream; import java.io.IOException; import java.io.InputStream; import java.net.URL; import junit.framework.Test; import org.jboss.classloader.plugins.ClassLoaderUtils; import org.jboss.classloading.spi.RealClassLoader; import org.jboss.classloading.spi.metadata.ClassLoadingMetaDataFactory; import org.jboss.classloading.spi.metadata.ExportAll; import org.jboss.classloading.spi.vfs.metadata.VFSClassLoaderFactory; import org.jboss.kernel.spi.deployment.KernelDeployment; import org.jboss.test.classloading.vfs.metadata.VFSClassLoadingMicrocontainerTest; import org.jboss.test.classloading.vfs.metadata.support.a.A; import org.jboss.test.classloading.vfs.metadata.support.b.B; import org.jboss.util.id.GUID; import org.jboss.virtual.MemoryFileFactory; import org.jboss.virtual.VFS; import org.jboss.virtual.plugins.context.memory.MemoryContextFactory; /** * DomainUnitTestCase. * * @author Kabir Khan * @version $Revision: 1.1 $ */ public class GeneratedClassesUnitTestCase extends VFSClassLoadingMicrocontainerTest { final static GeneratedClassInfo NEW_PACKAGE = new GeneratedClassInfo("newpackage.GeneratedClass"); final static GeneratedClassInfo OTHER_PACKAGE = new GeneratedClassInfo("otherpackage.GeneratedClass"); final static GeneratedClassInfo EXISTING_PACKAGE = new GeneratedClassInfo("org.jboss.test.classloading.vfs.metadata.support.a.GeneratedClass"); static { VFS.init(); } public static Test suite() { return suite(GeneratedClassesUnitTestCase.class); } public GeneratedClassesUnitTestCase(String name) { super(name); } public void testImportAllGenerateClassInExistingPackage() throws Exception { runImportAllGenerateClass(EXISTING_PACKAGE, true); } public void testImportAllGenerateClassInGlobalIncludedPackage() throws Exception { runImportAllGenerateClass(NEW_PACKAGE, true); } public void testImportAllGenerateClassInOtherPackage() throws Exception { runImportAllGenerateClass(OTHER_PACKAGE, false); } private void runImportAllGenerateClass(GeneratedClassInfo info, boolean expectSuccess) throws Exception { ClassLoadingMetaDataFactory factory = ClassLoadingMetaDataFactory.getInstance(); String dynamicClassRoot = getDynamicClassRoot(); VFSClassLoaderFactory a = new VFSClassLoaderFactory("a"); a.setImportAll(true); a.getRoots().add(getRoot(A.class)); a.getRoots().add(dynamicClassRoot); a.getCapabilities().addCapability(factory.createPackage(A.class.getPackage().getName())); KernelDeployment depA = install(a); VFSClassLoaderFactory b = new VFSClassLoaderFactory("b"); b.setExportAll(ExportAll.NON_EMPTY); b.setImportAll(true); b.getRoots().add(getRoot(B.class)); b.getCapabilities().addCapability(factory.createPackage(B.class.getPackage().getName())); KernelDeployment depB = install(b); try { ClassLoader clA = assertClassLoader(a); ClassLoader clB = assertClassLoader(b); assertLoadClass(A.class, clA); assertLoadClass(B.class, clB); assertLoadClass(A.class, clB, clA); assertLoadClass(B.class, clA, clB); Class clazz = generateClass(clA, dynamicClassRoot, info); Class clazzA = assertLoadClass(info.getClassname(), clA); assertSame(clazz, clazzA); try { Class clazzB = assertLoadClass(info.getClassname(), clB, clA); if (!expectSuccess) { fail("Should not have been able to load " + info.getClassname()); } assertSame(clazz, clazzB); } catch(Throwable t) { if (expectSuccess) { fail("Should have been able to load class" + info.getClassname() + " " + t); } } } finally { undeploy(depB); undeploy(depA); } } private Class generateClass(ClassLoader loader, String dynamicClassRoot, GeneratedClassInfo info) throws Exception { URL outputURL = new URL(dynamicClassRoot + "/" + info.getResourceName()); MemoryContextFactory factory = MemoryContextFactory.getInstance(); factory.putFile(outputURL, info.getClassBytes()); if (loader instanceof RealClassLoader) { ((RealClassLoader)loader).clearBlackList(info.getResourceName()); } return loader.loadClass(info.getClassname()); } private String getDynamicClassRoot() throws Exception { URL dynamicClassRoot = new URL("vfsmemory", GUID.asString(), ""); MemoryFileFactory.createRoot(dynamicClassRoot).getRoot(); return dynamicClassRoot.toString(); } private static class GeneratedClassInfo { String classname; String resourceName; byte[] classBytes; public GeneratedClassInfo(String classname) { this.classname = classname; resourceName = ClassLoaderUtils.classNameToPath(classname); loadClassBytes(); } public String getClassname() { return classname; } public String getPackageName() { return ClassLoaderUtils.getClassPackageName(classname); } public String getResourceName() { return resourceName; } public byte[] getClassBytes() { return classBytes; } private void loadClassBytes() { InputStream in = this.getClass().getClassLoader().getResourceAsStream("classes/" + resourceName); assertNotNull("Could not find inputstream for " + resourceName, in); try { ByteArrayOutputStream out = new ByteArrayOutputStream(); int i = in.read(); while(i != -1) { out.write((byte)i); i = in.read(); } classBytes = out.toByteArray(); } catch(Exception e) { throw new RuntimeException(e); } finally { if (in != null) { try { in.close(); } catch (IOException e) { // AutoGenerated throw new RuntimeException(e); } } } } } } ././@LongLink0000000000000000000000000000022200000000000011561 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloading-vfs/src/test/java/org/jboss/test/classloading/vfs/metadata/test/UsesPackageUnitTestCase.javalibjboss-classloader-java-2.0.6.GA.orig/classloading-vfs/src/test/java/org/jboss/test/classloading/v0000644000175000017500000000775310756304615033414 0ustar twernertwerner/* * JBoss, Home of Professional Open Source. * Copyright 2008, Red Hat Middleware LLC, and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.test.classloading.vfs.metadata.test; import junit.framework.Test; import org.jboss.classloading.spi.metadata.ClassLoadingMetaDataFactory; import org.jboss.classloading.spi.vfs.metadata.VFSClassLoaderFactory; import org.jboss.kernel.spi.deployment.KernelDeployment; import org.jboss.test.classloading.vfs.metadata.VFSClassLoadingMicrocontainerTest; import org.jboss.test.classloading.vfs.metadata.support.a.A; /** * ReExportPackageUnitTestCase. * * @author Adrian Brock * @version $Revision: 1.1 $ */ public class UsesPackageUnitTestCase extends VFSClassLoadingMicrocontainerTest { public static Test suite() { return suite(UsesPackageUnitTestCase.class); } public UsesPackageUnitTestCase(String name) { super(name); } public void testUsesImport() throws Exception { ClassLoadingMetaDataFactory factory = ClassLoadingMetaDataFactory.getInstance(); VFSClassLoaderFactory a1 = new VFSClassLoaderFactory("a1"); a1.getRoots().add(getRoot(A.class)); a1.setIncludedPackages(A.class.getPackage().getName()); a1.getCapabilities().addCapability(factory.createModule("a")); a1.getCapabilities().addCapability(factory.createPackage(A.class.getPackage().getName())); KernelDeployment depA1 = install(a1); try { ClassLoader clA1 = assertClassLoader(a1); assertLoadClass(A.class, clA1); VFSClassLoaderFactory a2 = new VFSClassLoaderFactory("a2"); a2.getRoots().add(getRoot(A.class)); a2.setIncludedPackages(A.class.getPackage().getName()); a2.getCapabilities().addCapability(factory.createModule("a2")); a2.getRequirements().addRequirement(factory.createUsesPackage(A.class.getPackage().getName())); KernelDeployment depA2 = install(a2); try { assertLoadClass(A.class, clA1); ClassLoader clA2 = assertClassLoader(a2); assertLoadClass(A.class, clA2, clA1); } finally { undeploy(depA2); } assertNoClassLoader(a2); assertLoadClass(A.class, clA1); } finally { undeploy(depA1); } assertNoClassLoader(a1); } public void testUsesNoImport() throws Exception { ClassLoadingMetaDataFactory factory = ClassLoadingMetaDataFactory.getInstance(); VFSClassLoaderFactory a1 = new VFSClassLoaderFactory("a1"); a1.getRoots().add(getRoot(A.class)); a1.setIncludedPackages(A.class.getPackage().getName()); a1.getCapabilities().addCapability(factory.createModule("a")); a1.getRequirements().addRequirement(factory.createUsesPackage(A.class.getPackage().getName())); KernelDeployment depA1 = install(a1); try { validate(); ClassLoader clA1 = assertClassLoader(a1); assertLoadClass(A.class, clA1); } finally { undeploy(depA1); } assertNoClassLoader(a1); } } ././@LongLink0000000000000000000000000000022000000000000011557 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloading-vfs/src/test/java/org/jboss/test/classloading/vfs/metadata/test/ImportAllUnitTestCase.javalibjboss-classloader-java-2.0.6.GA.orig/classloading-vfs/src/test/java/org/jboss/test/classloading/v0000644000175000017500000000607710756304615033412 0ustar twernertwerner/* * JBoss, Home of Professional Open Source. * Copyright 2008, Red Hat Middleware LLC, and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.test.classloading.vfs.metadata.test; import junit.framework.Test; import org.jboss.classloading.spi.metadata.ExportAll; import org.jboss.classloading.spi.vfs.metadata.VFSClassLoaderFactory; import org.jboss.kernel.spi.deployment.KernelDeployment; import org.jboss.test.classloading.vfs.metadata.VFSClassLoadingMicrocontainerTest; import org.jboss.test.classloading.vfs.metadata.support.a.A; import org.jboss.test.classloading.vfs.metadata.support.b.B; /** * ImportAllUnitTestCase. * * @author Adrian Brock * @version $Revision: 1.1 $ */ public class ImportAllUnitTestCase extends VFSClassLoadingMicrocontainerTest { public static Test suite() { return suite(ImportAllUnitTestCase.class); } public ImportAllUnitTestCase(String name) { super(name); } public void testImportAll() throws Exception { VFSClassLoaderFactory a = new VFSClassLoaderFactory("a"); a.setExportAll(ExportAll.NON_EMPTY); a.getRoots().add(getRoot(A.class)); a.setIncludedPackages(A.class.getPackage().getName()); KernelDeployment depA = install(a); try { ClassLoader clA = assertClassLoader(a); assertLoadClass(A.class, clA); assertLoadClassFail(B.class, clA); VFSClassLoaderFactory b = new VFSClassLoaderFactory("b"); b.setImportAll(true); b.getRoots().add(getRoot(B.class)); b.setIncludedPackages(B.class.getPackage().getName()); KernelDeployment depB = install(b); try { assertLoadClass(A.class, clA); assertLoadClassFail(B.class, clA); ClassLoader clB = assertClassLoader(b); assertLoadClass(B.class, clB); assertLoadClass(A.class, clB, clA); } finally { undeploy(depB); } assertLoadClass(A.class, clA); assertLoadClassFail(B.class, clA); assertNoClassLoader(b); } finally { undeploy(depA); } assertNoClassLoader(a); } } ././@LongLink0000000000000000000000000000023000000000000011560 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloading-vfs/src/test/java/org/jboss/test/classloading/vfs/metadata/test/PackageDependencyUnitTestCase.javalibjboss-classloader-java-2.0.6.GA.orig/classloading-vfs/src/test/java/org/jboss/test/classloading/v0000644000175000017500000001477710756304615033420 0ustar twernertwerner/* * JBoss, Home of Professional Open Source. * Copyright 2008, Red Hat Middleware LLC, and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.test.classloading.vfs.metadata.test; import junit.framework.Test; import org.jboss.classloading.spi.metadata.ClassLoadingMetaDataFactory; import org.jboss.classloading.spi.version.VersionRange; import org.jboss.classloading.spi.vfs.metadata.VFSClassLoaderFactory; import org.jboss.kernel.spi.deployment.KernelDeployment; import org.jboss.test.classloading.vfs.metadata.VFSClassLoadingMicrocontainerTest; import org.jboss.test.classloading.vfs.metadata.support.a.A; import org.jboss.test.classloading.vfs.metadata.support.b.B; /** * PackageDependencyUnitTestCase. * * @author Adrian Brock * @version $Revision: 1.1 $ */ public class PackageDependencyUnitTestCase extends VFSClassLoadingMicrocontainerTest { public static Test suite() { return suite(PackageDependencyUnitTestCase.class); } public PackageDependencyUnitTestCase(String name) { super(name); } public void testImportNoVersionCheck() throws Exception { VFSClassLoaderFactory a = new VFSClassLoaderFactory("a"); ClassLoadingMetaDataFactory factory = ClassLoadingMetaDataFactory.getInstance(); a.getCapabilities().addCapability(factory.createModule("ModuleA")); a.getCapabilities().addCapability(factory.createPackage(A.class.getPackage().getName())); a.getRoots().add(getRoot(A.class)); a.setIncludedPackages(A.class.getPackage().getName()); KernelDeployment depA = install(a); try { ClassLoader clA = assertClassLoader(a); assertLoadClass(A.class, clA); assertLoadClassFail(B.class, clA); VFSClassLoaderFactory b = new VFSClassLoaderFactory("b"); b.getRequirements().addRequirement(factory.createRequirePackage(A.class.getPackage().getName())); b.getRoots().add(getRoot(B.class)); b.setIncludedPackages(B.class.getPackage().getName()); KernelDeployment depB = install(b); try { assertLoadClass(A.class, clA); assertLoadClassFail(B.class, clA); ClassLoader clB = assertClassLoader(b); assertLoadClass(B.class, clB); assertLoadClass(A.class, clB, clA); } finally { undeploy(depB); } assertLoadClass(A.class, clA); assertLoadClassFail(B.class, clA); assertNoClassLoader(b); } finally { undeploy(depA); } assertNoClassLoader(a); } public void testImportVersionCheck() throws Exception { VFSClassLoaderFactory a = new VFSClassLoaderFactory("a"); ClassLoadingMetaDataFactory factory = ClassLoadingMetaDataFactory.getInstance(); a.getCapabilities().addCapability(factory.createModule("ModuleA")); a.getCapabilities().addCapability(factory.createPackage(A.class.getPackage().getName(), "1.0.0")); a.getRoots().add(getRoot(A.class)); a.setIncludedPackages(A.class.getPackage().getName()); KernelDeployment depA = install(a); try { ClassLoader clA = assertClassLoader(a); assertLoadClass(A.class, clA); assertLoadClassFail(B.class, clA); VFSClassLoaderFactory b = new VFSClassLoaderFactory("b"); b.getRequirements().addRequirement(factory.createRequirePackage(A.class.getPackage().getName(), new VersionRange("1.0.0", "2.0.0"))); b.getRoots().add(getRoot(B.class)); b.setIncludedPackages(B.class.getPackage().getName()); KernelDeployment depB = install(b); try { assertLoadClass(A.class, clA); assertLoadClassFail(B.class, clA); ClassLoader clB = assertClassLoader(b); assertLoadClass(B.class, clB); assertLoadClass(A.class, clB, clA); } finally { undeploy(depB); } assertLoadClass(A.class, clA); assertLoadClassFail(B.class, clA); assertNoClassLoader(b); } finally { undeploy(depA); } assertNoClassLoader(a); } public void testImportVersionCheckFailed() throws Exception { VFSClassLoaderFactory a = new VFSClassLoaderFactory("a"); ClassLoadingMetaDataFactory factory = ClassLoadingMetaDataFactory.getInstance(); a.getCapabilities().addCapability(factory.createModule("ModuleA")); a.getCapabilities().addCapability(factory.createPackage(A.class.getPackage().getName(), "3.0.0")); a.getRoots().add(getRoot(A.class)); a.setIncludedPackages(A.class.getPackage().getName()); KernelDeployment depA = install(a); try { ClassLoader clA = assertClassLoader(a); assertLoadClass(A.class, clA); assertLoadClassFail(B.class, clA); VFSClassLoaderFactory b = new VFSClassLoaderFactory("b"); b.getRequirements().addRequirement(factory.createRequirePackage(A.class.getPackage().getName(), new VersionRange("1.0.0", "2.0.0"))); b.getRoots().add(getRoot(B.class)); b.setIncludedPackages(B.class.getPackage().getName()); KernelDeployment depB = install(b); try { assertLoadClass(A.class, clA); assertLoadClassFail(B.class, clA); assertNoClassLoader(b); } finally { undeploy(depB); } assertLoadClass(A.class, clA); assertLoadClassFail(B.class, clA); assertNoClassLoader(b); } finally { undeploy(depA); } assertNoClassLoader(a); } } ././@LongLink0000000000000000000000000000022600000000000011565 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloading-vfs/src/test/java/org/jboss/test/classloading/vfs/metadata/test/ReExportPackageUnitTestCase.javalibjboss-classloader-java-2.0.6.GA.orig/classloading-vfs/src/test/java/org/jboss/test/classloading/v0000644000175000017500000002011410756304615033376 0ustar twernertwerner/* * JBoss, Home of Professional Open Source. * Copyright 2008, Red Hat Middleware LLC, and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.test.classloading.vfs.metadata.test; import junit.framework.Test; import org.jboss.classloading.spi.metadata.ClassLoadingMetaDataFactory; import org.jboss.classloading.spi.vfs.metadata.VFSClassLoaderFactory; import org.jboss.kernel.spi.deployment.KernelDeployment; import org.jboss.test.classloading.vfs.metadata.VFSClassLoadingMicrocontainerTest; import org.jboss.test.classloading.vfs.metadata.support.a.A; import org.jboss.test.classloading.vfs.metadata.support.b.B; import org.jboss.test.classloading.vfs.metadata.support.c.C; /** * ReExportPackageUnitTestCase. * * @author Adrian Brock * @version $Revision: 1.1 $ */ public class ReExportPackageUnitTestCase extends VFSClassLoadingMicrocontainerTest { public static Test suite() { return suite(ReExportPackageUnitTestCase.class); } public ReExportPackageUnitTestCase(String name) { super(name); } public void testReExport() throws Exception { ClassLoadingMetaDataFactory factory = ClassLoadingMetaDataFactory.getInstance(); VFSClassLoaderFactory a = new VFSClassLoaderFactory("a"); a.getRoots().add(getRoot(A.class)); a.setIncludedPackages(A.class.getPackage().getName()); a.getCapabilities().addCapability(factory.createModule("a")); a.getCapabilities().addCapability(factory.createPackage(A.class.getPackage().getName())); KernelDeployment depA = install(a); try { ClassLoader clA = assertClassLoader(a); assertLoadClass(A.class, clA); assertLoadClassFail(B.class, clA); assertLoadClassFail(C.class, clA); VFSClassLoaderFactory b = new VFSClassLoaderFactory("b"); b.getRoots().add(getRoot(B.class)); b.setIncludedPackages(B.class.getPackage().getName()); b.getCapabilities().addCapability(factory.createModule("b")); b.getCapabilities().addCapability(factory.createPackage(B.class.getPackage().getName())); b.getRequirements().addRequirement(factory.createReExportPackage(A.class.getPackage().getName())); KernelDeployment depB = install(b); try { assertLoadClass(A.class, clA); assertLoadClassFail(B.class, clA); assertLoadClassFail(C.class, clA); ClassLoader clB = assertClassLoader(b); assertLoadClass(A.class, clB, clA); assertLoadClass(B.class, clB); assertLoadClassFail(C.class, clB); VFSClassLoaderFactory c = new VFSClassLoaderFactory("c"); c.getRoots().add(getRoot(C.class)); c.setIncludedPackages(C.class.getPackage().getName()); c.getRequirements().addRequirement(factory.createRequireModule("b")); KernelDeployment depC = install(c); try { assertLoadClass(A.class, clA); assertLoadClassFail(B.class, clA); assertLoadClassFail(C.class, clA); assertLoadClass(A.class, clB, clA); assertLoadClass(B.class, clB); assertLoadClassFail(C.class, clB); ClassLoader clC = assertClassLoader(c); assertLoadClass(A.class, clC, clA); assertLoadClass(B.class, clC, clB); assertLoadClass(C.class, clC); } finally { undeploy(depC); } assertNoClassLoader(c); assertLoadClass(A.class, clA); assertLoadClassFail(B.class, clA); assertLoadClassFail(C.class, clA); assertLoadClass(A.class, clB, clA); assertLoadClass(B.class, clB); assertLoadClassFail(C.class, clB); } finally { undeploy(depB); } assertNoClassLoader(b); assertLoadClass(A.class, clA); assertLoadClassFail(B.class, clA); assertLoadClassFail(C.class, clA); } finally { undeploy(depA); } assertNoClassLoader(a); } public void testNoReExport() throws Exception { ClassLoadingMetaDataFactory factory = ClassLoadingMetaDataFactory.getInstance(); VFSClassLoaderFactory a = new VFSClassLoaderFactory("a"); a.getRoots().add(getRoot(A.class)); a.setIncludedPackages(A.class.getPackage().getName()); a.getCapabilities().addCapability(factory.createModule("a")); a.getCapabilities().addCapability(factory.createPackage(A.class.getPackage().getName())); KernelDeployment depA = install(a); try { ClassLoader clA = assertClassLoader(a); assertLoadClass(A.class, clA); assertLoadClassFail(B.class, clA); assertLoadClassFail(C.class, clA); VFSClassLoaderFactory b = new VFSClassLoaderFactory("b"); b.getRoots().add(getRoot(B.class)); b.setIncludedPackages(B.class.getPackage().getName()); b.getCapabilities().addCapability(factory.createModule("b")); b.getCapabilities().addCapability(factory.createPackage(B.class.getPackage().getName())); b.getRequirements().addRequirement(factory.createReExportModule("a")); KernelDeployment depB = install(b); try { assertLoadClass(A.class, clA); assertLoadClassFail(B.class, clA); assertLoadClassFail(C.class, clA); ClassLoader clB = assertClassLoader(b); assertLoadClass(A.class, clB, clA); assertLoadClass(B.class, clB); assertLoadClassFail(C.class, clB); VFSClassLoaderFactory c = new VFSClassLoaderFactory("c"); c.getRoots().add(getRoot(C.class)); c.setIncludedPackages(C.class.getPackage().getName()); c.getRequirements().addRequirement(factory.createRequirePackage(B.class.getPackage().getName())); KernelDeployment depC = install(c); try { assertLoadClass(A.class, clA); assertLoadClassFail(B.class, clA); assertLoadClassFail(C.class, clA); assertLoadClass(A.class, clB, clA); assertLoadClass(B.class, clB); assertLoadClassFail(C.class, clB); ClassLoader clC = assertClassLoader(c); assertLoadClassFail(A.class, clC); assertLoadClass(B.class, clC, clB); assertLoadClass(C.class, clC); } finally { undeploy(depC); } assertNoClassLoader(c); assertLoadClass(A.class, clA); assertLoadClassFail(B.class, clA); assertLoadClassFail(C.class, clA); assertLoadClass(A.class, clB, clA); assertLoadClass(B.class, clB); assertLoadClassFail(C.class, clB); } finally { undeploy(depB); } assertNoClassLoader(b); assertLoadClass(A.class, clA); assertLoadClassFail(B.class, clA); assertLoadClassFail(C.class, clA); } finally { undeploy(depA); } assertNoClassLoader(a); } } ././@LongLink0000000000000000000000000000023400000000000011564 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloading-vfs/src/test/java/org/jboss/test/classloading/vfs/metadata/test/VFSClassLoaderFactoryUnitTestCase.javalibjboss-classloader-java-2.0.6.GA.orig/classloading-vfs/src/test/java/org/jboss/test/classloading/v0000644000175000017500000001261410756304615033404 0ustar twernertwerner/* * JBoss, Home of Professional Open Source. * Copyright 2008, Red Hat Middleware LLC, and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.test.classloading.vfs.metadata.test; import junit.framework.Test; import org.jboss.kernel.spi.deployment.KernelDeployment; import org.jboss.test.classloading.vfs.metadata.VFSClassLoadingMicrocontainerTest; /** * VFSClassLoaderFactoryUnitTestCase. * * @author Adrian Brock * @version $Revision: 1.1 $ */ public class VFSClassLoaderFactoryUnitTestCase extends VFSClassLoadingMicrocontainerTest { public static Test suite() { return suite(VFSClassLoaderFactoryUnitTestCase.class); } public VFSClassLoaderFactoryUnitTestCase(String name) { super(name); } public void testSmoke() throws Exception { KernelDeployment deployment = deploy("SmokeTest.xml"); try { validate(); assertClassLoader("test", "0.0.0"); } finally { undeploy(deployment); } validate(); assertNoClassLoader("test", "0.0.0"); } public void testADependsUponBCorrectWay() throws Exception { KernelDeployment a = deploy("A1.0.0.xml"); try { validate(); assertClassLoader("a", "1.0.0"); KernelDeployment b = deploy("B1.0.0.xml"); try { validate(); assertClassLoader("a", "1.0.0"); assertClassLoader("b", "1.0.0"); } finally { undeploy(b); } validate(); assertNoClassLoader("b", "1.0.0"); assertClassLoader("a", "1.0.0"); } finally { undeploy(a); } validate(); assertNoClassLoader("a", "1.0.0"); } public void testADependsUponBWrongWay() throws Exception { KernelDeployment b = deploy("B1.0.0.xml"); try { assertNoClassLoader("b", "1.0.0"); KernelDeployment a = deploy("A1.0.0.xml"); try { validate(); assertClassLoader("a", "1.0.0"); assertClassLoader("b", "1.0.0"); } finally { undeploy(a); } assertNoClassLoader("a", "1.0.0"); assertNoClassLoader("b", "1.0.0"); } finally { undeploy(b); } validate(); } public void testADependsUponBRedeployA() throws Exception { KernelDeployment a = deploy("A1.0.0.xml"); try { validate(); assertClassLoader("a", "1.0.0"); KernelDeployment b = deploy("B1.0.0.xml"); try { validate(); assertClassLoader("a", "1.0.0"); assertClassLoader("b", "1.0.0"); undeploy(a); try { assertNoClassLoader("a", "1.0.0"); assertNoClassLoader("b", "1.0.0"); } finally { a = deploy("A1.0.0.xml"); } validate(); assertClassLoader("a", "1.0.0"); assertClassLoader("b", "1.0.0"); } finally { undeploy(b); } validate(); assertNoClassLoader("b", "1.0.0"); assertClassLoader("a", "1.0.0"); } finally { undeploy(a); } validate(); assertNoClassLoader("a", "1.0.0"); } public void testADependsUponBRedeployB() throws Exception { KernelDeployment a = deploy("A1.0.0.xml"); try { validate(); assertClassLoader("a", "1.0.0"); KernelDeployment b = deploy("B1.0.0.xml"); try { validate(); assertClassLoader("a", "1.0.0"); assertClassLoader("b", "1.0.0"); undeploy(b); try { assertClassLoader("a", "1.0.0"); assertNoClassLoader("b", "1.0.0"); } finally { b = deploy("B1.0.0.xml"); } validate(); assertClassLoader("a", "1.0.0"); assertClassLoader("b", "1.0.0"); } finally { undeploy(b); } validate(); assertNoClassLoader("b", "1.0.0"); assertClassLoader("a", "1.0.0"); } finally { undeploy(a); } validate(); assertNoClassLoader("a", "1.0.0"); } } ././@LongLink0000000000000000000000000000022700000000000011566 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloading-vfs/src/test/java/org/jboss/test/classloading/vfs/metadata/test/ModuleDependencyUnitTestCase.javalibjboss-classloader-java-2.0.6.GA.orig/classloading-vfs/src/test/java/org/jboss/test/classloading/v0000644000175000017500000001471610756304615033411 0ustar twernertwerner/* * JBoss, Home of Professional Open Source. * Copyright 2008, Red Hat Middleware LLC, and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.test.classloading.vfs.metadata.test; import junit.framework.Test; import org.jboss.classloading.spi.metadata.ClassLoadingMetaDataFactory; import org.jboss.classloading.spi.version.VersionRange; import org.jboss.classloading.spi.vfs.metadata.VFSClassLoaderFactory; import org.jboss.kernel.spi.deployment.KernelDeployment; import org.jboss.test.classloading.vfs.metadata.VFSClassLoadingMicrocontainerTest; import org.jboss.test.classloading.vfs.metadata.support.a.A; import org.jboss.test.classloading.vfs.metadata.support.b.B; /** * ModuleDependencyUnitTestCase. * * @author Adrian Brock * @version $Revision: 1.1 $ */ public class ModuleDependencyUnitTestCase extends VFSClassLoadingMicrocontainerTest { public static Test suite() { return suite(ModuleDependencyUnitTestCase.class); } public ModuleDependencyUnitTestCase(String name) { super(name); } public void testImportNoVersionCheck() throws Exception { VFSClassLoaderFactory a = new VFSClassLoaderFactory("a"); ClassLoadingMetaDataFactory factory = ClassLoadingMetaDataFactory.getInstance(); a.getCapabilities().addCapability(factory.createModule("ModuleA")); a.getCapabilities().addCapability(factory.createPackage(A.class.getPackage().getName())); a.getRoots().add(getRoot(A.class)); a.setIncludedPackages(A.class.getPackage().getName()); KernelDeployment depA = install(a); try { validate(); ClassLoader clA = assertClassLoader(a); assertLoadClass(A.class, clA); assertLoadClassFail(B.class, clA); VFSClassLoaderFactory b = new VFSClassLoaderFactory("b"); b.getRequirements().addRequirement(factory.createRequireModule("ModuleA")); b.getRoots().add(getRoot(B.class)); b.setIncludedPackages(B.class.getPackage().getName()); KernelDeployment depB = install(b); try { assertLoadClass(A.class, clA); assertLoadClassFail(B.class, clA); ClassLoader clB = assertClassLoader(b); assertLoadClass(B.class, clB); assertLoadClass(A.class, clB, clA); } finally { undeploy(depB); } assertLoadClass(A.class, clA); assertLoadClassFail(B.class, clA); assertNoClassLoader(b); } finally { undeploy(depA); } assertNoClassLoader(a); } public void testImportVersionCheck() throws Exception { VFSClassLoaderFactory a = new VFSClassLoaderFactory("a"); ClassLoadingMetaDataFactory factory = ClassLoadingMetaDataFactory.getInstance(); a.getCapabilities().addCapability(factory.createModule("ModuleA", "1.0.0")); a.getCapabilities().addCapability(factory.createPackage(A.class.getPackage().getName())); a.getRoots().add(getRoot(A.class)); a.setIncludedPackages(A.class.getPackage().getName()); KernelDeployment depA = install(a); try { ClassLoader clA = assertClassLoader(a); assertLoadClass(A.class, clA); assertLoadClassFail(B.class, clA); VFSClassLoaderFactory b = new VFSClassLoaderFactory("b"); b.getRequirements().addRequirement(factory.createRequireModule("ModuleA", new VersionRange("1.0.0", "2.0.0"))); b.getRoots().add(getRoot(B.class)); b.setIncludedPackages(B.class.getPackage().getName()); KernelDeployment depB = install(b); try { assertLoadClass(A.class, clA); assertLoadClassFail(B.class, clA); ClassLoader clB = assertClassLoader(b); assertLoadClass(B.class, clB); assertLoadClass(A.class, clB, clA); } finally { undeploy(depB); } assertLoadClass(A.class, clA); assertLoadClassFail(B.class, clA); assertNoClassLoader(b); } finally { undeploy(depA); } assertNoClassLoader(a); } public void testImportVersionCheckFailed() throws Exception { VFSClassLoaderFactory a = new VFSClassLoaderFactory("a"); ClassLoadingMetaDataFactory factory = ClassLoadingMetaDataFactory.getInstance(); a.getCapabilities().addCapability(factory.createModule("ModuleA", "3.0.0")); a.getCapabilities().addCapability(factory.createPackage(A.class.getPackage().getName())); a.getRoots().add(getRoot(A.class)); a.setIncludedPackages(A.class.getPackage().getName()); KernelDeployment depA = install(a); try { ClassLoader clA = assertClassLoader(a); assertLoadClass(A.class, clA); assertLoadClassFail(B.class, clA); VFSClassLoaderFactory b = new VFSClassLoaderFactory("b"); b.getRequirements().addRequirement(factory.createRequireModule("ModuleA", new VersionRange("1.0.0", "2.0.0"))); b.getRoots().add(getRoot(B.class)); b.setIncludedPackages(B.class.getPackage().getName()); KernelDeployment depB = install(b); try { assertLoadClass(A.class, clA); assertLoadClassFail(B.class, clA); assertNoClassLoader(b); } finally { undeploy(depB); } assertLoadClass(A.class, clA); assertLoadClassFail(B.class, clA); assertNoClassLoader(b); } finally { undeploy(depA); } assertNoClassLoader(a); } } ././@LongLink0000000000000000000000000000021500000000000011563 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloading-vfs/src/test/java/org/jboss/test/classloading/vfs/metadata/test/DomainUnitTestCase.javalibjboss-classloader-java-2.0.6.GA.orig/classloading-vfs/src/test/java/org/jboss/test/classloading/v0000644000175000017500000001520710756304615033405 0ustar twernertwerner/* * JBoss, Home of Professional Open Source. * Copyright 2008, Red Hat Middleware LLC, and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.test.classloading.vfs.metadata.test; import junit.framework.Test; import org.jboss.classloader.spi.ClassLoaderDomain; import org.jboss.classloader.spi.ParentPolicy; import org.jboss.classloading.spi.metadata.ExportAll; import org.jboss.classloading.spi.vfs.metadata.VFSClassLoaderFactory; import org.jboss.kernel.spi.deployment.KernelDeployment; import org.jboss.test.classloading.vfs.metadata.VFSClassLoadingMicrocontainerTest; import org.jboss.test.classloading.vfs.metadata.support.a.A; import org.jboss.test.classloading.vfs.metadata.support.b.B; /** * DomainUnitTestCase. * * @author Adrian Brock * @version $Revision: 1.1 $ */ public class DomainUnitTestCase extends VFSClassLoadingMicrocontainerTest { public static Test suite() { return suite(DomainUnitTestCase.class); } public DomainUnitTestCase(String name) { super(name); } public void testDefaultDomain() throws Exception { VFSClassLoaderFactory a = new VFSClassLoaderFactory("a"); a.getRoots().add(getRoot(A.class)); a.setIncludedPackages(A.class.getPackage().getName()); KernelDeployment depA = install(a); try { validate(); ClassLoader clA = assertClassLoader(a); assertLoadClass(A.class, clA); assertLoadClassFail(B.class, clA); } finally { undeploy(depA); } validate(); assertNoClassLoader(a); } public void testSubDomainParentBefore() throws Exception { VFSClassLoaderFactory a = new VFSClassLoaderFactory("a"); a.setExportAll(ExportAll.NON_EMPTY); a.getRoots().add(getRoot(A.class)); a.setIncludedPackages(A.class.getPackage().getName()); KernelDeployment depA = install(a); try { validate(); ClassLoader clA = assertClassLoader(a); assertLoadClass(A.class, clA); assertLoadClassFail(B.class, clA); VFSClassLoaderFactory b = new VFSClassLoaderFactory("b"); b.setDomain("SubDomainBefore"); b.getRoots().add(getRoot(B.class)); b.setIncludedPackages(A.class.getPackage().getName() + "," + B.class.getPackage().getName()); KernelDeployment depB = install(b); try { assertLoadClass(A.class, clA); assertLoadClassFail(B.class, clA); ClassLoader clB = assertClassLoader(b); assertLoadClass(B.class, clB); assertLoadClass(A.class, clB, clA); } finally { undeploy(depB); } assertLoadClass(A.class, clA); assertLoadClassFail(B.class, clA); assertNoClassLoader(b); } finally { undeploy(depA); } assertNoClassLoader(a); } public void testSubDomainParentAfter() throws Exception { VFSClassLoaderFactory a = new VFSClassLoaderFactory("a"); a.setExportAll(ExportAll.NON_EMPTY); a.getRoots().add(getRoot(A.class)); a.setIncludedPackages(A.class.getPackage().getName()); KernelDeployment depA = install(a); try { ClassLoader clA = assertClassLoader(a); assertLoadClass(A.class, clA); assertLoadClassFail(B.class, clA); VFSClassLoaderFactory b = new VFSClassLoaderFactory("b"); b.setDomain("SubDomainAfter"); b.setJ2seClassLoadingCompliance(false); b.getRoots().add(getRoot(B.class)); b.setIncludedPackages(A.class.getPackage().getName() + "," + B.class.getPackage().getName()); KernelDeployment depB = install(b); try { assertLoadClass(A.class, clA); assertLoadClassFail(B.class, clA); ClassLoader clB = assertClassLoader(b); assertLoadClass(B.class, clB); assertLoadClass(A.class, clB); } finally { undeploy(depB); } assertLoadClass(A.class, clA); assertLoadClassFail(B.class, clA); assertNoClassLoader(b); } finally { undeploy(depA); } assertNoClassLoader(a); } public void testParentDoesNotExist() throws Exception { VFSClassLoaderFactory a = new VFSClassLoaderFactory("a"); a.setDomain("SubDomain"); a.setParentDomain("DOESNOTEXIST"); a.getRoots().add(getRoot(A.class)); a.setIncludedPackages(A.class.getPackage().getName()); KernelDeployment depA = install(a); try { assertNoClassLoader(a); } catch (Throwable t) { checkThrowable(IllegalStateException.class, t); } finally { undeploy(depA); } assertNoClassLoader(a); } public void testParentDoesExists() throws Exception { ClassLoaderDomain domain = system.createAndRegisterDomain("TestDomain", ParentPolicy.BEFORE_BUT_JAVA_ONLY); try { VFSClassLoaderFactory a = new VFSClassLoaderFactory("a"); a.setDomain("SubDomain"); a.setParentDomain("TestDomain"); a.getRoots().add(getRoot(A.class)); a.setIncludedPackages(A.class.getPackage().getName()); KernelDeployment depA = install(a); try { ClassLoader clA = assertClassLoader(a); assertLoadClass(A.class, clA); assertLoadClassFail(B.class, clA); } catch (Throwable t) { checkThrowable(IllegalStateException.class, t); } finally { undeploy(depA); } assertNoClassLoader(a); } finally { system.unregisterDomain(domain); } } } ././@LongLink0000000000000000000000000000025100000000000011563 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloading-vfs/src/test/java/org/jboss/test/classloading/vfs/metadata/test/ManagedObjectVFSClassLoaderFactoryUnitTestCase.javalibjboss-classloader-java-2.0.6.GA.orig/classloading-vfs/src/test/java/org/jboss/test/classloading/v0000644000175000017500000002557111173151646033410 0ustar twernertwerner/* * JBoss, Home of Professional Open Source. * Copyright 2008, Red Hat Middleware LLC, and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.test.classloading.vfs.metadata.test; import java.lang.reflect.Field; import java.lang.reflect.Type; import java.util.Arrays; import java.util.List; import java.util.Set; import junit.framework.Test; import org.jboss.classloading.spi.metadata.CapabilitiesMetaData; import org.jboss.classloading.spi.metadata.ClassLoadingMetaDataFactory; import org.jboss.classloading.spi.metadata.ExportAll; import org.jboss.classloading.spi.metadata.RequirementsMetaData; import org.jboss.classloading.spi.version.Version; import org.jboss.classloading.spi.vfs.metadata.VFSClassLoaderFactory; import org.jboss.managed.api.ManagedObject; import org.jboss.managed.api.ManagedProperty; import org.jboss.managed.api.factory.ManagedObjectFactory; import org.jboss.metatype.api.types.MetaType; import org.jboss.metatype.api.types.MetaTypeFactory; import org.jboss.metatype.api.values.MetaValue; import org.jboss.metatype.api.values.MetaValueFactory; import org.jboss.test.BaseTestCase; /** * ManagedObjectVFSClassLoaderFactoryUnitTestCase. * * @author Adrian Brock * @version $Revision: 1.1 $ */ public class ManagedObjectVFSClassLoaderFactoryUnitTestCase extends BaseTestCase { private ManagedObjectFactory moFactory = ManagedObjectFactory.getInstance(); private MetaTypeFactory mtFactory = MetaTypeFactory.getInstance(); private MetaValueFactory mvFactory = MetaValueFactory.getInstance(); public static Test suite() { return suite(ManagedObjectVFSClassLoaderFactoryUnitTestCase.class); } public ManagedObjectVFSClassLoaderFactoryUnitTestCase(String name) { super(name); } protected ManagedObject assertManagedObject(VFSClassLoaderFactory test) { ManagedObject result = moFactory.initManagedObject(test, null, null); assertNotNull(result); List expectedProperties = Arrays.asList("name", "version", "context", "domain", "parentDomain", "exportAll", "included", "excluded", "excludedExport", "importAll", "parentFirst", "cache", "blackList", "system", "roots", "capabilities", "requirements"); Set actualProperties = result.getPropertyNames(); for (String expected : expectedProperties) { if (actualProperties.contains(expected) == false) fail("Expected property: " + expected); } for (String actual : actualProperties) { if (expectedProperties.contains(actual) == false) fail("Did not expect property: " + actual); } return result; } protected ManagedProperty assertManagedProperty(ManagedObject mo, String name, MetaType metaType, MetaValue metaValue) { ManagedProperty property = mo.getProperty(name); assertNotNull("No property " + name, property); assertEquals(metaType, property.getMetaType()); assertEquals(metaValue, property.getValue()); return property; } protected ManagedProperty assertManagedProperty(ManagedObject mo, String name, Type type, Object value) { MetaType metaType = mtFactory.resolve(type); MetaValue metaValue = null; if (value != null) metaValue = mvFactory.create(value, type); return assertManagedProperty(mo, name, metaType, metaValue); } protected ManagedProperty assertManagedProperty(ManagedObject mo, String name, Class type, T value) { return assertManagedProperty(mo, name, (Type) type, value); } public void testConstructor() throws Exception { VFSClassLoaderFactory test = new VFSClassLoaderFactory(); ManagedObject mo = assertManagedObject(test); assertManagedProperty(mo, "name", String.class, ""); assertManagedProperty(mo, "version", Version.class, Version.DEFAULT_VERSION); assertManagedProperty(mo, "domain", String.class, null); assertManagedProperty(mo, "parentDomain", String.class, null); assertManagedProperty(mo, "exportAll", ExportAll.class, null); assertManagedProperty(mo, "included", String.class, null); assertManagedProperty(mo, "excluded", String.class, null); assertManagedProperty(mo, "excludedExport", String.class, null); assertManagedProperty(mo, "importAll", boolean.class, false); assertManagedProperty(mo, "parentFirst", boolean.class, true); assertManagedProperty(mo, "capabilities", CapabilitiesMetaData.class, new CapabilitiesMetaData()); assertManagedProperty(mo, "requirements", RequirementsMetaData.class, new RequirementsMetaData()); } public void testSetName() throws Exception { VFSClassLoaderFactory test = new VFSClassLoaderFactory(); test.setName("test"); ManagedObject mo = assertManagedObject(test); assertManagedProperty(mo, "name", String.class, "test"); } public void testSetVersion() throws Exception { VFSClassLoaderFactory test = new VFSClassLoaderFactory(); test.setVersion("1.0.0"); ManagedObject mo = assertManagedObject(test); assertManagedProperty(mo, "version", Version.class, Version.parseVersion("1.0.0")); } public void testContext() throws Exception { VFSClassLoaderFactory test = new VFSClassLoaderFactory(); test.setContextName("context"); ManagedObject mo = assertManagedObject(test); assertManagedProperty(mo, "context", String.class, "context"); } public void testSetDomain() throws Exception { VFSClassLoaderFactory test = new VFSClassLoaderFactory(); test.setDomain("domain"); ManagedObject mo = assertManagedObject(test); assertManagedProperty(mo, "domain", String.class, "domain"); } public void testSetParentDomain() throws Exception { VFSClassLoaderFactory test = new VFSClassLoaderFactory(); test.setParentDomain("parentDomain"); ManagedObject mo = assertManagedObject(test); assertManagedProperty(mo, "parentDomain", String.class, "parentDomain"); } public void testSetExportAll() throws Exception { VFSClassLoaderFactory test = new VFSClassLoaderFactory(); test.setExportAll(ExportAll.ALL); ManagedObject mo = assertManagedObject(test); assertManagedProperty(mo, "exportAll", ExportAll.class, ExportAll.ALL); } public void testSetIncludedPackages() throws Exception { VFSClassLoaderFactory test = new VFSClassLoaderFactory(); test.setIncludedPackages("Included"); ManagedObject mo = assertManagedObject(test); assertManagedProperty(mo, "included", String.class, "Included"); } public void testSetExcludedPackages() throws Exception { VFSClassLoaderFactory test = new VFSClassLoaderFactory(); test.setExcludedPackages("Excluded"); ManagedObject mo = assertManagedObject(test); assertManagedProperty(mo, "excluded", String.class, "Excluded"); } public void testSetExcludedExportPackages() throws Exception { VFSClassLoaderFactory test = new VFSClassLoaderFactory(); test.setExcludedExportPackages("ExcludedExport"); ManagedObject mo = assertManagedObject(test); assertManagedProperty(mo, "excludedExport", String.class, "ExcludedExport"); } public void testSetImportAll() throws Exception { VFSClassLoaderFactory test = new VFSClassLoaderFactory(); test.setImportAll(true); ManagedObject mo = assertManagedObject(test); assertManagedProperty(mo, "importAll", boolean.class, true); } public void testJ2seClassLoadingComplaince() throws Exception { VFSClassLoaderFactory test = new VFSClassLoaderFactory(); test.setJ2seClassLoadingCompliance(false); ManagedObject mo = assertManagedObject(test); assertManagedProperty(mo, "parentFirst", boolean.class, false); } public void testCacheable() throws Exception { VFSClassLoaderFactory test = new VFSClassLoaderFactory(); test.setCacheable(false); ManagedObject mo = assertManagedObject(test); assertManagedProperty(mo, "cache", boolean.class, false); } public void testBlackList() throws Exception { VFSClassLoaderFactory test = new VFSClassLoaderFactory(); test.setBlackListable(false); ManagedObject mo = assertManagedObject(test); assertManagedProperty(mo, "blackList", boolean.class, false); } public void testSetSystem() throws Exception { VFSClassLoaderFactory test = new VFSClassLoaderFactory(); test.setClassLoaderSystemName("test"); ManagedObject mo = assertManagedObject(test); assertManagedProperty(mo, "system", String.class, "test"); } public void testSetRoots() throws Exception { VFSClassLoaderFactory test = new VFSClassLoaderFactory(); List roots = Arrays.asList("test1", "test2"); test.setRoots(roots); ManagedObject mo = assertManagedObject(test); Field field = getClass().getField("rootsSignature"); assertManagedProperty(mo, "roots", field.getGenericType(), roots); } public static List rootsSignature; public void testCapabilities() throws Exception { ClassLoadingMetaDataFactory factory = ClassLoadingMetaDataFactory.getInstance(); VFSClassLoaderFactory test = new VFSClassLoaderFactory(); test.getCapabilities().addCapability(factory.createModule("module")); test.getCapabilities().addCapability(factory.createPackage("package")); ManagedObject mo = assertManagedObject(test); assertManagedProperty(mo, "requirements", RequirementsMetaData.class, test.getRequirements()); } public void testRequirements() throws Exception { ClassLoadingMetaDataFactory factory = ClassLoadingMetaDataFactory.getInstance(); VFSClassLoaderFactory test = new VFSClassLoaderFactory(); test.getRequirements().addRequirement(factory.createRequireModule("module")); test.getRequirements().addRequirement(factory.createRequirePackage("package")); ManagedObject mo = assertManagedObject(test); assertManagedProperty(mo, "requirements", RequirementsMetaData.class, test.getRequirements()); } } ././@LongLink0000000000000000000000000000023100000000000011561 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloading-vfs/src/test/java/org/jboss/test/classloading/vfs/metadata/test/VFSResourceVisitorUnitTestCase.javalibjboss-classloader-java-2.0.6.GA.orig/classloading-vfs/src/test/java/org/jboss/test/classloading/v0000644000175000017500000003543611071406374033407 0ustar twernertwerner/* * JBoss, Home of Professional Open Source. * Copyright 2008, Red Hat Middleware LLC, and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.test.classloading.vfs.metadata.test; import java.io.IOException; import java.io.InputStream; import java.net.URL; import java.util.Arrays; import java.util.HashMap; import java.util.HashSet; import java.util.Iterator; import java.util.List; import java.util.Map; import java.util.Set; import java.util.TreeSet; import java.util.ArrayList; import junit.framework.Test; import org.jboss.classloader.plugins.ClassLoaderUtils; import org.jboss.classloading.plugins.visitor.FederatedResourceVisitor; import org.jboss.classloading.spi.dependency.Module; import org.jboss.classloading.spi.vfs.metadata.VFSClassLoaderFactory; import org.jboss.classloading.spi.visitor.ClassVisitor; import org.jboss.classloading.spi.visitor.ResourceContext; import org.jboss.classloading.spi.visitor.ResourceFilter; import org.jboss.classloading.spi.visitor.ResourceVisitor; import org.jboss.kernel.spi.deployment.KernelDeployment; import org.jboss.test.classloading.vfs.metadata.VFSClassLoadingMicrocontainerTest; import org.jboss.test.classloading.vfs.metadata.support.a.A; import org.jboss.test.classloading.vfs.metadata.support.b.B; import org.jboss.test.classloading.vfs.metadata.support.c.C; /** * VFSResourceVisitorUnitTestCase. * * @author Ales Justin */ public class VFSResourceVisitorUnitTestCase extends VFSClassLoadingMicrocontainerTest { private static Map> aliases; static { aliases = new HashMap>(); aliases.put("a/A.class", A.class); aliases.put("b/B.class", B.class); aliases.put("c/C.class", C.class); } public static Test suite() { return suite(VFSResourceVisitorUnitTestCase.class); } public VFSResourceVisitorUnitTestCase(String name) { super(name); } protected void setUp() throws Exception { super.setUp(); URL url = getClass().getResource("VFSResourceVisitorUnitTestCase.class"); String urlString = url.toExternalForm(); String end = "/test/VFSResourceVisitorUnitTestCase.class"; int length = urlString.length() - end.length(); urlString = urlString.substring(0, length); System.setProperty("test.dir", urlString); } public void testFromXml() throws Exception { KernelDeployment deployment = deploy("VFSResourceVisitorTest.xml"); try { validate(); visitModule(); } finally { undeploy(deployment); } } public void testFromAPI() throws Exception { VFSClassLoaderFactory factory = new VFSClassLoaderFactory("test"); factory.setRoots(Arrays.asList(System.getProperty("test.dir") + "/support/")); KernelDeployment deployment = install(factory); try { visitModule(); } finally { undeploy(deployment); } } public void testBytes() throws Exception { VFSClassLoaderFactory factory = new VFSClassLoaderFactory("test"); factory.setRoots(Arrays.asList(System.getProperty("test.dir") + "/support/")); KernelDeployment deployment = install(factory); try { final Map bytes = new HashMap(); ResourceVisitor visitor = new ClassVisitor() { public void visit(ResourceContext resource) { try { bytes.put(resource.getResourceName(), resource.getBytes()); } catch (IOException e) { throw new Error(e); } } }; Module module = assertModule("test:0.0.0"); module.visit(visitor); assertFalse(bytes.isEmpty()); for (Map.Entry entry : bytes.entrySet()) { Class clazz = aliases.get(entry.getKey()); assertNotNull(clazz); URL url = new URL(getRoot(clazz) + ClassLoaderUtils.classNameToPath(clazz)); InputStream in = url.openStream(); try { byte[] classBytes = ClassLoaderUtils.loadBytes(in); byte[] value = entry.getValue(); assertTrue(Arrays.equals(classBytes, value)); } finally { in.close(); } } } finally { undeploy(deployment); } } public void testClassloading() throws Exception { VFSClassLoaderFactory factory = new VFSClassLoaderFactory("test"); factory.setRoots(Arrays.asList(getRoot(getClass()))); KernelDeployment deployment = install(factory); try { ResourceVisitor visitor = new ResourceVisitor() { public ResourceFilter getFilter() { return new ResourceFilter() { public boolean accepts(ResourceContext resource) { return resource.isClass() && resource.getResourceName().contains("C.class"); } }; } public void visit(ResourceContext resource) { Class clazz = resource.loadClass(); assertEquals(C.class.getName(), clazz.getName()); } }; Module module = assertModule("test:0.0.0"); module.visit(visitor); } finally { undeploy(deployment); } } public void testRecurseFilter() throws Exception { VFSClassLoaderFactory factory = new VFSClassLoaderFactory("test"); factory.setRoots(Arrays.asList(System.getProperty("test.dir") + "/support/")); KernelDeployment deployment = install(factory); try { final Set classes = new HashSet(); ResourceVisitor visitor = new ClassVisitor() { public void visit(ResourceContext resource) { classes.add(resource.getResourceName()); } }; ResourceFilter recurseFilter = new ResourceFilter() { public boolean accepts(ResourceContext resource) { return "a".equals(resource.getResourceName()); } }; Module module = assertModule("test:0.0.0"); module.visit(visitor, visitor.getFilter(), recurseFilter); assertEquals(1, classes.size()); assertEquals(aliases.get(classes.iterator().next()), A.class); } finally { undeploy(deployment); } } public void testRecurseFilterFromTop() throws Exception { VFSClassLoaderFactory factory = new VFSClassLoaderFactory("test"); factory.setRoots(Arrays.asList(getRoot(getClass()))); KernelDeployment deployment = install(factory); try { final Set classes = new HashSet(); ResourceVisitor visitor = new ResourceVisitor() { public ResourceFilter getFilter() { return new ResourceFilter() { public boolean accepts(ResourceContext resource) { return resource.getResourceName().contains("support"); } }; } public void visit(ResourceContext resource) { classes.add(resource.getClassName()); } }; final String pathA = ClassLoaderUtils.packageNameToPath(A.class.getName()); final int pathAlength = pathA.length(); ResourceFilter recurseFilter = new ResourceFilter() { public boolean accepts(ResourceContext resource) { String resourceName = resource.getResourceName(); int min = Math.min(resourceName.length(), pathAlength); return pathA.substring(0, min).equals(resourceName.substring(0, min)); } }; Module module = assertModule("test:0.0.0"); module.visit(visitor, visitor.getFilter(), recurseFilter); assertEquals(1, classes.size()); assertEquals(classes.iterator().next(), A.class.getName()); } finally { undeploy(deployment); } } public void testUrlsParameter() throws Exception { VFSClassLoaderFactory factory = new VFSClassLoaderFactory("test"); factory.setRoots( Arrays.asList( System.getProperty("test.dir") + "/support/a", System.getProperty("test.dir") + "/support/b", System.getProperty("test.dir") + "/support/c" ) ); KernelDeployment deployment = install(factory); try { final Set classes = new HashSet(); ResourceVisitor visitor = new ClassVisitor() { public void visit(ResourceContext resource) { classes.add(resource.getResourceName()); } }; URL aURL = new URL("vfs" + System.getProperty("test.dir") + "/support/a/"); Module module = assertModule("test:0.0.0"); module.visit(visitor, visitor.getFilter(), null, aURL); assertEquals(1, classes.size()); assertEquals(classes.iterator().next(), A.class.getSimpleName() + ".class"); } finally { undeploy(deployment); } } public void testUrlsParameters() throws Exception { VFSClassLoaderFactory factory = new VFSClassLoaderFactory("test"); factory.setRoots( Arrays.asList( System.getProperty("test.dir") + "/support/a", System.getProperty("test.dir") + "/support/b", System.getProperty("test.dir") + "/support/c" ) ); KernelDeployment deployment = install(factory); try { final Set classes = new TreeSet(); ResourceVisitor visitor = new ClassVisitor() { public void visit(ResourceContext resource) { classes.add(resource.getResourceName()); } }; URL aURL = new URL("vfs" + System.getProperty("test.dir") + "/support/a/"); URL bURL = new URL("vfs" + System.getProperty("test.dir") + "/support/b/"); Module module = assertModule("test:0.0.0"); module.visit(visitor, visitor.getFilter(), null, aURL, bURL); assertEquals(2, classes.size()); Iterator iterator = classes.iterator(); assertEquals(iterator.next(), A.class.getSimpleName() + ".class"); assertEquals(iterator.next(), B.class.getSimpleName() + ".class"); } finally { undeploy(deployment); } } public void testFederated() throws Exception { VFSClassLoaderFactory factory = new VFSClassLoaderFactory("test"); factory.setRoots(Arrays.asList(System.getProperty("test.dir") + "/support/")); KernelDeployment deployment = install(factory); try { final List classes = new ArrayList(); ResourceVisitor visitor = new ClassVisitor() { public void visit(ResourceContext resource) { classes.add(resource.getResourceName()); } }; ResourceFilter rfA = new ResourceFilter() { public boolean accepts(ResourceContext resource) { return "a".equals(resource.getResourceName()); } }; ResourceFilter rfB = new ResourceFilter() { public boolean accepts(ResourceContext resource) { return "b".equals(resource.getResourceName()); } }; FederatedResourceVisitor fedRV = new FederatedResourceVisitor( new ResourceVisitor[]{visitor, visitor}, null, new ResourceFilter[]{rfA, rfB} ); Module module = assertModule("test:0.0.0"); module.visit(fedRV, fedRV.getFilter(), fedRV.getRecurseFilter()); assertEquals(2, classes.size()); assertTrue(classes.contains("a/A.class")); assertTrue(classes.contains("b/B.class")); } finally { undeploy(deployment); } } public void testFederatedMixed() throws Exception { VFSClassLoaderFactory factory = new VFSClassLoaderFactory("test"); factory.setRoots(Arrays.asList(System.getProperty("test.dir") + "/support/")); KernelDeployment deployment = install(factory); try { final List classes = new ArrayList(); ResourceVisitor visitor = new ClassVisitor() { public void visit(ResourceContext resource) { classes.add(resource.getResourceName()); } }; ResourceFilter rfA = new ResourceFilter() { public boolean accepts(ResourceContext resource) { return "a".equals(resource.getResourceName()); } }; FederatedResourceVisitor fedRV = new FederatedResourceVisitor( new ResourceVisitor[]{visitor, visitor}, null, new ResourceFilter[]{rfA, null} ); Module module = assertModule("test:0.0.0"); module.visit(fedRV, fedRV.getFilter(), fedRV.getRecurseFilter()); assertEquals(4, classes.size()); // A, A, B, C } finally { undeploy(deployment); } } protected void visitModule() { Module module = assertModule("test:0.0.0"); final Set set = new HashSet(); ResourceVisitor visitor = new ClassVisitor() { public void visit(ResourceContext resource) { set.add(resource.getResourceName()); } }; module.visit(visitor); assertEquals(aliases.keySet(), set); } }././@LongLink0000000000000000000000000000016500000000000011567 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloading-vfs/src/test/java/org/jboss/test/classloading/vfs/metadata/xml/libjboss-classloader-java-2.0.6.GA.orig/classloading-vfs/src/test/java/org/jboss/test/classloading/v0000755000175000017500000000000011620043415033363 5ustar twernertwerner././@LongLink0000000000000000000000000000017200000000000011565 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloading-vfs/src/test/java/org/jboss/test/classloading/vfs/metadata/xml/test/libjboss-classloader-java-2.0.6.GA.orig/classloading-vfs/src/test/java/org/jboss/test/classloading/v0000755000175000017500000000000011620043415033363 5ustar twernertwerner././@LongLink0000000000000000000000000000024300000000000011564 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloading-vfs/src/test/java/org/jboss/test/classloading/vfs/metadata/xml/test/VFSClassLoaderFactoryXMLUnitTestCase.javalibjboss-classloader-java-2.0.6.GA.orig/classloading-vfs/src/test/java/org/jboss/test/classloading/v0000644000175000017500000003626511005334164033402 0ustar twernertwerner/* * JBoss, Home of Professional Open Source. * Copyright 2008, Red Hat Middleware LLC, and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.test.classloading.vfs.metadata.xml.test; import java.util.ArrayList; import java.util.Arrays; import java.util.List; import junit.framework.Test; import org.jboss.classloading.spi.metadata.Capability; import org.jboss.classloading.spi.metadata.ClassLoadingMetaDataFactory; import org.jboss.classloading.spi.metadata.ExportAll; import org.jboss.classloading.spi.metadata.Requirement; import org.jboss.classloading.spi.version.Version; import org.jboss.classloading.spi.version.VersionRange; import org.jboss.classloading.spi.vfs.metadata.VFSClassLoaderFactory; import org.jboss.classloading.spi.vfs.metadata.VFSClassLoaderFactory10; import org.jboss.test.classloading.vfs.metadata.xml.AbstractJBossXBTest; import org.jboss.test.classloading.vfs.metadata.xml.support.TestCapability; import org.jboss.test.classloading.vfs.metadata.xml.support.TestRequirement; /** * VFSClassLoaderFactoryXMLUnitTestCase. * * @author Adrian Brock * @version $Revision: 1.1 $ */ public class VFSClassLoaderFactoryXMLUnitTestCase extends AbstractJBossXBTest { public static Test suite() { return suite(VFSClassLoaderFactoryXMLUnitTestCase.class); } public VFSClassLoaderFactoryXMLUnitTestCase(String name) { super(name); } public void testModuleName() throws Exception { VFSClassLoaderFactory result = unmarshal(); assertEquals("test", result.getName()); assertEquals(Version.DEFAULT_VERSION, result.getVersion()); assertNull(result.getContextName()); assertNull(result.getDomain()); assertNull(result.getParentDomain()); assertNull(result.getExportAll()); assertNull(result.getIncludedPackages()); assertNull(result.getExcludedPackages()); assertNull(result.getExcludedExportPackages()); assertFalse(result.isImportAll()); assertTrue(result.isJ2seClassLoadingCompliance()); assertTrue(result.isCacheable()); assertTrue(result.isBlackListable()); assertEmpty(result.getRoots()); assertEquals(VFSClassLoaderFactory.DEFAULT_CLASSLOADER_SYSTEM_NAME, result.getClassLoaderSystemName()); assertNull(result.getCapabilities().getCapabilities()); assertNull(result.getRequirements().getRequirements()); } public void testModuleVersion() throws Exception { VFSClassLoaderFactory result = unmarshal(); assertEquals(Version.parseVersion("1.0.0"), result.getVersion()); } public void testModuleContext() throws Exception { VFSClassLoaderFactory result = unmarshal(); assertEquals("Context", result.getContextName()); } public void testModuleDomain() throws Exception { VFSClassLoaderFactory result = unmarshal(); assertEquals("testDomain", result.getDomain()); } public void testModuleParentDomain() throws Exception { VFSClassLoaderFactory result = unmarshal(); assertEquals("testParentDomain", result.getParentDomain()); } public void testModuleExportAll() throws Exception { VFSClassLoaderFactory result = unmarshal(); assertEquals(ExportAll.ALL, result.getExportAll()); } public void testModuleIncluded() throws Exception { VFSClassLoaderFactory result = unmarshal(); assertEquals("Included", result.getIncludedPackages()); } public void testModuleExcluded() throws Exception { VFSClassLoaderFactory result = unmarshal(); assertEquals("Excluded", result.getExcludedPackages()); } public void testModuleExcludedExport() throws Exception { VFSClassLoaderFactory result = unmarshal(); assertEquals("ExcludedExport", result.getExcludedExportPackages()); } public void testModuleImportAll() throws Exception { VFSClassLoaderFactory result = unmarshal(); assertTrue(result.isImportAll()); } public void testModuleJ2seClassLoadingCompliance() throws Exception { VFSClassLoaderFactory result = unmarshal(); assertFalse(result.isJ2seClassLoadingCompliance()); } public void testModuleCache() throws Exception { VFSClassLoaderFactory result = unmarshal(); assertFalse(result.isCacheable()); } public void testModuleBlackList() throws Exception { VFSClassLoaderFactory result = unmarshal(); assertFalse(result.isBlackListable()); } public void testModuleSystem() throws Exception { VFSClassLoaderFactory result = unmarshal(); assertEquals("System", result.getClassLoaderSystemName()); } public void testModuleRoots() throws Exception { VFSClassLoaderFactory result = unmarshal(); assertEquals(Arrays.asList("root1", "root2", "root3"), result.getRoots()); } public void testExportOneModuleNoVersion() throws Exception { VFSClassLoaderFactory result = unmarshal(); ClassLoadingMetaDataFactory factory = ClassLoadingMetaDataFactory.getInstance(); assertCapabilities(result, factory.createModule("export1")); } public void testExportOneModuleVersioned() throws Exception { VFSClassLoaderFactory result = unmarshal(); ClassLoadingMetaDataFactory factory = ClassLoadingMetaDataFactory.getInstance(); assertCapabilities(result, factory.createModule("export1", "1.0.0")); } public void testExportThreeModules() throws Exception { VFSClassLoaderFactory result = unmarshal(); ClassLoadingMetaDataFactory factory = ClassLoadingMetaDataFactory.getInstance(); assertCapabilities(result, factory.createModule("export1", "1.0.0"), factory.createModule("export2", "2.0.0"), factory.createModule("export3", "3.0.0")); } public void testExportOnePackageNoVersion() throws Exception { VFSClassLoaderFactory result = unmarshal(); ClassLoadingMetaDataFactory factory = ClassLoadingMetaDataFactory.getInstance(); assertCapabilities(result, factory.createPackage("export1")); } public void testExportOnePackageVersioned() throws Exception { VFSClassLoaderFactory result = unmarshal(); ClassLoadingMetaDataFactory factory = ClassLoadingMetaDataFactory.getInstance(); assertCapabilities(result, factory.createPackage("export1", "1.0.0")); } public void testExportThreePackages() throws Exception { VFSClassLoaderFactory result = unmarshal(); ClassLoadingMetaDataFactory factory = ClassLoadingMetaDataFactory.getInstance(); assertCapabilities(result, factory.createPackage("export1", "1.0.0"), factory.createPackage("export2", "2.0.0"), factory.createPackage("export3", "3.0.0")); } public void testImportOneModuleNoVersion() throws Exception { VFSClassLoaderFactory result = unmarshal(); ClassLoadingMetaDataFactory factory = ClassLoadingMetaDataFactory.getInstance(); assertRequirements(result, factory.createRequireModule("export1")); } public void testImportOneModuleVersioned() throws Exception { VFSClassLoaderFactory result = unmarshal(); ClassLoadingMetaDataFactory factory = ClassLoadingMetaDataFactory.getInstance(); assertRequirements(result, factory.createRequireModule("export1", new VersionRange("1.0.0", "2.0.0"))); } public void testImportThreeModules() throws Exception { VFSClassLoaderFactory result = unmarshal(); ClassLoadingMetaDataFactory factory = ClassLoadingMetaDataFactory.getInstance(); assertRequirements(result, factory.createRequireModule("export1", new VersionRange("1.0.0", "1.1.0")), factory.createRequireModule("export2", new VersionRange("2.0.0", "2.1.0")), factory.createRequireModule("export3", new VersionRange("3.0.0", "3.1.0"))); } public void testImportOnePackageNoVersion() throws Exception { VFSClassLoaderFactory result = unmarshal(); ClassLoadingMetaDataFactory factory = ClassLoadingMetaDataFactory.getInstance(); assertRequirements(result, factory.createRequirePackage("export1")); } public void testImportOnePackageVersioned() throws Exception { VFSClassLoaderFactory result = unmarshal(); ClassLoadingMetaDataFactory factory = ClassLoadingMetaDataFactory.getInstance(); assertRequirements(result, factory.createRequirePackage("export1", new VersionRange("1.0.0", "2.0.0"))); } public void testImportThreePackages() throws Exception { VFSClassLoaderFactory result = unmarshal(); ClassLoadingMetaDataFactory factory = ClassLoadingMetaDataFactory.getInstance(); assertRequirements(result, factory.createRequirePackage("export1", new VersionRange("1.0.0", "1.1.0")), factory.createRequirePackage("export2", new VersionRange("2.0.0", "2.1.0")), factory.createRequirePackage("export3", new VersionRange("3.0.0", "3.1.0"))); } public void testImportVersionRange() throws Exception { VFSClassLoaderFactory result = unmarshal(); ClassLoadingMetaDataFactory factory = ClassLoadingMetaDataFactory.getInstance(); assertRequirements(result, factory.createRequireModule("export1"), factory.createRequireModule("export2", new VersionRange("1.0.0")), factory.createRequireModule("export3", new VersionRange("0.0.0", "1.0.0")), factory.createRequireModule("export4", new VersionRange("1.0.0", "2.0.0")), factory.createRequireModule("export5", new VersionRange("1.0.0", false, "2.0.0", false)), factory.createRequireModule("export6", new VersionRange("1.0.0", false, "2.0.0", true)), factory.createRequireModule("export7", new VersionRange("1.0.0", true, "2.0.0", false)), factory.createRequireModule("export8", new VersionRange("1.0.0", true, "2.0.0", true))); } public void testExportImportMixed() throws Exception { VFSClassLoaderFactory result = unmarshal(); ClassLoadingMetaDataFactory factory = ClassLoadingMetaDataFactory.getInstance(); assertCapabilities(result, factory.createModule("test2", "2.0.0"), factory.createPackage("test2", "2.0.0"), factory.createModule("test1", "1.0.0"), factory.createPackage("test1", "1.0.0")); assertRequirements(result, factory.createRequireModule("test2", new VersionRange("2.0.0")), factory.createRequirePackage("test2", new VersionRange("2.0.0")), factory.createRequireModule("test1", new VersionRange("1.0.0")), factory.createRequirePackage("test1", new VersionRange("1.0.0"))); } public void testWildcardCapability() throws Exception { VFSClassLoaderFactory result = unmarshal(TestCapability.class); ClassLoadingMetaDataFactory factory = ClassLoadingMetaDataFactory.getInstance(); assertCapabilities(result, factory.createModule("test1", "1.0.0"), factory.createPackage("test1", "1.0.0"), new TestCapability("test", "1.0.0")); } public void testWildcardRequirement() throws Exception { VFSClassLoaderFactory result = unmarshal(TestRequirement.class); ClassLoadingMetaDataFactory factory = ClassLoadingMetaDataFactory.getInstance(); assertRequirements(result, factory.createRequireModule("test1", new VersionRange("1.0.0")), factory.createRequirePackage("test1", new VersionRange("1.0.0")), new TestRequirement("test", new VersionRange("1.0.0"))); } public void testOptionalRequirement() throws Exception { VFSClassLoaderFactory result = unmarshal(TestRequirement.class); ClassLoadingMetaDataFactory factory = ClassLoadingMetaDataFactory.getInstance(); assertRequirements(result, factory.createRequireModule("test1", new VersionRange("1.0.0"), true, false, false), factory.createRequirePackage("test1", new VersionRange("1.0.0"), true, false, false)); } public void testReExportRequirement() throws Exception { VFSClassLoaderFactory result = unmarshal(TestRequirement.class); ClassLoadingMetaDataFactory factory = ClassLoadingMetaDataFactory.getInstance(); assertRequirements(result, factory.createReExportModule("test1", new VersionRange("1.0.0")), factory.createReExportPackage("test1", new VersionRange("1.0.0"))); } public void testDynamicRequirement() throws Exception { VFSClassLoaderFactory result = unmarshal(TestRequirement.class); ClassLoadingMetaDataFactory factory = ClassLoadingMetaDataFactory.getInstance(); assertRequirements(result, factory.createRequireModule("test1", new VersionRange("1.0.0"), false, false, true), factory.createRequirePackage("test1", new VersionRange("1.0.0"), false, false, true)); } public void testUsesRequirement() throws Exception { VFSClassLoaderFactory result = unmarshal(TestRequirement.class); ClassLoadingMetaDataFactory factory = ClassLoadingMetaDataFactory.getInstance(); assertRequirements(result, factory.createUsesPackage("test1", new VersionRange("1.0.0"))); } public void assertCapabilities(VFSClassLoaderFactory metadata, Capability... expected) { List temp = new ArrayList(); for (Capability capability : expected) temp.add(capability); assertEquals(temp, metadata.getCapabilities().getCapabilities()); } public void assertRequirements(org.jboss.classloading.spi.vfs.metadata.VFSClassLoaderFactory metadata, Requirement... expected) { List temp = new ArrayList(); for (Requirement requirement : expected) temp.add(requirement); assertEquals(temp, metadata.getRequirements().getRequirements()); } protected VFSClassLoaderFactory unmarshal(Class... extra) throws Exception { return unmarshalObject(VFSClassLoaderFactory10.class, VFSClassLoaderFactory10.class, extra); } } ././@LongLink0000000000000000000000000000024400000000000011565 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloading-vfs/src/test/java/org/jboss/test/classloading/vfs/metadata/xml/test/NoopClassLoaderFactoryXMLUnitTestCase.javalibjboss-classloader-java-2.0.6.GA.orig/classloading-vfs/src/test/java/org/jboss/test/classloading/v0000644000175000017500000000603711173151646033404 0ustar twernertwerner/* * JBoss, Home of Professional Open Source. * Copyright 2008, Red Hat Middleware LLC, and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.test.classloading.vfs.metadata.xml.test; import junit.framework.Test; import org.jboss.classloading.spi.vfs.metadata.VFSClassLoaderFactory10; import org.jboss.test.classloading.vfs.metadata.xml.AbstractJBossXBTest; import org.jboss.test.classloading.vfs.metadata.xml.support.NoopClassLoaderFactory; import org.jboss.xb.binding.resolver.MutableSchemaResolver; import org.jboss.xb.binding.sunday.unmarshalling.SchemaBindingResolver; import org.jboss.xb.binding.sunday.unmarshalling.SingletonSchemaResolverFactory; /** * NoopClassLoaderFactoryXMLUnitTestCase. * * @author Ales Justin */ public class NoopClassLoaderFactoryXMLUnitTestCase extends AbstractJBossXBTest { public static Test suite() { return suite(NoopClassLoaderFactoryXMLUnitTestCase.class); } public NoopClassLoaderFactoryXMLUnitTestCase(String name) { super(name); } protected void changeMetaDataClass(Class clazz) { SingletonSchemaResolverFactory factory = SingletonSchemaResolverFactory.getInstance(); SchemaBindingResolver resolver = factory.getSchemaBindingResolver(); MutableSchemaResolver msr = assertInstanceOf(resolver, MutableSchemaResolver.class); msr.removeLocationToClassMapping("urn:jboss:classloader:1.0"); msr.mapLocationToClass("urn:jboss:classloader:1.0", clazz); } @Override protected void setUp() throws Exception { changeMetaDataClass(NoopClassLoaderFactory.class); try { super.setUp(); } catch (Exception e) { changeMetaDataClass(VFSClassLoaderFactory10.class); throw e; } } @Override protected void tearDown() throws Exception { try { super.tearDown(); } finally { changeMetaDataClass(VFSClassLoaderFactory10.class); } } public void testExportImportMixed() throws Exception { NoopClassLoaderFactory result = unmarshalObject(NoopClassLoaderFactory.class); assertNotNull(result); } }././@LongLink0000000000000000000000000000021400000000000011562 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloading-vfs/src/test/java/org/jboss/test/classloading/vfs/metadata/xml/TestSchemaResolver.javalibjboss-classloader-java-2.0.6.GA.orig/classloading-vfs/src/test/java/org/jboss/test/classloading/v0000644000175000017500000000536111063447574033411 0ustar twernertwerner/* * JBoss, Home of Professional Open Source * Copyright 2006, JBoss Inc., and individual contributors as indicated * by the @authors tag. See the copyright.txt in the distribution for a * full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.test.classloading.vfs.metadata.xml; import java.util.HashMap; import org.jboss.logging.Logger; import org.jboss.xb.binding.sunday.unmarshalling.SchemaBinding; import org.jboss.xb.binding.sunday.unmarshalling.SchemaBindingResolver; import org.w3c.dom.ls.LSInput; /** * TestSchemaResolver. * * @author Ales Justin * @author Adrian Brock * @version $Revision: 1.1 $ */ public class TestSchemaResolver implements SchemaBindingResolver { private static final Logger log = Logger.getLogger(TestSchemaResolver.class); private HashMap bindings = new HashMap(); public String getBaseURI() { return null; } public void addSchemaBinding(SchemaBinding schemaBinding) { schemaBinding.setSchemaResolver(this); String nsURI = schemaBinding.getNamespaces().iterator().next(); bindings.put(nsURI, schemaBinding); if (log.isTraceEnabled()) { String schema = SchemaPrinter.printSchema(schemaBinding); log.trace("Bound: " + nsURI + "\n" + schema); } } public SchemaBinding resolve(String nsUri, String baseURI, String schemaLocation) { SchemaBinding result = bindings.get(nsUri); if (result == null) throw new RuntimeException("Schema not bound: " + nsUri + " available: " + bindings.keySet()); return result; } public LSInput resolveAsLSInput(String nsUri, String baseUri, String schemaLocation) { throw new UnsupportedOperationException(); } public void setBaseURI(String baseURI) { throw new org.jboss.util.NotImplementedException("setBaseURI"); } } ././@LongLink0000000000000000000000000000021500000000000011563 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloading-vfs/src/test/java/org/jboss/test/classloading/vfs/metadata/xml/JBossXBTestDelegate.javalibjboss-classloader-java-2.0.6.GA.orig/classloading-vfs/src/test/java/org/jboss/test/classloading/v0000644000175000017500000001253210770573424033405 0ustar twernertwerner/* * JBoss, Home of Professional Open Source * Copyright 2006, JBoss Inc., and individual contributors as indicated * by the @authors tag. See the copyright.txt in the distribution for a * full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.test.classloading.vfs.metadata.xml; import java.lang.reflect.Method; import java.net.URL; import org.jboss.net.protocol.URLStreamHandlerFactory; import org.jboss.test.AbstractTestDelegate; import org.jboss.xb.binding.Unmarshaller; import org.jboss.xb.binding.UnmarshallerFactory; import org.jboss.xb.binding.sunday.unmarshalling.DefaultSchemaResolver; import org.jboss.xb.binding.sunday.unmarshalling.SchemaBinding; import org.jboss.xb.binding.sunday.unmarshalling.SchemaBindingResolver; import org.jboss.xb.binding.sunday.unmarshalling.XsdBinder; /** * JBossXBTestDelegate. * * @author Ales Justin * @author Adrian Brock * @version $Revision: 40492 $ */ public class JBossXBTestDelegate extends AbstractTestDelegate { /** Whether initialization has been done */ private static boolean done = false; /** The unmarshaller factory */ protected UnmarshallerFactory unmarshallerFactory; /** The resolver */ protected SchemaBindingResolver defaultResolver; /** * Initialize */ public synchronized static void init() { if (done) return; done = true; URL.setURLStreamHandlerFactory(new URLStreamHandlerFactory()); URLStreamHandlerFactory.preload(); String handlerPkgs = System.getProperty("java.protocol.handler.pkgs"); if (handlerPkgs != null) handlerPkgs += "|org.jboss.net.protocol"; else handlerPkgs = "org.jboss.net.protocol"; System.setProperty("java.protocol.handler.pkgs", handlerPkgs); } /** * Create a new JBossXBTestDelegate. * * @param clazz the test class */ public JBossXBTestDelegate(Class clazz) { super(clazz); } @Override public void setUp() throws Exception { super.setUp(); init(); unmarshallerFactory = UnmarshallerFactory.newInstance(); initResolver(); } protected void initResolver() throws Exception { try { Method method = clazz.getMethod("initResolver", (Class[]) null); defaultResolver = (SchemaBindingResolver) method.invoke(null, (Object[]) null); } catch (NoSuchMethodException ignored) { defaultResolver = new DefaultSchemaResolver(); } } /** * Unmarshal an object * * @param url the url * @param resolver the resolver * @return the object * @throws Exception for any error */ public Object unmarshal(String url, SchemaBindingResolver resolver) throws Exception { if (resolver == null) resolver = defaultResolver; long start = System.currentTimeMillis(); Unmarshaller unmarshaller = unmarshallerFactory.newUnmarshaller(); log.debug("Initialized parsing in " + (System.currentTimeMillis() - start) + "ms"); try { Object result = unmarshaller.unmarshal(url, resolver); log.debug("Total parse for " + url + " took " + (System.currentTimeMillis() - start) + "ms"); return result; } catch (Exception e) { log.debug("Error during parsing: " + url, e); throw e; } } /** * Unmarshal an object * * @param url the url * @param schema the schema * @return the object * @throws Exception for any error */ public Object unmarshal(String url, SchemaBinding schema) throws Exception { long start = System.currentTimeMillis(); Unmarshaller unmarshaller = unmarshallerFactory.newUnmarshaller(); log.debug("Initialized parsing in " + (System.currentTimeMillis() - start) + "ms"); try { Object result = unmarshaller.unmarshal(url, schema); log.debug("Total parse for " + url + " took " + (System.currentTimeMillis() - start) + "ms"); return result; } catch (Exception e) { log.debug("Error during parsing: " + url, e); throw e; } } /** * Bind a schema * * @param url the url * @param resolver the resolver * @return the object * @throws Exception for any error */ public SchemaBinding bind(String url, SchemaBindingResolver resolver) throws Exception { return XsdBinder.bind(url, resolver); } } ././@LongLink0000000000000000000000000000017500000000000011570 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloading-vfs/src/test/java/org/jboss/test/classloading/vfs/metadata/xml/support/libjboss-classloader-java-2.0.6.GA.orig/classloading-vfs/src/test/java/org/jboss/test/classloading/v0000755000175000017500000000000011620043415033363 5ustar twernertwerner././@LongLink0000000000000000000000000000022000000000000011557 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloading-vfs/src/test/java/org/jboss/test/classloading/vfs/metadata/xml/support/TestCapability.javalibjboss-classloader-java-2.0.6.GA.orig/classloading-vfs/src/test/java/org/jboss/test/classloading/v0000644000175000017500000000351310756304615033402 0ustar twernertwerner/* * JBoss, Home of Professional Open Source * Copyright 2007, JBoss Inc., and individual contributors as indicated * by the @authors tag. See the copyright.txt in the distribution for a * full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.test.classloading.vfs.metadata.xml.support; import javax.xml.bind.annotation.XmlNsForm; import javax.xml.bind.annotation.XmlRootElement; import org.jboss.classloading.spi.dependency.Module; import org.jboss.classloading.spi.metadata.Requirement; import org.jboss.classloading.spi.metadata.helpers.AbstractCapability; import org.jboss.xb.annotations.JBossXmlSchema; @JBossXmlSchema(namespace="urn:jboss:test:classloader:capability:1.0", elementFormDefault=XmlNsForm.QUALIFIED) @XmlRootElement(name="test") public class TestCapability extends AbstractCapability { private static final long serialVersionUID = -1L; public TestCapability() { } public TestCapability(String name, Object version) { super(name, version); } public boolean resolves(Module module, Requirement requirement) { return false; } } ././@LongLink0000000000000000000000000000021600000000000011564 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloading-vfs/src/test/java/org/jboss/test/classloading/vfs/metadata/xml/support/package-info.javalibjboss-classloader-java-2.0.6.GA.orig/classloading-vfs/src/test/java/org/jboss/test/classloading/v0000644000175000017500000000262410756304615033404 0ustar twernertwerner/* * JBoss, Home of Professional Open Source * Copyright 2008, JBoss Inc., and individual contributors as indicated * by the @authors tag. See the copyright.txt in the distribution for a * full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ @JBossXmlAdaptedTypes ({ @JBossXmlAdaptedType(type=Version.class, valueAdapter=VersionValueAdapter.class) }) package org.jboss.test.classloading.vfs.metadata.xml.support; import org.jboss.classloading.plugins.metadata.VersionValueAdapter; import org.jboss.classloading.spi.version.Version; import org.jboss.xb.annotations.JBossXmlAdaptedType; import org.jboss.xb.annotations.JBossXmlAdaptedTypes; ././@LongLink0000000000000000000000000000022100000000000011560 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloading-vfs/src/test/java/org/jboss/test/classloading/vfs/metadata/xml/support/TestRequirement.javalibjboss-classloader-java-2.0.6.GA.orig/classloading-vfs/src/test/java/org/jboss/test/classloading/v0000644000175000017500000000327110756304615033403 0ustar twernertwerner/* * JBoss, Home of Professional Open Source * Copyright 2007, JBoss Inc., and individual contributors as indicated * by the @authors tag. See the copyright.txt in the distribution for a * full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.test.classloading.vfs.metadata.xml.support; import javax.xml.bind.annotation.XmlNsForm; import javax.xml.bind.annotation.XmlRootElement; import org.jboss.classloading.spi.metadata.helpers.AbstractRequirement; import org.jboss.classloading.spi.version.VersionRange; import org.jboss.xb.annotations.JBossXmlSchema; @JBossXmlSchema(namespace="urn:jboss:test:classloader:requirement:1.0", elementFormDefault=XmlNsForm.QUALIFIED) @XmlRootElement(name="test") public class TestRequirement extends AbstractRequirement { private static final long serialVersionUID = -1L; public TestRequirement() { } public TestRequirement(String name, VersionRange range) { super(name, range); } } ././@LongLink0000000000000000000000000000023000000000000011560 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloading-vfs/src/test/java/org/jboss/test/classloading/vfs/metadata/xml/support/NoopClassLoaderFactory.javalibjboss-classloader-java-2.0.6.GA.orig/classloading-vfs/src/test/java/org/jboss/test/classloading/v0000644000175000017500000000403011174313174033370 0ustar twernertwerner/* * JBoss, Home of Professional Open Source. * Copyright 2008, Red Hat Middleware LLC, and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.test.classloading.vfs.metadata.xml.support; import java.util.Collections; import java.util.List; import javax.xml.bind.annotation.XmlNsForm; import javax.xml.bind.annotation.XmlRootElement; import javax.xml.bind.annotation.XmlTransient; import javax.xml.bind.annotation.XmlType; import org.jboss.beans.metadata.spi.BeanMetaData; import org.jboss.classloading.spi.vfs.metadata.VFSClassLoaderFactory; import org.jboss.xb.annotations.JBossXmlSchema; /** * Noop cl factory. * * @author Ales Justin */ @JBossXmlSchema(namespace="urn:jboss:classloader:1.0", elementFormDefault=XmlNsForm.QUALIFIED) @XmlRootElement(name="classloader") @XmlType(propOrder = {"requirements", "capabilities", "roots"}) public class NoopClassLoaderFactory extends VFSClassLoaderFactory { private static final long serialVersionUID = 1l; @XmlTransient public List getBeans() { return Collections.emptyList(); } } ././@LongLink0000000000000000000000000000021500000000000011563 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloading-vfs/src/test/java/org/jboss/test/classloading/vfs/metadata/xml/AbstractJBossXBTest.javalibjboss-classloader-java-2.0.6.GA.orig/classloading-vfs/src/test/java/org/jboss/test/classloading/v0000644000175000017500000001064010770573424033403 0ustar twernertwerner/* * JBoss, Home of Professional Open Source * Copyright 2006, JBoss Inc., and individual contributors as indicated * by the @authors tag. See the copyright.txt in the distribution for a * full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.test.classloading.vfs.metadata.xml; import java.net.URL; import org.jboss.test.AbstractTestCaseWithSetup; import org.jboss.test.AbstractTestDelegate; import org.jboss.util.UnreachableStatementException; import org.jboss.xb.binding.sunday.unmarshalling.SchemaBinding; import org.jboss.xb.builder.JBossXBBuilder; /** * AbstractBuilderTest. * * @author Ales Justin * @author Adrian Brock * @version $Revision: 1.1 $ */ public class AbstractJBossXBTest extends AbstractTestCaseWithSetup { public AbstractJBossXBTest(String name) { super(name); } /** * Setup the test delegate * * @param clazz the class * @return the delegate * @throws Exception for any error */ public static AbstractTestDelegate getDelegate(Class clazz) throws Exception { return new JBossXBTestDelegate(clazz); } protected JBossXBTestDelegate getJBossXBDelegate() { return (JBossXBTestDelegate) getDelegate(); } @Override protected void setUp() throws Exception { super.setUp(); configureLogging(); } protected void tearDown() throws Exception { super.tearDown(); } protected T unmarshalObject(Class expected, Class reference, Class... others) throws Exception { TestSchemaResolver resolver = new TestSchemaResolver(); SchemaBinding schemaBinding = JBossXBBuilder.build(reference); resolver.addSchemaBinding(schemaBinding); if (others != null) { for (Class other : others) { SchemaBinding otherBinding = JBossXBBuilder.build(other); resolver.addSchemaBinding(otherBinding); } } String testXml = findTestXml(); Object o = unmarshal(testXml, schemaBinding); assertNotNull(o); getLog().debug("Unmarshalled " + o + " of type " + o.getClass().getName()); try { return expected.cast(o); } catch (ClassCastException e) { fail("Expected " + expected.getName() + " got " + o.getClass().getName()); throw new UnreachableStatementException(); } } /** * Unmarshal some xml * * @param name the name * @param schema the schema * @return the unmarshalled object * @throws Exception for any error */ protected Object unmarshal(String name, SchemaBinding schema) throws Exception { String url = findXML(name); return getJBossXBDelegate().unmarshal(url, schema); } protected T unmarshalObject(Class expected, Class reference) throws Exception { return unmarshalObject(expected, reference, (Class[]) null); } protected T unmarshalObject(Class expected) throws Exception { return unmarshalObject(expected, expected, (Class[]) null); } protected String findTestXml() { return getName().substring(4) + ".xml"; } /** * Find the xml * * @param name the name * @return the url of the xml */ protected String findXML(String name) { URL url = getResource(name); if (url == null) fail(name + " not found"); return url.toString(); } @Override public void configureLogging() { //enableTrace("org.jboss.xb"); } } ././@LongLink0000000000000000000000000000020700000000000011564 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloading-vfs/src/test/java/org/jboss/test/classloading/vfs/metadata/xml/SchemaPrinter.javalibjboss-classloader-java-2.0.6.GA.orig/classloading-vfs/src/test/java/org/jboss/test/classloading/v0000644000175000017500000002447111063447574033414 0ustar twernertwerner/* * JBoss, Home of Professional Open Source * Copyright 2006, JBoss Inc., and individual contributors as indicated * by the @authors tag. See the copyright.txt in the distribution for a * full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.test.classloading.vfs.metadata.xml; import java.util.Collection; import java.util.Iterator; import javax.xml.XMLConstants; import javax.xml.namespace.QName; import org.jboss.xb.binding.sunday.unmarshalling.AllBinding; import org.jboss.xb.binding.sunday.unmarshalling.AttributeBinding; import org.jboss.xb.binding.sunday.unmarshalling.ChoiceBinding; import org.jboss.xb.binding.sunday.unmarshalling.ElementBinding; import org.jboss.xb.binding.sunday.unmarshalling.ModelGroupBinding; import org.jboss.xb.binding.sunday.unmarshalling.ParticleBinding; import org.jboss.xb.binding.sunday.unmarshalling.SchemaBinding; import org.jboss.xb.binding.sunday.unmarshalling.SequenceBinding; import org.jboss.xb.binding.sunday.unmarshalling.TermBinding; import org.jboss.xb.binding.sunday.unmarshalling.TypeBinding; import org.jboss.xb.binding.sunday.unmarshalling.WildcardBinding; /** * SchemaPrinter. * * @author Ales Justin * @author Adrian Brock * @version $Revision: 1.1 $ */ public class SchemaPrinter { @SuppressWarnings("unchecked") public static String printSchema(SchemaBinding schemaBinding) { String nsURI = schemaBinding.getNamespaces().iterator().next(); StringBuilder builder = new StringBuilder(); builder.append("\n"); int pad=3; Iterator elements = schemaBinding.getElementParticles(); while (elements != null && elements.hasNext()) printElement(builder, pad, elements.next()); Iterator types = schemaBinding.getTypes(); while (types != null && types.hasNext()) printType(builder, pad, types.next()); builder.append(""); return builder.toString(); } public static void printElement(StringBuilder builder, int pad, ParticleBinding particle) { ElementBinding element = (ElementBinding) particle.getTerm(); pad(builder, pad); builder.append(""); if (type != null && type.getQName() == null) printAnonymousType(builder, pad + 3, type); pad(builder, pad); builder.append(""); } public static void printAnonymousType(StringBuilder builder, int pad, TypeBinding type) { pad(builder, pad); builder.append(""); TypeBinding baseTypeBinding = type.getBaseType(); String qName; if (baseTypeBinding != null) qName = baseTypeBinding.getQName().toString(); else qName = "xsd:anyType"; pad(builder, pad); builder.append(" "); printTypeInfo(builder, pad+6, type); pad(builder, pad); builder.append(" "); pad(builder, pad); builder.append(""); } public static void printType(StringBuilder builder, int pad, TypeBinding type) { QName name = type.getQName(); if (name != null) { if (XMLConstants.W3C_XML_SCHEMA_NS_URI.equals(name.getNamespaceURI())) return; } if (type.isSimple()) printSimpleType(builder, pad, type); else printComplexType(builder, pad, type); } public static void printSimpleType(StringBuilder builder, int pad, TypeBinding type) { pad(builder, pad); builder.append(""); printTypeInfo(builder, pad+3, type); pad(builder, pad); builder.append(""); } public static void printComplexType(StringBuilder builder, int pad, TypeBinding type) { pad(builder, pad); builder.append(""); printTypeInfo(builder, pad+3, type); pad(builder, pad); builder.append(""); } @SuppressWarnings("unchecked") public static void printTypeInfo(StringBuilder builder, int pad, TypeBinding type) { ParticleBinding particle = type.getParticle(); if (particle != null) { printParticle(builder, pad, particle); } Collection attributes = type.getAttributes(); if (attributes != null) { for (AttributeBinding attribute : attributes) { printAttribute(builder, pad, attribute); } } } public static void printParticle(StringBuilder builder, int pad, ParticleBinding particle) { TermBinding term = particle.getTerm(); if (term instanceof ElementBinding) printElement(builder, pad, particle); else if (term instanceof WildcardBinding) printWildcard(builder, pad, particle); else if (term instanceof SequenceBinding) printModel(builder, pad, particle, "sequence"); else if (term instanceof AllBinding) printModel(builder, pad, particle, "all"); else if (term instanceof ChoiceBinding) printModel(builder, pad, particle, "choice"); } @SuppressWarnings("unchecked") public static void printModel(StringBuilder builder, int pad, ParticleBinding particle, String prefix) { pad(builder, pad); builder.append("<").append(prefix); int minOccurs = particle.getMinOccurs(); if (minOccurs != 1) builder.append(" minOccurs=\"").append(minOccurs).append("\""); int maxOccurs = particle.getMaxOccurs(); if (maxOccurs != 1) { builder.append(" maxOccurs=\""); if (maxOccurs == -1) builder.append("unbounded"); else builder.append(maxOccurs); builder.append("\""); } builder.append(">"); ModelGroupBinding model = (ModelGroupBinding) particle.getTerm(); Collection particles = model.getParticles(); boolean newLine = true; if (particles != null) { for (ParticleBinding component : particles) printParticle(builder, pad+3, component); } else { newLine = false; } pad(builder, pad, newLine); builder.append(""); } public static void printWildcard(StringBuilder builder, int pad, ParticleBinding particle) { pad(builder, pad); builder.append(""); } public static void printAttribute(StringBuilder builder, int pad, AttributeBinding attribute) { pad(builder, pad); TypeBinding typeBinding = attribute.getType(); String qName = null; if (typeBinding != null && typeBinding.getQName() != null) qName = typeBinding.getQName().toString(); else qName = "CDATA"; builder.append(""); } public static void pad(StringBuilder builder, int pad) { pad(builder, pad, true); } public static void pad(StringBuilder builder, int pad, boolean newLine) { if (newLine) builder.append("\n"); for (int i = 0; i < pad; ++ i) builder.append(' '); } } ././@LongLink0000000000000000000000000000022700000000000011566 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloading-vfs/src/test/java/org/jboss/test/classloading/vfs/metadata/VFSClassLoadingMicrocontainerTest.javalibjboss-classloader-java-2.0.6.GA.orig/classloading-vfs/src/test/java/org/jboss/test/classloading/v0000644000175000017500000001763311005352444033401 0ustar twernertwerner/* * JBoss, Home of Professional Open Source * Copyright 2005, JBoss Inc., and individual contributors as indicated * by the @authors tag. See the copyright.txt in the distribution for a * full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.test.classloading.vfs.metadata; import java.net.URL; import java.security.CodeSource; import java.security.ProtectionDomain; import java.util.Collections; import org.jboss.beans.metadata.spi.BeanMetaDataFactory; import org.jboss.classloader.plugins.ClassLoaderUtils; import org.jboss.classloader.plugins.jdk.AbstractJDKChecker; import org.jboss.classloader.plugins.system.DefaultClassLoaderSystem; import org.jboss.classloader.spi.ClassLoaderDomain; import org.jboss.classloader.spi.ClassLoaderSystem; import org.jboss.classloader.spi.ParentPolicy; import org.jboss.classloading.spi.dependency.Module; import org.jboss.classloading.spi.vfs.metadata.VFSClassLoaderFactory; import org.jboss.kernel.plugins.deployment.AbstractKernelDeployment; import org.jboss.kernel.spi.deployment.KernelDeployment; import org.jboss.test.AbstractTestDelegate; import org.jboss.test.kernel.junit.MicrocontainerTest; /** * VFSClassLoadingMicrocontainerTest. * * @author Adrian Brock * @version $Revision: 1.1 $ */ public class VFSClassLoadingMicrocontainerTest extends MicrocontainerTest { protected ClassLoaderSystem system; public static AbstractTestDelegate getDelegate(Class clazz) throws Exception { return new VFSClassLoadingMicrocontainerTestDelegate(clazz); } public static ClassLoaderSystem getClassLoaderSystem() { DefaultClassLoaderSystem system = new DefaultClassLoaderSystem(); ClassLoaderDomain defaultDomain = system.getDefaultDomain(); defaultDomain.setParentPolicy(ParentPolicy.BEFORE_BUT_JAVA_ONLY); return system; } public VFSClassLoadingMicrocontainerTest(String name) { super(name); } protected String getRoot(Class clazz) { URL location = getRootURL(clazz); return location.toString(); } protected URL getRootURL(Class clazz) { ProtectionDomain pd = clazz.getProtectionDomain(); CodeSource cs = pd.getCodeSource(); return cs.getLocation(); } protected String getContextName(VFSClassLoaderFactory factory) { String contextName = factory.getContextName(); if (contextName == null) contextName = factory.getName() + ":" + factory.getVersion(); return contextName; } protected ClassLoader assertClassLoader(VFSClassLoaderFactory factory) throws Exception { return assertClassLoader(getContextName(factory)); } protected ClassLoader assertClassLoader(String name, String version) throws Exception { String contextName = name + ":" + version; return assertClassLoader(contextName); } protected ClassLoader assertClassLoader(String name) throws Exception { Object obj = getBean(name); return assertInstanceOf(obj, ClassLoader.class); } protected void assertNoClassLoader(VFSClassLoaderFactory factory) throws Exception { assertNoClassLoader(getContextName(factory)); } protected void assertNoClassLoader(String name, String version) throws Exception { String contextName = name + ":" + version; assertNoClassLoader(contextName); } protected void assertClassLoader(Class clazz, ClassLoader expected) { if (expected == null) return; ClassLoader cl = clazz.getClassLoader(); boolean result = expected.equals(cl); assertTrue(ClassLoaderUtils.classToString(clazz) + " should have expected classloader=" + expected, result); } protected void assertClassEquality(Class expected, Class actual) { assertTrue("Should be the same " + ClassLoaderUtils.classToString(expected) +" and " + ClassLoaderUtils.classToString(actual), expected == actual); } protected void assertNoClassEquality(Class expected, Class actual) { assertTrue("Should NOT be the same " + ClassLoaderUtils.classToString(expected) +" and " + ClassLoaderUtils.classToString(actual), expected != actual); } protected Class assertLoadClass(Class reference, ClassLoader start) { return assertLoadClass(reference, start, start, false); } protected Class assertLoadClass(Class reference, ClassLoader start, boolean isReference) { return assertLoadClass(reference, start, start, isReference); } protected Class assertLoadClass(Class reference, ClassLoader start, ClassLoader expected) { return assertLoadClass(reference, start, expected, false); } protected Class assertLoadClass(Class reference, ClassLoader start, ClassLoader expected, boolean isReference) { Class result = assertLoadClass(reference.getName(), start, expected); if (isReference) assertClassEquality(reference, result); else assertNoClassEquality(reference, result); return result; } protected Class assertLoadClass(String name, ClassLoader start) { return assertLoadClass(name, start, start); } protected Class assertLoadClass(String name, ClassLoader start, ClassLoader expected) { Class result = null; try { result = start.loadClass(name); getLog().debug("Got class: " + ClassLoaderUtils.classToString(result) + " for " + name + " from " + start); } catch (ClassNotFoundException e) { failure("Did not expect CNFE for " + name + " from " + start, e); } assertClassLoader(result, expected); return result; } protected void assertLoadClassFail(Class reference, ClassLoader start) { assertLoadClassFail(reference.getName(), start); } protected void assertLoadClassFail(String name, ClassLoader start) { try { start.loadClass(name); fail("Should not be here!"); } catch (Exception expected) { checkThrowable(ClassNotFoundException.class, expected); } } protected KernelDeployment install(VFSClassLoaderFactory metaData) throws Exception { AbstractKernelDeployment deployment = new AbstractKernelDeployment(); deployment.setName(metaData.getName() + ":" + metaData.getVersion()); deployment.setBeanFactories(Collections.singletonList((BeanMetaDataFactory) metaData)); deploy(deployment); return deployment; } protected void assertNoClassLoader(String name) throws Exception { try { Object bean = getBean(name, null); if (bean != null) fail("Should not be here: " + bean); } catch (Throwable t) { checkThrowable(IllegalStateException.class, t); } } protected Module assertModule(String contextName) { return assertBean(contextName + "$MODULE", Module.class); } protected void setUp() throws Exception { super.setUp(); // This is a hack for a hack. ;-) AbstractJDKChecker.getExcluded().add(VFSClassLoadingMicrocontainerTest.class); system = (ClassLoaderSystem) getBean("ClassLoaderSystem"); } } ././@LongLink0000000000000000000000000000023700000000000011567 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloading-vfs/src/test/java/org/jboss/test/classloading/vfs/metadata/VFSClassLoadingMicrocontainerTestDelegate.javalibjboss-classloader-java-2.0.6.GA.orig/classloading-vfs/src/test/java/org/jboss/test/classloading/v0000644000175000017500000000340011005334164033363 0ustar twernertwerner/* * JBoss, Home of Professional Open Source * Copyright 2008, JBoss Inc., and individual contributors as indicated * by the @authors tag. See the copyright.txt in the distribution for a * full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.test.classloading.vfs.metadata; import java.net.URL; import org.jboss.test.kernel.junit.MicrocontainerTestDelegate; /** * * An VFSCLMicrocontainerTestDelegate. * * @author Adrian Brock * @version $Revision: 63094 $ */ public class VFSClassLoadingMicrocontainerTestDelegate extends MicrocontainerTestDelegate { public VFSClassLoadingMicrocontainerTestDelegate(Class clazz) throws Exception { super(clazz); } protected void deploy() throws Exception { String common = "/org/jboss/test/classloading/vfs/metadata/Common.xml"; URL url = getClass().getResource(common); if (url == null) throw new IllegalStateException(common + " not found"); deploy(url); super.deploy(); } } ././@LongLink0000000000000000000000000000017100000000000011564 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloading-vfs/src/test/java/org/jboss/test/classloading/vfs/metadata/support/libjboss-classloader-java-2.0.6.GA.orig/classloading-vfs/src/test/java/org/jboss/test/classloading/v0000755000175000017500000000000011620043415033363 5ustar twernertwerner././@LongLink0000000000000000000000000000017300000000000011566 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloading-vfs/src/test/java/org/jboss/test/classloading/vfs/metadata/support/a/libjboss-classloader-java-2.0.6.GA.orig/classloading-vfs/src/test/java/org/jboss/test/classloading/v0000755000175000017500000000000011620043415033363 5ustar twernertwerner././@LongLink0000000000000000000000000000020100000000000011556 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloading-vfs/src/test/java/org/jboss/test/classloading/vfs/metadata/support/a/A.javalibjboss-classloader-java-2.0.6.GA.orig/classloading-vfs/src/test/java/org/jboss/test/classloading/v0000644000175000017500000000223010756304615033375 0ustar twernertwerner/* * JBoss, Home of Professional Open Source * Copyright 2008, JBoss Inc., and individual contributors as indicated * by the @authors tag. See the copyright.txt in the distribution for a * full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.test.classloading.vfs.metadata.support.a; /** * A. * * @author Adrian Brock * @version $Revision: 1.1 $ */ public class A { } ././@LongLink0000000000000000000000000000017300000000000011566 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloading-vfs/src/test/java/org/jboss/test/classloading/vfs/metadata/support/b/libjboss-classloader-java-2.0.6.GA.orig/classloading-vfs/src/test/java/org/jboss/test/classloading/v0000755000175000017500000000000011620043415033363 5ustar twernertwerner././@LongLink0000000000000000000000000000020100000000000011556 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloading-vfs/src/test/java/org/jboss/test/classloading/vfs/metadata/support/b/B.javalibjboss-classloader-java-2.0.6.GA.orig/classloading-vfs/src/test/java/org/jboss/test/classloading/v0000644000175000017500000000223010756304615033375 0ustar twernertwerner/* * JBoss, Home of Professional Open Source * Copyright 2008, JBoss Inc., and individual contributors as indicated * by the @authors tag. See the copyright.txt in the distribution for a * full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.test.classloading.vfs.metadata.support.b; /** * B. * * @author Adrian Brock * @version $Revision: 1.1 $ */ public class B { } ././@LongLink0000000000000000000000000000017300000000000011566 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloading-vfs/src/test/java/org/jboss/test/classloading/vfs/metadata/support/c/libjboss-classloader-java-2.0.6.GA.orig/classloading-vfs/src/test/java/org/jboss/test/classloading/v0000755000175000017500000000000011620043415033363 5ustar twernertwerner././@LongLink0000000000000000000000000000020100000000000011556 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloading-vfs/src/test/java/org/jboss/test/classloading/vfs/metadata/support/c/C.javalibjboss-classloader-java-2.0.6.GA.orig/classloading-vfs/src/test/java/org/jboss/test/classloading/v0000644000175000017500000000223010756304615033375 0ustar twernertwerner/* * JBoss, Home of Professional Open Source * Copyright 2008, JBoss Inc., and individual contributors as indicated * by the @authors tag. See the copyright.txt in the distribution for a * full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.test.classloading.vfs.metadata.support.c; /** * C. * * @author Adrian Brock * @version $Revision: 1.1 $ */ public class C { } libjboss-classloader-java-2.0.6.GA.orig/classloading-vfs/src/main/0000755000175000017500000000000011620043416024671 5ustar twernertwernerlibjboss-classloader-java-2.0.6.GA.orig/classloading-vfs/src/main/resources/0000755000175000017500000000000011620043416026703 5ustar twernertwernerlibjboss-classloader-java-2.0.6.GA.orig/classloading-vfs/src/main/resources/schema/0000755000175000017500000000000011620043416030143 5ustar twernertwerner././@LongLink0000000000000000000000000000015500000000000011566 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloading-vfs/src/main/resources/schema/jboss-classloader-1.0.xsdlibjboss-classloader-java-2.0.6.GA.orig/classloading-vfs/src/main/resources/schema/jboss-classloader0000644000175000017500000003305211071404475033511 0ustar twernertwerner file:/some/path ]]> file:/home/foo/bar/ ]]> using the context attribute you can change this name. ]]> ././@LongLink0000000000000000000000000000015600000000000011567 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloading-vfs/src/main/resources/schema/jboss-classloading-1.0.xsdlibjboss-classloader-java-2.0.6.GA.orig/classloading-vfs/src/main/resources/schema/jboss-classloadin0000644000175000017500000003025111173151646033511 0ustar twernertwerner libjboss-classloader-java-2.0.6.GA.orig/classloading-vfs/src/main/java/0000755000175000017500000000000011620043416025612 5ustar twernertwernerlibjboss-classloader-java-2.0.6.GA.orig/classloading-vfs/src/main/java/org/0000755000175000017500000000000011620043416026401 5ustar twernertwernerlibjboss-classloader-java-2.0.6.GA.orig/classloading-vfs/src/main/java/org/jboss/0000755000175000017500000000000011620043416027521 5ustar twernertwernerlibjboss-classloader-java-2.0.6.GA.orig/classloading-vfs/src/main/java/org/jboss/classloading/0000755000175000017500000000000011620043416032164 5ustar twernertwerner././@LongLink0000000000000000000000000000014700000000000011567 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloading-vfs/src/main/java/org/jboss/classloading/plugins/libjboss-classloader-java-2.0.6.GA.orig/classloading-vfs/src/main/java/org/jboss/classloading/plugin0000755000175000017500000000000011620043416033403 5ustar twernertwerner././@LongLink0000000000000000000000000000015300000000000011564 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloading-vfs/src/main/java/org/jboss/classloading/plugins/vfs/libjboss-classloader-java-2.0.6.GA.orig/classloading-vfs/src/main/java/org/jboss/classloading/plugin0000755000175000017500000000000011620043416033403 5ustar twernertwerner././@LongLink0000000000000000000000000000020200000000000011557 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloading-vfs/src/main/java/org/jboss/classloading/plugins/vfs/VFSResourceContext.javalibjboss-classloader-java-2.0.6.GA.orig/classloading-vfs/src/main/java/org/jboss/classloading/plugin0000644000175000017500000000374011104036311033402 0ustar twernertwerner/* * JBoss, Home of Professional Open Source * Copyright 2006, JBoss Inc., and individual contributors as indicated * by the @authors tag. See the copyright.txt in the distribution for a * full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.classloading.plugins.vfs; import java.net.URL; import java.io.InputStream; import java.io.IOException; import org.jboss.classloading.plugins.visitor.AbstractResourceContext; import org.jboss.virtual.VirtualFile; /** * VFS resource context. * * @author Ales Justin */ public class VFSResourceContext extends AbstractResourceContext { private VirtualFile file; public VFSResourceContext(VirtualFile file, String resourceName, ClassLoader classLoader) { super(resourceName, classLoader); if (file == null) throw new IllegalArgumentException("Null file"); this.file = file; } public URL getUrl() { try { return file.toURL(); } catch (Exception e) { throw new RuntimeException(e); } } public InputStream getInputStream() throws IOException { return file.openStream(); } } ././@LongLink0000000000000000000000000000020200000000000011557 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloading-vfs/src/main/java/org/jboss/classloading/plugins/vfs/VFSResourceVisitor.javalibjboss-classloader-java-2.0.6.GA.orig/classloading-vfs/src/main/java/org/jboss/classloading/plugin0000644000175000017500000001774211044573215033425 0ustar twernertwerner/* * JBoss, Home of Professional Open Source. * Copyright 2007, Red Hat Middleware LLC, and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.classloading.plugins.vfs; import java.net.URL; import org.jboss.classloader.spi.filter.ClassFilter; import org.jboss.classloading.spi.visitor.ResourceContext; import org.jboss.classloading.spi.visitor.ResourceFilter; import org.jboss.classloading.spi.visitor.ResourceVisitor; import org.jboss.virtual.VirtualFile; import org.jboss.virtual.VirtualFileVisitor; import org.jboss.virtual.VisitorAttributes; import org.jboss.virtual.plugins.vfs.helpers.AbstractVirtualFileFilterWithAttributes; /** * Visits a virtual file system recursively * to determine resources * * @author Adrian Brock * @author Ales Justin * @version $Revision: 1.1 $ */ public class VFSResourceVisitor extends AbstractVirtualFileFilterWithAttributes implements VirtualFileVisitor { /** The roots */ private VirtualFile[] roots; /** The excluded roots */ private VirtualFile[] excludedRoots; /** The current root */ private VirtualFile root; /** The root */ private String rootPath; /** The root with slash*/ private String rootPathWithSlash; /** The included packages */ private ClassFilter included; /** The excluded packages */ private ClassFilter excluded; /** The classLoader */ private ClassLoader classLoader; /** The resource visitor */ private ResourceVisitor visitor; /** The resource filter */ private ResourceFilter filter; /** The resource filter */ private ResourceFilter recurseFilter; /** * Visit the resources * * @param roots the roots * @param excludedRoots the excluded roots * @param included the included packages * @param excluded the excluded packages * @param classLoader the classLoader * @param visitor the visitor * @param filter the filter * @param recurseFilter the recurse filter * @param urls the urls */ public static void visit(VirtualFile[] roots, VirtualFile[] excludedRoots, ClassFilter included, ClassFilter excluded, ClassLoader classLoader, ResourceVisitor visitor, ResourceFilter filter, ResourceFilter recurseFilter, URL... urls) { VFSResourceVisitor vfsVisitor = new VFSResourceVisitor(roots, excludedRoots, included, excluded, classLoader, visitor, filter, recurseFilter); for (VirtualFile root : roots) { try { if (urls == null || urls.length == 0 || matchRootWithUrls(root, urls)) { vfsVisitor.setRoot(root); root.visit(vfsVisitor); } } catch (Exception e) { throw new Error("Error visiting " + root, e); } } } /** * Match root with urls. * * @param root one of the roots * @param urls the urls * @return true if root matches one of the urls * @throws Exception for any error */ protected static boolean matchRootWithUrls(VirtualFile root, URL[] urls) throws Exception { URL rootURL = root.toURL(); for (URL url : urls) { if (rootURL.equals(url)) { return true; } } return false; } /** * Create a new VFSResourceVisitor. * * @param roots the roots * @param excludedRoots the excluded roots * @param included the included packages * @param excluded the excluded packages * @param classLoader the classloader * @param visitor the visitor * @param filter the filter * @param recurseFilter the recurse filter */ VFSResourceVisitor(VirtualFile[] roots, VirtualFile[] excludedRoots, ClassFilter included, ClassFilter excluded, ClassLoader classLoader, ResourceVisitor visitor, ResourceFilter filter, ResourceFilter recurseFilter) { if (roots == null) throw new IllegalArgumentException("Null roots"); if (classLoader == null) throw new IllegalArgumentException("Null classloader"); if (visitor == null) throw new IllegalArgumentException("Null visitor"); this.roots = roots; this.excludedRoots = excludedRoots; this.included = included; this.excluded = excluded; this.classLoader = classLoader; this.visitor = visitor; this.filter = filter; this.recurseFilter = recurseFilter; } /** * Set the root * * @param root the root * @throws IllegalArgumentException for a null root */ void setRoot(VirtualFile root) { if (root == null) throw new IllegalArgumentException("Null root"); this.root = root; rootPath = root.getPathName(); rootPathWithSlash = rootPath + "/"; } public VisitorAttributes getAttributes() { VisitorAttributes attributes = new VisitorAttributes(); attributes.setIncludeRoot(false); attributes.setRecurseFilter(this); return attributes; } /** * Determine the file's path. * * @param file the file * @return file's path */ protected String determinePath(VirtualFile file) { String path = file.getPathName(); if (path.equals(rootPath)) path = ""; else if (path.startsWith(rootPathWithSlash)) path = path.substring(rootPathWithSlash.length()); return path; } public boolean accepts(VirtualFile file) { if (recurseFilter != null) { try { String path = determinePath(file); ResourceContext resource = new VFSResourceContext(file, path, classLoader); if (recurseFilter.accepts(resource) == false) return false; } catch (Exception e) { throw new Error("Error accepting " + file, e); } } // This is our current root if (file.equals(root)) return true; // Some other root, it will be handled later for (VirtualFile other : roots) { if (file.equals(other)) return false; } // Is it an excluded root? if (excludedRoots != null) { for (VirtualFile other : excludedRoots) { if (file.equals(other)) return false; } } // Ok return true; } public void visit(VirtualFile file) { try { // We don't want directories if (file.isLeaf() == false) return; // Determine the resource name String path = determinePath(file); // Check for inclusions/exclusions if (included != null && included.matchesResourcePath(path) == false) return; if (excluded != null && excluded.matchesResourcePath(path)) return; ResourceContext resource = new VFSResourceContext(file, path, classLoader); //Check the filter and visit if (filter == null || filter.accepts(resource)) visitor.visit(resource); } catch (Exception e) { throw new Error("Error visiting " + file, e); } } }././@LongLink0000000000000000000000000000017600000000000011571 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloading-vfs/src/main/java/org/jboss/classloading/plugins/vfs/PackageVisitor.javalibjboss-classloader-java-2.0.6.GA.orig/classloading-vfs/src/main/java/org/jboss/classloading/plugin0000644000175000017500000001650611113005567033417 0ustar twernertwerner/* * JBoss, Home of Professional Open Source. * Copyright 2007, Red Hat Middleware LLC, and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.classloading.plugins.vfs; import java.io.IOException; import java.util.HashSet; import java.util.List; import java.util.Set; import org.jboss.classloader.spi.filter.ClassFilter; import org.jboss.classloading.spi.metadata.ExportAll; import org.jboss.virtual.VirtualFile; import org.jboss.virtual.VirtualFileVisitor; import org.jboss.virtual.VisitorAttributes; import org.jboss.virtual.plugins.vfs.helpers.AbstractVirtualFileFilterWithAttributes; /** * Visits a virtual file system recursively * to determine package names based on the exportAll policy * * @author Adrian Brock * @version $Revision: 1.1 $ */ public class PackageVisitor extends AbstractVirtualFileFilterWithAttributes implements VirtualFileVisitor { /** The packages */ private Set packages = new HashSet(); /** The roots */ private VirtualFile[] roots; /** The excluded roots */ private VirtualFile[] excludedRoots; /** The current root */ private VirtualFile root; /** The export all */ private ExportAll exportAll; /** The root */ private String rootPath; /** The root with slash*/ private String rootPathWithSlash; /** The included packages */ private ClassFilter included; /** The excluded packages */ private ClassFilter excluded; /** The excluded export packages */ private ClassFilter excludedExport; /** * Determine the packages * * @param roots the roots * @param excludedRoots the excluded roots * @param exportAll the exportAll * @param included the included packages * @param excluded the excluded packages * @param excludedExport the excluded export packages * @return the packages */ public static Set determineAllPackages(VirtualFile[] roots, VirtualFile[] excludedRoots, ExportAll exportAll, ClassFilter included, ClassFilter excluded, ClassFilter excludedExport) { PackageVisitor visitor = new PackageVisitor(roots, excludedRoots, exportAll, included, excluded, excludedExport); for (VirtualFile root : roots) { try { visitor.setRoot(root); root.visit(visitor); } catch (Exception e) { throw new Error("Error visiting " + root, e); } } return visitor.getPackages(); } /** * Create a new PackageVisitor. * * @param roots the vfs roots * @param excludedRoots the excluded roots * @param exportAll the export all policy * @param included the included packages * @param excluded the excluded packages * @param excludedExport the excluded export packages * @throws IllegalArgumentException for a null exportAll policy */ PackageVisitor(VirtualFile[] roots, VirtualFile[] excludedRoots, ExportAll exportAll, ClassFilter included, ClassFilter excluded, ClassFilter excludedExport) { if (exportAll == null) throw new IllegalArgumentException("Null export policy"); this.roots = roots; this.excludedRoots = excludedRoots; this.exportAll = exportAll; this.included = included; this.excluded = excluded; this.excludedExport = excludedExport; } /** * Set the root * * @param root the root * @throws IllegalArgumentException for a null root */ void setRoot(VirtualFile root) { if (root == null) throw new IllegalArgumentException("Null root"); this.root = root; rootPath = root.getPathName(); rootPathWithSlash = rootPath + "/"; } /** * Get the packages. * * @return the packages. */ Set getPackages() { return packages; } public VisitorAttributes getAttributes() { VisitorAttributes attributes = new VisitorAttributes(); attributes.setIncludeRoot(true); attributes.setRecurseFilter(this); return attributes; } public boolean accepts(VirtualFile file) { // This is our current root if (file.equals(root)) return true; // Some other root, it will be handled later for (VirtualFile other : roots) { if (file.equals(other)) return false; } // Is this an excluded roots? if (excludedRoots != null) { for (VirtualFile other : excludedRoots) { if (file.equals(other)) return false; } } // Ok return true; } public void visit(VirtualFile file) { try { // We only want only directories if (file.isLeaf() == false && accepts(file)) { boolean empty = true; // Include empty directories? if (exportAll == ExportAll.ALL) empty = false; else { // Determine whether there is anything there List children = file.getChildren(); if (children != null && children.isEmpty() == false) { for (VirtualFile child : children) { // We must have a leaf to be non-empty if (child.isLeaf()) { empty = false; break; } } } } // This looks interesting if (empty == false) { String path = file.getPathName(); if (path.equals(rootPath)) path = ""; else if (path.startsWith(rootPathWithSlash)) path = path.substring(rootPathWithSlash.length()); String pkg = path.replace('/', '.'); // Check for inclusions/exclusions if (included != null && included.matchesPackageName(pkg) == false) return; if (excluded != null && excluded.matchesPackageName(pkg)) return; if (excludedExport != null && excludedExport.matchesPackageName(pkg)) return; // Ok this is a package for export packages.add(pkg); } } } catch (IOException e) { throw new Error("Error visiting " + file, e); } } }libjboss-classloader-java-2.0.6.GA.orig/classloading-vfs/src/main/java/org/jboss/classloading/spi/0000755000175000017500000000000011620043416032757 5ustar twernertwerner././@LongLink0000000000000000000000000000014700000000000011567 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloading-vfs/src/main/java/org/jboss/classloading/spi/vfs/libjboss-classloader-java-2.0.6.GA.orig/classloading-vfs/src/main/java/org/jboss/classloading/spi/vf0000755000175000017500000000000011620043416033313 5ustar twernertwerner././@LongLink0000000000000000000000000000015600000000000011567 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloading-vfs/src/main/java/org/jboss/classloading/spi/vfs/policy/libjboss-classloader-java-2.0.6.GA.orig/classloading-vfs/src/main/java/org/jboss/classloading/spi/vf0000755000175000017500000000000011620043416033313 5ustar twernertwerner././@LongLink0000000000000000000000000000020700000000000011564 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloading-vfs/src/main/java/org/jboss/classloading/spi/vfs/policy/VFSClassLoaderPolicy.javalibjboss-classloader-java-2.0.6.GA.orig/classloading-vfs/src/main/java/org/jboss/classloading/spi/vf0000644000175000017500000004347711113005567033336 0ustar twernertwerner/* * JBoss, Home of Professional Open Source. * Copyright 2007, Red Hat Middleware LLC, and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.classloading.spi.vfs.policy; import java.io.IOException; import java.io.InputStream; import java.net.URL; import java.security.CodeSource; import java.security.PermissionCollection; import java.security.Policy; import java.security.ProtectionDomain; import java.security.cert.Certificate; import java.util.Arrays; import java.util.Collections; import java.util.List; import java.util.Map; import java.util.Set; import java.util.concurrent.ConcurrentHashMap; import java.util.jar.Manifest; import org.jboss.classloader.plugins.ClassLoaderUtils; import org.jboss.classloader.spi.ClassLoaderPolicy; import org.jboss.classloader.spi.DelegateLoader; import org.jboss.classloader.spi.PackageInformation; import org.jboss.classloader.spi.filter.ClassFilter; import org.jboss.classloader.spi.filter.FilteredDelegateLoader; import org.jboss.classloading.plugins.vfs.PackageVisitor; import org.jboss.classloading.spi.metadata.ExportAll; import org.jboss.logging.Logger; import org.jboss.util.collection.SoftValueHashMap; import org.jboss.virtual.VFSUtils; import org.jboss.virtual.VirtualFile; /** * VFSClassLoaderPolicy. * * @author Adrian Brock * @author Ales Justin * @author Anil Saldhana * @version $Revision: 1.1 $ */ public class VFSClassLoaderPolicy extends ClassLoaderPolicy { /** The log */ private static Logger log = Logger.getLogger(VFSClassLoaderPolicy.class); /** Tag for no manifest */ private static final Manifest NO_MANIFEST = new Manifest(); /** A name for the policy */ private String name; /** The delegates */ private List delegates; /** The roots */ private VirtualFile[] roots; /** The excluded roots */ private VirtualFile[] excludedRoots; /** Whether to export all */ private ExportAll exportAll; /** The included */ private ClassFilter included; /** The excluded */ private ClassFilter excluded; /** The excluded for export */ private ClassFilter excludedExport; /** The exported packages */ private String[] exportedPackages; /** The import all */ private boolean importAll; /** Whether we are cachable */ private boolean cacheable = true; /** Whether we are blacklistable */ private boolean blackListable = true; /** Manifest cache */ private Map manifestCache = new ConcurrentHashMap(); /** Cache of virtual file information by path */ @SuppressWarnings("unchecked") private Map vfsCache = Collections.synchronizedMap(new SoftValueHashMap()); /** JBCL-64, JBVFS-77: CodeSource should use real url **/ private boolean useRealURL = true; /** * Determine a name from the roots * * @param roots the roots * @return the name */ private static String determineName(VirtualFile[] roots) { if (roots == null) return ""; try { for (VirtualFile root : roots) return root.toURL().toString(); } catch (Exception ignored) { } return ""; } /** * Create a new VFSClassLoaderPolicy. * * @param roots the roots * @return the classloader policy * @throws IllegalArgumentException for null roots */ public static VFSClassLoaderPolicy createVFSClassLoaderPolicy(VirtualFile... roots) { return new VFSClassLoaderPolicy(roots); } /** * Create a new VFSClassLoaderPolicy. * * @param name a name of the policy * @param roots the roots * @return the classloader policy * @throws IllegalArgumentException for null roots */ public static VFSClassLoaderPolicy createVFSClassLoaderPolicy(String name, VirtualFile... roots) { return new VFSClassLoaderPolicy(name, roots); } /** * Create a new VFSClassLoaderPolicy. * * @param roots the roots * @param excludedRoots the excluded roots * @return the classloader policy * @throws IllegalArgumentException for null roots */ public static VFSClassLoaderPolicy createVFSClassLoaderPolicy(VirtualFile[] roots, VirtualFile[] excludedRoots) { return new VFSClassLoaderPolicy(roots, excludedRoots); } /** * Create a new VFSClassLoaderPolicy. * * @param name a name of the policy * @param roots the roots * @param excludedRoots the excluded roots * @return the classloader policy * @throws IllegalArgumentException for null roots */ public static VFSClassLoaderPolicy createVFSClassLoaderPolicy(String name, VirtualFile[] roots, VirtualFile[] excludedRoots) { return new VFSClassLoaderPolicy(name, roots, excludedRoots); } /** * Create a new VFSClassLoaderPolicy. * * @param roots the roots * @throws IllegalArgumentException for null roots */ public VFSClassLoaderPolicy(VirtualFile[] roots) { this(determineName(roots), roots); } /** * Create a new VFSClassLoaderPolicy. * * @param roots the roots * @param excludedRoots the excluded roots * @throws IllegalArgumentException for null roots */ public VFSClassLoaderPolicy(VirtualFile[] roots, VirtualFile[] excludedRoots) { this(determineName(roots), roots, excludedRoots); } /** * Create a new VFSClassLoaderPolicy. * * @param name the name * @param roots the roots * @throws IllegalArgumentException for null roots */ public VFSClassLoaderPolicy(String name, VirtualFile[] roots) { this(name, roots, null); } /** * Create a new VFSClassLoaderPolicy. * * @param name the name * @param roots the roots * @param excludedRoots the excluded roots * @throws IllegalArgumentException for null roots */ public VFSClassLoaderPolicy(String name, VirtualFile[] roots, VirtualFile[] excludedRoots) { if (name == null) throw new IllegalArgumentException("Null name"); if (roots == null) throw new IllegalArgumentException("Null roots"); for (VirtualFile root : roots) { if (root == null) throw new IllegalArgumentException("Null root in " + Arrays.asList(roots)); } if (excludedRoots != null) { for (VirtualFile excludedRoot : excludedRoots) { if (excludedRoot == null) throw new IllegalArgumentException("Null excluded root in " + Arrays.asList(excludedRoots)); } } this.name = name; this.roots = roots; this.excludedRoots = excludedRoots; } @Override public String getName() { return name; } @Override public List getDelegates() { return delegates; } /** * Set the delegates. * * @param delegates the delegates. */ public void setDelegates(List delegates) { this.delegates = delegates; } /** * Get the included. * * @return the included. */ public ClassFilter getIncluded() { return included; } /** * Set the included. * * @param included the included. */ public void setIncluded(ClassFilter included) { this.included = included; } /** * Get the excluded. * * @return the excluded. */ public ClassFilter getExcluded() { return excluded; } /** * Set the excluded. * * @param excluded the excluded. */ public void setExcluded(ClassFilter excluded) { this.excluded = excluded; } /** * Get the excludedExport. * * @return the excludedExport. */ public ClassFilter getExcludedExport() { return excludedExport; } /** * Set the excludedExport. * * @param excludedExport the excludedExport. */ public void setExcludedExport(ClassFilter excludedExport) { this.excludedExport = excludedExport; } /** * Get the exportAll. * * @return the exportAll. */ public ExportAll getExportAll() { return exportAll; } /** * Set the exportAll. * * @param exportAll the exportAll. */ public void setExportAll(ExportAll exportAll) { this.exportAll = exportAll; if (exportAll != null) { if (exportedPackages == null) { Set exported = PackageVisitor.determineAllPackages(roots, excludedRoots, exportAll, included, excluded, excludedExport); exportedPackages = exported.toArray(new String[exported.size()]); } } } /** * Get the exported packages * * @return the exported packages */ public String[] getExportedPackages() { return exportedPackages; } /** * Set the exportedPackages. * * @param exportedPackages the exportedPackages. */ public void setExportedPackages(String[] exportedPackages) { this.exportedPackages = exportedPackages; } @Override public String[] getPackageNames() { return exportedPackages; } @Override public boolean isImportAll() { return importAll; } /** * Set the importAll. * * @param importAll the importAll. */ public void setImportAll(boolean importAll) { this.importAll = importAll; } @Override public boolean isCacheable() { return cacheable; } /** * Set the cacheable. * * @param cacheable the cacheable. */ public void setCacheable(boolean cacheable) { this.cacheable = cacheable; } @Override public boolean isBlackListable() { return blackListable; } /** * Set the blackListable. * * @param blackListable the blackListable. */ public void setBlackListable(boolean blackListable) { this.blackListable = blackListable; } @Override public DelegateLoader getExported() { if (getExportAll() != null) return new FilteredDelegateLoader(this, ClassFilter.EVERYTHING); return super.getExported(); } @Override public URL getResource(String path) { if (checkFilters(path, "getResource")) return null; VirtualFile child = findChild(path); if (child != null) { try { return child.toURL(); } catch (Exception ignored) { log.debug("Error determining URL for " + child, ignored); return null; } } return null; } @Override public InputStream getResourceAsStream(String path) { if (checkFilters(path, "getResourceAsStream")) return null; VirtualFile child = findChild(path); if (child != null) { try { return child.openStream(); } catch (Exception ignored) { log.debug("Error opening stream for " + child, ignored); return null; } } return null; } /** * Do we use real url. * * @return true if real url should be used */ public boolean isUseRealURL() { return useRealURL; } /** * Set use real url flag. * * @param useRealURL the real url flag */ public void setUseRealURL(boolean useRealURL) { this.useRealURL = useRealURL; } @Override public void getResources(String name, Set urls) throws IOException { if (checkFilters(name, "getResources")) return; for (VirtualFile root : roots) { try { VirtualFile child = root.getChild(name); if (child != null) urls.add(child.toURL()); } catch (Exception e) { log.debug("Error getting resources for " + root, e); } } } /** * Find a child from a path * * @param path the path * @return the child if found in the roots */ protected VirtualFile findChild(String path) { VirtualFileInfo vfi = findVirtualFileInfo(path); if (vfi == null) return null; return vfi.getFile(); } /** * Find a root from a path * * @param path the path * @return the root if found in the roots */ protected VirtualFile findRoot(String path) { VirtualFileInfo vfi = findVirtualFileInfo(path); if (vfi == null) return null; return vfi.getRoot(); } /** * Find the virtual file information for a path * * @param path the path * @return the virtual file information */ protected VirtualFileInfo findVirtualFileInfo(String path) { VirtualFileInfo result = vfsCache.get(path); if (result != null) return result; for (VirtualFile root : roots) { try { VirtualFile file = root.getChild(path); if (file != null) { result = new VirtualFileInfo(file, root); vfsCache.put(path, result); return result; } } catch (Exception ignored) { } } return null; } @Override public PackageInformation getClassPackageInformation(String className, String packageName) { String path = ClassLoaderUtils.classNameToPath(className); VirtualFile root = findRoot(path); Manifest manifest = null; URL rootURL = null; if (root != null) { try { rootURL = root.toURL(); manifest = manifestCache.get(rootURL); if (manifest == null) { manifest = VFSUtils.getManifest(root); if (manifest == null) manifestCache.put(rootURL, NO_MANIFEST); else manifestCache.put(rootURL, manifest); } if (manifest == NO_MANIFEST) manifest = null; } catch (Exception ignored) { if (log.isTraceEnabled()) log.trace("Unable to retrieve manifest for " + path + " url=" + rootURL + " error=" + ignored.getMessage()); } } return new PackageInformation(packageName, manifest); } @Override protected void toLongString(StringBuilder builder) { builder.append(" roots=").append(Arrays.asList(roots)).append(" "); super.toLongString(builder); if (exportAll != null) builder.append(exportAll); } @Override protected ProtectionDomain getProtectionDomain(String className, String path) { VirtualFile clazz = findChild(path); if (clazz == null) { if (log.isTraceEnabled()) log.trace("Unable to determine class file for " + className); return null; } try { VirtualFile root = findRoot(path); URL codeSourceURL = isUseRealURL() ? VFSUtils.getRealURL(root) : root.toURL(); if (log.isTraceEnabled()) log.trace("getProtectionDomain:className="+ className + " path="+ path + " codeSourceURL=" + codeSourceURL); Certificate[] certs = null; // TODO JBCL-67 determine certificates CodeSource cs = new CodeSource(codeSourceURL, certs); PermissionCollection permissions = Policy.getPolicy().getPermissions(cs); return new ProtectionDomain(cs, permissions); } catch (Exception e) { throw new Error("Error determining protection domain for " + clazz, e); } } /** * Check the filters * * @param path the path to check * @param context the context * @return true if it fails the filters */ protected boolean checkFilters(String path, String context) { if (included != null && included.matchesResourcePath(path) == false) { if (log.isTraceEnabled()) log.trace(this + " " + context + " path=" + path + " doesn't match include filter: " + included); return true; } if (excluded != null && excluded.matchesResourcePath(path)) { if (log.isTraceEnabled()) log.trace(this + " " + context + " path=" + path + " matches exclude filter: " + excluded); return true; } return false; } /** * VirtualFileInfo. */ private static class VirtualFileInfo { /** The file */ private VirtualFile file; /** The root */ private VirtualFile root; public VirtualFileInfo(VirtualFile file, VirtualFile root) { this.file = file; this.root = root; } /** * Get the file. * * @return the file. */ public VirtualFile getFile() { return file; } /** * Get the root. * * @return the root. */ public VirtualFile getRoot() { return root; } } } ././@LongLink0000000000000000000000000000016000000000000011562 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloading-vfs/src/main/java/org/jboss/classloading/spi/vfs/metadata/libjboss-classloader-java-2.0.6.GA.orig/classloading-vfs/src/main/java/org/jboss/classloading/spi/vf0000755000175000017500000000000011620043416033313 5ustar twernertwerner././@LongLink0000000000000000000000000000020100000000000011556 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloading-vfs/src/main/java/org/jboss/classloading/spi/vfs/metadata/package-info.javalibjboss-classloader-java-2.0.6.GA.orig/classloading-vfs/src/main/java/org/jboss/classloading/spi/vf0000644000175000017500000000260710756304615033334 0ustar twernertwerner/* * JBoss, Home of Professional Open Source * Copyright 2008, JBoss Inc., and individual contributors as indicated * by the @authors tag. See the copyright.txt in the distribution for a * full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ @JBossXmlAdaptedTypes ({ @JBossXmlAdaptedType(type=Version.class, valueAdapter=VersionValueAdapter.class) }) package org.jboss.classloading.spi.vfs.metadata; import org.jboss.classloading.plugins.metadata.VersionValueAdapter; import org.jboss.classloading.spi.version.Version; import org.jboss.xb.annotations.JBossXmlAdaptedType; import org.jboss.xb.annotations.JBossXmlAdaptedTypes; ././@LongLink0000000000000000000000000000021400000000000011562 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloading-vfs/src/main/java/org/jboss/classloading/spi/vfs/metadata/VFSClassLoaderFactory10.javalibjboss-classloader-java-2.0.6.GA.orig/classloading-vfs/src/main/java/org/jboss/classloading/spi/vf0000644000175000017500000000326711173151646033335 0ustar twernertwerner/* * JBoss, Home of Professional Open Source * Copyright 2008, JBoss Inc., and individual contributors as indicated * by the @authors tag. See the copyright.txt in the distribution for a * full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.classloading.spi.vfs.metadata; import javax.xml.bind.annotation.XmlNsForm; import javax.xml.bind.annotation.XmlRootElement; import javax.xml.bind.annotation.XmlType; import org.jboss.xb.annotations.JBossXmlSchema; /** * VFSClassLoaderFactory. * * @author Adrian Brock * @version $Revision: 1.1 $ */ @JBossXmlSchema(namespace="urn:jboss:classloader:1.0", elementFormDefault=XmlNsForm.QUALIFIED) @XmlRootElement(name="classloader") @XmlType(propOrder = {"requirements", "capabilities", "roots"}) public class VFSClassLoaderFactory10 extends VFSClassLoaderFactory { /** The serialVersionUID */ private static final long serialVersionUID = -4446195023830263521L; } ././@LongLink0000000000000000000000000000021200000000000011560 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloading-vfs/src/main/java/org/jboss/classloading/spi/vfs/metadata/VFSClassLoaderFactory.javalibjboss-classloader-java-2.0.6.GA.orig/classloading-vfs/src/main/java/org/jboss/classloading/spi/vf0000644000175000017500000001414711104036311033315 0ustar twernertwerner/* * JBoss, Home of Professional Open Source * Copyright 2008, JBoss Inc., and individual contributors as indicated * by the @authors tag. See the copyright.txt in the distribution for a * full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.classloading.spi.vfs.metadata; import java.util.Arrays; import java.util.List; import java.util.concurrent.CopyOnWriteArrayList; import javax.xml.bind.annotation.XmlAttribute; import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlTransient; import org.jboss.beans.metadata.spi.BeanMetaData; import org.jboss.beans.metadata.spi.BeanMetaDataFactory; import org.jboss.beans.metadata.spi.builder.BeanMetaDataBuilder; import org.jboss.classloader.spi.ClassLoaderSystem; import org.jboss.classloading.spi.metadata.ClassLoadingMetaData; import org.jboss.classloading.spi.version.Version; import org.jboss.classloading.spi.vfs.dependency.VFSClassLoaderPolicyModule; import org.jboss.managed.api.annotation.ManagementProperty; /** * VFSClassLoaderFactory. * * @author Adrian Brock * @version $Revision: 1.1 $ */ public class VFSClassLoaderFactory extends ClassLoadingMetaData implements BeanMetaDataFactory { /** The serialVersionUID */ private static final long serialVersionUID = -4446195023830263521L; /** The default name for the classloading system */ public static final String DEFAULT_CLASSLOADER_SYSTEM_NAME = "ClassLoaderSystem"; /** The name of the classloader system */ private String classLoaderSystemName = DEFAULT_CLASSLOADER_SYSTEM_NAME; /** The context name */ private String contextName = null; /** The roots */ private List roots = new CopyOnWriteArrayList(); /** * Create a new VFSClassLoaderFactory. */ public VFSClassLoaderFactory() { } /** * Create a new VFSClassLoaderFactory. * * @param name the name */ public VFSClassLoaderFactory(String name) { this(name, Version.DEFAULT_VERSION); } /** * Create a new VFSClassLoaderFactory. * * @param name the name * @param version the version */ public VFSClassLoaderFactory(String name, String version) { this(name, Version.parseVersion(version)); } /** * Create a new VFSClassLoaderFactory. * * @param name the name * @param version the version */ public VFSClassLoaderFactory(String name, Version version) { setName(name); setVersion(version); } /** * Get the classLoaderSystemName. * * @return the classLoaderSystemName. */ public String getClassLoaderSystemName() { return classLoaderSystemName; } /** * Set the classLoaderSystemName. * * @param classLoaderSystemName the classLoaderSystemName. */ @ManagementProperty(name="system") @XmlAttribute(name="system") public void setClassLoaderSystemName(String classLoaderSystemName) { if (classLoaderSystemName == null) classLoaderSystemName = DEFAULT_CLASSLOADER_SYSTEM_NAME; this.classLoaderSystemName = classLoaderSystemName; } /** * Get the contextName. * * @return the contextName. */ public String getContextName() { return contextName; } /** * Set the contextName. * * @param contextName the contextName. */ @ManagementProperty(name="context") @XmlAttribute(name="context") public void setContextName(String contextName) { this.contextName = contextName; } /** * Get the roots. * * @return the roots. */ public List getRoots() { return roots; } /** * Set the roots. * * @param roots the roots. */ @ManagementProperty(name="roots") @XmlElement(name="root") public void setRoots(List roots) { if (roots == null) roots = new CopyOnWriteArrayList(); this.roots = roots; } /** * Get module class. * * @return the module class. */ protected Class getModuleClass() { return VFSClassLoaderPolicyModule.class; } @XmlTransient public List getBeans() { // Determine some properties String contextName = getContextName(); if (contextName == null) contextName = getName() + ":" + getVersion(); String moduleName = contextName + "$MODULE"; // Create the module BeanMetaDataBuilder builder = BeanMetaDataBuilder.createBuilder(moduleName, getModuleClass().getName()); builder.addConstructorParameter(VFSClassLoaderFactory.class.getName(), this); builder.addConstructorParameter(String.class.getName(), moduleName); builder.addPropertyMetaData("roots", roots); builder.setNoClassLoader(); builder.addUninstall("removeClassLoader"); BeanMetaData module = builder.getBeanMetaData(); // Create the classloader builder = BeanMetaDataBuilder.createBuilder(contextName, ClassLoader.class.getName()); builder.setNoClassLoader(); builder.setFactory(moduleName); builder.setFactoryMethod("registerClassLoaderPolicy"); builder.addConstructorParameter(ClassLoaderSystem.class.getName(), builder.createInject(classLoaderSystemName)); BeanMetaData classLoader = builder.getBeanMetaData(); return Arrays.asList(classLoader, module); } } ././@LongLink0000000000000000000000000000016200000000000011564 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloading-vfs/src/main/java/org/jboss/classloading/spi/vfs/dependency/libjboss-classloader-java-2.0.6.GA.orig/classloading-vfs/src/main/java/org/jboss/classloading/spi/vf0000755000175000017500000000000011620043416033313 5ustar twernertwerner././@LongLink0000000000000000000000000000022100000000000011560 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloading-vfs/src/main/java/org/jboss/classloading/spi/vfs/dependency/VFSClassLoaderPolicyModule.javalibjboss-classloader-java-2.0.6.GA.orig/classloading-vfs/src/main/java/org/jboss/classloading/spi/vf0000644000175000017500000001676311137603706033341 0ustar twernertwerner/* * JBoss, Home of Professional Open Source * Copyright 2008, JBoss Inc., and individual contributors as indicated * by the @authors tag. See the copyright.txt in the distribution for a * full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.classloading.spi.vfs.dependency; import java.net.URI; import java.net.URL; import java.util.List; import java.util.Set; import java.util.concurrent.CopyOnWriteArrayList; import org.jboss.classloader.spi.filter.ClassFilter; import org.jboss.classloading.plugins.vfs.PackageVisitor; import org.jboss.classloading.plugins.vfs.VFSResourceVisitor; import org.jboss.classloading.spi.dependency.policy.ClassLoaderPolicyModule; import org.jboss.classloading.spi.metadata.Capability; import org.jboss.classloading.spi.metadata.ClassLoadingMetaDataFactory; import org.jboss.classloading.spi.metadata.ExportAll; import org.jboss.classloading.spi.vfs.metadata.VFSClassLoaderFactory; import org.jboss.classloading.spi.vfs.policy.VFSClassLoaderPolicy; import org.jboss.classloading.spi.visitor.ResourceFilter; import org.jboss.classloading.spi.visitor.ResourceVisitor; import org.jboss.kernel.spi.dependency.KernelControllerContext; import org.jboss.kernel.spi.dependency.KernelControllerContextAware; import org.jboss.virtual.VFS; import org.jboss.virtual.VirtualFile; /** * VFSClassLoaderPolicyModule. * * @author Adrian Brock * @version $Revision: 1.1 $ */ public class VFSClassLoaderPolicyModule extends ClassLoaderPolicyModule implements KernelControllerContextAware { /** The serialVersionUID */ private static final long serialVersionUID = 1L; /** The roots */ private List roots; /** Our cached vfs roots */ private VirtualFile[] vfsRoots; /** * Create a new VFSClassLoaderPolicyModule. * * @param classLoadingMetaData the classloading metadata * @param contextName the context name */ public VFSClassLoaderPolicyModule(VFSClassLoaderFactory classLoadingMetaData, String contextName) { super(classLoadingMetaData, contextName); } /** * Get the roots. * * @return the roots. */ public List getRoots() { return roots; } /** * Set the roots. * * @param roots the roots. */ public void setRoots(List roots) { this.roots = roots; } @Override protected List determineCapabilities() { // While we are here, check the roots VirtualFile[] roots = determineVFSRoots(); List capabilities = super.determineCapabilities(); if (capabilities != null) return capabilities; // We need to work it out ClassLoadingMetaDataFactory factory = ClassLoadingMetaDataFactory.getInstance(); capabilities = new CopyOnWriteArrayList(); // We have a module capability Object version = getVersion(); Capability capability = factory.createModule(getName(), version); capabilities.add(capability); // Do we determine package capabilities ClassFilter included = getIncluded(); ClassFilter excluded = getExcluded(); ClassFilter excludedExport = getExcludedExport(); ExportAll exportAll = getExportAll(); if (exportAll != null) { Set exportedPackages = PackageVisitor.determineAllPackages(roots, null, exportAll, included, excluded, excludedExport); for (String packageName : exportedPackages) { capability = factory.createPackage(packageName, version); capabilities.add(capability); } } return capabilities; } public void setKernelControllerContext(KernelControllerContext context) throws Exception { setControllerContext(context); } public void unsetKernelControllerContext(KernelControllerContext context) throws Exception { setControllerContext(null); } @Override protected VFSClassLoaderFactory getClassLoadingMetaData() { return (VFSClassLoaderFactory) super.getClassLoadingMetaData(); } /** * Get the virtual file roots * * @return the roots */ protected VirtualFile[] determineVFSRoots() { if (vfsRoots != null) return vfsRoots; if (roots == null) { vfsRoots = new VirtualFile[0]; } else { VirtualFile[] vfsRoots = new VirtualFile[roots.size()]; for (int i = 0; i < roots.size(); ++i) { String root = roots.get(i); try { URI uri = new URI(root); vfsRoots[i] = getVirtualFile(uri); } catch (RuntimeException e) { throw e; } catch (Exception e) { throw new RuntimeException("Error creating VFS file for " + root, e); } } this.vfsRoots = vfsRoots; } return vfsRoots; } /** * Get virtual file for uri. * * @param uri the uri * @return virtual file for uri * @throws Exception for any error */ protected VirtualFile getVirtualFile(URI uri) throws Exception { if (isCacheable()) return VFS.getRoot(uri); else return VFS.createNewRoot(uri); } @Override public VFSClassLoaderPolicy getPolicy() { return (VFSClassLoaderPolicy) super.getPolicy(); } @Override protected VFSClassLoaderPolicy determinePolicy() { VirtualFile[] roots = determineVFSRoots(); VFSClassLoaderPolicy policy = VFSClassLoaderPolicy.createVFSClassLoaderPolicy(getContextName(), roots); String[] packageNames = getPackageNames(); policy.setExportedPackages(packageNames); policy.setIncluded(getIncluded()); policy.setExcluded(getExcluded()); policy.setExcludedExport(getExcludedExport()); policy.setExportAll(getExportAll()); policy.setImportAll(isImportAll()); policy.setCacheable(isCacheable()); policy.setBlackListable(isBlackListable()); policy.setDelegates(getDelegates()); return policy; } @Override public void reset() { super.reset(); vfsRoots = null; } @Override public void visit(ResourceVisitor visitor, ResourceFilter filter, ResourceFilter recurseFilter, URL... urls) { ClassLoader classLoader = getClassLoader(); if (classLoader == null) throw new IllegalStateException("ClassLoader has not been constructed for " + getContextName()); VirtualFile[] roots = determineVFSRoots(); if (roots != null && roots.length > 0) { ClassFilter included = getIncluded(); ClassFilter excluded = getExcluded(); VFSResourceVisitor.visit(roots, null, included, excluded, classLoader, visitor, filter, recurseFilter, urls); } } } libjboss-classloader-java-2.0.6.GA.orig/classloading-vfs/.settings/0000755000175000017500000000000011620043416025074 5ustar twernertwernerlibjboss-classloader-java-2.0.6.GA.orig/classloading-vfs/.settings/org.eclipse.jdt.core.prefs0000644000175000017500000000031311042271742032056 0ustar twernertwerner#Tue Apr 29 21:03:22 PDT 2008 eclipse.preferences.version=1 org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5 org.eclipse.jdt.core.compiler.compliance=1.5 org.eclipse.jdt.core.compiler.source=1.5 libjboss-classloader-java-2.0.6.GA.orig/classloading-vfs/.project0000644000175000017500000000066011015015610024620 0ustar twernertwerner jboss-classloading-vfs JBoss ClassLoading VFS jboss-classloader jboss-classloading org.eclipse.jdt.core.javabuilder org.eclipse.jdt.core.javanature libjboss-classloader-java-2.0.6.GA.orig/classloader/0000755000175000017500000000000011620043423022211 5ustar twernertwernerlibjboss-classloader-java-2.0.6.GA.orig/classloader/.classpath0000644000175000017500000000502311177646777024230 0ustar twernertwerner libjboss-classloader-java-2.0.6.GA.orig/classloader/pom.xml0000644000175000017500000000553711202514647023547 0ustar twernertwerner org.jboss.cl jboss-cl 2.0.6.GA 4.0.0 jboss-classloader jar JBoss ClassLoader http://www.jboss.org/jbossmc JBoss ClassLoader org.jboss.test jboss-test ${version.org.jboss.test} compile junit junit ${version.junit} compile org.jboss.integration jboss-classloading-spi org.jboss jboss-common-core org.jboss.logging jboss-logging-spi org.jboss jboss-common-core jboss jboss-common-logging-spi apache-httpclient commons-httpclient apache-slide webdavlib apache-xerces xml-apis org.jboss.test jboss-test true junit junit true javassist javassist true libjboss-classloader-java-2.0.6.GA.orig/classloader/src/0000755000175000017500000000000011620043422022777 5ustar twernertwernerlibjboss-classloader-java-2.0.6.GA.orig/classloader/src/test/0000755000175000017500000000000011620043422023756 5ustar twernertwernerlibjboss-classloader-java-2.0.6.GA.orig/classloader/src/test/resources/0000755000175000017500000000000011620043422025770 5ustar twernertwernerlibjboss-classloader-java-2.0.6.GA.orig/classloader/src/test/resources/a/0000755000175000017500000000000011620043422026210 5ustar twernertwernerlibjboss-classloader-java-2.0.6.GA.orig/classloader/src/test/resources/a/testResource0000644000175000017500000000001610616435067030635 0ustar twernertwernera/testResourcelibjboss-classloader-java-2.0.6.GA.orig/classloader/src/test/resources/a/com/0000755000175000017500000000000011620043422026766 5ustar twernertwernerlibjboss-classloader-java-2.0.6.GA.orig/classloader/src/test/resources/a/com/acme/0000755000175000017500000000000011620043422027673 5ustar twernertwernerlibjboss-classloader-java-2.0.6.GA.orig/classloader/src/test/resources/a/com/acme/p1/0000755000175000017500000000000011620043422030213 5ustar twernertwernerlibjboss-classloader-java-2.0.6.GA.orig/classloader/src/test/resources/a/com/acme/p1/testResource0000644000175000017500000000003210616435067032636 0ustar twernertwernera/com/acme/p1/testResource././@LongLink0000000000000000000000000000014600000000000011566 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloader/src/test/resources/a/com/acme/p1/testResource.xmllibjboss-classloader-java-2.0.6.GA.orig/classloader/src/test/resources/a/com/acme/p1/testResource.xm0000644000175000017500000000003610645715160033262 0ustar twernertwernera/com/acme/p1/testResource.xmllibjboss-classloader-java-2.0.6.GA.orig/classloader/src/test/resources/a/testResource.xml0000644000175000017500000000003610645715160031433 0ustar twernertwernera/com/acme/p1/testResource.xmllibjboss-classloader-java-2.0.6.GA.orig/classloader/src/test/resources/b/0000755000175000017500000000000011620043422026211 5ustar twernertwernerlibjboss-classloader-java-2.0.6.GA.orig/classloader/src/test/resources/b/testResource0000644000175000017500000000001610616435067030636 0ustar twernertwernerb/testResourcelibjboss-classloader-java-2.0.6.GA.orig/classloader/src/test/resources/b/com/0000755000175000017500000000000011620043422026767 5ustar twernertwernerlibjboss-classloader-java-2.0.6.GA.orig/classloader/src/test/resources/b/com/acme/0000755000175000017500000000000011620043422027674 5ustar twernertwernerlibjboss-classloader-java-2.0.6.GA.orig/classloader/src/test/resources/b/com/acme/p1/0000755000175000017500000000000011620043422030214 5ustar twernertwernerlibjboss-classloader-java-2.0.6.GA.orig/classloader/src/test/resources/b/com/acme/p1/testResource0000644000175000017500000000003210616435067032637 0ustar twernertwernerb/com/acme/p1/testResourcelibjboss-classloader-java-2.0.6.GA.orig/classloader/src/test/resources/b/com/acme/p2/0000755000175000017500000000000011620043422030215 5ustar twernertwernerlibjboss-classloader-java-2.0.6.GA.orig/classloader/src/test/resources/b/com/acme/p2/testResource0000644000175000017500000000003210616435067032640 0ustar twernertwernerb/com/acme/p2/testResourcelibjboss-classloader-java-2.0.6.GA.orig/classloader/src/test/java/0000755000175000017500000000000011620043421024676 5ustar twernertwernerlibjboss-classloader-java-2.0.6.GA.orig/classloader/src/test/java/TestDefaultPackage.java0000644000175000017500000000224311060021700031234 0ustar twernertwerner/* * JBoss, Home of Professional Open Source. * Copyright 2007, Red Hat Middleware LLC, and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ /** * TestDefaultPackage * * @author Adrian Brock * @version $Revision: 1.1 $ */ public class TestDefaultPackage { } libjboss-classloader-java-2.0.6.GA.orig/classloader/src/test/java/org/0000755000175000017500000000000011620043421025465 5ustar twernertwernerlibjboss-classloader-java-2.0.6.GA.orig/classloader/src/test/java/org/jboss/0000755000175000017500000000000011620043421026605 5ustar twernertwernerlibjboss-classloader-java-2.0.6.GA.orig/classloader/src/test/java/org/jboss/test/0000755000175000017500000000000011620043421027564 5ustar twernertwernerlibjboss-classloader-java-2.0.6.GA.orig/classloader/src/test/java/org/jboss/test/classloader/0000755000175000017500000000000011620043422032061 5ustar twernertwerner././@LongLink0000000000000000000000000000014500000000000011565 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloader/src/test/java/org/jboss/test/classloader/policy/libjboss-classloader-java-2.0.6.GA.orig/classloader/src/test/java/org/jboss/test/classloader/policy/0000755000175000017500000000000011620043421033357 5ustar twernertwerner././@LongLink0000000000000000000000000000015200000000000011563 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloader/src/test/java/org/jboss/test/classloader/policy/test/libjboss-classloader-java-2.0.6.GA.orig/classloader/src/test/java/org/jboss/test/classloader/policy/0000755000175000017500000000000011620043421033357 5ustar twernertwerner././@LongLink0000000000000000000000000000021400000000000011562 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloader/src/test/java/org/jboss/test/classloader/policy/test/ClassLoaderPolicyUnitTestCase.javalibjboss-classloader-java-2.0.6.GA.orig/classloader/src/test/java/org/jboss/test/classloader/policy/0000644000175000017500000004452210761270232033377 0ustar twernertwerner/* * JBoss, Home of Professional Open Source. * Copyright 2007, Red Hat Middleware LLC, and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.test.classloader.policy.test; import java.io.FilePermission; import java.net.URL; import java.security.CodeSource; import java.security.PermissionCollection; import java.security.ProtectionDomain; import java.util.Collections; import javax.naming.Context; import junit.framework.Test; import org.jboss.classloader.plugins.ClassLoaderUtils; import org.jboss.classloader.spi.ClassLoaderDomain; import org.jboss.classloader.spi.ClassLoaderSystem; import org.jboss.classloader.spi.ParentPolicy; import org.jboss.classloader.spi.filter.ClassFilter; import org.jboss.classloader.spi.filter.FilteredDelegateLoader; import org.jboss.classloader.test.support.MockClassLoaderPolicy; import org.jboss.test.classloader.AbstractClassLoaderTest; import org.jboss.test.classloader.policy.support.TestClass; import org.jboss.test.classloader.policy.support.TestClassLoaderPolicy; import org.jboss.test.classloader.policy.support.TestClassLoaderPolicyFactory; import org.jboss.test.classloader.policy.support.TestDelegateLoader; /** * ClassLoaderSystemUnitTestCase. * * @author Adrian Brock * @version $Revision: 1.1 $ */ public class ClassLoaderPolicyUnitTestCase extends AbstractClassLoaderTest { public static Test suite() { return suite(ClassLoaderPolicyUnitTestCase.class); } public ClassLoaderPolicyUnitTestCase(String name) { super(name); } public void testLoadClassInvoked() throws Exception { ClassLoaderSystem system = createClassLoaderSystemWithModifiedBootstrap(); TestClassLoaderPolicy policy = new TestClassLoaderPolicy(); ClassLoader classLoader = system.registerClassLoaderPolicy(policy); Class clazz = assertLoadClass(TestClass.class, classLoader); assertEquals("getResourceAsStream should have been invoked", TestClassLoaderPolicy.testClassPath, policy.getResourceAsStreamInvoked); assertEquals("getResource should have been invoked", TestClassLoaderPolicy.testClassPath, policy.getResourceInvoked); Package pkge = clazz.getPackage(); getLog().debug("Package " + pkge); assertEquals(ClassLoaderUtils.getClassPackageName(TestClass.class.getName()), pkge.getName()); assertEquals("SpecTitle", pkge.getSpecificationTitle()); assertEquals("SpecVendor", pkge.getSpecificationVendor()); assertEquals("SpecVersion", pkge.getSpecificationVersion()); assertEquals("ImplTitle", pkge.getImplementationTitle()); assertEquals("ImplVendor", pkge.getImplementationVendor()); assertEquals("ImplVersion", pkge.getImplementationVersion()); assertTrue("Package should be sealed ", pkge.isSealed()); assertTrue("URL should be sealed ", pkge.isSealed(TestClassLoaderPolicy.sealBase)); ProtectionDomain pd = clazz.getProtectionDomain(); CodeSource cs = pd.getCodeSource(); assertEquals(TestClassLoaderPolicy.codeSourceURL, cs.getLocation()); PermissionCollection permissions = pd.getPermissions(); URL url = getClass().getClassLoader().getResource("java/lang/Object.class"); String file = url.getFile(); FilePermission fp = new FilePermission(file, "read"); assertTrue("Should have read permission", permissions.implies(fp)); RuntimePermission rp = new RuntimePermission("createClassLoader"); assertFalse("Shouldn't have classloader permissions", permissions.implies(rp)); } public void testGetResourceInvoked() throws Exception { ClassLoaderSystem system = createClassLoaderSystem(); TestClassLoaderPolicy policy = new TestClassLoaderPolicy(); ClassLoader classLoader = system.registerClassLoaderPolicy(policy); classLoader.getResource("test"); assertEquals("getResource() should have been invoked", "test", policy.getResourceInvoked); } public void testGetResourcesInvoked() throws Exception { ClassLoaderSystem system = createClassLoaderSystem(); TestClassLoaderPolicy policy = new TestClassLoaderPolicy(); ClassLoader classLoader = system.registerClassLoaderPolicy(policy); classLoader.getResources("test"); assertEquals("getResources() should have been invoked", "test", policy.getResourcesInvoked); } public void testIsJDKRequest() throws Exception { ClassLoaderSystem system = createClassLoaderSystem(); // Hide java ParentPolicy parentPolicy = new ParentPolicy(ClassFilter.NOTHING, ClassFilter.NOTHING); ClassLoaderDomain domain = system.createAndRegisterDomain("test", parentPolicy); TestClassLoaderPolicy policy = new TestClassLoaderPolicy(); ClassLoader classLoader = system.registerClassLoaderPolicy(domain, policy); // Can't see java assertLoadClassFail(Object.class, classLoader); // Should be able to load javax.naming.Context assertLoadClass(Context.class, classLoader, null, true); } public void testNotImportAll() throws Exception { ClassLoaderSystem system = createClassLoaderSystemWithModifiedBootstrap(); MockClassLoaderPolicy mock = createMockClassLoaderPolicy(); mock.setPathsAndPackageNames(ClassLoaderDomain.class); system.registerClassLoaderPolicy(mock); TestClassLoaderPolicy policy = new TestClassLoaderPolicy(); ClassLoader classLoader = system.registerClassLoaderPolicy(policy); assertLoadClassFail(ClassLoaderDomain.class, classLoader); assertNotNull("Should have tried to load through us ", policy.getResourceInvoked); } public void testImportAll() throws Exception { ClassLoaderSystem system = createClassLoaderSystemWithModifiedBootstrap(); MockClassLoaderPolicy mock = createMockClassLoaderPolicy(); mock.setPathsAndPackageNames(ClassLoaderDomain.class); ClassLoader mockClassLoader = system.registerClassLoaderPolicy(mock); TestClassLoaderPolicy policy = new TestClassLoaderPolicy(); policy.isImportAll = true; ClassLoader classLoader = system.registerClassLoaderPolicy(policy); assertLoadClass(ClassLoaderDomain.class, classLoader, mockClassLoader); assertNull("Should NOT have tried to load through us ", policy.getResourceInvoked); } public void testPackageIndexed() throws Exception { ClassLoaderSystem system = createClassLoaderSystemWithModifiedBootstrap(); MockClassLoaderPolicy mock = createMockClassLoaderPolicy(); mock.setImportAll(true); ClassLoader mockClassLoader = system.registerClassLoaderPolicy(mock); TestClassLoaderPolicy policy = new TestClassLoaderPolicy(); policy.packageNames = new String[] { ClassLoaderUtils.getClassPackageName(ClassLoaderDomain.class.getName())}; system.registerClassLoaderPolicy(policy); assertLoadClassFail(ClassLoaderDomain.class, mockClassLoader); assertNotNull("Should have tried to load through us ", policy.getResourceInvoked); } public void testPackageNotIndexed() throws Exception { ClassLoaderSystem system = createClassLoaderSystemWithModifiedBootstrap(); MockClassLoaderPolicy mock = createMockClassLoaderPolicy(); mock.setImportAll(true); ClassLoader mockClassLoader = system.registerClassLoaderPolicy(mock); TestClassLoaderPolicy policy = new TestClassLoaderPolicy(); system.registerClassLoaderPolicy(policy); assertLoadClassFail(ClassLoaderDomain.class, mockClassLoader); assertNull("Should NOT have tried to load through us ", policy.getResourceInvoked); } public void testDelegateInvoked() throws Exception { ClassLoaderSystem system = createClassLoaderSystemWithModifiedBootstrap(); TestClassLoaderPolicy policy1 = new TestClassLoaderPolicy(); TestClassLoaderPolicy policy2 = new TestClassLoaderPolicy(); policy1.delegates = Collections.singletonList(new FilteredDelegateLoader(policy2)); ClassLoader classLoader = system.registerClassLoaderPolicy(policy1); system.registerClassLoaderPolicy(policy2); assertLoadClassFail(ClassLoaderDomain.class, classLoader); assertNotNull("Should have tried policy1 ", policy1.getResourceInvoked); assertNotNull("Should have tried policy2 ", policy2.getResourceInvoked); } public void testDelegateInvokedSuccessfully() throws Exception { ClassLoaderSystem system = createClassLoaderSystemWithModifiedBootstrap(); TestClassLoaderPolicy policy1 = new TestClassLoaderPolicy(); TestClassLoaderPolicy policy2 = new TestClassLoaderPolicy(); policy1.delegates = Collections.singletonList(new FilteredDelegateLoader(policy2)); ClassLoader classLoader1 = system.registerClassLoaderPolicy(policy1); ClassLoader classLoader2 = system.registerClassLoaderPolicy(policy2); assertLoadClass(TestClass.class, classLoader1, classLoader2); assertNull("Should NOT have tried policy1 ", policy1.getResourceInvoked); assertNotNull("Should have tried policy2 ", policy2.getResourceInvoked); } public void testNonDelegateNotInvoked() throws Exception { ClassLoaderSystem system = createClassLoaderSystemWithModifiedBootstrap(); TestClassLoaderPolicy policy1 = new TestClassLoaderPolicy(); TestClassLoaderPolicy policy2 = new TestClassLoaderPolicy(); ClassLoader classLoader = system.registerClassLoaderPolicy(policy1); system.registerClassLoaderPolicy(policy2); assertLoadClassFail(ClassLoaderDomain.class, classLoader); assertNotNull("Should have tried policy1 ", policy1.getResourceInvoked); assertNull("Should NOT have tried policy2 ", policy2.getResourceInvoked); } public void testExportLoaderInvoked() throws Exception { ClassLoaderSystem system = createClassLoaderSystemWithModifiedBootstrap(); MockClassLoaderPolicy mock = createMockClassLoaderPolicy(); mock.setImportAll(true); ClassLoader mockClassLoader = system.registerClassLoaderPolicy(mock); TestClassLoaderPolicy policy = new TestClassLoaderPolicy(); policy.packageNames = new String[] { ClassLoaderUtils.getClassPackageName(ClassLoaderDomain.class.getName())}; TestDelegateLoader exported = new TestDelegateLoader(policy); policy.exported = exported; system.registerClassLoaderPolicy(policy); assertLoadClassFail(ClassLoaderDomain.class, mockClassLoader); assertNotNull("Should have tried to the export delegate ", exported.getResourceInvoked); assertNotNull("Should have tried to the export delegate to load the class ", exported.loadClassInvoked); assertNull("Should NOT have tried to load through us ", policy.getResourceInvoked); } public void testFactoryInvoked() throws Exception { ClassLoaderSystem system = createClassLoaderSystemWithModifiedBootstrap(); TestClassLoaderPolicy policy1 = new TestClassLoaderPolicy(); TestClassLoaderPolicy policy2 = new TestClassLoaderPolicy(); TestClassLoaderPolicyFactory factory2 = new TestClassLoaderPolicyFactory(policy2, true); policy1.delegates = Collections.singletonList(new FilteredDelegateLoader(factory2)); ClassLoader classLoader = system.registerClassLoaderPolicy(policy1); system.registerClassLoaderPolicy(policy2); assertLoadClassFail(ClassLoaderDomain.class, classLoader); assertNotNull("Should have tried policy1 ", policy1.getResourceInvoked); assertNotNull("Should have tried policy2 ", policy2.getResourceInvoked); } public void testFactoryInvokedSuccessfully() throws Exception { ClassLoaderSystem system = createClassLoaderSystemWithModifiedBootstrap(); TestClassLoaderPolicy policy1 = new TestClassLoaderPolicy(); TestClassLoaderPolicy policy2 = new TestClassLoaderPolicy(); TestClassLoaderPolicyFactory factory2 = new TestClassLoaderPolicyFactory(policy2, true); policy1.delegates = Collections.singletonList(new FilteredDelegateLoader(factory2)); ClassLoader classLoader1 = system.registerClassLoaderPolicy(policy1); ClassLoader classLoader2 = system.registerClassLoaderPolicy(policy2); assertLoadClass(TestClass.class, classLoader1, classLoader2); assertNull("Should NOT have tried policy1 ", policy1.getResourceInvoked); assertNotNull("Should have tried policy2 ", policy2.getResourceInvoked); } public void testLazyFactoryInvoked() throws Exception { ClassLoaderSystem system = createClassLoaderSystemWithModifiedBootstrap(); TestClassLoaderPolicy policy1 = new TestClassLoaderPolicy(); TestClassLoaderPolicy policy2 = new TestClassLoaderPolicy(); TestClassLoaderPolicyFactory factory2 = new TestClassLoaderPolicyFactory(policy2, false); policy1.delegates = Collections.singletonList(new FilteredDelegateLoader(factory2)); ClassLoader classLoader = system.registerClassLoaderPolicy(policy1); system.registerClassLoaderPolicy(policy2); assertLoadClassFail(ClassLoaderDomain.class, classLoader); assertNotNull("Should have tried policy1 ", policy1.getResourceInvoked); assertNull("Should have tried policy2 ", policy2.getResourceInvoked); factory2.setCanCreate(true); policy1.getResourceInvoked = null; assertLoadClassFail(ClassLoaderDomain.class, classLoader); assertNull("Should NOT have tried policy1 ", policy1.getResourceInvoked); assertNotNull("Should have tried policy2 ", policy2.getResourceInvoked); } public void testLazyFactoryInvokedSuccessfully() throws Exception { ClassLoaderSystem system = createClassLoaderSystemWithModifiedBootstrap(); MockClassLoaderPolicy policy1 = createMockClassLoaderPolicy(); TestClassLoaderPolicy policy2 = new TestClassLoaderPolicy(); TestClassLoaderPolicyFactory factory2 = new TestClassLoaderPolicyFactory(policy2, false); policy1.setDelegates(Collections.singletonList(new FilteredDelegateLoader(factory2))); ClassLoader classLoader1 = system.registerClassLoaderPolicy(policy1); ClassLoader classLoader2 = system.registerClassLoaderPolicy(policy2); assertLoadClassFail(TestClass.class, classLoader1); assertNull("Should NOT have tried policy2 ", policy2.getResourceInvoked); factory2.setCanCreate(true); assertLoadClass(TestClass.class, classLoader1, classLoader2); assertNotNull("Should have tried policy2 ", policy2.getResourceInvoked); } public void testExportFactoryInvoked() throws Exception { ClassLoaderSystem system = createClassLoaderSystemWithModifiedBootstrap(); MockClassLoaderPolicy mock = createMockClassLoaderPolicy(); mock.setImportAll(true); ClassLoader mockClassLoader = system.registerClassLoaderPolicy(mock); TestClassLoaderPolicy policy = new TestClassLoaderPolicy(); TestClassLoaderPolicyFactory factory = new TestClassLoaderPolicyFactory(policy, true); policy.packageNames = new String[] { ClassLoaderUtils.getClassPackageName(ClassLoaderDomain.class.getName())}; TestDelegateLoader exported = new TestDelegateLoader(factory); policy.exported = exported; system.registerClassLoaderPolicy(policy); assertLoadClassFail(ClassLoaderDomain.class, mockClassLoader); assertNotNull("Should have tried to the export delegate ", exported.getResourceInvoked); assertNotNull("Should have tried to the export delegate to load the class ", exported.loadClassInvoked); assertNull("Should NOT have tried to load through us ", policy.getResourceInvoked); } public void testLazyExportNotAllowed() throws Exception { ClassLoaderSystem system = createClassLoaderSystemWithModifiedBootstrap(); TestClassLoaderPolicy policy = new TestClassLoaderPolicy(); TestClassLoaderPolicyFactory factory = new TestClassLoaderPolicyFactory(policy, false); policy.packageNames = new String[] { ClassLoaderUtils.getClassPackageName(ClassLoaderDomain.class.getName())}; TestDelegateLoader exported = new TestDelegateLoader(factory); policy.exported = exported; try { system.registerClassLoaderPolicy(policy); fail("Should not be here!"); } catch (Throwable t) { checkThrowable(IllegalStateException.class, t); } } public void testCircularFactoryInDelegates() throws Exception { ClassLoaderSystem system = createClassLoaderSystemWithModifiedBootstrap(); TestClassLoaderPolicy policy1 = new TestClassLoaderPolicy(); TestClassLoaderPolicy policy2 = new TestClassLoaderPolicy(); TestClassLoaderPolicyFactory factory1 = new TestClassLoaderPolicyFactory(policy1, true); TestClassLoaderPolicyFactory factory2 = new TestClassLoaderPolicyFactory(policy2, true); policy1.setDelegates(Collections.singletonList(new FilteredDelegateLoader(factory2))); policy2.setDelegates(Collections.singletonList(new FilteredDelegateLoader(factory1))); ClassLoader classLoader1 = system.registerClassLoaderPolicy(policy1); ClassLoader classLoader2 = system.registerClassLoaderPolicy(policy2); assertLoadClass(TestClass.class, classLoader1, classLoader2); assertNull("Should NOT have tried policy1 ", policy1.getResourceInvoked); assertNotNull("Should have tried policy2 ", policy2.getResourceInvoked); policy1.getResourceInvoked = null; assertLoadClass(TestClass.class, classLoader2); assertNull("Should NOT have tried policy1 ", policy1.getResourceInvoked); assertNotNull("Should have tried policy2 ", policy2.getResourceInvoked); } } ././@LongLink0000000000000000000000000000015500000000000011566 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloader/src/test/java/org/jboss/test/classloader/policy/support/libjboss-classloader-java-2.0.6.GA.orig/classloader/src/test/java/org/jboss/test/classloader/policy/0000755000175000017500000000000011620043421033357 5ustar twernertwerner././@LongLink0000000000000000000000000000021600000000000011564 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloader/src/test/java/org/jboss/test/classloader/policy/support/TestClassLoaderPolicyFactory.javalibjboss-classloader-java-2.0.6.GA.orig/classloader/src/test/java/org/jboss/test/classloader/policy/0000644000175000017500000000343510761270232033375 0ustar twernertwerner/* * JBoss, Home of Professional Open Source * Copyright 2008, JBoss Inc., and individual contributors as indicated * by the @authors tag. See the copyright.txt in the distribution for a * full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.test.classloader.policy.support; import org.jboss.classloader.spi.ClassLoaderPolicy; import org.jboss.classloader.spi.ClassLoaderPolicyFactory; /** * TestClassLoaderPolicyFactory. * * @author Adrian Brock * @version $Revision: 1.1 $ */ public class TestClassLoaderPolicyFactory implements ClassLoaderPolicyFactory { private ClassLoaderPolicy policy; private boolean canCreate; public TestClassLoaderPolicyFactory(ClassLoaderPolicy policy, boolean canCreate) { this.policy = policy; this.canCreate = canCreate; } public void setCanCreate(boolean canCreate) { this.canCreate = canCreate; } public ClassLoaderPolicy createClassLoaderPolicy() { if (canCreate) return policy; return null; } } ././@LongLink0000000000000000000000000000020700000000000011564 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloader/src/test/java/org/jboss/test/classloader/policy/support/TestClassLoaderPolicy.javalibjboss-classloader-java-2.0.6.GA.orig/classloader/src/test/java/org/jboss/test/classloader/policy/0000644000175000017500000001116710761270232033376 0ustar twernertwerner/* * JBoss, Home of Professional Open Source. * Copyright 2007, Red Hat Middleware LLC, and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.test.classloader.policy.support; import java.io.FilePermission; import java.io.IOException; import java.io.InputStream; import java.net.MalformedURLException; import java.net.URL; import java.security.CodeSource; import java.security.PermissionCollection; import java.security.Permissions; import java.security.ProtectionDomain; import java.security.cert.Certificate; import java.util.List; import java.util.Set; import javax.naming.Context; import org.jboss.classloader.plugins.ClassLoaderUtils; import org.jboss.classloader.spi.ClassLoaderPolicy; import org.jboss.classloader.spi.DelegateLoader; import org.jboss.classloader.spi.PackageInformation; /** * TestClassLoaderPolicy. * * @author Adrian Brock * @version $Revision: 1.1 $ */ public class TestClassLoaderPolicy extends ClassLoaderPolicy { public static String testClassPath = ClassLoaderUtils.classNameToPath(TestClass.class.getName()); public static URL sealBase; public static URL codeSourceURL; public String getResourceInvoked; public String getResourceAsStreamInvoked; public String getResourcesInvoked; public List delegates; public String[] packageNames; public boolean isImportAll = false; public DelegateLoader exported; static { try { sealBase = new URL("http://localhost:9090"); codeSourceURL = new URL("http://localhost:8080"); } catch (MalformedURLException e) { throw new Error("Unexpected", e); } } @Override protected List getDelegates() { return delegates; } public void setDelegates(List delegates) { this.delegates = delegates; } @Override public String[] getPackageNames() { return packageNames; } @Override public DelegateLoader getExported() { if (exported != null) return exported; return super.getExported(); } @Override protected boolean isImportAll() { return isImportAll; } @Override public PackageInformation getPackageInformation(String packageName) { PackageInformation pi = new PackageInformation(ClassLoaderUtils.getClassPackageName(TestClass.class.getName())); pi.specTitle = "SpecTitle"; pi.specVendor = "SpecVendor"; pi.specVersion = "SpecVersion"; pi.implTitle = "ImplTitle"; pi.implVendor = "ImplVendor"; pi.implVersion = "ImplVersion"; pi.sealBase = sealBase; return pi; } @Override protected ProtectionDomain getProtectionDomain(String className, String path) { CodeSource codeSource = new CodeSource(codeSourceURL, (Certificate[]) null); PermissionCollection permissions = new Permissions(); permissions.add(new FilePermission("<>", "read")); return new ProtectionDomain(codeSource, permissions); } @Override public URL getResource(String path) { getResourceInvoked = path; if (testClassPath.equals(path)) return getClass().getClassLoader().getResource(path); return null; } @Override public InputStream getResourceAsStream(String path) { getResourceAsStreamInvoked = path; return super.getResourceAsStream(path); } @Override public void getResources(String name, Set urls) throws IOException { getResourcesInvoked = name; } @Override protected ClassLoader isJDKRequest(String name) { if (Context.class.getName().equals(name)) return getClass().getClassLoader(); return super.isJDKRequest(name); } } ././@LongLink0000000000000000000000000000020400000000000011561 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloader/src/test/java/org/jboss/test/classloader/policy/support/TestDelegateLoader.javalibjboss-classloader-java-2.0.6.GA.orig/classloader/src/test/java/org/jboss/test/classloader/policy/0000644000175000017500000000367610761270232033404 0ustar twernertwerner/* * JBoss, Home of Professional Open Source. * Copyright 2007, Red Hat Middleware LLC, and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.test.classloader.policy.support; import java.net.URL; import org.jboss.classloader.spi.ClassLoaderPolicy; import org.jboss.classloader.spi.ClassLoaderPolicyFactory; import org.jboss.classloader.spi.DelegateLoader; /** * TestDelegateLoader. * * @author Adrian Brock * @version $Revision: 1.1 $ */ public class TestDelegateLoader extends DelegateLoader { public String getResourceInvoked; public String loadClassInvoked; public TestDelegateLoader(ClassLoaderPolicy delegate) { super(delegate); } public TestDelegateLoader(ClassLoaderPolicyFactory factory) { super(factory); } @Override public Class loadClass(String className) { loadClassInvoked = className; return null; } @Override public URL getResource(String name) { getResourceInvoked = name; return TestClassLoaderPolicy.codeSourceURL; } } ././@LongLink0000000000000000000000000000017300000000000011566 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloader/src/test/java/org/jboss/test/classloader/policy/support/TestClass.javalibjboss-classloader-java-2.0.6.GA.orig/classloader/src/test/java/org/jboss/test/classloader/policy/0000644000175000017500000000230610616435067033401 0ustar twernertwerner/* * JBoss, Home of Professional Open Source. * Copyright 2007, Red Hat Middleware LLC, and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.test.classloader.policy.support; /** * TestClass. * * @author Adrian Brock * @version $Revision: 1.1 $ */ public class TestClass { } ././@LongLink0000000000000000000000000000020400000000000011561 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloader/src/test/java/org/jboss/test/classloader/policy/ClassLoaderPolicyTestSuite.javalibjboss-classloader-java-2.0.6.GA.orig/classloader/src/test/java/org/jboss/test/classloader/policy/0000644000175000017500000000357110616435067033406 0ustar twernertwerner/* * JBoss, Home of Professional Open Source. * Copyright 2007, Red Hat Middleware LLC, and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.test.classloader.policy; import junit.framework.Test; import junit.framework.TestSuite; import junit.textui.TestRunner; import org.jboss.test.classloader.policy.test.ClassLoaderPolicyUnitTestCase; /** * ClassLoaderPolicy Test Suite. * * @author Adrian Brock * @version $Revision: 37459 $ */ public class ClassLoaderPolicyTestSuite extends TestSuite { /** * For running the testsuite from the command line * * @param args the command line args */ public static void main(String[] args) { TestRunner.run(suite()); } /** * Create the testsuite * * @return the testsuite */ public static Test suite() { TestSuite suite = new TestSuite("ClassLoader Policy Tests"); suite.addTest(ClassLoaderPolicyUnitTestCase.suite()); return suite; } } ././@LongLink0000000000000000000000000000020600000000000011563 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloader/src/test/java/org/jboss/test/classloader/AbstractClassLoaderTestWithSecurity.javalibjboss-classloader-java-2.0.6.GA.orig/classloader/src/test/java/org/jboss/test/classloader/Abstrac0000644000175000017500000000333210615651036033375 0ustar twernertwerner/* * JBoss, Home of Professional Open Source. * Copyright 2007, Red Hat Middleware LLC, and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.test.classloader; import org.jboss.test.AbstractTestDelegate; import org.jboss.test.security.NothingPolicyPlugin; /** * AbstractClassLoaderTest. * * @author Adrian Brock * @version $Revision: 1.1 $ */ public abstract class AbstractClassLoaderTestWithSecurity extends AbstractClassLoaderTest { public static AbstractTestDelegate getDelegate(Class clazz) { AbstractTestDelegate delegate = new AbstractTestDelegate(clazz); delegate.enableSecurity = true; delegate.securityPolicyName = NothingPolicyPlugin.class.getName(); return delegate; } public AbstractClassLoaderTestWithSecurity(String name) { super(name); } } ././@LongLink0000000000000000000000000000014500000000000011565 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloader/src/test/java/org/jboss/test/classloader/filter/libjboss-classloader-java-2.0.6.GA.orig/classloader/src/test/java/org/jboss/test/classloader/filter/0000755000175000017500000000000011620043421033345 5ustar twernertwerner././@LongLink0000000000000000000000000000015200000000000011563 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloader/src/test/java/org/jboss/test/classloader/filter/test/libjboss-classloader-java-2.0.6.GA.orig/classloader/src/test/java/org/jboss/test/classloader/filter/0000755000175000017500000000000011620043421033345 5ustar twernertwerner././@LongLink0000000000000000000000000000020100000000000011556 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloader/src/test/java/org/jboss/test/classloader/filter/test/FilterUnitTestCase.javalibjboss-classloader-java-2.0.6.GA.orig/classloader/src/test/java/org/jboss/test/classloader/filter/0000644000175000017500000001302010741370313033351 0ustar twernertwerner/* * JBoss, Home of Professional Open Source. * Copyright 2007, Red Hat Middleware LLC, and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.test.classloader.filter.test; import junit.framework.Test; import org.jboss.classloader.spi.filter.ClassFilter; import org.jboss.test.classloader.AbstractClassLoaderTestWithSecurity; /** * FilterUnitTestCase. * * @author Adrian Brock * @version $Revision: 1.1 $ */ public class FilterUnitTestCase extends AbstractClassLoaderTestWithSecurity { public static Test suite() { return suite(FilterUnitTestCase.class); } public FilterUnitTestCase(String name) { super(name); } public void testEverything() throws Exception { ClassFilter filter = ClassFilter.EVERYTHING; assertFilterMatchesClassName("gibberish", filter); assertFilterMatchesClassName("", filter); assertFilterMatchesClassName(null, filter); assertFilterMatchesResourcePath("gibberish", filter); assertFilterMatchesResourcePath("", filter); assertFilterMatchesResourcePath(null, filter); assertFilterMatchesPackageName("gibberish", filter); assertFilterMatchesPackageName("", filter); assertFilterMatchesPackageName(null, filter); } public void testNothing() throws Exception { ClassFilter filter = ClassFilter.NOTHING; assertFilterNoMatchClassName("gibberish", filter); assertFilterNoMatchClassName("", filter); assertFilterNoMatchClassName(null, filter); assertFilterNoMatchResourcePath("gibberish", filter); assertFilterNoMatchResourcePath("", filter); assertFilterNoMatchResourcePath(null, filter); assertFilterNoMatchPackageName("gibberish", filter); assertFilterNoMatchPackageName("", filter); assertFilterNoMatchPackageName(null, filter); } public void testJavaOnly() throws Exception { ClassFilter filter = ClassFilter.JAVA_ONLY; assertFilterMatchesClassName("java.x", filter); assertFilterMatchesClassName("java.lang.Object", filter); assertFilterMatchesClassName("java.lang.ref.Method", filter); assertFilterMatchesClassName("java.util.Collection", filter); assertFilterMatchesClassName("javax.x", filter); assertFilterMatchesClassName("javax.naming.Context", filter); assertFilterNoMatchClassName("java.", filter); assertFilterNoMatchClassName("java", filter); assertFilterNoMatchClassName("javaa.", filter); assertFilterNoMatchClassName("javaa.whatever", filter); assertFilterNoMatchClassName("javax", filter); assertFilterNoMatchClassName("javax.", filter); assertFilterNoMatchClassName("javaxa.", filter); assertFilterNoMatchClassName("javaxa.whatever", filter); assertFilterNoMatchClassName("gibberish", filter); assertFilterNoMatchClassName("", filter); assertFilterNoMatchClassName(null, filter); assertFilterMatchesResourcePath("java/x", filter); assertFilterMatchesResourcePath("java/lang/Object", filter); assertFilterMatchesResourcePath("java/lang/ref/Method", filter); assertFilterMatchesResourcePath("java/util/Collection", filter); assertFilterMatchesResourcePath("javax/x", filter); assertFilterMatchesResourcePath("javax/naming/Context", filter); assertFilterNoMatchResourcePath("java/", filter); assertFilterNoMatchResourcePath("java", filter); assertFilterNoMatchResourcePath("javaa.", filter); assertFilterNoMatchResourcePath("javaa/whatever", filter); assertFilterNoMatchResourcePath("javax", filter); assertFilterNoMatchResourcePath("javax/", filter); assertFilterNoMatchResourcePath("javaxa/", filter); assertFilterNoMatchResourcePath("javaxa/whatever", filter); assertFilterNoMatchResourcePath("gibberish", filter); assertFilterNoMatchResourcePath("", filter); assertFilterNoMatchResourcePath(null, filter); assertFilterMatchesPackageName("java", filter); assertFilterMatchesPackageName("java.lang", filter); assertFilterMatchesPackageName("java.lang.ref", filter); assertFilterMatchesPackageName("java.util", filter); assertFilterMatchesPackageName("javax", filter); assertFilterMatchesPackageName("javax.naming", filter); assertFilterNoMatchPackageName("javaa.", filter); assertFilterNoMatchPackageName("javaa.whatever", filter); assertFilterNoMatchPackageName("javaxa.", filter); assertFilterNoMatchPackageName("javaxa.whatever", filter); assertFilterNoMatchPackageName("gibberish", filter); assertFilterNoMatchPackageName("", filter); assertFilterNoMatchPackageName(null, filter); } } ././@LongLink0000000000000000000000000000021200000000000011560 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloader/src/test/java/org/jboss/test/classloader/filter/test/CombiningFilterUnitTestCase.javalibjboss-classloader-java-2.0.6.GA.orig/classloader/src/test/java/org/jboss/test/classloader/filter/0000644000175000017500000001173310755315541033371 0ustar twernertwerner/* * JBoss, Home of Professional Open Source. * Copyright 2008, Red Hat Middleware LLC, and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.test.classloader.filter.test; import junit.framework.Test; import org.jboss.classloader.plugins.filter.CombiningClassFilter; import org.jboss.classloader.spi.filter.ClassFilter; import org.jboss.classloader.spi.filter.PackageClassFilter; import org.jboss.test.classloader.AbstractClassLoaderTestWithSecurity; /** * CombiningFilterUnitTestCase. * * @author Adrian Brock * @version $Revision: 1.1 $ */ public class CombiningFilterUnitTestCase extends AbstractClassLoaderTestWithSecurity { public static Test suite() { return suite(CombiningFilterUnitTestCase.class); } public CombiningFilterUnitTestCase(String name) { super(name); } public void testNothing() throws Exception { ClassFilter filter = CombiningClassFilter.create(); assertFilterNoMatchClassName("gibberish", filter); assertFilterNoMatchClassName("", filter); assertFilterNoMatchClassName(null, filter); assertFilterNoMatchResourcePath("x.xml", filter); assertFilterNoMatchPackageName("gibberish", filter); assertFilterNoMatchPackageName("", filter); assertFilterNoMatchPackageName(null, filter); } public void testJavaLangReflectAnd() throws Exception { ClassFilter filter1 = PackageClassFilter.createPackageClassFilter("java.lang"); ClassFilter filter2 = PackageClassFilter.createPackageClassFilter("java.lang.reflect"); ClassFilter filter = CombiningClassFilter.create(true, filter1, filter2); assertFilterMatchesClassName("java.lang.Object", filter); assertFilterMatchesClassName("java.lang.X", filter); assertFilterNoMatchClassName("java.lang", filter); assertFilterNoMatchClassName("java.lang.", filter); assertFilterNoMatchClassName("java.lang.reflect.Method", filter); assertFilterNoMatchClassName("gibberish", filter); assertFilterNoMatchClassName("", filter); assertFilterNoMatchClassName(null, filter); assertFilterMatchesResourcePath("java/lang/something.xml", filter); assertFilterMatchesPackageName("java.lang", filter); assertFilterNoMatchPackageName("java.langx", filter); assertFilterNoMatchPackageName("java.lang.X.", filter); assertFilterNoMatchPackageName("gibberish", filter); assertFilterNoMatchPackageName("", filter); assertFilterNoMatchPackageName(null, filter); } public void testJavaLangReflectOr() throws Exception { ClassFilter filter1 = PackageClassFilter.createPackageClassFilter("java.lang"); ClassFilter filter2 = PackageClassFilter.createPackageClassFilter("java.lang.reflect"); ClassFilter filter = CombiningClassFilter.create(false, filter1, filter2); assertFilterMatchesClassName("java.lang.Object", filter); assertFilterMatchesClassName("java.lang.X", filter); assertFilterMatchesClassName("java.lang.reflect.Method", filter); assertFilterMatchesClassName("java.lang.reflect.X", filter); assertFilterMatchesClassName("java.lang.reflect", filter); assertFilterNoMatchClassName("java.lang", filter); assertFilterNoMatchClassName("java.lang.", filter); assertFilterNoMatchClassName("java.lang.reflect.", filter); assertFilterNoMatchClassName("java.lang.reflect.subpackage.Something", filter); assertFilterNoMatchClassName("gibberish", filter); assertFilterNoMatchClassName("", filter); assertFilterNoMatchClassName(null, filter); assertFilterMatchesPackageName("java.lang", filter); assertFilterNoMatchPackageName("java.langx", filter); assertFilterNoMatchPackageName("java.lang.X.", filter); assertFilterMatchesPackageName("java.lang.reflect", filter); assertFilterNoMatchPackageName("java.lang.reflectx", filter); assertFilterNoMatchPackageName("java.lang.reflect.X", filter); assertFilterNoMatchPackageName("gibberish", filter); assertFilterNoMatchPackageName("", filter); assertFilterNoMatchPackageName(null, filter); } } ././@LongLink0000000000000000000000000000021000000000000011556 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloader/src/test/java/org/jboss/test/classloader/filter/test/PackageFilterUnitTestCase.javalibjboss-classloader-java-2.0.6.GA.orig/classloader/src/test/java/org/jboss/test/classloader/filter/0000644000175000017500000001545410755315422033373 0ustar twernertwerner/* * JBoss, Home of Professional Open Source. * Copyright 2007, Red Hat Middleware LLC, and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.test.classloader.filter.test; import junit.framework.Test; import org.jboss.classloader.spi.filter.ClassFilter; import org.jboss.classloader.spi.filter.PackageClassFilter; import org.jboss.test.classloader.AbstractClassLoaderTestWithSecurity; /** * PackageFilterUnitTestCase. * * @author Adrian Brock * @version $Revision: 1.1 $ */ public class PackageFilterUnitTestCase extends AbstractClassLoaderTestWithSecurity { public static Test suite() { return suite(PackageFilterUnitTestCase.class); } public PackageFilterUnitTestCase(String name) { super(name); } public void testNothing() throws Exception { ClassFilter filter = PackageClassFilter.createPackageClassFilter(); assertFilterNoMatchClassName("gibberish", filter); assertFilterNoMatchClassName("", filter); assertFilterNoMatchClassName(null, filter); assertFilterNoMatchResourcePath("x.xml", filter); assertFilterNoMatchPackageName("gibberish", filter); assertFilterNoMatchPackageName("", filter); assertFilterNoMatchPackageName(null, filter); } public void testJavaLang() throws Exception { ClassFilter filter = PackageClassFilter.createPackageClassFilter("java.lang"); assertFilterMatchesClassName("java.lang.Object", filter); assertFilterMatchesClassName("java.lang.X", filter); assertFilterNoMatchClassName("java.lang", filter); assertFilterNoMatchClassName("java.lang.", filter); assertFilterNoMatchClassName("java.lang.reflect.Method", filter); assertFilterNoMatchClassName("gibberish", filter); assertFilterNoMatchClassName("", filter); assertFilterNoMatchClassName(null, filter); assertFilterMatchesResourcePath("java/lang/something.xml", filter); assertFilterMatchesPackageName("java.lang", filter); assertFilterNoMatchPackageName("java.langx", filter); assertFilterNoMatchPackageName("java.lang.X.", filter); assertFilterNoMatchPackageName("gibberish", filter); assertFilterNoMatchPackageName("", filter); assertFilterNoMatchPackageName(null, filter); } public void testJavaLangAndJavaLangReflect() throws Exception { ClassFilter filter = PackageClassFilter.createPackageClassFilter("java.lang", "java.lang.reflect"); assertFilterMatchesClassName("java.lang.Object", filter); assertFilterMatchesClassName("java.lang.X", filter); assertFilterMatchesClassName("java.lang.reflect.Method", filter); assertFilterMatchesClassName("java.lang.reflect.X", filter); assertFilterMatchesClassName("java.lang.reflect", filter); assertFilterNoMatchClassName("java.lang", filter); assertFilterNoMatchClassName("java.lang.", filter); assertFilterNoMatchClassName("java.lang.reflect.", filter); assertFilterNoMatchClassName("java.lang.reflect.subpackage.Something", filter); assertFilterNoMatchClassName("gibberish", filter); assertFilterNoMatchClassName("", filter); assertFilterNoMatchClassName(null, filter); assertFilterMatchesPackageName("java.lang", filter); assertFilterNoMatchPackageName("java.langx", filter); assertFilterNoMatchPackageName("java.lang.X.", filter); assertFilterMatchesPackageName("java.lang.reflect", filter); assertFilterNoMatchPackageName("java.lang.reflectx", filter); assertFilterNoMatchPackageName("java.lang.reflect.X", filter); assertFilterNoMatchPackageName("gibberish", filter); assertFilterNoMatchPackageName("", filter); assertFilterNoMatchPackageName(null, filter); } public void testFromString() throws Exception { ClassFilter filter = PackageClassFilter.createPackageClassFilterFromString("java.lang,java.lang.reflect"); assertFilterMatchesClassName("java.lang.Object", filter); assertFilterMatchesClassName("java.lang.X", filter); assertFilterMatchesClassName("java.lang.reflect.Method", filter); assertFilterMatchesClassName("java.lang.reflect.X", filter); assertFilterMatchesClassName("java.lang.reflect", filter); assertFilterNoMatchClassName("java.lang", filter); assertFilterNoMatchClassName("java.lang.", filter); assertFilterNoMatchClassName("java.lang.reflect.", filter); assertFilterNoMatchClassName("java.lang.reflect.subpackage.Something", filter); assertFilterNoMatchClassName("gibberish", filter); assertFilterNoMatchClassName("", filter); assertFilterNoMatchClassName(null, filter); assertFilterMatchesPackageName("java.lang", filter); assertFilterNoMatchPackageName("java.langx", filter); assertFilterNoMatchPackageName("java.lang.X.", filter); assertFilterMatchesPackageName("java.lang.reflect", filter); assertFilterNoMatchPackageName("java.lang.reflectx", filter); assertFilterNoMatchPackageName("java.lang.reflect.X", filter); assertFilterNoMatchPackageName("gibberish", filter); assertFilterNoMatchPackageName("", filter); assertFilterNoMatchPackageName(null, filter); } public void testDefaultPackage() throws Exception { ClassFilter filter = PackageClassFilter.createPackageClassFilter(""); assertFilterMatchesClassName("Root", filter); assertFilterNoMatchClassName("java.NotRoot", filter); assertFilterMatchesClassName("", filter); assertFilterNoMatchClassName(null, filter); assertFilterMatchesResourcePath("Root", filter); assertFilterMatchesResourcePath("Root.xml", filter); assertFilterMatchesResourcePath("", filter); assertFilterNoMatchResourcePath("java/Root.xml", filter); assertFilterNoMatchResourcePath(null, filter); assertFilterMatchesPackageName("", filter); assertFilterNoMatchPackageName("java", filter); assertFilterNoMatchPackageName(null, filter); } } ././@LongLink0000000000000000000000000000022100000000000011560 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloader/src/test/java/org/jboss/test/classloader/filter/test/RecursivePackageFilterUnitTestCase.javalibjboss-classloader-java-2.0.6.GA.orig/classloader/src/test/java/org/jboss/test/classloader/filter/0000644000175000017500000001577711143034455033377 0ustar twernertwerner/* * JBoss, Home of Professional Open Source. * Copyright 2007, Red Hat Middleware LLC, and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.test.classloader.filter.test; import junit.framework.Test; import org.jboss.classloader.spi.filter.ClassFilter; import org.jboss.classloader.spi.filter.RecursivePackageClassFilter; import org.jboss.test.classloader.AbstractClassLoaderTestWithSecurity; /** * RecursivePackageFilterUnitTestCase. * * @author Adrian Brock * @version $Revision: 1.1 $ */ public class RecursivePackageFilterUnitTestCase extends AbstractClassLoaderTestWithSecurity { public static Test suite() { return suite(RecursivePackageFilterUnitTestCase.class); } public RecursivePackageFilterUnitTestCase(String name) { super(name); } public void testNothing() throws Exception { ClassFilter filter = RecursivePackageClassFilter.createRecursivePackageClassFilter(); assertFilterNoMatchClassName("gibberish", filter); assertFilterNoMatchClassName("", filter); assertFilterNoMatchClassName(null, filter); assertFilterNoMatchResourcePath("x.xml", filter); assertFilterNoMatchPackageName("gibberish", filter); assertFilterNoMatchPackageName("", filter); assertFilterNoMatchPackageName(null, filter); } public void testJavaLang() throws Exception { ClassFilter filter = RecursivePackageClassFilter.createRecursivePackageClassFilter("java.lang"); assertFilterMatchesClassName("java.lang.Object", filter); assertFilterMatchesClassName("java.lang.X", filter); assertFilterNoMatchClassName("java.lang", filter); assertFilterNoMatchClassName("java.lang.", filter); assertFilterMatchesClassName("java.lang.reflect.Method", filter); assertFilterNoMatchClassName("gibberish", filter); assertFilterNoMatchClassName("", filter); assertFilterNoMatchClassName(null, filter); assertFilterMatchesResourcePath("java/lang/something.xml", filter); assertFilterMatchesResourcePath("java/lang/x/something.xml", filter); assertFilterMatchesPackageName("java.lang", filter); assertFilterNoMatchPackageName("java.langx", filter); assertFilterMatchesPackageName("java.lang.X.", filter); assertFilterNoMatchPackageName("gibberish", filter); assertFilterNoMatchPackageName("", filter); assertFilterNoMatchPackageName(null, filter); } public void testJavaLangAndJavaLangReflect() throws Exception { ClassFilter filter = RecursivePackageClassFilter.createRecursivePackageClassFilter("java.lang", "java.lang.reflect"); assertFilterMatchesClassName("java.lang.Object", filter); assertFilterMatchesClassName("java.lang.X", filter); assertFilterMatchesClassName("java.lang.reflect.Method", filter); assertFilterMatchesClassName("java.lang.reflect.X", filter); assertFilterMatchesClassName("java.lang.reflect", filter); assertFilterNoMatchClassName("java.lang", filter); assertFilterNoMatchClassName("java.lang.", filter); assertFilterMatchesClassName("java.lang.reflect.", filter); assertFilterMatchesClassName("java.lang.reflect.subpackage.Something", filter); assertFilterNoMatchClassName("gibberish", filter); assertFilterNoMatchClassName("", filter); assertFilterNoMatchClassName(null, filter); assertFilterMatchesPackageName("java.lang", filter); assertFilterNoMatchPackageName("java.langx", filter); assertFilterMatchesPackageName("java.lang.X.", filter); assertFilterMatchesPackageName("java.lang.reflect", filter); assertFilterMatchesPackageName("java.lang.reflectx", filter); assertFilterMatchesPackageName("java.lang.reflect.X", filter); assertFilterNoMatchPackageName("gibberish", filter); assertFilterNoMatchPackageName("", filter); assertFilterNoMatchPackageName(null, filter); } public void testFromString() throws Exception { ClassFilter filter = RecursivePackageClassFilter.createRecursivePackageClassFilterFromString("java.lang,java.lang.reflect"); assertFilterMatchesClassName("java.lang.Object", filter); assertFilterMatchesClassName("java.lang.X", filter); assertFilterMatchesClassName("java.lang.reflect.Method", filter); assertFilterMatchesClassName("java.lang.reflect.X", filter); assertFilterMatchesClassName("java.lang.reflect", filter); assertFilterNoMatchClassName("java.lang", filter); assertFilterNoMatchClassName("java.lang.", filter); assertFilterMatchesClassName("java.lang.reflect.", filter); assertFilterMatchesClassName("java.lang.reflect.subpackage.Something", filter); assertFilterNoMatchClassName("gibberish", filter); assertFilterNoMatchClassName("", filter); assertFilterNoMatchClassName(null, filter); assertFilterMatchesPackageName("java.lang", filter); assertFilterNoMatchPackageName("java.langx", filter); assertFilterMatchesPackageName("java.lang.X.", filter); assertFilterMatchesPackageName("java.lang.reflect", filter); assertFilterMatchesPackageName("java.lang.reflectx", filter); assertFilterMatchesPackageName("java.lang.reflect.X", filter); assertFilterNoMatchPackageName("gibberish", filter); assertFilterNoMatchPackageName("", filter); assertFilterNoMatchPackageName(null, filter); } public void testDefaultPackage() throws Exception { ClassFilter filter = RecursivePackageClassFilter.createRecursivePackageClassFilter(""); assertFilterMatchesClassName("Root", filter); assertFilterMatchesClassName("java.NotRoot", filter); assertFilterMatchesClassName("", filter); assertFilterNoMatchClassName(null, filter); assertFilterMatchesResourcePath("Root", filter); assertFilterMatchesResourcePath("Root.xml", filter); assertFilterMatchesResourcePath("", filter); assertFilterMatchesResourcePath("java/Root.xml", filter); assertFilterNoMatchResourcePath(null, filter); assertFilterMatchesPackageName("", filter); assertFilterMatchesPackageName("java", filter); assertFilterNoMatchPackageName(null, filter); } } ././@LongLink0000000000000000000000000000017100000000000011564 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloader/src/test/java/org/jboss/test/classloader/filter/FilterTestSuite.javalibjboss-classloader-java-2.0.6.GA.orig/classloader/src/test/java/org/jboss/test/classloader/filter/0000644000175000017500000000433211143034455033360 0ustar twernertwerner/* * JBoss, Home of Professional Open Source. * Copyright 2007, Red Hat Middleware LLC, and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.test.classloader.filter; import junit.framework.Test; import junit.framework.TestSuite; import junit.textui.TestRunner; import org.jboss.test.classloader.filter.test.CombiningFilterUnitTestCase; import org.jboss.test.classloader.filter.test.FilterUnitTestCase; import org.jboss.test.classloader.filter.test.PackageFilterUnitTestCase; import org.jboss.test.classloader.filter.test.RecursivePackageFilterUnitTestCase; /** * Filter Test Suite. * * @author Adrian Brock * @version $Revision: 37459 $ */ public class FilterTestSuite extends TestSuite { /** * For running the testsuite from the command line * * @param args the command line args */ public static void main(String[] args) { TestRunner.run(suite()); } /** * Create the testsuite * * @return the testsuite */ public static Test suite() { TestSuite suite = new TestSuite("Filter Tests"); suite.addTest(FilterUnitTestCase.suite()); suite.addTest(PackageFilterUnitTestCase.suite()); suite.addTest(RecursivePackageFilterUnitTestCase.suite()); suite.addTest(CombiningFilterUnitTestCase.suite()); return suite; } } ././@LongLink0000000000000000000000000000014700000000000011567 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloader/src/test/java/org/jboss/test/classloader/delegate/libjboss-classloader-java-2.0.6.GA.orig/classloader/src/test/java/org/jboss/test/classloader/delegat0000755000175000017500000000000011620043421033406 5ustar twernertwerner././@LongLink0000000000000000000000000000015400000000000011565 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloader/src/test/java/org/jboss/test/classloader/delegate/test/libjboss-classloader-java-2.0.6.GA.orig/classloader/src/test/java/org/jboss/test/classloader/delegat0000755000175000017500000000000011620043421033406 5ustar twernertwerner././@LongLink0000000000000000000000000000021300000000000011561 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloader/src/test/java/org/jboss/test/classloader/delegate/test/DelegateLoaderUnitTestCase.javalibjboss-classloader-java-2.0.6.GA.orig/classloader/src/test/java/org/jboss/test/classloader/delegat0000644000175000017500000001165010761301356033424 0ustar twernertwerner/* * JBoss, Home of Professional Open Source. * Copyright 2007, Red Hat Middleware LLC, and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.test.classloader.delegate.test; import junit.framework.Test; import org.jboss.classloader.plugins.ClassLoaderUtils; import org.jboss.classloader.spi.ClassLoaderSystem; import org.jboss.classloader.spi.DelegateLoader; import org.jboss.classloader.spi.filter.ClassFilter; import org.jboss.classloader.spi.filter.FilteredDelegateLoader; import org.jboss.classloader.spi.filter.LazyFilteredDelegateLoader; import org.jboss.classloader.test.support.MockClassLoaderPolicy; import org.jboss.test.classloader.AbstractClassLoaderTestWithSecurity; import org.jboss.test.classloader.delegate.support.a.TestA1; import org.jboss.test.classloader.delegate.support.b.TestB1; import org.jboss.test.classloader.policy.support.TestClassLoaderPolicyFactory; /** * DelegateUnitTestCase * * @author Adrian Brock * @version $Revision: 1.1 $ */ public class DelegateLoaderUnitTestCase extends AbstractClassLoaderTestWithSecurity { public static Test suite() { return suite(DelegateLoaderUnitTestCase.class); } public DelegateLoaderUnitTestCase(String name) { super(name); } public void testLoadClassNoFilter() throws Exception { ClassLoaderSystem system = createClassLoaderSystemWithModifiedBootstrap(); MockClassLoaderPolicy policy = createMockClassLoaderPolicy(); policy.setPathsAndPackageNames(TestA1.class); system.registerClassLoaderPolicy(policy); FilteredDelegateLoader delegate = new FilteredDelegateLoader(policy); assertLoadClass(TestA1.class, delegate); } public void testLoadClassFiltered() throws Exception { ClassLoaderSystem system = createClassLoaderSystemWithModifiedBootstrap(); MockClassLoaderPolicy policy = createMockClassLoaderPolicy(); policy.setPathsAndPackageNames(TestA1.class); system.registerClassLoaderPolicy(policy); FilteredDelegateLoader delegate = new FilteredDelegateLoader(policy, ClassFilter.NOTHING); assertLoadClassFail(TestA1.class, delegate); } public void testLoadClassPolicyNotRegistered() throws Exception { MockClassLoaderPolicy policy = createMockClassLoaderPolicy(); policy.setPathsAndPackageNames(TestA1.class); FilteredDelegateLoader delegate = new FilteredDelegateLoader(policy); assertLoadClassFail(TestA1.class, delegate); } public void testLazyLoadClass() throws Exception { ClassLoaderSystem system = createClassLoaderSystemWithModifiedBootstrap(); MockClassLoaderPolicy policy = createMockClassLoaderPolicy("a"); policy.setPaths(TestA1.class, TestB1.class); policy.setPackageNames(TestA1.class); ClassLoader cl = system.registerClassLoaderPolicy(policy); assertLoadClass(TestA1.class, cl); assertLoadClass(TestB1.class, cl); TestClassLoaderPolicyFactory factory = new TestClassLoaderPolicyFactory(policy, false); LazyFilteredDelegateLoader delegate = new LazyFilteredDelegateLoader(factory); assertLoadClassFail(TestA1.class, delegate); assertLoadClassFail(TestB1.class, delegate); factory.setCanCreate(true); assertLoadClass(TestA1.class, delegate); assertLoadClassFail(TestB1.class, delegate); } protected Class assertLoadClass(Class reference, DelegateLoader delegate) throws Exception { Class result = delegate.loadClass(reference.getName()); assertNotNull("Should have loaded " + reference.getName() + " from " + delegate, result); getLog().debug("Loaded " + ClassLoaderUtils.classToString(result) + " from " + delegate); return result; } protected void assertLoadClassFail(Class reference, DelegateLoader delegate) throws Exception { Class result = delegate.loadClass(reference.getName()); String message = "Should not have loaded " + ClassLoaderUtils.classToString(result) + " from " + delegate; assertNull(message, result); } } ././@LongLink0000000000000000000000000000020500000000000011562 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloader/src/test/java/org/jboss/test/classloader/delegate/test/DelegateUnitTestCase.javalibjboss-classloader-java-2.0.6.GA.orig/classloader/src/test/java/org/jboss/test/classloader/delegat0000644000175000017500000003233611143027354033426 0ustar twernertwerner/* * JBoss, Home of Professional Open Source. * Copyright 2007, Red Hat Middleware LLC, and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.test.classloader.delegate.test; import java.lang.reflect.Field; import java.lang.reflect.Method; import java.util.ArrayList; import java.util.Collections; import java.util.List; import java.util.concurrent.CountDownLatch; import junit.framework.Test; import org.jboss.classloader.plugins.ClassLoaderUtils; import org.jboss.classloader.spi.ClassLoaderDomain; import org.jboss.classloader.spi.ClassLoaderSystem; import org.jboss.classloader.spi.DelegateLoader; import org.jboss.classloader.spi.ParentPolicy; import org.jboss.classloader.spi.base.BaseClassLoader; import org.jboss.classloader.spi.filter.FilteredDelegateLoader; import org.jboss.classloader.test.support.MockClassLoaderPolicy; import org.jboss.test.classloader.AbstractClassLoaderTestWithSecurity; import org.jboss.test.classloader.delegate.support.a.TestA1; import org.jboss.test.classloader.delegate.support.a.TestADelegateClassLoaderDomain; import org.jboss.test.classloader.delegate.support.a.TestAbstractFactory; import org.jboss.test.classloader.delegate.support.a.TestSleep; import org.jboss.test.classloader.delegate.support.b.TestB1; import org.jboss.test.classloader.delegate.support.b.TestFactoryImplementation; import org.jboss.test.thread.TestThread; /** * DelegateUnitTestCase * * @author Adrian Brock * @version $Revision: 1.1 $ */ public class DelegateUnitTestCase extends AbstractClassLoaderTestWithSecurity { public static Test suite() { return suite(DelegateUnitTestCase.class); } public DelegateUnitTestCase(String name) { super(name); } public void testNoDelegateAToB() throws Exception { ClassLoaderSystem system = createClassLoaderSystemWithModifiedBootstrap(); MockClassLoaderPolicy pb = createMockClassLoaderPolicy("B"); pb.setPaths(TestB1.class); ClassLoader b = system.registerClassLoaderPolicy(pb); MockClassLoaderPolicy pa = createMockClassLoaderPolicy("A"); pa.setPaths(TestA1.class); ClassLoader a = system.registerClassLoaderPolicy(pa); assertLoadClass(TestB1.class, b, false); assertLoadClassFail(TestB1.class, a); } public void testDelegateAToB() throws Exception { ClassLoaderSystem system = createClassLoaderSystemWithModifiedBootstrap(); MockClassLoaderPolicy pb = createMockClassLoaderPolicy("B"); pb.setPaths(TestB1.class); ClassLoader b = system.registerClassLoaderPolicy(pb); MockClassLoaderPolicy pa = createMockClassLoaderPolicy("A"); pa.setPaths(TestA1.class); pa.setDelegates(Collections.singletonList(new FilteredDelegateLoader(pb))); ClassLoader a = system.registerClassLoaderPolicy(pa); Class fromB = assertLoadClass(TestB1.class, b, false); Class fromA = assertLoadClass(TestB1.class, a, b, false); assertClassEquality(fromB, fromA); } public void testAbstractFactoryObviousWay() throws Exception { ClassLoaderSystem system = createClassLoaderSystemWithModifiedBootstrap(); MockClassLoaderPolicy pb = createMockClassLoaderPolicy("B"); pb.setPaths(TestB1.class); MockClassLoaderPolicy pa = createMockClassLoaderPolicy("A"); pa.setPaths(TestA1.class); List delegates = new ArrayList(); delegates.add(new FilteredDelegateLoader(pa)); delegates.add(new FilteredDelegateLoader(pb)); pa.setDelegates(delegates); pb.setDelegates(delegates); ClassLoader a = system.registerClassLoaderPolicy(pa); ClassLoader b = system.registerClassLoaderPolicy(pb); Class testAbstractFactoryClass = assertLoadClass(TestAbstractFactory.class, a); Method method = testAbstractFactoryClass.getMethod("getInstance", (Class[]) null); Object instance = method.invoke(null, (Object[]) null); Class testFactoryImplementationClass = assertLoadClass(TestFactoryImplementation.class, b); assertClassEquality(testFactoryImplementationClass, instance.getClass()); } public void testDelegateToAnotherCodeSource() throws Exception { ClassLoaderSystem system = createClassLoaderSystemWithModifiedBootstrap(); MockClassLoaderPolicy pb = createMockClassLoaderPolicy("B"); pb.setPaths(ClassLoaderDomain.class); ClassLoader b = system.registerClassLoaderPolicy(pb); MockClassLoaderPolicy pa = createMockClassLoaderPolicy("A"); pa.setPaths(TestADelegateClassLoaderDomain.class); pa.setDelegates(Collections.singletonList(new FilteredDelegateLoader(pb))); ClassLoader a = system.registerClassLoaderPolicy(pa); Class fromB = assertLoadClass(ClassLoaderDomain.class, b, false); Class fromA = assertLoadClass(ClassLoaderDomain.class, a, b, false); Class delegate = assertLoadClass(TestADelegateClassLoaderDomain.class, a, false); Method method = delegate.getMethod("getSomething", (Class[]) null); fromA = method.getReturnType(); assertNotNull(fromA); assertClassLoader(fromA, b); assertClassEquality(fromB, fromA); } public void testAbstractFactoryWrongWay() throws Exception { ClassLoaderSystem system = createClassLoaderSystemWithModifiedBootstrap(); MockClassLoaderPolicy pb = createMockClassLoaderPolicy("B"); pb.setPaths(TestB1.class); MockClassLoaderPolicy pa = createMockClassLoaderPolicy("A"); pa.setPaths(TestA1.class); List delegates = new ArrayList(); delegates.add(new FilteredDelegateLoader(pa)); delegates.add(new FilteredDelegateLoader(pb)); pa.setDelegates(delegates); pb.setDelegates(delegates); ClassLoader a = system.registerClassLoaderPolicy(pa); ClassLoader b = system.registerClassLoaderPolicy(pb); Class testAbstractFactoryClass = assertLoadClass(TestAbstractFactory.class, b, a); Method method = testAbstractFactoryClass.getMethod("getInstance", (Class[]) null); Object instance = method.invoke(null, (Object[]) null); Class testFactoryImplementationClass = assertLoadClass(TestFactoryImplementation.class, a, b); assertClassEquality(testFactoryImplementationClass, instance.getClass()); } public void testLoadClassFromDefaultPackage() throws Exception { ClassLoaderSystem system = createClassLoaderSystemWithModifiedBootstrap(); MockClassLoaderPolicy policy = createMockClassLoaderPolicy(); policy.setPath(""); policy.setPackageNames(new String[] { "" }); ClassLoader classLoader = system.registerClassLoaderPolicy(policy); assertLoadClass("TestDefaultPackage", classLoader); } public void testLoadClassFromDefaultPackageFromDelegate() throws Exception { ClassLoaderSystem system = createClassLoaderSystemWithModifiedBootstrap(); MockClassLoaderPolicy policy = createMockClassLoaderPolicy(); policy.setPath(""); policy.setPackageNames(new String[] { "" }); MockClassLoaderPolicy policy2 = createMockClassLoaderPolicy(); policy2.setDelegates(Collections.singletonList(new FilteredDelegateLoader(policy))); ClassLoader classLoader = system.registerClassLoaderPolicy(policy); ClassLoader classLoader2 = system.registerClassLoaderPolicy(policy2); assertLoadClass("TestDefaultPackage", classLoader2, classLoader); } public void testLoadClassFromDefaultPackageFromExports() throws Exception { ClassLoaderSystem system = createClassLoaderSystemWithModifiedBootstrap(); MockClassLoaderPolicy policy = createMockClassLoaderPolicy(); policy.setPath(""); policy.setPackageNames(new String[] { "" }); MockClassLoaderPolicy policy2 = createMockClassLoaderPolicy(); policy2.setImportAll(true); ClassLoader classLoader = system.registerClassLoaderPolicy(policy); ClassLoader classLoader2 = system.registerClassLoaderPolicy(policy2); assertLoadClass("TestDefaultPackage", classLoader2, classLoader); } public void testLoadClassFromDefaultPackageFromParent() throws Exception { ClassLoaderSystem system = createClassLoaderSystem(); ClassLoaderDomain parent = system.createAndRegisterDomain("parent", ParentPolicy.BEFORE_BUT_JAVA_ONLY); MockClassLoaderPolicy policy = createMockClassLoaderPolicy(); policy.setPath(""); policy.setPackageNames(new String[] { "" }); ClassLoaderDomain child = system.createAndRegisterDomain("child", ParentPolicy.BEFORE, parent); MockClassLoaderPolicy policy2 = createMockClassLoaderPolicy(); ClassLoader classLoader = system.registerClassLoaderPolicy(parent, policy); ClassLoader classLoader2 = system.registerClassLoaderPolicy(child, policy2); assertLoadClass("TestDefaultPackage", classLoader2, classLoader); } public void testAbstractFactoryConcurrent() throws Exception { for (int i = 0; i < 10; ++i) { getLog().debug("Attempt: " + i); ClassLoaderSystem system = createClassLoaderSystemWithModifiedBootstrap(); MockClassLoaderPolicy pb = createMockClassLoaderPolicy("B"); pb.setPaths(TestB1.class); MockClassLoaderPolicy pa = createMockClassLoaderPolicy("A"); pa.setPaths(TestA1.class); List delegates = new ArrayList(); delegates.add(new FilteredDelegateLoader(pa)); delegates.add(new FilteredDelegateLoader(pb)); pa.setDelegates(delegates); pb.setDelegates(delegates); final ClassLoader a = system.registerClassLoaderPolicy(pa); final ClassLoader b = system.registerClassLoaderPolicy(pb); Class testSleep = assertLoadClass(TestSleep.class, a); Field field = testSleep.getField("sleep"); field.set(null, new Long(1)); final CountDownLatch startALatch = new CountDownLatch(1); final CountDownLatch startBLatch = new CountDownLatch(1); TestThread threadA = new TestThread("A") { public void run() { try { startBLatch.await(); } catch (InterruptedException ignored) { } startALatch.countDown(); Class testAbstractFactoryClass = assertLoadClass(TestAbstractFactory.class, a); try { Method method = testAbstractFactoryClass.getMethod("getInstance", (Class[]) null); method.invoke(null, (Object[]) null); } catch (Exception e) { throw new Error("Error", e); } } }; TestThread threadB = new TestThread("B") { public void run() { startBLatch.countDown(); try { startALatch.await(); } catch (InterruptedException ignored) { } assertLoadClass(TestFactoryImplementation.class, b); } }; threadA.start(); threadB.start(); threadA.doJoin(); threadB.doJoin(); } } public void testFlushOnImports() throws Exception { ClassLoaderSystem system = createClassLoaderSystemWithModifiedBootstrap(); MockClassLoaderPolicy pa = createMockClassLoaderPolicy("A"); pa.setPaths(TestA1.class); pa.setExcluded(TestA1.class); ClassLoader a = system.registerClassLoaderPolicy(pa); MockClassLoaderPolicy pb = createMockClassLoaderPolicy("B"); pb.setPaths(TestB1.class); List delegates = new ArrayList(); delegates.add(new FilteredDelegateLoader(pa)); pb.setDelegates(delegates); ClassLoader b = system.registerClassLoaderPolicy(pb); assertLoadClassFail(TestA1.class, a); assertLoadClassFail(TestA1.class, b); pa.setExcluded(new String[0]); String testA1Path = ClassLoaderUtils.classNameToPath(TestA1.class.getName()); ((BaseClassLoader) a).clearBlackList(testA1Path); assertLoadClass(TestA1.class, a); assertLoadClass(TestA1.class, b, a); } } ././@LongLink0000000000000000000000000000017500000000000011570 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloader/src/test/java/org/jboss/test/classloader/delegate/DelegateTestSuite.javalibjboss-classloader-java-2.0.6.GA.orig/classloader/src/test/java/org/jboss/test/classloader/delegat0000644000175000017500000000372410616435067033435 0ustar twernertwerner/* * JBoss, Home of Professional Open Source. * Copyright 2007, Red Hat Middleware LLC, and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.test.classloader.delegate; import junit.framework.Test; import junit.framework.TestSuite; import junit.textui.TestRunner; import org.jboss.test.classloader.delegate.test.DelegateLoaderUnitTestCase; import org.jboss.test.classloader.delegate.test.DelegateUnitTestCase; /** * Delegate Test Suite. * * @author Adrian Brock * @version $Revision: 37459 $ */ public class DelegateTestSuite extends TestSuite { /** * For running the testsuite from the command line * * @param args the command line args */ public static void main(String[] args) { TestRunner.run(suite()); } /** * Create the testsuite * * @return the testsuite */ public static Test suite() { TestSuite suite = new TestSuite("Delegate Tests"); suite.addTest(DelegateLoaderUnitTestCase.suite()); suite.addTest(DelegateUnitTestCase.suite()); return suite; } } ././@LongLink0000000000000000000000000000015700000000000011570 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloader/src/test/java/org/jboss/test/classloader/delegate/support/libjboss-classloader-java-2.0.6.GA.orig/classloader/src/test/java/org/jboss/test/classloader/delegat0000755000175000017500000000000011620043421033406 5ustar twernertwerner././@LongLink0000000000000000000000000000016100000000000011563 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloader/src/test/java/org/jboss/test/classloader/delegate/support/a/libjboss-classloader-java-2.0.6.GA.orig/classloader/src/test/java/org/jboss/test/classloader/delegat0000755000175000017500000000000011620043421033406 5ustar twernertwerner././@LongLink0000000000000000000000000000017700000000000011572 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloader/src/test/java/org/jboss/test/classloader/delegate/support/a/TestSleep.javalibjboss-classloader-java-2.0.6.GA.orig/classloader/src/test/java/org/jboss/test/classloader/delegat0000644000175000017500000000235210614350067033423 0ustar twernertwerner/* * JBoss, Home of Professional Open Source. * Copyright 2007, Red Hat Middleware LLC, and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.test.classloader.delegate.support.a; /** * TestSleep. * * @author Adrian Brock * @version $Revision: 1.1 $ */ public class TestSleep { public static long sleep = 0; } ././@LongLink0000000000000000000000000000022400000000000011563 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloader/src/test/java/org/jboss/test/classloader/delegate/support/a/TestADelegateClassLoaderDomain.javalibjboss-classloader-java-2.0.6.GA.orig/classloader/src/test/java/org/jboss/test/classloader/delegat0000644000175000017500000000256710615374311033432 0ustar twernertwerner/* * JBoss, Home of Professional Open Source. * Copyright 2007, Red Hat Middleware LLC, and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.test.classloader.delegate.support.a; import org.jboss.classloader.spi.ClassLoaderDomain; /** * TestADelegateClassLoaderDomain. * * @author Adrian Brock * @version $Revision: 1.1 $ */ public class TestADelegateClassLoaderDomain { public static ClassLoaderDomain getSomething() { return null; } } ././@LongLink0000000000000000000000000000017400000000000011567 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloader/src/test/java/org/jboss/test/classloader/delegate/support/a/TestA1.javalibjboss-classloader-java-2.0.6.GA.orig/classloader/src/test/java/org/jboss/test/classloader/delegat0000644000175000017500000000230410614350067033420 0ustar twernertwerner/* * JBoss, Home of Professional Open Source. * Copyright 2007, Red Hat Middleware LLC, and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.test.classloader.delegate.support.a; /** * TestA1. * * @author Adrian Brock * @version $Revision: 1.1 $ */ public class TestA1 { } ././@LongLink0000000000000000000000000000021100000000000011557 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloader/src/test/java/org/jboss/test/classloader/delegate/support/a/TestAbstractFactory.javalibjboss-classloader-java-2.0.6.GA.orig/classloader/src/test/java/org/jboss/test/classloader/delegat0000644000175000017500000000345610614350067033431 0ustar twernertwerner/* * JBoss, Home of Professional Open Source. * Copyright 2007, Red Hat Middleware LLC, and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.test.classloader.delegate.support.a; import org.jboss.test.classloader.delegate.support.b.TestFactoryImplementation; /** * TestAbstractFactory. * * @author Adrian Brock * @version $Revision: 1.1 $ */ public class TestAbstractFactory { private static TestAbstractFactory instance; static { long sleep = TestSleep.sleep; if (sleep != 0) { try { Thread.sleep(sleep); } catch (InterruptedException e) { throw new Error("Interrupted"); } } init(); } public static void init() { instance = new TestFactoryImplementation(); } public static TestAbstractFactory getInstance() { return instance; } } ././@LongLink0000000000000000000000000000016100000000000011563 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloader/src/test/java/org/jboss/test/classloader/delegate/support/b/libjboss-classloader-java-2.0.6.GA.orig/classloader/src/test/java/org/jboss/test/classloader/delegat0000755000175000017500000000000011620043421033406 5ustar twernertwerner././@LongLink0000000000000000000000000000021700000000000011565 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloader/src/test/java/org/jboss/test/classloader/delegate/support/b/TestFactoryImplementation.javalibjboss-classloader-java-2.0.6.GA.orig/classloader/src/test/java/org/jboss/test/classloader/delegat0000644000175000017500000000252010614350067033420 0ustar twernertwerner/* * JBoss, Home of Professional Open Source. * Copyright 2007, Red Hat Middleware LLC, and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.test.classloader.delegate.support.b; import org.jboss.test.classloader.delegate.support.a.TestAbstractFactory; /** * TestFactoryImplementation. * * @author Adrian Brock * @version $Revision: 1.1 $ */ public class TestFactoryImplementation extends TestAbstractFactory { } ././@LongLink0000000000000000000000000000017400000000000011567 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloader/src/test/java/org/jboss/test/classloader/delegate/support/b/TestB1.javalibjboss-classloader-java-2.0.6.GA.orig/classloader/src/test/java/org/jboss/test/classloader/delegat0000644000175000017500000000230410614350067033420 0ustar twernertwerner/* * JBoss, Home of Professional Open Source. * Copyright 2007, Red Hat Middleware LLC, and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.test.classloader.delegate.support.b; /** * TestB1. * * @author Adrian Brock * @version $Revision: 1.1 $ */ public class TestB1 { } ././@LongLink0000000000000000000000000000015000000000000011561 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloader/src/test/java/org/jboss/test/classloader/transform/libjboss-classloader-java-2.0.6.GA.orig/classloader/src/test/java/org/jboss/test/classloader/transfo0000755000175000017500000000000011620043421033455 5ustar twernertwerner././@LongLink0000000000000000000000000000015500000000000011566 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloader/src/test/java/org/jboss/test/classloader/transform/test/libjboss-classloader-java-2.0.6.GA.orig/classloader/src/test/java/org/jboss/test/classloader/transfo0000755000175000017500000000000011620043421033455 5ustar twernertwerner././@LongLink0000000000000000000000000000021500000000000011563 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloader/src/test/java/org/jboss/test/classloader/transform/test/PolicyTransformUnitTestCase.javalibjboss-classloader-java-2.0.6.GA.orig/classloader/src/test/java/org/jboss/test/classloader/transfo0000644000175000017500000000451611173151646033501 0ustar twernertwerner/* * JBoss, Home of Professional Open Source. * Copyright 2008, Red Hat Middleware LLC, and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.test.classloader.transform.test; import java.lang.reflect.Method; import junit.framework.Test; import org.jboss.classloader.spi.ClassLoaderPolicy; import org.jboss.classloader.spi.ClassLoaderSystem; import org.jboss.test.classloader.transform.support.AuthorTranslator; /** * Per policy transformation tests. * * @author Ales Justin */ public class PolicyTransformUnitTestCase extends TransformTest { public PolicyTransformUnitTestCase(String name) { super(name); } public static Test suite() { return suite(PolicyTransformUnitTestCase.class); } protected void prepareTransform(ClassLoaderSystem system, ClassLoaderPolicy policy) { policy.addTranslator(new AuthorTranslator()); } protected String getClassName() { return "org.jboss.test.classloader.transform.support.PolicyTester"; } protected void testInstance(Object instance) throws Exception { Method author = instance.getClass().getDeclaredMethod("author"); assertNotNull(author.invoke(instance)); try { instance.getClass().getDeclaredMethod("locale"); fail("Should not be here."); } catch (Exception ignored) { } } }././@LongLink0000000000000000000000000000021500000000000011563 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloader/src/test/java/org/jboss/test/classloader/transform/test/SystemTransformUnitTestCase.javalibjboss-classloader-java-2.0.6.GA.orig/classloader/src/test/java/org/jboss/test/classloader/transfo0000644000175000017500000000451611173151646033501 0ustar twernertwerner/* * JBoss, Home of Professional Open Source. * Copyright 2008, Red Hat Middleware LLC, and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.test.classloader.transform.test; import java.lang.reflect.Method; import junit.framework.Test; import org.jboss.classloader.spi.ClassLoaderPolicy; import org.jboss.classloader.spi.ClassLoaderSystem; import org.jboss.test.classloader.transform.support.LocaleTranslator; /** * Per system transformation tests. * * @author Ales Justin */ public class SystemTransformUnitTestCase extends TransformTest { public SystemTransformUnitTestCase(String name) { super(name); } public static Test suite() { return suite(SystemTransformUnitTestCase.class); } protected void prepareTransform(ClassLoaderSystem system, ClassLoaderPolicy policy) { system.addTranslator(new LocaleTranslator()); } protected String getClassName() { return "org.jboss.test.classloader.transform.support.SystemTester"; } protected void testInstance(Object instance) throws Exception { try { instance.getClass().getDeclaredMethod("author"); fail("Should not be here."); } catch (Exception ignored) { } Method locale = instance.getClass().getDeclaredMethod("locale"); assertNotNull(locale.invoke(instance)); } }././@LongLink0000000000000000000000000000021400000000000011562 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloader/src/test/java/org/jboss/test/classloader/transform/test/MixedTransformUnitTestCase.javalibjboss-classloader-java-2.0.6.GA.orig/classloader/src/test/java/org/jboss/test/classloader/transfo0000644000175000017500000000460611173151646033501 0ustar twernertwerner/* * JBoss, Home of Professional Open Source. * Copyright 2008, Red Hat Middleware LLC, and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.test.classloader.transform.test; import java.lang.reflect.Method; import junit.framework.Test; import org.jboss.classloader.spi.ClassLoaderPolicy; import org.jboss.classloader.spi.ClassLoaderSystem; import org.jboss.test.classloader.transform.support.AuthorTranslator; import org.jboss.test.classloader.transform.support.LocaleTranslator; /** * Mixed transformation tests. * * @author Ales Justin */ public class MixedTransformUnitTestCase extends TransformTest { public MixedTransformUnitTestCase(String name) { super(name); } public static Test suite() { return suite(MixedTransformUnitTestCase.class); } protected void prepareTransform(ClassLoaderSystem system, ClassLoaderPolicy policy) { policy.addTranslator(new AuthorTranslator()); system.addTranslator(new LocaleTranslator()); } protected String getClassName() { return "org.jboss.test.classloader.transform.support.MixedTester"; } protected void testInstance(Object instance) throws Exception { Method author = instance.getClass().getDeclaredMethod("author"); assertNotNull(author.invoke(instance)); Method locale = instance.getClass().getDeclaredMethod("locale"); assertNotNull(locale.invoke(instance)); } }././@LongLink0000000000000000000000000000017700000000000011572 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloader/src/test/java/org/jboss/test/classloader/transform/test/TransformTest.javalibjboss-classloader-java-2.0.6.GA.orig/classloader/src/test/java/org/jboss/test/classloader/transfo0000644000175000017500000000445411173151646033502 0ustar twernertwerner/* * JBoss, Home of Professional Open Source. * Copyright 2008, Red Hat Middleware LLC, and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.test.classloader.transform.test; import org.jboss.classloader.spi.ClassLoaderPolicy; import org.jboss.classloader.spi.ClassLoaderSystem; import org.jboss.classloader.test.support.MockClassLoaderPolicy; import org.jboss.test.classloader.AbstractClassLoaderTest; /** * Transformation tests. * * @author Ales Justin */ public abstract class TransformTest extends AbstractClassLoaderTest { protected TransformTest(String name) { super(name); } public void testTransform() throws Exception { ClassLoaderSystem system = createClassLoaderSystemWithModifiedBootstrap(); MockClassLoaderPolicy policy = createMockClassLoaderPolicy(); policy.setPaths("org/jboss/test/classloader/transform/support"); prepareTransform(system, policy); ClassLoader cl = system.registerClassLoaderPolicy(policy); Class clazz = cl.loadClass(getClassName()); Object instance = clazz.newInstance(); testInstance(instance); } protected abstract void prepareTransform(ClassLoaderSystem system, ClassLoaderPolicy policy); protected abstract String getClassName(); protected abstract void testInstance(Object instance) throws Exception; } ././@LongLink0000000000000000000000000000017700000000000011572 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloader/src/test/java/org/jboss/test/classloader/transform/TransformTestSuite.javalibjboss-classloader-java-2.0.6.GA.orig/classloader/src/test/java/org/jboss/test/classloader/transfo0000644000175000017500000000421211173151646033472 0ustar twernertwerner/* * JBoss, Home of Professional Open Source. * Copyright 2008, Red Hat Middleware LLC, and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.test.classloader.transform; import junit.framework.Test; import junit.framework.TestSuite; import junit.textui.TestRunner; import org.jboss.test.classloader.transform.test.MixedTransformUnitTestCase; import org.jboss.test.classloader.transform.test.PolicyTransformUnitTestCase; import org.jboss.test.classloader.transform.test.SystemTransformUnitTestCase; /** * Transform Test Suite. * * @author Ales Justin */ public class TransformTestSuite extends TestSuite { /** * For running the testsuite from the command line * * @param args the command line args */ public static void main(String[] args) { TestRunner.run(suite()); } /** * Create the testsuite * * @return the testsuite */ public static Test suite() { TestSuite suite = new TestSuite("Transform Tests"); suite.addTest(PolicyTransformUnitTestCase.suite()); suite.addTest(SystemTransformUnitTestCase.suite()); suite.addTest(MixedTransformUnitTestCase.suite()); return suite; } } ././@LongLink0000000000000000000000000000016000000000000011562 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloader/src/test/java/org/jboss/test/classloader/transform/support/libjboss-classloader-java-2.0.6.GA.orig/classloader/src/test/java/org/jboss/test/classloader/transfo0000755000175000017500000000000011620043421033455 5ustar twernertwerner././@LongLink0000000000000000000000000000020000000000000011555 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloader/src/test/java/org/jboss/test/classloader/transform/support/MixedTester.javalibjboss-classloader-java-2.0.6.GA.orig/classloader/src/test/java/org/jboss/test/classloader/transfo0000644000175000017500000000230111173151646033467 0ustar twernertwerner/* * JBoss, Home of Professional Open Source. * Copyright 2008, Red Hat Middleware LLC, and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.test.classloader.transform.support; /** * @author Ales Justin */ public class MixedTester { }././@LongLink0000000000000000000000000000020100000000000011556 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloader/src/test/java/org/jboss/test/classloader/transform/support/PolicyTester.javalibjboss-classloader-java-2.0.6.GA.orig/classloader/src/test/java/org/jboss/test/classloader/transfo0000644000175000017500000000230411173151646033472 0ustar twernertwerner/* * JBoss, Home of Professional Open Source. * Copyright 2008, Red Hat Middleware LLC, and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.test.classloader.transform.support; /** * @author Ales Justin */ public class PolicyTester { } ././@LongLink0000000000000000000000000000020100000000000011556 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloader/src/test/java/org/jboss/test/classloader/transform/support/SystemTester.javalibjboss-classloader-java-2.0.6.GA.orig/classloader/src/test/java/org/jboss/test/classloader/transfo0000644000175000017500000000230211173151646033470 0ustar twernertwerner/* * JBoss, Home of Professional Open Source. * Copyright 2008, Red Hat Middleware LLC, and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.test.classloader.transform.support; /** * @author Ales Justin */ public class SystemTester { }././@LongLink0000000000000000000000000000020500000000000011562 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloader/src/test/java/org/jboss/test/classloader/transform/support/LocaleTranslator.javalibjboss-classloader-java-2.0.6.GA.orig/classloader/src/test/java/org/jboss/test/classloader/transfo0000644000175000017500000000256011173151646033476 0ustar twernertwerner/* * JBoss, Home of Professional Open Source. * Copyright 2008, Red Hat Middleware LLC, and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.test.classloader.transform.support; import javassist.CtClass; /** * @author Ales Justin */ public class LocaleTranslator extends JavassistTranslator { protected void addMethods(CtClass ctClass) throws Exception { addMethod(ctClass, "locale"); } }././@LongLink0000000000000000000000000000020500000000000011562 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloader/src/test/java/org/jboss/test/classloader/transform/support/AuthorTranslator.javalibjboss-classloader-java-2.0.6.GA.orig/classloader/src/test/java/org/jboss/test/classloader/transfo0000644000175000017500000000256211173151646033500 0ustar twernertwerner/* * JBoss, Home of Professional Open Source. * Copyright 2008, Red Hat Middleware LLC, and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.test.classloader.transform.support; import javassist.CtClass; /** * @author Ales Justin */ public class AuthorTranslator extends JavassistTranslator { protected void addMethods(CtClass ctClass) throws Exception { addMethod(ctClass, "author"); } } ././@LongLink0000000000000000000000000000020100000000000011556 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloader/src/test/java/org/jboss/test/classloader/transform/support/MethodHelper.javalibjboss-classloader-java-2.0.6.GA.orig/classloader/src/test/java/org/jboss/test/classloader/transfo0000644000175000017500000000264011173151646033475 0ustar twernertwerner/* * JBoss, Home of Professional Open Source. * Copyright 2008, Red Hat Middleware LLC, and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.test.classloader.transform.support; import java.util.Locale; /** * @author Ales Justin */ public class MethodHelper { public static String author() { return System.getProperty("user.name", "Ales"); } public static Locale locale() { return Locale.getDefault(); } }././@LongLink0000000000000000000000000000021000000000000011556 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloader/src/test/java/org/jboss/test/classloader/transform/support/JavassistTranslator.javalibjboss-classloader-java-2.0.6.GA.orig/classloader/src/test/java/org/jboss/test/classloader/transfo0000644000175000017500000000454711173151646033505 0ustar twernertwerner/* * JBoss, Home of Professional Open Source. * Copyright 2008, Red Hat Middleware LLC, and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.test.classloader.transform.support; import java.security.ProtectionDomain; import javassist.ClassPool; import javassist.CtClass; import javassist.CtMethod; import javassist.CtNewMethod; import org.jboss.util.loading.Translator; /** * @author Ales Justin */ public abstract class JavassistTranslator implements Translator { private ClassPool pool = ClassPool.getDefault(); public byte[] transform(ClassLoader loader, String className, Class classBeingRedefined, ProtectionDomain protectionDomain, byte[] classfileBuffer) throws Exception { // do not modify MethodHelper if (className.contains("MethodHelper")) return classfileBuffer; CtClass ctClass = pool.getCtClass(className); ctClass.defrost(); addMethods(ctClass); return ctClass.toBytecode(); } protected abstract void addMethods(CtClass ctClass) throws Exception; protected void addMethod(CtClass ctClass, String methodName) throws Exception { CtMethod body = pool.getCtClass(MethodHelper.class.getName()).getDeclaredMethod(methodName); CtMethod newMethod = CtNewMethod.delegator(body, ctClass); ctClass.addMethod(newMethod); } public void unregisterClassLoader(ClassLoader loader) { } }././@LongLink0000000000000000000000000000017200000000000011565 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloader/src/test/java/org/jboss/test/classloader/AbstractClassLoaderTest.javalibjboss-classloader-java-2.0.6.GA.orig/classloader/src/test/java/org/jboss/test/classloader/Abstrac0000644000175000017500000003156210755316116033405 0ustar twernertwerner/* * JBoss, Home of Professional Open Source. * Copyright 2007, Red Hat Middleware LLC, and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.test.classloader; import junit.framework.TestCase; import org.jboss.classloader.plugins.ClassLoaderUtils; import org.jboss.classloader.plugins.jdk.AbstractJDKChecker; import org.jboss.classloader.spi.ClassLoaderDomain; import org.jboss.classloader.spi.ClassLoaderPolicy; import org.jboss.classloader.spi.ClassLoaderSystem; import org.jboss.classloader.spi.ParentPolicy; import org.jboss.classloader.spi.filter.ClassFilter; import org.jboss.classloader.test.support.MockClassLoaderHelper; import org.jboss.classloader.test.support.MockClassLoaderPolicy; import org.jboss.test.AbstractTestCaseWithSetup; import org.jboss.test.AbstractTestDelegate; /** * AbstractClassLoaderTest. * * @author Adrian Brock * @version $Revision: 1.1 $ */ public abstract class AbstractClassLoaderTest extends AbstractTestCaseWithSetup { static { // Make sure the mock classloader doesn't think we are part of the JDK AbstractJDKChecker.getExcluded().add(TestCase.class); } public static AbstractTestDelegate getDelegate(Class clazz) { return new AbstractTestDelegate(clazz); } @Override protected void setUp() throws Exception { super.setUp(); configureLogging(); } public AbstractClassLoaderTest(String name) { super(name); } protected ClassLoaderSystem createClassLoaderSystem() { // We always create a new one to avoid things in the default domain leaking across tests return MockClassLoaderHelper.createMockClassLoaderSystem(); } protected ClassLoaderSystem createClassLoaderSystemWithModifiedBootstrap() { ClassLoaderSystem result = createClassLoaderSystem(); result.getDefaultDomain().setParentPolicy(ParentPolicy.BEFORE_BUT_JAVA_ONLY); return result; } protected ClassLoader createClassLoaderSystemWithModifiedBootstrapAndMockClassLoader() { ClassLoaderSystem system = createClassLoaderSystemWithModifiedBootstrap(); return createAndRegisterMockClassLoader(system); } protected ClassLoader registerPolicyWithDefaultDomain(ClassLoaderPolicy policy, ClassLoaderSystem system) { return system.registerClassLoaderPolicy(policy); } protected MockClassLoaderPolicy createMockClassLoaderPolicy() { return createMockClassLoaderPolicy(null); } protected MockClassLoaderPolicy createMockClassLoaderPolicy(String name) { return MockClassLoaderHelper.createMockClassLoaderPolicy(name); } protected ClassLoader createAndRegisterMockClassLoader(ClassLoaderSystem system) { return createAndRegisterMockClassLoader(system, "mock"); } protected ClassLoader createAndRegisterMockClassLoader(ClassLoaderSystem system, String name) { return MockClassLoaderHelper.createAndRegisterMockClassLoader(system, (ClassLoaderDomain) null, name); } protected ClassLoader createAndRegisterMockClassLoader(ClassLoaderSystem system, ClassLoaderDomain domain) { return createAndRegisterMockClassLoader(system, domain, "mock"); } protected ClassLoader createAndRegisterMockClassLoader(ClassLoaderSystem system, String domainName, String name) { return MockClassLoaderHelper.createAndRegisterMockClassLoader(system, domainName, name); } protected ClassLoader createAndRegisterMockClassLoader(ClassLoaderSystem system, String domainName, ParentPolicy parentPolicy, String name) { return MockClassLoaderHelper.createAndRegisterMockClassLoader(system, domainName, parentPolicy, name); } protected ClassLoader createAndRegisterMockClassLoader(ClassLoaderSystem system, String domainName, ParentPolicy parentPolicy, String parentDomainName, String name) { return MockClassLoaderHelper.createAndRegisterMockClassLoader(system, domainName, parentPolicy, parentDomainName, name); } protected ClassLoader createAndRegisterMockClassLoader(ClassLoaderSystem system, ClassLoaderDomain domain, String name) { return MockClassLoaderHelper.createAndRegisterMockClassLoader(system, domain, name); } protected void assertClassEquality(Class expected, Class actual) { assertTrue("Should be the same " + ClassLoaderUtils.classToString(expected) +" and " + ClassLoaderUtils.classToString(actual), expected == actual); } protected void assertNoClassEquality(Class expected, Class actual) { assertTrue("Should NOT be the same " + ClassLoaderUtils.classToString(expected) +" and " + ClassLoaderUtils.classToString(actual), expected != actual); } protected void assertClassLoader(Class clazz, ClassLoader expected) { if (expected == null) return; boolean result = MockClassLoaderHelper.isExpectedClassLoader(clazz, expected); assertTrue(ClassLoaderUtils.classToString(clazz) + " should have expected classloader=" + expected, result); } protected Class assertLoadClass(Class reference, ClassLoader start) { return assertLoadClass(reference, start, start, false); } protected Class assertLoadClass(Class reference, ClassLoader start, boolean isReference) { return assertLoadClass(reference, start, start, isReference); } protected Class assertLoadClass(Class reference, ClassLoader start, ClassLoader expected) { return assertLoadClass(reference, start, expected, false); } protected Class assertLoadClass(Class reference, ClassLoader start, ClassLoader expected, boolean isReference) { Class result = assertLoadClass(reference.getName(), start, expected); if (isReference) assertClassEquality(reference, result); else assertNoClassEquality(reference, result); return result; } protected Class assertLoadClass(String name, ClassLoader start) { return assertLoadClass(name, start, start); } protected Class assertLoadClass(String name, ClassLoader start, ClassLoader expected) { Class result = null; try { result = start.loadClass(name); getLog().debug("Got class: " + ClassLoaderUtils.classToString(result) + " for " + name + " from " + start); } catch (ClassNotFoundException e) { failure("Did not expect CNFE for " + name + " from " + start, e); } assertClassLoader(result, expected); return result; } protected void assertLoadClassFail(Class reference, ClassLoader start) { assertLoadClassFail(reference.getName(), start); } protected void assertLoadClassFail(String name, ClassLoader start) { try { start.loadClass(name); fail("Should not be here!"); } catch (Exception expected) { checkThrowable(ClassNotFoundException.class, expected); } } protected Class assertClassForName(Class reference, ClassLoader start) { return assertClassForName(reference, start, start, false); } protected Class assertClassForName(Class reference, ClassLoader start, boolean isReference) { return assertClassForName(reference, start, start, isReference); } protected Class assertClassForName(Class reference, ClassLoader start, ClassLoader expected) { return assertClassForName(reference, start, expected, false); } protected Class assertClassForName(Class reference, ClassLoader start, ClassLoader expected, boolean isReference) { Class result = assertClassForName(reference.getName(), start, expected); if (isReference) assertClassEquality(reference, result); else assertNoClassEquality(reference, result); return result; } protected Class assertClassForName(String name, ClassLoader start) { return assertLoadClass(name, start, start); } protected Class assertClassForName(String name, ClassLoader start, ClassLoader expected) { Class result = null; try { result = Class.forName(name, true, start); getLog().debug("Got class: " + ClassLoaderUtils.classToString(result) + " for " + name + " from " + start); } catch (ClassNotFoundException e) { failure("Did not expect CNFE for " + name + " from " + start, e); } assertClassLoader(result, expected); return result; } protected void assertClassForNameFail(Class reference, ClassLoader start) { assertClassForNameFail(reference.getName(), start); } protected void assertClassForNameFail(String name, ClassLoader start) { try { Class.forName(name, true, start); } catch (Exception expected) { checkThrowable(ClassNotFoundException.class, expected); } } protected void assertPackage(Class reference, ClassLoader classLoader) throws Exception { Class clazz = classLoader.loadClass(reference.getName()); Package pkge = Package.getPackage(ClassLoaderUtils.getClassPackageName(clazz.getName())); assertEquals(pkge,clazz.getPackage()); } protected void assertPackage(Class reference, ClassLoader classLoader, MockClassLoaderPolicy policy) throws Exception { Class clazz = classLoader.loadClass(reference.getName()); Package pkge = clazz.getPackage(); assertNotNull("Expected a package for " + clazz.getName(), pkge); assertEquals(policy.getName(), pkge.getImplementationTitle()); } protected void assertFilterMatchesClassName(String test, ClassFilter filter) { getLog().debug("Checking " + test + " expect it to match filter=" + filter); boolean result = filter.matchesClassName(test); getLog().debug("Checked " + test + " result was " + result + " for filter=" + filter); assertTrue("Expected " + test + " to match " + filter, result); } protected void assertFilterNoMatchClassName(String test, ClassFilter filter) { getLog().debug("Checking " + test + " expect it NOT to match filter=" + filter); boolean result = filter.matchesClassName(test); getLog().debug("Checked " + test + " result was " + result + " for filter=" + filter); assertFalse("Expected " + test + " NOT to match " + filter, result); } protected void assertFilterMatchesResourcePath(String test, ClassFilter filter) { getLog().debug("Checking " + test + " expect it to match filter=" + filter); boolean result = filter.matchesResourcePath(test); getLog().debug("Checked " + test + " result was " + result + " for filter=" + filter); assertTrue("Expected " + test + " to match " + filter, result); } protected void assertFilterNoMatchResourcePath(String test, ClassFilter filter) { getLog().debug("Checking " + test + " expect it NOT to match filter=" + filter); boolean result = filter.matchesResourcePath(test); getLog().debug("Checked " + test + " result was " + result + " for filter=" + filter); assertFalse("Expected " + test + " NOT to match " + filter, result); } protected void assertFilterMatchesPackageName(String test, ClassFilter filter) { getLog().debug("Checking " + test + " expect it to match filter=" + filter); boolean result = filter.matchesPackageName(test); getLog().debug("Checked " + test + " result was " + result + " for filter=" + filter); assertTrue("Expected " + test + " to match " + filter, result); } protected void assertFilterNoMatchPackageName(String test, ClassFilter filter) { getLog().debug("Checking " + test + " expect it NOT to match filter=" + filter); boolean result = filter.matchesPackageName(test); getLog().debug("Checked " + test + " result was " + result + " for filter=" + filter); assertFalse("Expected " + test + " NOT to match " + filter, result); } protected void configureLogging() { //enableTrace("org.jboss.classloader"); } } ././@LongLink0000000000000000000000000000017200000000000011565 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloader/src/test/java/org/jboss/test/classloader/ClassLoaderAllTestSuite.javalibjboss-classloader-java-2.0.6.GA.orig/classloader/src/test/java/org/jboss/test/classloader/ClassLo0000644000175000017500000000574411173151646033371 0ustar twernertwerner/* * JBoss, Home of Professional Open Source. * Copyright 2007, Red Hat Middleware LLC, and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.test.classloader; import junit.framework.Test; import junit.framework.TestSuite; import junit.textui.TestRunner; import org.jboss.test.classloader.bootstrap.BootstrapTestSuite; import org.jboss.test.classloader.delegate.DelegateTestSuite; import org.jboss.test.classloader.domain.ClassLoaderDomainTestSuite; import org.jboss.test.classloader.filter.FilterTestSuite; import org.jboss.test.classloader.jmx.JMXTestSuite; import org.jboss.test.classloader.junit.JUnitTestSuite; import org.jboss.test.classloader.old.OldTestSuite; import org.jboss.test.classloader.policy.test.ClassLoaderPolicyUnitTestCase; import org.jboss.test.classloader.resources.ResourceTestSuite; import org.jboss.test.classloader.system.ClassLoaderSystemTestSuite; import org.jboss.test.classloader.transform.TransformTestSuite; /** * ClassLoader All Test Suite. * * @author Adrian Brock * @author Ales Justin * @version $Revision: 37459 $ */ public class ClassLoaderAllTestSuite extends TestSuite { /** * For running the testsuite from the command line * * @param args the command line args */ public static void main(String[] args) { TestRunner.run(suite()); } /** * Create the testsuite * * @return the testsuite */ public static Test suite() { TestSuite suite = new TestSuite("ClassLoader All Tests"); suite.addTest(ClassLoaderSystemTestSuite.suite()); suite.addTest(ClassLoaderDomainTestSuite.suite()); suite.addTest(ClassLoaderPolicyUnitTestCase.suite()); suite.addTest(BootstrapTestSuite.suite()); suite.addTest(OldTestSuite.suite()); suite.addTest(FilterTestSuite.suite()); suite.addTest(DelegateTestSuite.suite()); suite.addTest(ResourceTestSuite.suite()); suite.addTest(JMXTestSuite.suite()); suite.addTest(JUnitTestSuite.suite()); suite.addTest(TransformTestSuite.suite()); return suite; } } libjboss-classloader-java-2.0.6.GA.orig/classloader/src/test/java/org/jboss/test/classloader/jmx/0000755000175000017500000000000011620043422032657 5ustar twernertwerner././@LongLink0000000000000000000000000000014700000000000011567 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloader/src/test/java/org/jboss/test/classloader/jmx/test/libjboss-classloader-java-2.0.6.GA.orig/classloader/src/test/java/org/jboss/test/classloader/jmx/tes0000755000175000017500000000000011620043422033373 5ustar twernertwerner././@LongLink0000000000000000000000000000017300000000000011566 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloader/src/test/java/org/jboss/test/classloader/jmx/test/JMXUnitTestCase.javalibjboss-classloader-java-2.0.6.GA.orig/classloader/src/test/java/org/jboss/test/classloader/jmx/tes0000644000175000017500000005153011042050234033376 0ustar twernertwerner/* * JBoss, Home of Professional Open Source. * Copyright 2007, Red Hat Middleware LLC, and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.test.classloader.jmx.test; import java.net.URL; import java.util.Arrays; import java.util.Collections; import java.util.HashMap; import java.util.HashSet; import java.util.List; import java.util.Map; import java.util.Set; import javax.management.MBeanInfo; import javax.management.MBeanServer; import javax.management.MBeanServerFactory; import javax.management.MalformedObjectNameException; import javax.management.ObjectName; import junit.framework.Test; import org.jboss.classloader.plugins.ClassLoaderUtils; import org.jboss.classloader.plugins.jdk.AbstractJDKChecker; import org.jboss.classloader.spi.ClassLoaderDomain; import org.jboss.classloader.spi.ClassLoaderSystem; import org.jboss.classloader.spi.ParentPolicy; import org.jboss.classloader.test.support.MockClassLoaderPolicy; import org.jboss.classloading.spi.RealClassLoader; import org.jboss.test.classloader.AbstractClassLoaderTest; import org.jboss.test.classloader.jmx.support.Simple; import org.jboss.test.classloader.jmx.support.a.A; import org.jboss.test.classloader.jmx.support.b.B; /** * JMXUnitTestCase * * @author Adrian Brock * @version $Revision: 1.1 $ */ public class JMXUnitTestCase extends AbstractClassLoaderTest { private static final ObjectName CLASSLOADER_SYSTEM_OBJECT_NAME; static { try { CLASSLOADER_SYSTEM_OBJECT_NAME = new ObjectName("test:type=ClassLoaderSystem"); } catch (MalformedObjectNameException e) { throw new RuntimeException("Unexpected error", e); } AbstractJDKChecker.getExcluded().add(JMXUnitTestCase.class); } public static Test suite() { return suite(JMXUnitTestCase.class); } public JMXUnitTestCase(String name) { super(name); } public void testJMXClassLoader() throws Exception { ClassLoaderSystem system = createClassLoaderSystemWithModifiedBootstrap(); MockClassLoaderPolicy policy = createMockClassLoaderPolicy("simple"); policy.setPathsAndPackageNames(Simple.class); RealClassLoader cl = (RealClassLoader) system.registerClassLoaderPolicy(policy); MBeanServer server = MBeanServerFactory.newMBeanServer(); ObjectName clName = cl.getObjectName(); server.registerMBean(cl, clName); getLog().debug("Registered classloader " + cl + " with name " + clName); ObjectName name = new ObjectName("test:test=simple"); server.createMBean(Simple.class.getName(), name, clName); MBeanInfo info = server.getMBeanInfo(name); assertEquals(Simple.class.getName(), info.getClassName()); Object actual = server.getAttribute(name, "ClassLoader"); getLog().debug("Actual ClassLoader=" + actual + " expected " + cl); assertEquals(cl, actual); } @SuppressWarnings("unchecked") public void testClassLoaderSystemMBean() throws Exception { ClassLoaderSystem system = createClassLoaderSystemWithModifiedBootstrap(); MBeanServer server = MBeanServerFactory.newMBeanServer(); server.registerMBean(system, CLASSLOADER_SYSTEM_OBJECT_NAME); Set domainNames = (Set) server.getAttribute(CLASSLOADER_SYSTEM_OBJECT_NAME, "DomainNames"); Set expected = makeSet(ClassLoaderSystem.DEFAULT_DOMAIN_NAME); assertEquals(expected, domainNames); ClassLoaderDomain defaultDomain = system.getDefaultDomain(); ObjectName defaultDomainObjectName = defaultDomain.getObjectName(); Set domains = (Set) server.getAttribute(CLASSLOADER_SYSTEM_OBJECT_NAME, "Domains"); Set expectedObjectNames = makeSet(defaultDomainObjectName); assertEquals(expectedObjectNames, domains); String domainName = (String) server.getAttribute(defaultDomainObjectName, "Name"); assertEquals(ClassLoaderSystem.DEFAULT_DOMAIN_NAME, domainName); } @SuppressWarnings("unchecked") public void testRegisterDomain() throws Exception { ClassLoaderSystem system = createClassLoaderSystemWithModifiedBootstrap(); MBeanServer server = MBeanServerFactory.newMBeanServer(); server.registerMBean(system, CLASSLOADER_SYSTEM_OBJECT_NAME); ClassLoaderDomain defaultDomain = system.getDefaultDomain(); ObjectName defaultDomainObjectName = defaultDomain.getObjectName(); ClassLoaderDomain domain = system.createAndRegisterDomain("test"); ObjectName testObjectName = domain.getObjectName(); Set domainNames = (Set) server.getAttribute(CLASSLOADER_SYSTEM_OBJECT_NAME, "DomainNames"); Set expected = makeSet("test", ClassLoaderSystem.DEFAULT_DOMAIN_NAME); assertEquals(expected, domainNames); Set domains = (Set) server.getAttribute(CLASSLOADER_SYSTEM_OBJECT_NAME, "Domains"); Set expectedObjectNames = makeSet(defaultDomainObjectName, testObjectName); assertEquals(expectedObjectNames, domains); String domainName = (String) server.getAttribute(testObjectName, "Name"); assertEquals("test", domainName); system.unregisterDomain(domain); assertFalse(server.isRegistered(testObjectName)); domainNames = (Set) server.getAttribute(CLASSLOADER_SYSTEM_OBJECT_NAME, "DomainNames"); expected = makeSet(ClassLoaderSystem.DEFAULT_DOMAIN_NAME); assertEquals(expected, domainNames); domains = (Set) server.getAttribute(CLASSLOADER_SYSTEM_OBJECT_NAME, "Domains"); expectedObjectNames = makeSet(defaultDomainObjectName); assertEquals(expectedObjectNames, domains); } @SuppressWarnings("unchecked") public void testLazyRegisterDomain() throws Exception { ClassLoaderSystem system = createClassLoaderSystemWithModifiedBootstrap(); MBeanServer server = MBeanServerFactory.newMBeanServer(); ClassLoaderDomain test = system.createAndRegisterDomain("test"); server.registerMBean(system, CLASSLOADER_SYSTEM_OBJECT_NAME); Set domainNames = (Set) server.getAttribute(CLASSLOADER_SYSTEM_OBJECT_NAME, "DomainNames"); Set expected = makeSet("test", ClassLoaderSystem.DEFAULT_DOMAIN_NAME); assertEquals(expected, domainNames); ClassLoaderDomain defaultDomain = system.getDefaultDomain(); ObjectName defaultDomainObjectName = defaultDomain.getObjectName(); ObjectName testObjectName = test.getObjectName(); Set domains = (Set) server.getAttribute(CLASSLOADER_SYSTEM_OBJECT_NAME, "Domains"); Set expectedObjectNames = makeSet(defaultDomainObjectName, testObjectName); assertEquals(expectedObjectNames, domains); } @SuppressWarnings("unchecked") public void testUnregisterClassLoaderSystemUnregistersDomains() throws Exception { ClassLoaderSystem system = createClassLoaderSystemWithModifiedBootstrap(); MBeanServer server = MBeanServerFactory.newMBeanServer(); ClassLoaderDomain test = system.createAndRegisterDomain("test"); server.registerMBean(system, CLASSLOADER_SYSTEM_OBJECT_NAME); Set domainNames = (Set) server.getAttribute(CLASSLOADER_SYSTEM_OBJECT_NAME, "DomainNames"); Set expected = makeSet("test", ClassLoaderSystem.DEFAULT_DOMAIN_NAME); assertEquals(expected, domainNames); ClassLoaderDomain defaultDomain = system.getDefaultDomain(); ObjectName defaultDomainObjectName = defaultDomain.getObjectName(); ObjectName testObjectName = test.getObjectName(); Set domains = (Set) server.getAttribute(CLASSLOADER_SYSTEM_OBJECT_NAME, "Domains"); Set expectedObjectNames = makeSet(defaultDomainObjectName, testObjectName); assertEquals(expectedObjectNames, domains); server.unregisterMBean(CLASSLOADER_SYSTEM_OBJECT_NAME); assertFalse(server.isRegistered(CLASSLOADER_SYSTEM_OBJECT_NAME)); for (ObjectName domain : domains) assertFalse(server.isRegistered(domain)); } public void testClassLoaderDomainMBean() throws Exception { ClassLoaderSystem system = createClassLoaderSystemWithModifiedBootstrap(); MBeanServer server = MBeanServerFactory.newMBeanServer(); server.registerMBean(system, CLASSLOADER_SYSTEM_OBJECT_NAME); ClassLoaderDomain defaultDomain = system.getDefaultDomain(); ClassLoaderDomain domain = system.createAndRegisterDomain("test", ParentPolicy.AFTER_BUT_JAVA_BEFORE, defaultDomain); ObjectName testObjectName = domain.getObjectName(); assertEquals(CLASSLOADER_SYSTEM_OBJECT_NAME, server.getAttribute(testObjectName, "System")); assertEquals(domain.getName(), server.getAttribute(testObjectName, "Name")); assertEquals(ParentPolicy.AFTER_BUT_JAVA_BEFORE.toString(), server.getAttribute(testObjectName, "ParentPolicyName")); assertEquals(defaultDomain.getObjectName(), server.getAttribute(testObjectName, "ParentDomain")); assertEquals(defaultDomain.getName(), server.getAttribute(testObjectName, "ParentDomainName")); } public void testRegisterClassLoader() throws Exception { ClassLoaderSystem system = createClassLoaderSystemWithModifiedBootstrap(); MBeanServer server = MBeanServerFactory.newMBeanServer(); server.registerMBean(system, CLASSLOADER_SYSTEM_OBJECT_NAME); ClassLoaderDomain domain = system.createAndRegisterDomain("test"); MockClassLoaderPolicy policy = createMockClassLoaderPolicy("simple"); policy.setPathsAndPackageNames(Simple.class); RealClassLoader cl = (RealClassLoader) system.registerClassLoaderPolicy(domain.getName(), policy); assertTrue(server.isRegistered(cl.getObjectName())); system.unregisterClassLoader((ClassLoader) cl); assertFalse(server.isRegistered(cl.getObjectName())); } public void testLazyRegisterClassLoader() throws Exception { ClassLoaderSystem system = createClassLoaderSystemWithModifiedBootstrap(); MBeanServer server = MBeanServerFactory.newMBeanServer(); ClassLoaderDomain domain = system.createAndRegisterDomain("test"); MockClassLoaderPolicy policy = createMockClassLoaderPolicy("simple"); policy.setPathsAndPackageNames(Simple.class); RealClassLoader cl = (RealClassLoader) system.registerClassLoaderPolicy(domain.getName(), policy); server.registerMBean(system, CLASSLOADER_SYSTEM_OBJECT_NAME); assertTrue(server.isRegistered(cl.getObjectName())); } public void testUnregisterClassLoaderSystemUnregistersClassLoader() throws Exception { ClassLoaderSystem system = createClassLoaderSystemWithModifiedBootstrap(); MBeanServer server = MBeanServerFactory.newMBeanServer(); server.registerMBean(system, CLASSLOADER_SYSTEM_OBJECT_NAME); ClassLoaderDomain domain = system.createAndRegisterDomain("test"); MockClassLoaderPolicy policy = createMockClassLoaderPolicy("simple"); policy.setPathsAndPackageNames(Simple.class); RealClassLoader cl = (RealClassLoader) system.registerClassLoaderPolicy(domain.getName(), policy); assertTrue(server.isRegistered(cl.getObjectName())); server.unregisterMBean(CLASSLOADER_SYSTEM_OBJECT_NAME); assertFalse(server.isRegistered(cl.getObjectName())); } public void testUnregisterDomainUnregistersClassLoader() throws Exception { ClassLoaderSystem system = createClassLoaderSystemWithModifiedBootstrap(); MBeanServer server = MBeanServerFactory.newMBeanServer(); server.registerMBean(system, CLASSLOADER_SYSTEM_OBJECT_NAME); ClassLoaderDomain domain = system.createAndRegisterDomain("test"); MockClassLoaderPolicy policy = createMockClassLoaderPolicy("simple"); policy.setPathsAndPackageNames(Simple.class); RealClassLoader cl = (RealClassLoader) system.registerClassLoaderPolicy(domain.getName(), policy); assertTrue(server.isRegistered(cl.getObjectName())); system.unregisterDomain(domain); assertFalse(server.isRegistered(cl.getObjectName())); } @SuppressWarnings("unchecked") public void testClassLoaderDomainClassLoaders() throws Exception { ClassLoaderSystem system = createClassLoaderSystemWithModifiedBootstrap(); MBeanServer server = MBeanServerFactory.newMBeanServer(); server.registerMBean(system, CLASSLOADER_SYSTEM_OBJECT_NAME); ClassLoaderDomain defaultDomain = system.getDefaultDomain(); ClassLoaderDomain domain = system.createAndRegisterDomain("test", ParentPolicy.BEFORE_BUT_JAVA_ONLY, defaultDomain); MockClassLoaderPolicy a1 = createMockClassLoaderPolicy("a1"); a1.setPathsAndPackageNames(A.class); RealClassLoader clA1 = (RealClassLoader) system.registerClassLoaderPolicy(domain, a1); MockClassLoaderPolicy a2 = createMockClassLoaderPolicy("a2"); a2.setPathsAndPackageNames(A.class); RealClassLoader clA2 = (RealClassLoader) system.registerClassLoaderPolicy(domain, a2); MockClassLoaderPolicy b1 = createMockClassLoaderPolicy("b1"); b1.setPathsAndPackageNames(B.class); RealClassLoader clB1 = (RealClassLoader) system.registerClassLoaderPolicy(domain, b1); MockClassLoaderPolicy b2 = createMockClassLoaderPolicy("b2"); b2.setPaths(B.class); RealClassLoader clB2 = (RealClassLoader) system.registerClassLoaderPolicy(domain, b2); ObjectName testDomain = domain.getObjectName(); List classLoaders = (List) server.invoke(testDomain, "listClassLoaders", null, null); List expected = Arrays.asList(clA1.getObjectName(), clA2.getObjectName(), clB1.getObjectName(), clB2.getObjectName()); assertEquals(expected, classLoaders); Map> packageClassLoaders = (Map) server.invoke(testDomain, "listExportingClassLoaders", null, null); Map> expectedMap = new HashMap>(); expectedMap.put(A.class.getPackage().getName(), Arrays.asList(clA1.getObjectName(), clA2.getObjectName())); expectedMap.put(B.class.getPackage().getName(), Arrays.asList(clB1.getObjectName())); assertEquals(expectedMap, packageClassLoaders); classLoaders = (List) server.invoke(testDomain, "listExportingClassLoaders", new Object[] { A.class.getPackage().getName() }, new String[] { String.class.getName()}); expected = Arrays.asList(clA1.getObjectName(), clA2.getObjectName()); classLoaders = (List) server.invoke(testDomain, "listExportingClassLoaders", new Object[] { B.class.getPackage().getName() }, new String[] { String.class.getName()}); expected = Arrays.asList(clB1.getObjectName()); Class clazz = (Class) server.invoke(testDomain, "loadClass", new Object[] { A.class.getName() }, new String[] { String.class.getName() }); assertEquals(((ClassLoader) clA1).loadClass(A.class.getName()), clazz); ObjectName result = (ObjectName) server.invoke(testDomain, "findClassLoaderForClass", new Object[] { A.class.getName() }, new String[] { String.class.getName() }); assertEquals(clA1.getObjectName(), result); assertNull(server.invoke(testDomain, "findClassLoaderForClass", new Object[] { Object.class.getName() }, new String[] { String.class.getName() })); String resourceName = ClassLoaderUtils.classNameToPath(A.class.getName()); Set urls = (Set) server.invoke(testDomain, "loadResources", new Object[] { resourceName }, new String[] { String.class.getName()}); Set expectedURLs = makeSet(getClass().getClassLoader().getResource(resourceName)); assertEquals(expectedURLs, urls); } @SuppressWarnings("unchecked") public void testClassLoaderMBean() throws Exception { ClassLoaderSystem system = createClassLoaderSystemWithModifiedBootstrap(); MBeanServer server = MBeanServerFactory.newMBeanServer(); server.registerMBean(system, CLASSLOADER_SYSTEM_OBJECT_NAME); ClassLoaderDomain defaultDomain = system.getDefaultDomain(); ClassLoaderDomain domain = system.createAndRegisterDomain("test", ParentPolicy.BEFORE_BUT_JAVA_ONLY, defaultDomain); MockClassLoaderPolicy a = createMockClassLoaderPolicy("a"); a.setPathsAndPackageNames(A.class); RealClassLoader clA = (RealClassLoader) system.registerClassLoaderPolicy(domain.getName(), a); MockClassLoaderPolicy b = createMockClassLoaderPolicy("b"); b.setPathsAndPackageNames(B.class); RealClassLoader clB = (RealClassLoader) system.registerClassLoaderPolicy(domain.getName(), b); MockClassLoaderPolicy test = createMockClassLoaderPolicy("test"); test.setImportAll(true); test.setDelegates(Arrays.asList(a.getExported(), b.getExported())); test.setPathsAndPackageNames(A.class, B.class); RealClassLoader cl = (RealClassLoader) system.registerClassLoaderPolicy(domain, test); ObjectName testObjectName = cl.getObjectName(); assertEquals(domain.getObjectName(), server.getAttribute(testObjectName, "ClassLoaderDomain")); assertEquals("test", server.getAttribute(testObjectName, "Name")); assertTrue((Boolean) server.getAttribute(testObjectName, "ImportAll")); assertTrue((Boolean) server.getAttribute(testObjectName, "Valid")); Set expectedPackages = makeSet(A.class.getPackage().getName(), B.class.getPackage().getName()); assertEquals(expectedPackages, server.invoke(testObjectName, "listExportedPackages", null, null)); List expectedImports = Arrays.asList(clA.getObjectName(), clB.getObjectName()); assertEquals(expectedImports, server.invoke(testObjectName, "listImports", null, null)); assertEquals(test.toLongString(), server.invoke(testObjectName, "listPolicyDetails", null, null)); } @SuppressWarnings("unchecked") public void testClassLoader() throws Exception { ClassLoaderSystem system = createClassLoaderSystemWithModifiedBootstrap(); MBeanServer server = MBeanServerFactory.newMBeanServer(); server.registerMBean(system, CLASSLOADER_SYSTEM_OBJECT_NAME); system.getDefaultDomain().setParentPolicy(ParentPolicy.BEFORE_BUT_JAVA_ONLY); MockClassLoaderPolicy test = createMockClassLoaderPolicy("test"); test.setPathsAndPackageNames(A.class, B.class); RealClassLoader cl = (RealClassLoader) system.registerClassLoaderPolicy(test); ObjectName testObjectName = cl.getObjectName(); Set loadedClasses = (Set) server.invoke(testObjectName, "listLoadedClasses", null, null); assertFalse(loadedClasses.contains(A.class.getName())); Class expected = ((ClassLoader) cl).loadClass(A.class.getName()); assertEquals(expected, server.invoke(testObjectName, "loadClass", new Object[] { A.class.getName() }, new String[] { String.class.getName() })); loadedClasses = (Set) server.invoke(testObjectName, "listLoadedClasses", null, null); assertTrue(loadedClasses.contains(A.class.getName())); assertEquals(cl.getObjectName(), server.invoke(testObjectName, "findClassLoaderForClass", new Object[] { A.class.getName() }, new String[] { String.class.getName() })); assertNull(server.invoke(testObjectName, "findClassLoaderForClass", new Object[] { Object.class.getName() }, new String[] { String.class.getName() })); String resourceName = ClassLoaderUtils.classNameToPath(B.class.getName()); Set loadedResourceNames = (Set) server.invoke(testObjectName, "listLoadedResourceNames", null, null); assertFalse(loadedResourceNames.contains(resourceName)); Set expectedURLs = makeSet(((ClassLoader) cl).getResource(resourceName)); assertEquals(expectedURLs, server.invoke(testObjectName, "loadResources", new Object[] { resourceName }, new String[] { String.class.getName() })); loadedResourceNames = (Set) server.invoke(testObjectName, "listLoadedResourceNames", null, null); assertTrue(loadedResourceNames.contains(resourceName)); } protected static Set makeSet(T... values) { Set result = new HashSet(); Collections.addAll(result, values); return result; } } ././@LongLink0000000000000000000000000000016300000000000011565 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloader/src/test/java/org/jboss/test/classloader/jmx/JMXTestSuite.javalibjboss-classloader-java-2.0.6.GA.orig/classloader/src/test/java/org/jboss/test/classloader/jmx/JMX0000644000175000017500000000345410624241712033253 0ustar twernertwerner/* * JBoss, Home of Professional Open Source. * Copyright 2007, Red Hat Middleware LLC, and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.test.classloader.jmx; import junit.framework.Test; import junit.framework.TestSuite; import junit.textui.TestRunner; import org.jboss.test.classloader.jmx.test.JMXUnitTestCase; /** * JMX Test Suite. * * @author Adrian Brock * @version $Revision: 37459 $ */ public class JMXTestSuite extends TestSuite { /** * For running the testsuite from the command line * * @param args the command line args */ public static void main(String[] args) { TestRunner.run(suite()); } /** * Create the testsuite * * @return the testsuite */ public static Test suite() { TestSuite suite = new TestSuite("JMX Tests"); suite.addTest(JMXUnitTestCase.suite()); return suite; } } ././@LongLink0000000000000000000000000000015200000000000011563 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloader/src/test/java/org/jboss/test/classloader/jmx/support/libjboss-classloader-java-2.0.6.GA.orig/classloader/src/test/java/org/jboss/test/classloader/jmx/sup0000755000175000017500000000000011620043422033407 5ustar twernertwerner././@LongLink0000000000000000000000000000016500000000000011567 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloader/src/test/java/org/jboss/test/classloader/jmx/support/Simple.javalibjboss-classloader-java-2.0.6.GA.orig/classloader/src/test/java/org/jboss/test/classloader/jmx/sup0000644000175000017500000000245610624241712033425 0ustar twernertwerner/* * JBoss, Home of Professional Open Source. * Copyright 2007, Red Hat Middleware LLC, and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.test.classloader.jmx.support; /** * Simple. * * @author Adrian Brock * @version $Revision: 1.1 $ */ public class Simple implements SimpleMBean { public ClassLoader getClassLoader() { return getClass().getClassLoader(); } } ././@LongLink0000000000000000000000000000015400000000000011565 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloader/src/test/java/org/jboss/test/classloader/jmx/support/a/libjboss-classloader-java-2.0.6.GA.orig/classloader/src/test/java/org/jboss/test/classloader/jmx/sup0000755000175000017500000000000011620043422033407 5ustar twernertwerner././@LongLink0000000000000000000000000000016200000000000011564 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloader/src/test/java/org/jboss/test/classloader/jmx/support/a/A.javalibjboss-classloader-java-2.0.6.GA.orig/classloader/src/test/java/org/jboss/test/classloader/jmx/sup0000644000175000017500000000221710760647753033440 0ustar twernertwerner/* * JBoss, Home of Professional Open Source * Copyright 2007, JBoss Inc., and individual contributors as indicated * by the @authors tag. See the copyright.txt in the distribution for a * full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.test.classloader.jmx.support.a; /** * A. * * @author Adrian Brock * @version $Revision: 1.1 $ */ public class A { } ././@LongLink0000000000000000000000000000015400000000000011565 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloader/src/test/java/org/jboss/test/classloader/jmx/support/b/libjboss-classloader-java-2.0.6.GA.orig/classloader/src/test/java/org/jboss/test/classloader/jmx/sup0000755000175000017500000000000011620043422033407 5ustar twernertwerner././@LongLink0000000000000000000000000000016200000000000011564 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloader/src/test/java/org/jboss/test/classloader/jmx/support/b/B.javalibjboss-classloader-java-2.0.6.GA.orig/classloader/src/test/java/org/jboss/test/classloader/jmx/sup0000644000175000017500000000221710760647753033440 0ustar twernertwerner/* * JBoss, Home of Professional Open Source * Copyright 2007, JBoss Inc., and individual contributors as indicated * by the @authors tag. See the copyright.txt in the distribution for a * full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.test.classloader.jmx.support.b; /** * B. * * @author Adrian Brock * @version $Revision: 1.1 $ */ public class B { } ././@LongLink0000000000000000000000000000017200000000000011565 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloader/src/test/java/org/jboss/test/classloader/jmx/support/SimpleMBean.javalibjboss-classloader-java-2.0.6.GA.orig/classloader/src/test/java/org/jboss/test/classloader/jmx/sup0000644000175000017500000000235310624241712033421 0ustar twernertwerner/* * JBoss, Home of Professional Open Source. * Copyright 2007, Red Hat Middleware LLC, and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.test.classloader.jmx.support; /** * SimpleMBean. * * @author Adrian Brock * @version $Revision: 1.1 $ */ public interface SimpleMBean { ClassLoader getClassLoader(); } ././@LongLink0000000000000000000000000000014500000000000011565 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloader/src/test/java/org/jboss/test/classloader/system/libjboss-classloader-java-2.0.6.GA.orig/classloader/src/test/java/org/jboss/test/classloader/system/0000755000175000017500000000000011620043421033404 5ustar twernertwerner././@LongLink0000000000000000000000000000015200000000000011563 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloader/src/test/java/org/jboss/test/classloader/system/test/libjboss-classloader-java-2.0.6.GA.orig/classloader/src/test/java/org/jboss/test/classloader/system/0000755000175000017500000000000011620043421033404 5ustar twernertwerner././@LongLink0000000000000000000000000000022600000000000011565 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloader/src/test/java/org/jboss/test/classloader/system/test/ClassLoaderSystemNoSecurityUnitTestCase.javalibjboss-classloader-java-2.0.6.GA.orig/classloader/src/test/java/org/jboss/test/classloader/system/0000644000175000017500000001142310616435067033426 0ustar twernertwerner/* * JBoss, Home of Professional Open Source. * Copyright 2007, Red Hat Middleware LLC, and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.test.classloader.system.test; import java.net.URL; import java.net.URLClassLoader; import junit.framework.Test; import org.jboss.classloader.spi.ClassLoaderSystem; import org.jboss.test.classloader.AbstractClassLoaderTest; import org.jboss.test.classloader.system.support.MockClassLoaderDomain; import org.jboss.test.classloader.system.support.MockClassLoaderSystem; import org.jboss.test.classloader.system.support.SimpleMockClassLoaderPolicy; /** * ClassLoaderSystemUnitTestCase. * * @author Adrian Brock * @version $Revision: 1.1 $ */ public class ClassLoaderSystemNoSecurityUnitTestCase extends AbstractClassLoaderTest { public static Test suite() { return suite(ClassLoaderSystemNoSecurityUnitTestCase.class); } public ClassLoaderSystemNoSecurityUnitTestCase(String name) { super(name); } public void testGetInstance() throws Exception { ClassLoaderSystem instance = ClassLoaderSystem.getInstance(); assertNotNull(instance); ClassLoaderSystem instance2 = ClassLoaderSystem.getInstance(); assertTrue("Should be the same instance", instance == instance2); } public void testClassLoaderPolicyShutdownFromClassLoaderSystemShutdown() throws Exception { MockClassLoaderSystem system = createMockClassLoaderSystem(); SimpleMockClassLoaderPolicy policy = new SimpleMockClassLoaderPolicy(); MockClassLoaderDomain domain = system.createAndRegisterDomain("mock"); system.registerClassLoaderPolicy(domain, policy); assertFalse(policy.shutdown); system.shutdown(); assertTrue("Policy should be shutdown", policy.shutdown); } public void testClassLoaderPolicyShutdownFromClassLoaderDomainUnregister() throws Exception { MockClassLoaderSystem system = createMockClassLoaderSystem(); SimpleMockClassLoaderPolicy policy = new SimpleMockClassLoaderPolicy(); MockClassLoaderDomain domain = system.createAndRegisterDomain("mock"); system.registerClassLoaderPolicy(domain, policy); assertFalse(policy.shutdown); system.unregisterDomain(domain); assertTrue("Policy should be shutdown", policy.shutdown); } public void testClassLoaderPolicyShutdownFromClassLoaderPolicyUnregister() throws Exception { MockClassLoaderSystem system = createMockClassLoaderSystem(); SimpleMockClassLoaderPolicy policy = new SimpleMockClassLoaderPolicy(); MockClassLoaderDomain domain = system.createAndRegisterDomain("mock"); system.registerClassLoaderPolicy(domain, policy); assertFalse(policy.shutdown); system.unregisterClassLoaderPolicy(policy); assertTrue("Policy should be shutdown", policy.shutdown); } public void testClassLoaderPolicyShutdownFromClassLoaderUnregister() throws Exception { MockClassLoaderSystem system = createMockClassLoaderSystem(); SimpleMockClassLoaderPolicy policy = new SimpleMockClassLoaderPolicy(); MockClassLoaderDomain domain = system.createAndRegisterDomain("mock"); ClassLoader cl = system.registerClassLoaderPolicy(domain, policy); assertFalse(policy.shutdown); system.unregisterClassLoader(cl); assertTrue("Policy should be shutdown", policy.shutdown); } public void testUnregisterClassLoaderNotRegistered() throws Exception { MockClassLoaderSystem system = createMockClassLoaderSystem(); ClassLoader cl = new URLClassLoader(new URL[0]); try { system.unregisterClassLoader(cl); fail("Should not be here!"); } catch (Exception e) { checkThrowable(IllegalStateException.class, e); } } protected MockClassLoaderSystem createMockClassLoaderSystem() { return new MockClassLoaderSystem(); } } ././@LongLink0000000000000000000000000000021400000000000011562 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloader/src/test/java/org/jboss/test/classloader/system/test/ClassLoaderSystemUnitTestCase.javalibjboss-classloader-java-2.0.6.GA.orig/classloader/src/test/java/org/jboss/test/classloader/system/0000644000175000017500000006172610755316116033436 0ustar twernertwerner/* * JBoss, Home of Professional Open Source. * Copyright 2007, Red Hat Middleware LLC, and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.test.classloader.system.test; import java.security.AccessControlException; import java.util.ArrayList; import java.util.List; import junit.framework.Test; import org.jboss.classloader.spi.ClassLoaderDomain; import org.jboss.classloader.spi.ClassLoaderSystem; import org.jboss.classloader.spi.ParentPolicy; import org.jboss.classloader.test.support.MockClassLoaderHelper; import org.jboss.classloader.test.support.MockClassLoaderPolicy; import org.jboss.test.classloader.AbstractClassLoaderTestWithSecurity; import org.jboss.test.classloader.system.support.MockClassLoaderDomain; import org.jboss.test.classloader.system.support.MockClassLoaderSystem; /** * ClassLoaderSystemUnitTestCase. * * @author Adrian Brock * @version $Revision: 1.1 $ */ public class ClassLoaderSystemUnitTestCase extends AbstractClassLoaderTestWithSecurity { public static Test suite() { return suite(ClassLoaderSystemUnitTestCase.class); } public ClassLoaderSystemUnitTestCase(String name) { super(name); } public void testGetInstance() throws Exception { try { ClassLoaderSystem.getInstance(); fail("Should not be here!"); } catch (Exception e) { checkThrowable(AccessControlException.class, e); } } public void testDefaultDomain() throws Exception { ClassLoaderSystem system = createClassLoaderSystem(); assertTrue(system.isRegistered(ClassLoaderSystem.DEFAULT_DOMAIN_NAME)); ClassLoaderDomain domain = system.getDefaultDomain(); assertNotNull(domain); assertEquals(ClassLoaderSystem.DEFAULT_DOMAIN_NAME, domain.getName()); assertTrue(system.isRegistered(ClassLoaderSystem.DEFAULT_DOMAIN_NAME)); assertTrue(system.isDomainRegistered(domain)); } public void testRegisterDomain() throws Exception { ClassLoaderSystem system = createClassLoaderSystem(); assertFalse(system.isRegistered("mock")); MockClassLoaderDomain domain = new MockClassLoaderDomain("mock"); assertFalse(system.isDomainRegistered(domain)); system.registerDomain(domain); assertTrue(system.isRegistered("mock")); assertTrue(system.isDomainRegistered(domain)); } public void testRegisterDomains() throws Exception { ClassLoaderSystem system = createClassLoaderSystem(); assertFalse(system.isRegistered("a")); MockClassLoaderDomain a = new MockClassLoaderDomain("a"); assertFalse(system.isDomainRegistered(a)); assertFalse(system.isRegistered("b")); MockClassLoaderDomain b = new MockClassLoaderDomain("b"); assertFalse(system.isDomainRegistered(a)); system.registerDomain(a); system.registerDomain(b); assertTrue(system.isRegistered("a")); assertTrue(system.isDomainRegistered(a)); assertTrue(system.isRegistered("b")); assertTrue(system.isDomainRegistered(b)); } public void testRegisterNullDomain() throws Exception { ClassLoaderSystem system = createClassLoaderSystem(); try { system.registerDomain(null); fail("Should not be here!"); } catch (Exception e) { checkThrowable(IllegalArgumentException.class, e); } } public void testRegisterDefaultDomain() throws Exception { ClassLoaderSystem system = createClassLoaderSystem(); MockClassLoaderDomain domain = new MockClassLoaderDomain(ClassLoaderSystem.DEFAULT_DOMAIN_NAME); try { system.registerDomain(domain); fail("Should not be here!"); } catch (Exception e) { checkThrowable(IllegalStateException.class, e); } } public void testRegisterDuplicateDomain() throws Exception { ClassLoaderSystem system = createClassLoaderSystem(); assertFalse(system.isRegistered("a")); MockClassLoaderDomain a = new MockClassLoaderDomain("a"); assertFalse(system.isDomainRegistered(a)); system.registerDomain(a); assertTrue(system.isRegistered("a")); assertTrue(system.isDomainRegistered(a)); try { system.registerDomain(a); fail("Should not be here!"); } catch (Exception e) { checkThrowable(IllegalStateException.class, e); } } public void testRegisterDuplicateDomainName() throws Exception { ClassLoaderSystem system = createClassLoaderSystem(); assertFalse(system.isRegistered("a")); MockClassLoaderDomain a = new MockClassLoaderDomain("a"); assertFalse(system.isDomainRegistered(a)); MockClassLoaderDomain b = new MockClassLoaderDomain("a"); system.registerDomain(a); assertTrue(system.isRegistered("a")); assertTrue(system.isDomainRegistered(a)); try { system.registerDomain(b); fail("Should not be here!"); } catch (Exception e) { checkThrowable(IllegalStateException.class, e); } } public void testUnregisterDomain() throws Exception { ClassLoaderSystem system = createClassLoaderSystem(); MockClassLoaderDomain domain = new MockClassLoaderDomain("mock"); system.registerDomain(domain); assertTrue(system.isRegistered("mock")); assertTrue(system.isDomainRegistered(domain)); system.unregisterDomain(domain); assertFalse(system.isRegistered("mock")); assertFalse(system.isDomainRegistered(domain)); } public void testUnregisterWrongDomain() throws Exception { ClassLoaderSystem system = createClassLoaderSystem(); MockClassLoaderDomain domain = new MockClassLoaderDomain("mock"); system.registerDomain(domain); assertTrue(system.isRegistered("mock")); assertTrue(system.isDomainRegistered(domain)); MockClassLoaderDomain notDomain = new MockClassLoaderDomain("mock"); try { system.unregisterDomain(notDomain); fail("Should not be here!"); } catch (Exception e) { checkThrowable(IllegalStateException.class, e); } assertTrue(system.isRegistered("mock")); assertTrue(system.isDomainRegistered(domain)); } public void testUnregisterDefaultDomain() throws Exception { ClassLoaderSystem system = createClassLoaderSystem(); ClassLoaderDomain domain = system.getDefaultDomain(); try { system.unregisterDomain(domain); fail("Should not be here!"); } catch (Exception e) { checkThrowable(IllegalArgumentException.class, e); } assertTrue(system.isRegistered(ClassLoaderSystem.DEFAULT_DOMAIN_NAME)); assertTrue(system.isDomainRegistered(domain)); } public void testUnregisterNullDomain() throws Exception { ClassLoaderSystem system = createClassLoaderSystem(); try { system.unregisterDomain(null); fail("Should not be here!"); } catch (Exception e) { checkThrowable(IllegalArgumentException.class, e); } } public void testUnregisterUnregisteredDomain() throws Exception { ClassLoaderSystem system = createClassLoaderSystem(); ClassLoaderDomain domain = system.createAndRegisterDomain("test"); system.unregisterDomain(domain); try { system.unregisterDomain(domain); fail("Should not be here!"); } catch (Exception e) { checkThrowable(IllegalStateException.class, e); } } public void testDomainShutdownFromClassLoaderSystemShutdown() throws Exception { ClassLoaderSystem system = createMockClassLoaderSystem(); MockClassLoaderDomain domain = new MockClassLoaderDomain(); system.registerDomain(domain); assertFalse(domain.shutdown); system.shutdown(); assertTrue("Domain should be shutdown", domain.shutdown); } public void testDomainShutdownFromUnregister() throws Exception { ClassLoaderSystem system = createMockClassLoaderSystem(); MockClassLoaderDomain domain = new MockClassLoaderDomain(); system.registerDomain(domain); assertFalse(domain.shutdown); system.unregisterDomain(domain); assertTrue("Domain should be shutdown", domain.shutdown); } public void testRegisterClassLoaderDefaultDomain() throws Exception { MockClassLoaderSystem system = createMockClassLoaderSystem(); MockClassLoaderDomain domain = (MockClassLoaderDomain) system.getDefaultDomain(); ClassLoader cl1 = createAndRegisterMockClassLoader(system); List expected = new ArrayList(); expected.add(cl1); assertEquals(expected, domain.added); assertEmpty(domain.removed); ClassLoader cl2 = createAndRegisterMockClassLoader(system, domain); expected.add(cl2); assertEquals(expected, domain.added); assertEmpty(domain.removed); } public void testRegisterClassLoaderExplicitDomain() throws Exception { MockClassLoaderSystem system = createMockClassLoaderSystem(); MockClassLoaderDomain domain = system.createAndRegisterDomain("mock"); ClassLoader cl1 = createAndRegisterMockClassLoader(system, domain); List expected = new ArrayList(); expected.add(cl1); assertEquals(expected, domain.added); assertEmpty(domain.removed); ClassLoader cl2 = createAndRegisterMockClassLoader(system, domain); expected.add(cl2); assertEquals(expected, domain.added); assertEmpty(domain.removed); } public void testRegisterClassLoaderConstructDomain() throws Exception { MockClassLoaderSystem system = createMockClassLoaderSystem(); ClassLoader cl1 = createAndRegisterMockClassLoader(system, "test", "mock"); MockClassLoaderDomain domain = (MockClassLoaderDomain) system.getDomain("test"); assertEquals(ParentPolicy.BEFORE, domain.getParentPolicy()); assertFalse(domain.getParent() instanceof ClassLoaderDomain); List expected = new ArrayList(); expected.add(cl1); assertEquals(expected, domain.added); assertEmpty(domain.removed); } public void testRegisterClassLoaderConstructDomainWithoutParentDomain() throws Exception { MockClassLoaderSystem system = createMockClassLoaderSystem(); ClassLoader cl1 = createAndRegisterMockClassLoader(system, "test", ParentPolicy.AFTER, "mock"); MockClassLoaderDomain domain = (MockClassLoaderDomain) system.getDomain("test"); assertEquals(ParentPolicy.AFTER, domain.getParentPolicy()); assertFalse(domain.getParent() instanceof ClassLoaderDomain); List expected = new ArrayList(); expected.add(cl1); assertEquals(expected, domain.added); assertEmpty(domain.removed); } public void testRegisterClassLoaderConstructDomainWithParentDomain() throws Exception { MockClassLoaderSystem system = createMockClassLoaderSystem(); ClassLoader cl1 = createAndRegisterMockClassLoader(system, "test", ParentPolicy.AFTER, ClassLoaderSystem.DEFAULT_DOMAIN_NAME, "mock"); MockClassLoaderDomain domain = (MockClassLoaderDomain) system.getDomain("test"); MockClassLoaderDomain parent = (MockClassLoaderDomain) system.getDomain(ClassLoaderSystem.DEFAULT_DOMAIN_NAME); assertEquals(ParentPolicy.AFTER, domain.getParentPolicy()); assertEquals(parent, domain.getParent()); List expected = new ArrayList(); expected.add(cl1); assertEquals(expected, domain.added); assertEmpty(domain.removed); } public void testRegisterClassLoaderConstructDomainWithParentDomainAlreadyExists() throws Exception { MockClassLoaderSystem system = createMockClassLoaderSystem(); MockClassLoaderDomain domain = new MockClassLoaderDomain("test"); system.registerDomain(domain); ClassLoader cl1 = createAndRegisterMockClassLoader(system, "test", ParentPolicy.AFTER, ClassLoaderSystem.DEFAULT_DOMAIN_NAME, "mock"); List expected = new ArrayList(); expected.add(cl1); assertEquals(expected, domain.added); assertEmpty(domain.removed); } public void testRegisterClassLoaderConstructDomainWithParentPolicyAlreadyExists() throws Exception { MockClassLoaderSystem system = createMockClassLoaderSystem(); MockClassLoaderDomain domain = new MockClassLoaderDomain("test"); system.registerDomain(domain); ClassLoader cl1 = createAndRegisterMockClassLoader(system, "test", ParentPolicy.AFTER, "mock"); List expected = new ArrayList(); expected.add(cl1); assertEquals(expected, domain.added); assertEmpty(domain.removed); } public void testRegisterClassLoaderConstructDomainAlreadyExists() throws Exception { MockClassLoaderSystem system = createMockClassLoaderSystem(); MockClassLoaderDomain domain = new MockClassLoaderDomain("test"); system.registerDomain(domain); ClassLoader cl1 = createAndRegisterMockClassLoader(system, "test", "mock"); List expected = new ArrayList(); expected.add(cl1); assertEquals(expected, domain.added); assertEmpty(domain.removed); } public void testRegisterNullClassLoaderPolicyDefaultDomain() { MockClassLoaderSystem system = createMockClassLoaderSystem(); try { system.registerClassLoaderPolicy(null); fail("Should not be here!"); } catch (Exception e) { checkThrowable(IllegalArgumentException.class, e); } } public void testRegisterNullClassLoaderPolicyExplicitDomain() { MockClassLoaderSystem system = createMockClassLoaderSystem(); MockClassLoaderDomain domain = new MockClassLoaderDomain(); system.registerDomain(domain); try { system.registerClassLoaderPolicy(domain, null); fail("Should not be here!"); } catch (Exception e) { checkThrowable(IllegalArgumentException.class, e); } } public void testRegisterClassLoaderPolicyNullDomain() { MockClassLoaderSystem system = createMockClassLoaderSystem(); MockClassLoaderPolicy policy = createMockClassLoaderPolicy(); try { system.registerClassLoaderPolicy((ClassLoaderDomain) null, policy); fail("Should not be here!"); } catch (Exception e) { checkThrowable(IllegalArgumentException.class, e); } } public void testRegisterClassLoaderPolicyWithNotRegisteredDomain() { MockClassLoaderSystem system = createMockClassLoaderSystem(); MockClassLoaderDomain domain = new MockClassLoaderDomain(); MockClassLoaderPolicy policy = createMockClassLoaderPolicy(); try { system.registerClassLoaderPolicy(domain, policy); fail("Should not be here!"); } catch (Exception e) { checkThrowable(IllegalStateException.class, e); } } public void testRegisterClassLoaderPolicyWithUnregisteredDomain() { MockClassLoaderSystem system = createMockClassLoaderSystem(); MockClassLoaderDomain domain = new MockClassLoaderDomain(); MockClassLoaderPolicy policy = createMockClassLoaderPolicy(); system.registerDomain(domain); system.unregisterDomain(domain); try { system.registerClassLoaderPolicy(domain, policy); fail("Should not be here!"); } catch (Exception e) { checkThrowable(IllegalStateException.class, e); } } public void testRegisterClassLoaderPolicyTwiceDefaultDomain() { MockClassLoaderSystem system = createMockClassLoaderSystem(); MockClassLoaderPolicy policy = createMockClassLoaderPolicy(); system.registerClassLoaderPolicy(policy); try { system.registerClassLoaderPolicy(policy); fail("Should not be here!"); } catch (Exception e) { checkThrowable(IllegalStateException.class, e); } } public void testRegisterClassLoaderPolicyTwiceExplicitDomain() { MockClassLoaderSystem system = createMockClassLoaderSystem(); MockClassLoaderDomain domain = new MockClassLoaderDomain(); MockClassLoaderPolicy policy = createMockClassLoaderPolicy(); system.registerDomain(domain); system.registerClassLoaderPolicy(domain, policy); try { system.registerClassLoaderPolicy(domain, policy); fail("Should not be here!"); } catch (Exception e) { checkThrowable(IllegalStateException.class, e); } } public void testRegisterClassLoaderPolicyTwiceDifferentDomains() { MockClassLoaderSystem system = createMockClassLoaderSystem(); MockClassLoaderDomain domain1 = new MockClassLoaderDomain("domain1"); MockClassLoaderDomain domain2 = new MockClassLoaderDomain("domain2"); MockClassLoaderPolicy policy = createMockClassLoaderPolicy(); system.registerDomain(domain1); system.registerDomain(domain2); system.registerClassLoaderPolicy(domain1, policy); try { system.registerClassLoaderPolicy(domain2, policy); fail("Should not be here!"); } catch (Exception e) { checkThrowable(IllegalStateException.class, e); } } public void testRegisterClassLoaderPolicyAndConstructDomainNoParentDomain() { MockClassLoaderSystem system = createMockClassLoaderSystem(); MockClassLoaderPolicy policy = createMockClassLoaderPolicy(); try { system.registerClassLoaderPolicy("test", ParentPolicy.BEFORE, "DOESNOTEXIST", policy); fail("Should not be here!"); } catch (Exception e) { checkThrowable(IllegalStateException.class, e); } assertFalse(system.isRegistered("test")); } public void testRegisterClassLoaderPolicyAndConstructDomainNoParentPolicy() { MockClassLoaderSystem system = createMockClassLoaderSystem(); MockClassLoaderPolicy policy = createMockClassLoaderPolicy(); try { system.registerClassLoaderPolicy("test", null, ClassLoaderSystem.DEFAULT_DOMAIN_NAME, policy); fail("Should not be here!"); } catch (Exception e) { checkThrowable(IllegalArgumentException.class, e); } try { system.registerClassLoaderPolicy("test", null, policy); fail("Should not be here!"); } catch (Exception e) { checkThrowable(IllegalArgumentException.class, e); } assertFalse(system.isRegistered("test")); } public void testRegisterClassLoaderPolicyAndConstructDomainNoDomainName() { MockClassLoaderSystem system = createMockClassLoaderSystem(); MockClassLoaderPolicy policy = createMockClassLoaderPolicy(); try { system.registerClassLoaderPolicy(null, ParentPolicy.BEFORE, ClassLoaderSystem.DEFAULT_DOMAIN_NAME, policy); fail("Should not be here!"); } catch (Exception e) { checkThrowable(IllegalArgumentException.class, e); } try { system.registerClassLoaderPolicy(null, ParentPolicy.BEFORE, policy); fail("Should not be here!"); } catch (Exception e) { checkThrowable(IllegalArgumentException.class, e); } try { system.registerClassLoaderPolicy((String) null, policy); fail("Should not be here!"); } catch (Exception e) { checkThrowable(IllegalArgumentException.class, e); } } public void testUnregisterClassLoaderDefaultDomain() throws Exception { MockClassLoaderSystem system = createMockClassLoaderSystem(); MockClassLoaderDomain domain = (MockClassLoaderDomain) system.getDefaultDomain(); ClassLoader cl1 = createAndRegisterMockClassLoader(system); List expected = new ArrayList(); expected.add(cl1); assertEquals(expected, domain.added); assertEmpty(domain.removed); system.unregisterClassLoader(cl1); assertEquals(expected, domain.added); assertEquals(expected, domain.removed); } public void testUnregisterClassLoaderExplicitDomain() throws Exception { MockClassLoaderSystem system = createMockClassLoaderSystem(); MockClassLoaderDomain domain = system.createAndRegisterDomain("mock"); ClassLoader cl1 = createAndRegisterMockClassLoader(system, domain); List expected = new ArrayList(); expected.add(cl1); assertEquals(expected, domain.added); assertEmpty(domain.removed); system.unregisterClassLoader(cl1); assertEquals(expected, domain.added); assertEquals(expected, domain.removed); } public void testUnregisterClassLoaderPolicyExplicitDomain() throws Exception { MockClassLoaderSystem system = createMockClassLoaderSystem(); MockClassLoaderPolicy policy = createMockClassLoaderPolicy(); MockClassLoaderDomain domain = system.createAndRegisterDomain("mock"); ClassLoader cl1 = MockClassLoaderHelper.registerMockClassLoader(system, domain, policy); List expected = new ArrayList(); expected.add(cl1); assertEquals(expected, domain.added); assertEmpty(domain.removed); system.unregisterClassLoaderPolicy(policy); assertEquals(expected, domain.added); assertEquals(expected, domain.removed); } public void testUnregisterNullClassLoader() throws Exception { MockClassLoaderSystem system = createMockClassLoaderSystem(); try { system.unregisterClassLoader(null); fail("Should not be here!"); } catch (Exception e) { checkThrowable(IllegalArgumentException.class, e); } } public void testUnregisterNullClassLoaderPolicy() throws Exception { MockClassLoaderSystem system = createMockClassLoaderSystem(); try { system.unregisterClassLoaderPolicy(null); fail("Should not be here!"); } catch (Exception e) { checkThrowable(IllegalArgumentException.class, e); } } public void testUnregisterClassLoaderUnregistered() throws Exception { MockClassLoaderSystem system = createMockClassLoaderSystem(); MockClassLoaderPolicy policy = createMockClassLoaderPolicy(); ClassLoader cl = system.registerClassLoaderPolicy(policy); system.unregisterClassLoaderPolicy(policy); try { system.unregisterClassLoader(cl); fail("Should not be here!"); } catch (Exception e) { checkThrowable(IllegalStateException.class, e); } } public void testUnregisterClassLoaderPolicyNotRegistered() throws Exception { MockClassLoaderSystem system = createMockClassLoaderSystem(); MockClassLoaderPolicy policy = createMockClassLoaderPolicy(); try { system.unregisterClassLoaderPolicy(policy); fail("Should not be here!"); } catch (Exception e) { checkThrowable(IllegalStateException.class, e); } } public void testUnregisterClassLoaderPolicyUnregistered() throws Exception { MockClassLoaderSystem system = createMockClassLoaderSystem(); MockClassLoaderPolicy policy = createMockClassLoaderPolicy(); system.registerClassLoaderPolicy(policy); system.unregisterClassLoaderPolicy(policy); try { system.unregisterClassLoaderPolicy(policy); fail("Should not be here!"); } catch (Exception e) { checkThrowable(IllegalStateException.class, e); } } protected MockClassLoaderSystem createMockClassLoaderSystem() { return new MockClassLoaderSystem(); } } ././@LongLink0000000000000000000000000000020400000000000011561 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloader/src/test/java/org/jboss/test/classloader/system/ClassLoaderSystemTestSuite.javalibjboss-classloader-java-2.0.6.GA.orig/classloader/src/test/java/org/jboss/test/classloader/system/0000644000175000017500000000402610616435067033427 0ustar twernertwerner/* * JBoss, Home of Professional Open Source. * Copyright 2007, Red Hat Middleware LLC, and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.test.classloader.system; import org.jboss.test.classloader.system.test.ClassLoaderSystemNoSecurityUnitTestCase; import org.jboss.test.classloader.system.test.ClassLoaderSystemUnitTestCase; import junit.framework.Test; import junit.framework.TestSuite; import junit.textui.TestRunner; /** * ClassLoaderSystem Test Suite. * * @author Adrian Brock * @version $Revision: 37459 $ */ public class ClassLoaderSystemTestSuite extends TestSuite { /** * For running the testsuite from the command line * * @param args the command line args */ public static void main(String[] args) { TestRunner.run(suite()); } /** * Create the testsuite * * @return the testsuite */ public static Test suite() { TestSuite suite = new TestSuite("ClassLoader System Tests"); suite.addTest(ClassLoaderSystemNoSecurityUnitTestCase.suite()); suite.addTest(ClassLoaderSystemUnitTestCase.suite()); return suite; } } ././@LongLink0000000000000000000000000000015500000000000011566 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloader/src/test/java/org/jboss/test/classloader/system/support/libjboss-classloader-java-2.0.6.GA.orig/classloader/src/test/java/org/jboss/test/classloader/system/0000755000175000017500000000000011620043421033404 5ustar twernertwerner././@LongLink0000000000000000000000000000021500000000000011563 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloader/src/test/java/org/jboss/test/classloader/system/support/SimpleMockClassLoaderPolicy.javalibjboss-classloader-java-2.0.6.GA.orig/classloader/src/test/java/org/jboss/test/classloader/system/0000644000175000017500000000325710616435067033434 0ustar twernertwerner/* * JBoss, Home of Professional Open Source. * Copyright 2007, Red Hat Middleware LLC, and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.test.classloader.system.support; import java.io.IOException; import java.net.URL; import java.util.Set; import org.jboss.classloader.spi.ClassLoaderPolicy; /** * SimpleMockClassLoaderPolicy. * * @author Adrian Brock * @version $Revision: 1.1 $ */ public class SimpleMockClassLoaderPolicy extends ClassLoaderPolicy { public boolean shutdown = false; public URL getResource(String path) { return null; } public void getResources(String name, Set urls) throws IOException { } protected synchronized void shutdownPolicy() { shutdown = true; super.shutdownPolicy(); } } ././@LongLink0000000000000000000000000000020700000000000011564 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloader/src/test/java/org/jboss/test/classloader/system/support/MockClassLoaderDomain.javalibjboss-classloader-java-2.0.6.GA.orig/classloader/src/test/java/org/jboss/test/classloader/system/0000644000175000017500000000416510616435067033433 0ustar twernertwerner/* * JBoss, Home of Professional Open Source. * Copyright 2007, Red Hat Middleware LLC, and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.test.classloader.system.support; import java.util.List; import java.util.concurrent.CopyOnWriteArrayList; import org.jboss.classloader.spi.ClassLoaderDomain; import org.jboss.classloader.spi.ClassLoaderPolicy; /** * MockClassLoaderDomain. * * @author Adrian Brock * @version $Revision: 1.1 $ */ public class MockClassLoaderDomain extends ClassLoaderDomain { public List added = new CopyOnWriteArrayList(); public List removed = new CopyOnWriteArrayList(); public boolean shutdown = false; public MockClassLoaderDomain() { super("mock"); } public MockClassLoaderDomain(String name) { super(name); } protected void afterRegisterClassLoader(ClassLoader classLoader, ClassLoaderPolicy policy) { added.add(classLoader); } protected void afterUnregisterClassLoader(ClassLoader classLoader, ClassLoaderPolicy policy) { removed.add(classLoader); } protected void shutdownDomain() { shutdown = true; super.shutdownDomain(); } } ././@LongLink0000000000000000000000000000020700000000000011564 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloader/src/test/java/org/jboss/test/classloader/system/support/MockClassLoaderSystem.javalibjboss-classloader-java-2.0.6.GA.orig/classloader/src/test/java/org/jboss/test/classloader/system/0000644000175000017500000000317010616073100033410 0ustar twernertwerner/* * JBoss, Home of Professional Open Source. * Copyright 2007, Red Hat Middleware LLC, and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.test.classloader.system.support; import org.jboss.classloader.spi.ClassLoaderDomain; import org.jboss.classloader.spi.ClassLoaderSystem; /** * MockClassLoaderSystem. * * @author Adrian Brock * @version $Revision: 1.1 $ */ public class MockClassLoaderSystem extends ClassLoaderSystem { @Override protected ClassLoaderDomain createDomain(String name) { return new MockClassLoaderDomain(name); } public MockClassLoaderDomain createAndRegisterDomain(String name) { return (MockClassLoaderDomain) super.createAndRegisterDomain(name); } } ././@LongLink0000000000000000000000000000015000000000000011561 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloader/src/test/java/org/jboss/test/classloader/resources/libjboss-classloader-java-2.0.6.GA.orig/classloader/src/test/java/org/jboss/test/classloader/resourc0000755000175000017500000000000011620043421033463 5ustar twernertwerner././@LongLink0000000000000000000000000000015600000000000011567 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloader/src/test/java/org/jboss/test/classloader/resources/tests/libjboss-classloader-java-2.0.6.GA.orig/classloader/src/test/java/org/jboss/test/classloader/resourc0000755000175000017500000000000011620043421033463 5ustar twernertwerner././@LongLink0000000000000000000000000000020700000000000011564 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloader/src/test/java/org/jboss/test/classloader/resources/tests/ResourceUnitTestCase.javalibjboss-classloader-java-2.0.6.GA.orig/classloader/src/test/java/org/jboss/test/classloader/resourc0000644000175000017500000005566510755315715033526 0ustar twernertwerner/* * JBoss, Home of Professional Open Source. * Copyright 2007, Red Hat Middleware LLC, and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.test.classloader.resources.tests; import java.io.InputStream; import java.io.InputStreamReader; import java.net.URL; import java.util.Collections; import java.util.Enumeration; import java.util.HashSet; import junit.framework.Test; import org.jboss.classloader.spi.ClassLoaderDomain; import org.jboss.classloader.spi.ClassLoaderSystem; import org.jboss.classloader.spi.ParentPolicy; import org.jboss.classloader.spi.filter.FilteredDelegateLoader; import org.jboss.classloader.test.support.MockClassLoaderPolicy; import org.jboss.test.classloader.AbstractClassLoaderTestWithSecurity; /** * ClassLoaderSystemUnitTestCase. * * @author Adrian Brock * @version $Revision: 1.1 $ */ public class ResourceUnitTestCase extends AbstractClassLoaderTestWithSecurity { public static Test suite() { return suite(ResourceUnitTestCase.class); } public ResourceUnitTestCase(String name) { super(name); } public void testGetResource() throws Exception { ClassLoaderSystem system = createClassLoaderSystem(); MockClassLoaderPolicy policy = createMockClassLoaderPolicy(); policy.setPrefix("a/"); policy.setPath("com/acme/p1"); ClassLoader classLoader = system.registerClassLoaderPolicy(policy); assertGetResource("a/", "com/acme/p1/testResource", classLoader); } public void testGetResourceFromDefaultPackage() throws Exception { ClassLoaderSystem system = createClassLoaderSystem(); MockClassLoaderPolicy policy = createMockClassLoaderPolicy(); policy.setPrefix("a/"); policy.setPath(""); ClassLoader classLoader = system.registerClassLoaderPolicy(policy); assertGetResource("a/", "testResource", classLoader); } public void testGetResourceFromDelegate() throws Exception { ClassLoaderSystem system = createClassLoaderSystem(); MockClassLoaderPolicy policy = createMockClassLoaderPolicy(); policy.setPrefix("a/"); policy.setPath("com/acme/p1"); MockClassLoaderPolicy policy2 = createMockClassLoaderPolicy(); policy2.setDelegates(Collections.singletonList(new FilteredDelegateLoader(policy))); system.registerClassLoaderPolicy(policy); ClassLoader classLoader = system.registerClassLoaderPolicy(policy2); assertGetResource("a/", "com/acme/p1/testResource", classLoader); } public void testGetResourceFromDefaultPackageFromDelegate() throws Exception { ClassLoaderSystem system = createClassLoaderSystem(); MockClassLoaderPolicy policy = createMockClassLoaderPolicy(); policy.setPrefix("a/"); policy.setPath(""); MockClassLoaderPolicy policy2 = createMockClassLoaderPolicy(); policy2.setDelegates(Collections.singletonList(new FilteredDelegateLoader(policy))); system.registerClassLoaderPolicy(policy); ClassLoader classLoader = system.registerClassLoaderPolicy(policy2); assertGetResource("a/", "testResource", classLoader); } public void testGetResourceWithDotFromDelegate() throws Exception { ClassLoaderSystem system = createClassLoaderSystem(); MockClassLoaderPolicy policy = createMockClassLoaderPolicy(); policy.setPrefix("a/"); policy.setPath("com/acme/p1"); policy.setPackageNames(new String[] { "com.acme.p1" } ); MockClassLoaderPolicy policy2 = createMockClassLoaderPolicy(); policy2.setDelegates(Collections.singletonList(new FilteredDelegateLoader(policy))); system.registerClassLoaderPolicy(policy); ClassLoader classLoader = system.registerClassLoaderPolicy(policy2); assertGetResource("a/", "com/acme/p1/testResource.xml", classLoader); } public void testGetResourceWithDotFromDelegatNotFound() throws Exception { ClassLoaderSystem system = createClassLoaderSystem(); MockClassLoaderPolicy policy = createMockClassLoaderPolicy(); policy.setPrefix("a/"); policy.setPath("com/acme/p1"); policy.setPackageNames(new String[] { "com.acme.p1" } ); MockClassLoaderPolicy policy2 = createMockClassLoaderPolicy(); policy2.setDelegates(Collections.singletonList(new FilteredDelegateLoader(policy))); system.registerClassLoaderPolicy(policy); ClassLoader classLoader = system.registerClassLoaderPolicy(policy2); assertGetResourceFail("testResource.xml", classLoader); } public void testGetResourceUsingAllImports() throws Exception { ClassLoaderSystem system = createClassLoaderSystem(); MockClassLoaderPolicy policy = createMockClassLoaderPolicy(); policy.setPrefix("a/"); policy.setPath("com/acme/p1"); policy.setPackageNames(new String[] { "com.acme.p1" } ); MockClassLoaderPolicy policy2 = createMockClassLoaderPolicy(); policy2.setImportAll(true); system.registerClassLoaderPolicy(policy); ClassLoader classLoader = system.registerClassLoaderPolicy(policy2); assertGetResource("a/", "com/acme/p1/testResource", classLoader); } public void testGetResourceFromDefaultPackageUsingAllImports() throws Exception { ClassLoaderSystem system = createClassLoaderSystem(); MockClassLoaderPolicy policy = createMockClassLoaderPolicy(); policy.setPrefix("a/"); policy.setPath(""); policy.setPackageNames(new String[] { "" } ); MockClassLoaderPolicy policy2 = createMockClassLoaderPolicy(); policy2.setImportAll(true); system.registerClassLoaderPolicy(policy); ClassLoader classLoader = system.registerClassLoaderPolicy(policy2); assertGetResource("a/", "testResource", classLoader); } public void testGetResourceNotFound() throws Exception { ClassLoaderSystem system = createClassLoaderSystem(); MockClassLoaderPolicy policy = createMockClassLoaderPolicy(); policy.setPrefix("a/"); policy.setPath("com/acme/p1"); policy.setPackageNames(new String[] { "com.acme.p1" } ); MockClassLoaderPolicy policy2 = createMockClassLoaderPolicy(); system.registerClassLoaderPolicy(policy); ClassLoader classLoader = system.registerClassLoaderPolicy(policy2); assertGetResourceFail("com/acme/p1/testResource", classLoader); } public void testGetResourceFromParentBefore() throws Exception { ClassLoaderSystem system = createClassLoaderSystem(); ClassLoaderDomain parent = system.createAndRegisterDomain("parent"); MockClassLoaderPolicy policy = createMockClassLoaderPolicy(); policy.setPrefix("a/"); policy.setPath("com/acme/p1"); policy.setPackageNames(new String[] { "com.acme.p1" } ); system.registerClassLoaderPolicy(parent, policy); ClassLoaderDomain child = system.createAndRegisterDomain("child", ParentPolicy.BEFORE, parent); MockClassLoaderPolicy policy2 = createMockClassLoaderPolicy(); policy2.setPrefix("b/"); policy2.setPath("com/acme/p1"); ClassLoader classLoader = system.registerClassLoaderPolicy(child, policy2); assertGetResource("b/", "com/acme/p1/testResource", classLoader); } public void testGetResourceFromParentAfter() throws Exception { ClassLoaderSystem system = createClassLoaderSystem(); ClassLoaderDomain parent = system.createAndRegisterDomain("parent"); MockClassLoaderPolicy policy = createMockClassLoaderPolicy(); policy.setPrefix("a/"); policy.setPath("com/acme/p1"); policy.setPackageNames(new String[] { "com.acme.p1" } ); system.registerClassLoaderPolicy(parent, policy); ClassLoaderDomain child = system.createAndRegisterDomain("child", ParentPolicy.AFTER, parent); MockClassLoaderPolicy policy2 = createMockClassLoaderPolicy(); ClassLoader classLoader = system.registerClassLoaderPolicy(child, policy2); assertGetResource("a/", "com/acme/p1/testResource", classLoader); } public void testGetResourceFromParentAfterNotReached() throws Exception { ClassLoaderSystem system = createClassLoaderSystem(); ClassLoaderDomain parent = system.createAndRegisterDomain("parent"); MockClassLoaderPolicy policy = createMockClassLoaderPolicy(); policy.setPrefix("a/"); policy.setPath("com/acme/p1"); policy.setPackageNames(new String[] { "com.acme.p1" } ); system.registerClassLoaderPolicy(parent, policy); ClassLoaderDomain child = system.createAndRegisterDomain("child", ParentPolicy.AFTER, parent); MockClassLoaderPolicy policy2 = createMockClassLoaderPolicy(); policy2.setPrefix("b/"); policy2.setPath("com/acme/p1"); ClassLoader classLoader = system.registerClassLoaderPolicy(child, policy2); assertGetResource("b/", "com/acme/p1/testResource", classLoader); } public void testGetResourceFromDefaultPackageFromParent() throws Exception { ClassLoaderSystem system = createClassLoaderSystem(); ClassLoaderDomain parent = system.createAndRegisterDomain("parent"); MockClassLoaderPolicy policy = createMockClassLoaderPolicy(); policy.setPrefix("a/"); policy.setPath(""); policy.setPackageNames(new String[] { "" } ); system.registerClassLoaderPolicy(parent, policy); ClassLoaderDomain child = system.createAndRegisterDomain("child", ParentPolicy.BEFORE, parent); MockClassLoaderPolicy policy2 = createMockClassLoaderPolicy(); policy2.setPrefix("b/"); policy2.setPath("com/acme/p1"); ClassLoader classLoader = system.registerClassLoaderPolicy(child, policy2); assertGetResource("a/", "testResource", classLoader); } public void testGetResources() throws Exception { ClassLoaderSystem system = createClassLoaderSystem(); MockClassLoaderPolicy policy = createMockClassLoaderPolicy(); policy.setPrefix("a/"); policy.setPath("com/acme/p1"); ClassLoader classLoader = system.registerClassLoaderPolicy(policy); assertGetResources("com/acme/p1/testResource", classLoader, "a/"); } public void testGetResourcesFromDefaultPackage() throws Exception { ClassLoaderSystem system = createClassLoaderSystem(); MockClassLoaderPolicy policy = createMockClassLoaderPolicy(); policy.setPrefix("a/"); policy.setPath(""); ClassLoader classLoader = system.registerClassLoaderPolicy(policy); assertGetResources("testResource", classLoader, "a/"); } public void testGetResourcesMultiple() throws Exception { ClassLoaderSystem system = createClassLoaderSystem(); MockClassLoaderPolicy policy = createMockClassLoaderPolicy(); policy.setImportAll(true); policy.setPrefix("a/"); policy.setPath("com/acme/p1"); MockClassLoaderPolicy policy2 = createMockClassLoaderPolicy(); policy2.setPrefix("b/"); policy2.setPath("com/acme/p1"); policy2.setPackageNames(new String[] { "com.acme.p1" }); ClassLoader classLoader = system.registerClassLoaderPolicy(policy); system.registerClassLoaderPolicy(policy2); assertGetResources("com/acme/p1/testResource", classLoader, "a/", "b/"); } public void testGetResourcesFromDefaultPackageMultiple() throws Exception { ClassLoaderSystem system = createClassLoaderSystem(); MockClassLoaderPolicy policy = createMockClassLoaderPolicy(); policy.setImportAll(true); policy.setPrefix("a/"); policy.setPath(""); MockClassLoaderPolicy policy2 = createMockClassLoaderPolicy(); policy2.setPrefix("b/"); policy2.setPath(""); policy2.setPackageNames(new String[] { "" }); ClassLoader classLoader = system.registerClassLoaderPolicy(policy); system.registerClassLoaderPolicy(policy2); assertGetResources("testResource", classLoader, "a/", "b/"); } public void testGetResourcesFromDelegate() throws Exception { ClassLoaderSystem system = createClassLoaderSystem(); MockClassLoaderPolicy policy = createMockClassLoaderPolicy(); policy.setPrefix("a/"); policy.setPath("com/acme/p1"); MockClassLoaderPolicy policy2 = createMockClassLoaderPolicy(); policy2.setDelegates(Collections.singletonList(new FilteredDelegateLoader(policy))); system.registerClassLoaderPolicy(policy); ClassLoader classLoader = system.registerClassLoaderPolicy(policy2); assertGetResources("com/acme/p1/testResource", classLoader, "a/"); } public void testGetResourcesFromDefaultPackageFromDelegate() throws Exception { ClassLoaderSystem system = createClassLoaderSystem(); MockClassLoaderPolicy policy = createMockClassLoaderPolicy(); policy.setPrefix("a/"); policy.setPath(""); MockClassLoaderPolicy policy2 = createMockClassLoaderPolicy(); policy2.setDelegates(Collections.singletonList(new FilteredDelegateLoader(policy))); system.registerClassLoaderPolicy(policy); ClassLoader classLoader = system.registerClassLoaderPolicy(policy2); assertGetResources("testResource", classLoader, "a/"); } public void testGetResourcesWithDotFromDelegate() throws Exception { ClassLoaderSystem system = createClassLoaderSystem(); MockClassLoaderPolicy policy = createMockClassLoaderPolicy(); policy.setPrefix("a/"); policy.setPath("com/acme/p1"); policy.setPackageNames(new String[] { "com.acme.p1" } ); MockClassLoaderPolicy policy2 = createMockClassLoaderPolicy(); policy2.setDelegates(Collections.singletonList(new FilteredDelegateLoader(policy))); system.registerClassLoaderPolicy(policy); ClassLoader classLoader = system.registerClassLoaderPolicy(policy2); assertGetResources("com/acme/p1/testResource.xml", classLoader, "a/"); } public void testGetResourcesWithDotFromDelegateNotFound() throws Exception { ClassLoaderSystem system = createClassLoaderSystem(); MockClassLoaderPolicy policy = createMockClassLoaderPolicy(); policy.setPrefix("a/"); policy.setPath("com/acme/p1"); policy.setPackageNames(new String[] { "com.acme.p1" } ); MockClassLoaderPolicy policy2 = createMockClassLoaderPolicy(); policy2.setDelegates(Collections.singletonList(new FilteredDelegateLoader(policy))); system.registerClassLoaderPolicy(policy); ClassLoader classLoader = system.registerClassLoaderPolicy(policy2); assertGetResourcesFail("testResource.xml", classLoader); } public void testGetResourcesUsingAllImports() throws Exception { ClassLoaderSystem system = createClassLoaderSystem(); MockClassLoaderPolicy policy = createMockClassLoaderPolicy(); policy.setPrefix("a/"); policy.setPath("com/acme/p1"); policy.setPackageNames(new String[] { "com.acme.p1" } ); MockClassLoaderPolicy policy2 = createMockClassLoaderPolicy(); policy2.setImportAll(true); system.registerClassLoaderPolicy(policy); ClassLoader classLoader = system.registerClassLoaderPolicy(policy2); assertGetResources("com/acme/p1/testResource", classLoader, "a/"); } public void testGetResourcesFromDefaultPackageUsingAllImports() throws Exception { ClassLoaderSystem system = createClassLoaderSystem(); MockClassLoaderPolicy policy = createMockClassLoaderPolicy(); policy.setPrefix("a/"); policy.setPath(""); policy.setPackageNames(new String[] { "" } ); MockClassLoaderPolicy policy2 = createMockClassLoaderPolicy(); policy2.setImportAll(true); system.registerClassLoaderPolicy(policy); ClassLoader classLoader = system.registerClassLoaderPolicy(policy2); assertGetResources("testResource", classLoader, "a/"); } public void testGetResourcesNotFound() throws Exception { ClassLoaderSystem system = createClassLoaderSystem(); MockClassLoaderPolicy policy = createMockClassLoaderPolicy(); policy.setPrefix("a/"); policy.setPath("com/acme/p1"); policy.setPackageNames(new String[] { "com.acme.p1" } ); MockClassLoaderPolicy policy2 = createMockClassLoaderPolicy(); system.registerClassLoaderPolicy(policy); ClassLoader classLoader = system.registerClassLoaderPolicy(policy2); assertGetResourcesFail("com/acme/p1/testResource", classLoader); } public void testGetResourcesFromParentBefore() throws Exception { ClassLoaderSystem system = createClassLoaderSystem(); ClassLoaderDomain parent = system.createAndRegisterDomain("parent"); MockClassLoaderPolicy policy = createMockClassLoaderPolicy(); policy.setPrefix("a/"); policy.setPath("com/acme/p1"); policy.setPackageNames(new String[] { "com.acme.p1" } ); system.registerClassLoaderPolicy(parent, policy); ClassLoaderDomain child = system.createAndRegisterDomain("child", ParentPolicy.BEFORE, parent); MockClassLoaderPolicy policy2 = createMockClassLoaderPolicy(); policy2.setPrefix("b/"); policy2.setPath("com/acme/p1"); ClassLoader classLoader = system.registerClassLoaderPolicy(child, policy2); assertGetResources("com/acme/p1/testResource", classLoader, "a/", "b/"); } public void testGetResourcesFromParentAfter() throws Exception { ClassLoaderSystem system = createClassLoaderSystem(); ClassLoaderDomain parent = system.createAndRegisterDomain("parent"); MockClassLoaderPolicy policy = createMockClassLoaderPolicy(); policy.setPrefix("a/"); policy.setPath("com/acme/p1"); policy.setPackageNames(new String[] { "com.acme.p1" } ); system.registerClassLoaderPolicy(parent, policy); ClassLoaderDomain child = system.createAndRegisterDomain("child", ParentPolicy.AFTER, parent); MockClassLoaderPolicy policy2 = createMockClassLoaderPolicy(); policy2.setPrefix("b/"); policy2.setPath("com/acme/p1"); ClassLoader classLoader = system.registerClassLoaderPolicy(child, policy2); assertGetResources("com/acme/p1/testResource", classLoader, "a/", "b/"); } public void testGetResourcesFromDefaultPackageFromParent() throws Exception { ClassLoaderSystem system = createClassLoaderSystem(); ClassLoaderDomain parent = system.createAndRegisterDomain("parent"); MockClassLoaderPolicy policy = createMockClassLoaderPolicy(); policy.setPrefix("a/"); policy.setPath(""); policy.setPackageNames(new String[] { "" } ); system.registerClassLoaderPolicy(parent, policy); ClassLoaderDomain child = system.createAndRegisterDomain("child", ParentPolicy.BEFORE, parent); MockClassLoaderPolicy policy2 = createMockClassLoaderPolicy(); policy2.setPrefix("b/"); policy2.setPath(""); ClassLoader classLoader = system.registerClassLoaderPolicy(child, policy2); assertGetResources("testResource", classLoader, "a/", "b/"); } protected URL assertGetResource(String prefix, String resourcePath, ClassLoader classLoader) throws Exception { URL url = classLoader.getResource(resourcePath); assertNotNull("Should have got resource prefix=" + prefix + " resourcePath " + resourcePath + " from " + classLoader, url); SecurityManager sm = suspendSecurity(); try { InputStream is = url.openStream(); try { InputStreamReader reader = new InputStreamReader(is); char[] chars = new char[1000]; int count = 0; int read = reader.read(chars); while (read != -1) { count += read; read = reader.read(chars, read, 1000 - read); } String string = new String(chars, 0, count); assertEquals("Should have read the correct resource", prefix + resourcePath, string); } finally { is.close(); } } finally { resumeSecurity(sm); } return url; } protected void assertGetResourceFail(String resourcePath, ClassLoader classLoader) throws Exception { URL url = classLoader.getResource(resourcePath); assertNull("Should NOT have got resource " + resourcePath + " from " + classLoader, url); } protected Enumeration assertGetResources(String resourcePath, ClassLoader classLoader, String... prefixes) throws Exception { Enumeration urls = classLoader.getResources(resourcePath); HashSet foundResources = new HashSet(); SecurityManager sm = suspendSecurity(); try { while (urls.hasMoreElements()) { URL url = urls.nextElement(); InputStream is = url.openStream(); try { InputStreamReader reader = new InputStreamReader(is); char[] chars = new char[1000]; int count = 0; int read = reader.read(chars); while (read != -1) { count += read; read = reader.read(chars, read, 1000 - read); } String string = new String(chars, 0, count); foundResources.add(string); } finally { is.close(); } } } finally { resumeSecurity(sm); } HashSet expectedResources = new HashSet(); for (String prefix : prefixes) expectedResources.add(prefix + resourcePath); assertEquals(expectedResources, foundResources); return urls; } protected void assertGetResourcesFail(String resourcePath, ClassLoader classLoader) throws Exception { Enumeration urls = classLoader.getResources(resourcePath); if (urls.hasMoreElements()) { HashSet found = new HashSet(); while (urls.hasMoreElements()) found.add(urls.nextElement()); fail("Should NOT have got resources " + resourcePath + " from " + classLoader + " found " + urls); } } } ././@LongLink0000000000000000000000000000017600000000000011571 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloader/src/test/java/org/jboss/test/classloader/resources/ResourceTestSuite.javalibjboss-classloader-java-2.0.6.GA.orig/classloader/src/test/java/org/jboss/test/classloader/resourc0000644000175000017500000000352210616435067033506 0ustar twernertwerner/* * JBoss, Home of Professional Open Source. * Copyright 2007, Red Hat Middleware LLC, and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.test.classloader.resources; import org.jboss.test.classloader.resources.tests.ResourceUnitTestCase; import junit.framework.Test; import junit.framework.TestSuite; import junit.textui.TestRunner; /** * Resource Test Suite. * * @author Adrian Brock * @version $Revision: 37459 $ */ public class ResourceTestSuite extends TestSuite { /** * For running the testsuite from the command line * * @param args the command line args */ public static void main(String[] args) { TestRunner.run(suite()); } /** * Create the testsuite * * @return the testsuite */ public static Test suite() { TestSuite suite = new TestSuite("Resource Tests"); suite.addTest(ResourceUnitTestCase.suite()); return suite; } } libjboss-classloader-java-2.0.6.GA.orig/classloader/src/test/java/org/jboss/test/classloader/junit/0000755000175000017500000000000011620043421033211 5ustar twernertwerner././@LongLink0000000000000000000000000000015100000000000011562 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloader/src/test/java/org/jboss/test/classloader/junit/test/libjboss-classloader-java-2.0.6.GA.orig/classloader/src/test/java/org/jboss/test/classloader/junit/t0000755000175000017500000000000011620043421033375 5ustar twernertwerner././@LongLink0000000000000000000000000000021500000000000011563 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloader/src/test/java/org/jboss/test/classloader/junit/test/IsolatedClassLoaderUnitTestCase.javalibjboss-classloader-java-2.0.6.GA.orig/classloader/src/test/java/org/jboss/test/classloader/junit/t0000644000175000017500000001030410741370313033403 0ustar twernertwerner/* * JBoss, Home of Professional Open Source * Copyright 2006, JBoss Inc., and individual contributors as indicated * by the @authors tag. See the copyright.txt in the distribution for a * full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.test.classloader.junit.test; import java.util.Set; import javax.naming.InitialContext; import junit.framework.Test; import org.jboss.classloader.spi.ClassLoaderSystem; import org.jboss.classloader.test.support.IsolatedClassLoaderTest; import org.jboss.test.classloader.junit.notsupport.NotSupport; import org.jboss.test.classloader.junit.support.Support; /** * IsolatedClassLoaderUnitTestCase. * * @author Adrian Brock * @version $Revision: 1.1 $ */ public class IsolatedClassLoaderUnitTestCase extends IsolatedClassLoaderTest { private static final String NOT_SUPPORT_PACKAGE = "org.jboss.test.classloader.junit.notsupport"; private static final String NOT_SUPPORT_CLASS = NOT_SUPPORT_PACKAGE + ".NotSupport"; public static Test suite() { return suite(IsolatedClassLoaderUnitTestCase.class, true, Support.class); } public IsolatedClassLoaderUnitTestCase(String name) { super(name); } public void testClassLoader() { ClassLoader classLoader = getClass().getClassLoader(); assertFalse(classLoader.equals(IsolatedClassLoaderTest.class.getClassLoader())); } public void testClassLoaderSystem() { ClassLoaderSystem system = getClassLoaderSystem(); assertTrue(system.isRegistered("TEST")); } public void testSupport() { assertEquals(Support.class.getClassLoader(), getClass().getClassLoader()); } public void testNotSupport() { // This should fail since it is not suite() above try { getLog().debug(NotSupport.class); fail("Should not be here!"); } catch (Throwable expected) { checkThrowable(NoClassDefFoundError.class, expected); } } public void testCreateClassLoader() throws Exception { ClassLoader classLoader = createClassLoader("NewClassLoader", NOT_SUPPORT_PACKAGE); try { Class clazz = classLoader.loadClass(NOT_SUPPORT_CLASS); assertEquals(classLoader, clazz.getClassLoader()); Class clazz2 = getClass().getClassLoader().loadClass(NOT_SUPPORT_CLASS); assertEquals(classLoader, clazz2.getClassLoader()); } finally { unregisterClassLoader(classLoader); } } public void testUnregisterClassLoader() throws Exception { ClassLoader classLoader = createClassLoader("NewClassLoader", NOT_SUPPORT_PACKAGE); unregisterClassLoader(classLoader); try { classLoader.loadClass(NOT_SUPPORT_CLASS); fail("Should not be here!"); } catch (Throwable t) { checkThrowable(IllegalStateException.class, t); } try { getClass().getClassLoader().loadClass(NOT_SUPPORT_CLASS); fail("Should not be here!"); } catch (Throwable t) { checkThrowable(ClassNotFoundException.class, t); } } public void testJavaClass() throws Exception { Class clazz = getClass().getClassLoader().loadClass("java.util.Set"); assertEquals(Set.class, clazz); clazz = getClass().getClassLoader().loadClass("javax.naming.InitialContext"); assertEquals(InitialContext.class, clazz); } } ././@LongLink0000000000000000000000000000016700000000000011571 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloader/src/test/java/org/jboss/test/classloader/junit/JUnitTestSuite.javalibjboss-classloader-java-2.0.6.GA.orig/classloader/src/test/java/org/jboss/test/classloader/junit/J0000644000175000017500000000352210651427771033350 0ustar twernertwerner/* * JBoss, Home of Professional Open Source. * Copyright 2007, Red Hat Middleware LLC, and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.test.classloader.junit; import junit.framework.Test; import junit.framework.TestSuite; import junit.textui.TestRunner; import org.jboss.test.classloader.junit.test.IsolatedClassLoaderUnitTestCase; /** * JunitTestSuite. * * @author Adrian Brock * @version $Revision: 1.1 $ */ public class JUnitTestSuite extends TestSuite { /** * For running the testsuite from the command line * * @param args the command line args */ public static void main(String[] args) { TestRunner.run(suite()); } /** * Create the testsuite * * @return the testsuite */ public static Test suite() { TestSuite suite = new TestSuite("Junit Tests"); suite.addTest(IsolatedClassLoaderUnitTestCase.suite()); return suite; } } ././@LongLink0000000000000000000000000000015400000000000011565 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloader/src/test/java/org/jboss/test/classloader/junit/support/libjboss-classloader-java-2.0.6.GA.orig/classloader/src/test/java/org/jboss/test/classloader/junit/s0000755000175000017500000000000011620043421033374 5ustar twernertwerner././@LongLink0000000000000000000000000000017000000000000011563 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloader/src/test/java/org/jboss/test/classloader/junit/support/Support.javalibjboss-classloader-java-2.0.6.GA.orig/classloader/src/test/java/org/jboss/test/classloader/junit/s0000644000175000017500000000223210651427771033416 0ustar twernertwerner/* * JBoss, Home of Professional Open Source * Copyright 2006, JBoss Inc., and individual contributors as indicated * by the @authors tag. See the copyright.txt in the distribution for a * full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.test.classloader.junit.support; /** * Support. * * @author Adrian Brock * @version $Revision: 1.1 $ */ public class Support { } ././@LongLink0000000000000000000000000000015700000000000011570 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloader/src/test/java/org/jboss/test/classloader/junit/notsupport/libjboss-classloader-java-2.0.6.GA.orig/classloader/src/test/java/org/jboss/test/classloader/junit/n0000755000175000017500000000000011620043421033367 5ustar twernertwerner././@LongLink0000000000000000000000000000017600000000000011571 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloader/src/test/java/org/jboss/test/classloader/junit/notsupport/NotSupport.javalibjboss-classloader-java-2.0.6.GA.orig/classloader/src/test/java/org/jboss/test/classloader/junit/n0000644000175000017500000000224410651427771033414 0ustar twernertwerner/* * JBoss, Home of Professional Open Source * Copyright 2006, JBoss Inc., and individual contributors as indicated * by the @authors tag. See the copyright.txt in the distribution for a * full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.test.classloader.junit.notsupport; /** * NotSupport. * * @author Adrian Brock * @version $Revision: 1.1 $ */ public class NotSupport { } ././@LongLink0000000000000000000000000000014500000000000011565 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloader/src/test/java/org/jboss/test/classloader/domain/libjboss-classloader-java-2.0.6.GA.orig/classloader/src/test/java/org/jboss/test/classloader/domain/0000755000175000017500000000000011620043421033327 5ustar twernertwerner././@LongLink0000000000000000000000000000020400000000000011561 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloader/src/test/java/org/jboss/test/classloader/domain/ClassLoaderDomainTestSuite.javalibjboss-classloader-java-2.0.6.GA.orig/classloader/src/test/java/org/jboss/test/classloader/domain/0000644000175000017500000000446211200012564033335 0ustar twernertwerner/* * JBoss, Home of Professional Open Source. * Copyright 2007, Red Hat Middleware LLC, and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.test.classloader.domain; import org.jboss.test.classloader.domain.test.CustomParentLoaderUnitTestCase; import org.jboss.test.classloader.domain.test.HierarchicalParentClassLoaderUnitTestCase; import org.jboss.test.classloader.domain.test.HierarchicalParentLoaderUnitTestCase; import org.jboss.test.classloader.domain.test.ParentPolicyUnitTestCase; import junit.framework.Test; import junit.framework.TestSuite; import junit.textui.TestRunner; /** * ClassLoaderDomain Test Suite. * * @author Adrian Brock * @version $Revision: 37459 $ */ public class ClassLoaderDomainTestSuite extends TestSuite { /** * For running the testsuite from the command line * * @param args the command line args */ public static void main(String[] args) { TestRunner.run(suite()); } /** * Create the testsuite * * @return the testsuite */ public static Test suite() { TestSuite suite = new TestSuite("ClassLoader Domain Tests"); suite.addTest(ParentPolicyUnitTestCase.suite()); suite.addTest(CustomParentLoaderUnitTestCase.suite()); suite.addTest(HierarchicalParentLoaderUnitTestCase.suite()); suite.addTest(HierarchicalParentClassLoaderUnitTestCase.suite()); return suite; } } ././@LongLink0000000000000000000000000000015200000000000011563 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloader/src/test/java/org/jboss/test/classloader/domain/test/libjboss-classloader-java-2.0.6.GA.orig/classloader/src/test/java/org/jboss/test/classloader/domain/0000755000175000017500000000000011620043421033327 5ustar twernertwerner././@LongLink0000000000000000000000000000022300000000000011562 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloader/src/test/java/org/jboss/test/classloader/domain/test/HierarchicalParentLoaderUnitTestCase.javalibjboss-classloader-java-2.0.6.GA.orig/classloader/src/test/java/org/jboss/test/classloader/domain/0000644000175000017500000001555211200016332033334 0ustar twernertwerner/* * JBoss, Home of Professional Open Source. * Copyright 2007, Red Hat Middleware LLC, and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.test.classloader.domain.test; import junit.framework.Test; import org.jboss.classloader.spi.ClassLoaderDomain; import org.jboss.classloader.spi.ClassLoaderSystem; import org.jboss.classloader.spi.Loader; import org.jboss.classloader.spi.ParentPolicy; import org.jboss.classloader.spi.filter.ClassFilter; import org.jboss.classloader.test.support.MockClassLoaderPolicy; import org.jboss.test.classloader.AbstractClassLoaderTestWithSecurity; import org.jboss.test.classloader.domain.support.MockLoader; import org.jboss.test.classloader.domain.support.NoMatchClassFilter; /** * ParentPolicyUnitTestCase. * * @author Adrian Brock * @version $Revision: 1.1 $ */ public class HierarchicalParentLoaderUnitTestCase extends AbstractClassLoaderTestWithSecurity { public static Test suite() { return suite(HierarchicalParentLoaderUnitTestCase.class); } public HierarchicalParentLoaderUnitTestCase(String name) { super(name); } public void testHierarchyBefore() throws Exception { ClassLoaderSystem system = createClassLoaderSystem(); ClassLoaderDomain parent = system.createAndRegisterDomain("parent", ParentPolicy.BEFORE_BUT_JAVA_ONLY); ClassLoaderDomain child = system.createAndRegisterDomain("child", ParentPolicy.BEFORE, parent); MockClassLoaderPolicy parentPolicy = createMockClassLoaderPolicy(); parentPolicy.setPathsAndPackageNames(MockLoader.class, Loader.class); parentPolicy.setImportAll(true); ClassLoader parentClassLoader = system.registerClassLoaderPolicy(parent, parentPolicy); MockClassLoaderPolicy childPolicy = createMockClassLoaderPolicy(); childPolicy.setPathsAndPackageNames(MockLoader.class, Loader.class); childPolicy.setImportAll(true); ClassLoader classLoader = system.registerClassLoaderPolicy(child, childPolicy); assertLoadClass(MockLoader.class, classLoader, parentClassLoader); assertLoadClass(MockLoader.class, classLoader, parentClassLoader); } public void testHierarchyBeforeNotFound() throws Exception { ClassLoaderSystem system = createClassLoaderSystem(); ClassLoaderDomain parent = system.createAndRegisterDomain("parent", ParentPolicy.BEFORE_BUT_JAVA_ONLY); ClassLoaderDomain child = system.createAndRegisterDomain("child", ParentPolicy.BEFORE, parent); MockClassLoaderPolicy childPolicy = createMockClassLoaderPolicy(); childPolicy.setPathsAndPackageNames(MockLoader.class, Loader.class); ClassLoader classLoader = system.registerClassLoaderPolicy(child, childPolicy); assertLoadClass(MockLoader.class, classLoader); assertLoadClass(MockLoader.class, classLoader); } public void testHierarchyAfterNotReached() throws Exception { ClassLoaderSystem system = createClassLoaderSystem(); ClassLoaderDomain parent = system.createAndRegisterDomain("parent", ParentPolicy.BEFORE_BUT_JAVA_ONLY); ClassLoaderDomain child = system.createAndRegisterDomain("child", ParentPolicy.AFTER_BUT_JAVA_BEFORE, parent); MockClassLoaderPolicy parentPolicy = createMockClassLoaderPolicy(); parentPolicy.setPathsAndPackageNames(MockLoader.class, Loader.class); parentPolicy.setImportAll(true); system.registerClassLoaderPolicy(parent, parentPolicy); MockClassLoaderPolicy childPolicy = createMockClassLoaderPolicy(); childPolicy.setPathsAndPackageNames(MockLoader.class, Loader.class); childPolicy.setImportAll(true); ClassLoader classLoader = system.registerClassLoaderPolicy(child, childPolicy); assertLoadClass(MockLoader.class, classLoader); assertLoadClass(MockLoader.class, classLoader); } public void testHierarchyAfterReached() throws Exception { ClassLoaderSystem system = createClassLoaderSystem(); ClassLoaderDomain parent = system.createAndRegisterDomain("parent", ParentPolicy.BEFORE_BUT_JAVA_ONLY); ClassLoaderDomain child = system.createAndRegisterDomain("child", ParentPolicy.AFTER_BUT_JAVA_BEFORE, parent); MockClassLoaderPolicy parentPolicy = createMockClassLoaderPolicy(); parentPolicy.setPathsAndPackageNames(MockLoader.class, Loader.class); parentPolicy.setImportAll(true); ClassLoader parentClassLoader = system.registerClassLoaderPolicy(parent, parentPolicy); MockClassLoaderPolicy childPolicy = createMockClassLoaderPolicy(); ClassLoader classLoader = system.registerClassLoaderPolicy(child, childPolicy); childPolicy.setImportAll(true); assertLoadClass(MockLoader.class, classLoader, parentClassLoader); assertLoadClass(MockLoader.class, classLoader, parentClassLoader); } public void testHierarchyFiltered() throws Exception { ClassLoaderSystem system = createClassLoaderSystem(); NoMatchClassFilter filter = new NoMatchClassFilter(MockLoader.class); ParentPolicy pp = new ParentPolicy(filter, ClassFilter.NOTHING); ClassLoaderDomain parent = system.createAndRegisterDomain("parent", ParentPolicy.BEFORE_BUT_JAVA_ONLY); ClassLoaderDomain child = system.createAndRegisterDomain("child", pp, parent); MockClassLoaderPolicy parentPolicy = createMockClassLoaderPolicy(); parentPolicy.setPathsAndPackageNames(MockLoader.class, Loader.class); parentPolicy.setImportAll(true); system.registerClassLoaderPolicy(parent, parentPolicy); MockClassLoaderPolicy childPolicy = createMockClassLoaderPolicy(); childPolicy.setPathsAndPackageNames(MockLoader.class, Loader.class); childPolicy.setImportAll(true); ClassLoader classLoader = system.registerClassLoaderPolicy(child, childPolicy); assertLoadClass(MockLoader.class, classLoader); assertTrue("Should have been filtered", filter.filtered); assertLoadClass(MockLoader.class, classLoader); } } ././@LongLink0000000000000000000000000000023000000000000011560 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloader/src/test/java/org/jboss/test/classloader/domain/test/HierarchicalParentClassLoaderUnitTestCase.javalibjboss-classloader-java-2.0.6.GA.orig/classloader/src/test/java/org/jboss/test/classloader/domain/0000644000175000017500000003277411200012564033344 0ustar twernertwerner/* * JBoss, Home of Professional Open Source. * Copyright 2007, Red Hat Middleware LLC, and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.test.classloader.domain.test; import junit.framework.Test; import org.jboss.classloader.plugins.loader.ClassLoaderToLoaderAdapter; import org.jboss.classloader.spi.ClassLoaderDomain; import org.jboss.classloader.spi.ClassLoaderSystem; import org.jboss.classloader.spi.Loader; import org.jboss.classloader.spi.ParentPolicy; import org.jboss.classloader.spi.filter.ClassFilter; import org.jboss.classloader.test.support.MockClassLoaderPolicy; import org.jboss.test.classloader.AbstractClassLoaderTestWithSecurity; import org.jboss.test.classloader.domain.support.MockLoader; import org.jboss.test.classloader.domain.support.NoMatchClassFilter; /** * ParentPolicyUnitTestCase. * * @author Adrian Brock * @version $Revision: 1.1 $ */ public class HierarchicalParentClassLoaderUnitTestCase extends AbstractClassLoaderTestWithSecurity { public static Test suite() { return suite(HierarchicalParentClassLoaderUnitTestCase.class); } public HierarchicalParentClassLoaderUnitTestCase(String name) { super(name); } public void testHierarchyBefore() throws Exception { ClassLoaderSystem system = createClassLoaderSystem(); ClassLoaderDomain parent = system.createAndRegisterDomain("parent", ParentPolicy.BEFORE_BUT_JAVA_ONLY); MockClassLoaderPolicy parentPolicy = createMockClassLoaderPolicy(); parentPolicy.setPathsAndPackageNames(MockLoader.class, Loader.class); parentPolicy.setImportAll(true); ClassLoader parentClassLoader = system.registerClassLoaderPolicy(parent, parentPolicy); Loader parentLoader = new ClassLoaderToLoaderAdapter(parentClassLoader); ClassLoaderDomain child = system.createAndRegisterDomain("child", ParentPolicy.BEFORE, parentLoader); MockClassLoaderPolicy childPolicy = createMockClassLoaderPolicy(); childPolicy.setPathsAndPackageNames(MockLoader.class, Loader.class); childPolicy.setImportAll(true); ClassLoader classLoader = system.registerClassLoaderPolicy(child, childPolicy); assertLoadClass(MockLoader.class, classLoader, parentClassLoader); assertLoadClass(MockLoader.class, classLoader, parentClassLoader); } public void testHierarchyBeforeNotFound() throws Exception { ClassLoaderSystem system = createClassLoaderSystem(); ClassLoaderDomain parent = system.createAndRegisterDomain("parent", ParentPolicy.BEFORE_BUT_JAVA_ONLY); MockClassLoaderPolicy parentPolicy = createMockClassLoaderPolicy(); parentPolicy.setImportAll(true); ClassLoader parentClassLoader = system.registerClassLoaderPolicy(parent, parentPolicy); Loader parentLoader = new ClassLoaderToLoaderAdapter(parentClassLoader); ClassLoaderDomain child = system.createAndRegisterDomain("child", ParentPolicy.BEFORE, parentLoader); MockClassLoaderPolicy childPolicy = createMockClassLoaderPolicy(); childPolicy.setPathsAndPackageNames(MockLoader.class, Loader.class); childPolicy.setImportAll(true); ClassLoader classLoader = system.registerClassLoaderPolicy(child, childPolicy); assertLoadClass(MockLoader.class, classLoader); assertLoadClass(MockLoader.class, classLoader); } public void testHierarchyAfterNotReached() throws Exception { ClassLoaderSystem system = createClassLoaderSystem(); ClassLoaderDomain parent = system.createAndRegisterDomain("parent", ParentPolicy.BEFORE_BUT_JAVA_ONLY); MockClassLoaderPolicy parentPolicy = createMockClassLoaderPolicy(); parentPolicy.setPathsAndPackageNames(MockLoader.class, Loader.class); parentPolicy.setImportAll(true); ClassLoader parentClassLoader = system.registerClassLoaderPolicy(parent, parentPolicy); Loader parentLoader = new ClassLoaderToLoaderAdapter(parentClassLoader); ClassLoaderDomain child = system.createAndRegisterDomain("child", ParentPolicy.AFTER_BUT_JAVA_BEFORE, parentLoader); MockClassLoaderPolicy childPolicy = createMockClassLoaderPolicy(); childPolicy.setPathsAndPackageNames(MockLoader.class, Loader.class); childPolicy.setImportAll(true); ClassLoader classLoader = system.registerClassLoaderPolicy(child, childPolicy); assertLoadClass(MockLoader.class, classLoader); assertLoadClass(MockLoader.class, classLoader); } public void testHierarchyAfterReached() throws Exception { ClassLoaderSystem system = createClassLoaderSystem(); ClassLoaderDomain parent = system.createAndRegisterDomain("parent", ParentPolicy.BEFORE_BUT_JAVA_ONLY); MockClassLoaderPolicy parentPolicy = createMockClassLoaderPolicy(); parentPolicy.setPathsAndPackageNames(MockLoader.class, Loader.class); parentPolicy.setImportAll(true); ClassLoader parentClassLoader = system.registerClassLoaderPolicy(parent, parentPolicy); Loader parentLoader = new ClassLoaderToLoaderAdapter(parentClassLoader); ClassLoaderDomain child = system.createAndRegisterDomain("child", ParentPolicy.AFTER_BUT_JAVA_BEFORE, parentLoader); MockClassLoaderPolicy childPolicy = createMockClassLoaderPolicy(); childPolicy.setImportAll(true); ClassLoader classLoader = system.registerClassLoaderPolicy(child, childPolicy); assertLoadClass(MockLoader.class, classLoader, parentClassLoader); assertLoadClass(MockLoader.class, classLoader, parentClassLoader); } public void testHierarchyFiltered() throws Exception { ClassLoaderSystem system = createClassLoaderSystem(); NoMatchClassFilter filter = new NoMatchClassFilter(MockLoader.class); ParentPolicy pp = new ParentPolicy(filter, ClassFilter.NOTHING); ClassLoaderDomain parent = system.createAndRegisterDomain("parent", ParentPolicy.BEFORE_BUT_JAVA_ONLY); MockClassLoaderPolicy parentPolicy = createMockClassLoaderPolicy(); parentPolicy.setPathsAndPackageNames(MockLoader.class, Loader.class); parentPolicy.setImportAll(true); ClassLoader parentClassLoader = system.registerClassLoaderPolicy(parent, parentPolicy); Loader parentLoader = new ClassLoaderToLoaderAdapter(parentClassLoader); ClassLoaderDomain child = system.createAndRegisterDomain("child", pp, parentLoader); MockClassLoaderPolicy childPolicy = createMockClassLoaderPolicy(); childPolicy.setPathsAndPackageNames(MockLoader.class, Loader.class); childPolicy.setImportAll(true); ClassLoader classLoader = system.registerClassLoaderPolicy(child, childPolicy); assertLoadClass(MockLoader.class, classLoader); assertTrue("Should have been filtered", filter.filtered); assertLoadClass(MockLoader.class, classLoader); } public void testHierarchyBeforeFind() throws Exception { ClassLoaderSystem system = createClassLoaderSystem(); ClassLoaderDomain parent = system.createAndRegisterDomain("parent", ParentPolicy.BEFORE_BUT_JAVA_ONLY); MockClassLoaderPolicy parentPolicy = createMockClassLoaderPolicy(); parentPolicy.setPathsAndPackageNames(MockLoader.class, Loader.class); parentPolicy.setImportAll(true); ClassLoader parentClassLoader = system.registerClassLoaderPolicy(parent, parentPolicy); Loader parentLoader = new ClassLoaderToLoaderAdapter(parentClassLoader); ClassLoaderDomain child = system.createAndRegisterDomain("child", ParentPolicy.BEFORE, parentLoader); child.setUseLoadClassForParent(false); MockClassLoaderPolicy childPolicy = createMockClassLoaderPolicy(); childPolicy.setPathsAndPackageNames(MockLoader.class, Loader.class); childPolicy.setImportAll(true); ClassLoader classLoader = system.registerClassLoaderPolicy(child, childPolicy); assertLoadClass(MockLoader.class, classLoader, parentClassLoader); assertLoadClass(MockLoader.class, classLoader, parentClassLoader); } public void testHierarchyBeforeNotFoundFind() throws Exception { ClassLoaderSystem system = createClassLoaderSystem(); ClassLoaderDomain parent = system.createAndRegisterDomain("parent", ParentPolicy.BEFORE_BUT_JAVA_ONLY); MockClassLoaderPolicy parentPolicy = createMockClassLoaderPolicy(); parentPolicy.setImportAll(true); ClassLoader parentClassLoader = system.registerClassLoaderPolicy(parent, parentPolicy); Loader parentLoader = new ClassLoaderToLoaderAdapter(parentClassLoader); ClassLoaderDomain child = system.createAndRegisterDomain("child", ParentPolicy.BEFORE, parentLoader); child.setUseLoadClassForParent(false); MockClassLoaderPolicy childPolicy = createMockClassLoaderPolicy(); childPolicy.setPathsAndPackageNames(MockLoader.class, Loader.class); childPolicy.setImportAll(true); ClassLoader classLoader = system.registerClassLoaderPolicy(child, childPolicy); assertLoadClass(MockLoader.class, classLoader); assertLoadClass(MockLoader.class, classLoader); } public void testHierarchyAfterNotReachedFind() throws Exception { ClassLoaderSystem system = createClassLoaderSystem(); ClassLoaderDomain parent = system.createAndRegisterDomain("parent", ParentPolicy.BEFORE_BUT_JAVA_ONLY); MockClassLoaderPolicy parentPolicy = createMockClassLoaderPolicy(); parentPolicy.setPathsAndPackageNames(MockLoader.class, Loader.class); parentPolicy.setImportAll(true); ClassLoader parentClassLoader = system.registerClassLoaderPolicy(parent, parentPolicy); Loader parentLoader = new ClassLoaderToLoaderAdapter(parentClassLoader); ClassLoaderDomain child = system.createAndRegisterDomain("child", ParentPolicy.AFTER_BUT_JAVA_BEFORE, parentLoader); child.setUseLoadClassForParent(false); MockClassLoaderPolicy childPolicy = createMockClassLoaderPolicy(); childPolicy.setPathsAndPackageNames(MockLoader.class, Loader.class); childPolicy.setImportAll(true); ClassLoader classLoader = system.registerClassLoaderPolicy(child, childPolicy); assertLoadClass(MockLoader.class, classLoader); assertLoadClass(MockLoader.class, classLoader); } public void testHierarchyAfterReachedFind() throws Exception { ClassLoaderSystem system = createClassLoaderSystem(); ClassLoaderDomain parent = system.createAndRegisterDomain("parent", ParentPolicy.BEFORE_BUT_JAVA_ONLY); MockClassLoaderPolicy parentPolicy = createMockClassLoaderPolicy(); parentPolicy.setPathsAndPackageNames(MockLoader.class, Loader.class); parentPolicy.setImportAll(true); ClassLoader parentClassLoader = system.registerClassLoaderPolicy(parent, parentPolicy); Loader parentLoader = new ClassLoaderToLoaderAdapter(parentClassLoader); ClassLoaderDomain child = system.createAndRegisterDomain("child", ParentPolicy.AFTER_BUT_JAVA_BEFORE, parentLoader); child.setUseLoadClassForParent(false); MockClassLoaderPolicy childPolicy = createMockClassLoaderPolicy(); childPolicy.setImportAll(true); ClassLoader classLoader = system.registerClassLoaderPolicy(child, childPolicy); assertLoadClass(MockLoader.class, classLoader, parentClassLoader); assertLoadClass(MockLoader.class, classLoader, parentClassLoader); } public void testHierarchyFilteredFind() throws Exception { ClassLoaderSystem system = createClassLoaderSystem(); NoMatchClassFilter filter = new NoMatchClassFilter(MockLoader.class); ParentPolicy pp = new ParentPolicy(filter, ClassFilter.NOTHING); ClassLoaderDomain parent = system.createAndRegisterDomain("parent", ParentPolicy.BEFORE_BUT_JAVA_ONLY); MockClassLoaderPolicy parentPolicy = createMockClassLoaderPolicy(); parentPolicy.setPathsAndPackageNames(MockLoader.class, Loader.class); parentPolicy.setImportAll(true); ClassLoader parentClassLoader = system.registerClassLoaderPolicy(parent, parentPolicy); Loader parentLoader = new ClassLoaderToLoaderAdapter(parentClassLoader); ClassLoaderDomain child = system.createAndRegisterDomain("child", pp, parentLoader); child.setUseLoadClassForParent(false); MockClassLoaderPolicy childPolicy = createMockClassLoaderPolicy(); childPolicy.setPathsAndPackageNames(MockLoader.class, Loader.class); childPolicy.setImportAll(true); ClassLoader classLoader = system.registerClassLoaderPolicy(child, childPolicy); assertLoadClass(MockLoader.class, classLoader); assertTrue("Should have been filtered", filter.filtered); assertLoadClass(MockLoader.class, classLoader); } } ././@LongLink0000000000000000000000000000020700000000000011564 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloader/src/test/java/org/jboss/test/classloader/domain/test/ParentPolicyUnitTestCase.javalibjboss-classloader-java-2.0.6.GA.orig/classloader/src/test/java/org/jboss/test/classloader/domain/0000644000175000017500000003473611113041551033345 0ustar twernertwerner/* * JBoss, Home of Professional Open Source. * Copyright 2007, Red Hat Middleware LLC, and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.test.classloader.domain.test; import javax.swing.MutableComboBoxModel; import junit.framework.Test; import org.jboss.classloader.spi.ClassLoaderDomain; import org.jboss.classloader.spi.ClassLoaderSystem; import org.jboss.classloader.spi.ParentPolicy; import org.jboss.classloader.spi.filter.ClassFilter; import org.jboss.classloader.spi.filter.PackageClassFilter; import org.jboss.classloader.test.support.MockClassLoaderPolicy; import org.jboss.test.classloader.AbstractClassLoaderTestWithSecurity; import org.jboss.test.classloader.domain.support.MatchClassFilter; import org.jboss.test.classloader.domain.support.NoMatchClassFilter; /** * ParentPolicyUnitTestCase. * * @author Adrian Brock * @version $Revision: 1.1 $ */ public class ParentPolicyUnitTestCase extends AbstractClassLoaderTestWithSecurity { public static Test suite() { return suite(ParentPolicyUnitTestCase.class); } public ParentPolicyUnitTestCase(String name) { super(name); } public void testNoParentLoadsFromJBossClassLoadersClassLoader() throws Exception { ClassLoaderSystem system = createClassLoaderSystem(); ClassLoaderDomain domain = system.createAndRegisterDomain("test", ParentPolicy.BEFORE, null); MockClassLoaderPolicy policy = createMockClassLoaderPolicy(); ClassLoader classLoader = system.registerClassLoaderPolicy(domain, policy); assertLoadClass(Object.class, classLoader, null, true); assertPackage(ClassLoaderDomain.class, classLoader); assertLoadClass(ClassLoaderDomain.class, classLoader, null, true); assertPackage(ClassLoaderDomain.class, classLoader); } public void testBefore() throws Exception { ClassLoaderSystem system = createClassLoaderSystem(); ClassLoaderDomain domain = system.createAndRegisterDomain("test", ParentPolicy.BEFORE, null); MockClassLoaderPolicy policy = createMockClassLoaderPolicy(); policy.setPathsAndPackageNames(ClassLoaderDomain.class); ClassLoader classLoader = system.registerClassLoaderPolicy(domain, policy); assertLoadClass(Object.class, classLoader, null, true); assertLoadClass(ClassLoaderDomain.class, classLoader, null, true); assertPackage(ClassLoaderDomain.class, classLoader); } public void testBeforeButJavaOnly() throws Exception { ClassLoaderSystem system = createClassLoaderSystem(); ClassLoaderDomain domain = system.createAndRegisterDomain("test", ParentPolicy.BEFORE_BUT_JAVA_ONLY, null); MockClassLoaderPolicy policy = createMockClassLoaderPolicy(); policy.setPathsAndPackageNames(ClassLoaderDomain.class); ClassLoader classLoader = system.registerClassLoaderPolicy(domain, policy); assertLoadClass(Object.class, classLoader, null, true); assertLoadClass(ClassLoaderDomain.class, classLoader); assertPackage(ClassLoaderDomain.class, classLoader, policy); } public void testBeforeButJavaOnlyNotFound() throws Exception { ClassLoaderSystem system = createClassLoaderSystem(); ClassLoaderDomain domain = system.createAndRegisterDomain("test", ParentPolicy.BEFORE_BUT_JAVA_ONLY, null); MockClassLoaderPolicy policy = createMockClassLoaderPolicy(); ClassLoader classLoader = system.registerClassLoaderPolicy(domain, policy); assertLoadClass(Object.class, classLoader, null, true); assertLoadClassFail(ClassLoaderDomain.class, classLoader); } public void testAfterNotReached() throws Exception { ClassLoaderSystem system = createClassLoaderSystem(); ClassLoaderDomain domain = system.createAndRegisterDomain("test", ParentPolicy.AFTER, null); MockClassLoaderPolicy policy = createMockClassLoaderPolicy(); policy.setPathsAndPackageNames(ClassLoaderDomain.class); ClassLoader classLoader = system.registerClassLoaderPolicy(domain, policy); assertLoadClass(Object.class, classLoader, null, true); assertLoadClass(ClassLoaderDomain.class, classLoader); assertPackage(ClassLoaderDomain.class, classLoader); } public void testAfterReached() throws Exception { ClassLoaderSystem system = createClassLoaderSystem(); ClassLoaderDomain domain = system.createAndRegisterDomain("test", ParentPolicy.AFTER, null); MockClassLoaderPolicy policy = createMockClassLoaderPolicy(); ClassLoader classLoader = system.registerClassLoaderPolicy(domain, policy); assertLoadClass(Object.class, classLoader, null, true); assertLoadClass(ClassLoaderDomain.class, classLoader, null, true); assertPackage(ClassLoaderDomain.class, classLoader); } public void testAfterButJavaBeforeNotReached() throws Exception { ClassLoaderSystem system = createClassLoaderSystem(); ClassLoaderDomain domain = system.createAndRegisterDomain("test", ParentPolicy.AFTER_BUT_JAVA_BEFORE, null); MockClassLoaderPolicy policy = createMockClassLoaderPolicy(); policy.setPathsAndPackageNames(ClassLoaderDomain.class, MutableComboBoxModel.class); ClassLoader classLoader = system.registerClassLoaderPolicy(domain, policy); assertLoadClass(Object.class, classLoader, null, true); assertLoadClass(MutableComboBoxModel.class, classLoader, null, true); assertLoadClass(ClassLoaderDomain.class, classLoader); assertPackage(ClassLoaderDomain.class, classLoader); } public void testAfterButJavaBeforeReached() throws Exception { ClassLoaderSystem system = createClassLoaderSystem(); ClassLoaderDomain domain = system.createAndRegisterDomain("test", ParentPolicy.AFTER_BUT_JAVA_BEFORE, null); MockClassLoaderPolicy policy = createMockClassLoaderPolicy(); policy.setPathsAndPackageNames(MutableComboBoxModel.class); ClassLoader classLoader = system.registerClassLoaderPolicy(domain, policy); assertLoadClass(Object.class, classLoader, null, true); assertLoadClass(MutableComboBoxModel.class, classLoader, null, true); assertLoadClass(ClassLoaderDomain.class, classLoader, null, true); assertPackage(ClassLoaderDomain.class, classLoader); } public void testAfterButOnlyJavaBeforeNotReached() throws Exception { ClassLoaderSystem system = createClassLoaderSystem(); ClassLoaderDomain domain = system.createAndRegisterDomain("test", ParentPolicy.AFTER_BUT_ONLY_JAVA_BEFORE, null); MockClassLoaderPolicy policy = createMockClassLoaderPolicy(); policy.setPathsAndPackageNames(ClassLoaderDomain.class); ClassLoader classLoader = system.registerClassLoaderPolicy(domain, policy); assertLoadClass(Object.class, classLoader, null, true); assertLoadClass(MutableComboBoxModel.class, classLoader, null, true); assertLoadClass(ClassLoaderDomain.class, classLoader); assertPackage(ClassLoaderDomain.class, classLoader); } public void testAfterButOnlyJavaBeforeReached() throws Exception { ClassLoaderSystem system = createClassLoaderSystem(); ClassLoaderDomain domain = system.createAndRegisterDomain("test", ParentPolicy.AFTER_BUT_ONLY_JAVA_BEFORE, null); MockClassLoaderPolicy policy = createMockClassLoaderPolicy(); policy.setPathsAndPackageNames(MutableComboBoxModel.class); ClassLoader classLoader = system.registerClassLoaderPolicy(domain, policy); assertLoadClass(Object.class, classLoader, null, true); assertLoadClass(MutableComboBoxModel.class, classLoader, classLoader); assertLoadClass(ClassLoaderDomain.class, classLoader, null, true); assertPackage(ClassLoaderDomain.class, classLoader); } public void testBeforeFilteredNotMatched() throws Exception { ClassLoaderSystem system = createClassLoaderSystem(); NoMatchClassFilter filter = new NoMatchClassFilter(ClassLoaderDomain.class); ParentPolicy parentPolicy = new ParentPolicy(filter, ClassFilter.NOTHING); ClassLoaderDomain domain = system.createAndRegisterDomain("test", parentPolicy, null); MockClassLoaderPolicy policy = createMockClassLoaderPolicy(); policy.setPathsAndPackageNames(ClassLoaderDomain.class); ClassLoader classLoader = system.registerClassLoaderPolicy(domain, policy); assertLoadClass(Object.class, classLoader, null, true); assertLoadClass(ClassLoaderDomain.class, classLoader); assertTrue("Should have been filtered", filter.filtered); assertPackage(ClassLoaderDomain.class, classLoader, policy); } public void testBeforeFilteredMatched() throws Exception { ClassLoaderSystem system = createClassLoaderSystem(); MatchClassFilter filter = new MatchClassFilter(ClassLoaderDomain.class); ParentPolicy parentPolicy = new ParentPolicy(filter, ClassFilter.NOTHING); ClassLoaderDomain domain = system.createAndRegisterDomain("test", parentPolicy, null); MockClassLoaderPolicy policy = createMockClassLoaderPolicy(); policy.setPathsAndPackageNames(ClassLoaderDomain.class); ClassLoader classLoader = system.registerClassLoaderPolicy(domain, policy); assertLoadClass(Object.class, classLoader, null, true); assertLoadClass(ClassLoaderDomain.class, classLoader, null, true); assertTrue("Should have been filtered", filter.filtered); assertPackage(ClassLoaderDomain.class, classLoader); } public void testAfterFilteredNotReached() throws Exception { ClassLoaderSystem system = createClassLoaderSystem(); NoMatchClassFilter filter = new NoMatchClassFilter(ClassLoaderDomain.class); ParentPolicy parentPolicy = new ParentPolicy(ClassFilter.JAVA_ONLY, filter); ClassLoaderDomain domain = system.createAndRegisterDomain("test", parentPolicy, null); MockClassLoaderPolicy policy = createMockClassLoaderPolicy(); policy.setPathsAndPackageNames(ClassLoaderDomain.class); ClassLoader classLoader = system.registerClassLoaderPolicy(domain, policy); assertLoadClass(Object.class, classLoader, null, true); assertLoadClass(ClassLoaderDomain.class, classLoader); assertFalse("Should NOT have been filtered", filter.filtered); assertPackage(ClassLoaderDomain.class, classLoader, policy); } public void testAfterFilteredReachedNotMatched() throws Exception { ClassLoaderSystem system = createClassLoaderSystem(); NoMatchClassFilter filter = new NoMatchClassFilter(ClassLoaderDomain.class); ParentPolicy parentPolicy = new ParentPolicy(ClassFilter.JAVA_ONLY, filter); ClassLoaderDomain domain = system.createAndRegisterDomain("test", parentPolicy, null); MockClassLoaderPolicy policy = createMockClassLoaderPolicy(); ClassLoader classLoader = system.registerClassLoaderPolicy(domain, policy); assertLoadClass(Object.class, classLoader, null, true); assertLoadClassFail(ClassLoaderDomain.class, classLoader); assertTrue("Should have been filtered", filter.filtered); } public void testAfterFilteredReachedMatched() throws Exception { ClassLoaderSystem system = createClassLoaderSystem(); MatchClassFilter filter = new MatchClassFilter(ClassLoaderDomain.class); ParentPolicy parentPolicy = new ParentPolicy(ClassFilter.JAVA_ONLY, filter); ClassLoaderDomain domain = system.createAndRegisterDomain("test", parentPolicy, null); MockClassLoaderPolicy policy = createMockClassLoaderPolicy(); ClassLoader classLoader = system.registerClassLoaderPolicy(domain, policy); assertLoadClass(Object.class, classLoader, null, true); assertLoadClass(ClassLoaderDomain.class, classLoader, null, true); assertTrue("Should have been filtered", filter.filtered); assertPackage(ClassLoaderDomain.class, classLoader); } public void testNoMatchBeforeAndAfter() throws Exception { ClassLoaderSystem system = createClassLoaderSystem(); ParentPolicy parentPolicy = new ParentPolicy(ClassFilter.NOTHING, ClassFilter.NOTHING); ClassLoaderDomain domain = system.createAndRegisterDomain("test", parentPolicy, null); MockClassLoaderPolicy policy = createMockClassLoaderPolicy(); ClassLoader classLoader = system.registerClassLoaderPolicy(domain, policy); assertLoadClassFail(Object.class, classLoader); } public void testPackageFilterNoJava() throws Exception { ClassLoaderSystem system = createClassLoaderSystem(); PackageClassFilter filter = PackageClassFilter.createPackageClassFilter("dummy"); ParentPolicy parentPolicy = new ParentPolicy(filter, ClassFilter.NOTHING); ClassLoaderDomain domain = system.createAndRegisterDomain("test", parentPolicy, null); MockClassLoaderPolicy policy = createMockClassLoaderPolicy(); ClassLoader classLoader = system.registerClassLoaderPolicy(domain, policy); assertLoadClassFail(Object.class, classLoader); } public void testPackageFilterIncludeJava() throws Exception { ClassLoaderSystem system = createClassLoaderSystem(); PackageClassFilter filter = PackageClassFilter.createPackageClassFilter("dummy"); filter.setIncludeJava(true); ParentPolicy parentPolicy = new ParentPolicy(filter, ClassFilter.NOTHING); ClassLoaderDomain domain = system.createAndRegisterDomain("test", parentPolicy, null); MockClassLoaderPolicy policy = createMockClassLoaderPolicy(); ClassLoader classLoader = system.registerClassLoaderPolicy(domain, policy); assertLoadClass(Object.class, classLoader, null, true); } } ././@LongLink0000000000000000000000000000021500000000000011563 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloader/src/test/java/org/jboss/test/classloader/domain/test/CustomParentLoaderUnitTestCase.javalibjboss-classloader-java-2.0.6.GA.orig/classloader/src/test/java/org/jboss/test/classloader/domain/0000644000175000017500000002463111032646441033347 0ustar twernertwerner/* * JBoss, Home of Professional Open Source. * Copyright 2007, Red Hat Middleware LLC, and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.test.classloader.domain.test; import java.util.HashSet; import java.util.Set; import javax.management.MBeanRegistration; import junit.framework.Test; import org.jboss.classloader.plugins.ClassLoaderUtils; import org.jboss.classloader.spi.ClassLoaderDomain; import org.jboss.classloader.spi.ClassLoaderDomainMBean; import org.jboss.classloader.spi.ClassLoaderSystem; import org.jboss.classloader.spi.Loader; import org.jboss.classloader.spi.ParentPolicy; import org.jboss.classloader.spi.base.BaseClassLoaderDomain; import org.jboss.classloader.spi.filter.ClassFilter; import org.jboss.classloader.test.support.MockClassLoaderPolicy; import org.jboss.test.classloader.AbstractClassLoaderTestWithSecurity; import org.jboss.test.classloader.domain.support.MockLoader; import org.jboss.test.classloader.domain.support.NoMatchClassFilter; /** * ParentPolicyUnitTestCase. * * @author Adrian Brock * @version $Revision: 1.1 $ */ public class CustomParentLoaderUnitTestCase extends AbstractClassLoaderTestWithSecurity { public static Test suite() { return suite(CustomParentLoaderUnitTestCase.class); } public CustomParentLoaderUnitTestCase(String name) { super(name); } public void testCustomLoaderBefore() throws Exception { ClassLoaderSystem system = createClassLoaderSystem(); MockLoader loader = new MockLoader(); ClassLoaderDomain domain = system.createAndRegisterDomain("test", ParentPolicy.BEFORE, loader); MockClassLoaderPolicy policy = createMockClassLoaderPolicy(); policy.setPathsAndPackageNames(MockLoader.class); ClassLoader classLoader = system.registerClassLoaderPolicy(domain, policy); assertLoadClass(MockLoader.class, classLoader, null, true); checkLoadClass(loader, MockLoader.class); } public void testCustomLoaderBeforeNotFound() throws Exception { ClassLoaderSystem system = createClassLoaderSystem(); MockLoader loader = new MockLoader(false); ClassLoaderDomain domain = system.createAndRegisterDomain("test", ParentPolicy.BEFORE, loader); MockClassLoaderPolicy policy = createMockClassLoaderPolicy(); policy.setPathsAndPackageNames(ClassLoaderDomain.class); ClassLoader classLoader = system.registerClassLoaderPolicy(domain, policy); assertLoadClass(ClassLoaderDomain.class, classLoader); checkLoadClassAttempted(loader, ClassLoaderDomain.class); } public void testCustomLoaderAfterNotReached() throws Exception { ClassLoaderSystem system = createClassLoaderSystem(); MockLoader loader = new MockLoader(); ClassLoaderDomain domain = system.createAndRegisterDomain("test", ParentPolicy.AFTER, loader); MockClassLoaderPolicy policy = createMockClassLoaderPolicy(); policy.setPathsAndPackageNames(MockLoader.class, Loader.class); ClassLoader classLoader = system.registerClassLoaderPolicy(domain, policy); assertLoadClass(MockLoader.class, classLoader); checkLoadClassNotAttempted(loader, MockLoader.class); } public void testCustomLoaderAfterReached() throws Exception { ClassLoaderSystem system = createClassLoaderSystem(); MockLoader loader = new MockLoader(); ClassLoaderDomain domain = system.createAndRegisterDomain("test", ParentPolicy.AFTER, loader); MockClassLoaderPolicy policy = createMockClassLoaderPolicy(); ClassLoader classLoader = system.registerClassLoaderPolicy(domain, policy); assertLoadClass(MockLoader.class, classLoader, null, true); checkLoadClass(loader, MockLoader.class); } public void testCustomLoaderFiltered() throws Exception { ClassLoaderSystem system = createClassLoaderSystem(); MockLoader loader = new MockLoader(); NoMatchClassFilter filter = new NoMatchClassFilter(MockLoader.class); ParentPolicy parentPolicy = new ParentPolicy(filter, ClassFilter.NOTHING); ClassLoaderDomain domain = system.createAndRegisterDomain("test", parentPolicy, loader); MockClassLoaderPolicy policy = createMockClassLoaderPolicy(); policy.setPathsAndPackageNames(MockLoader.class, Loader.class); ClassLoader classLoader = system.registerClassLoaderPolicy(domain, policy); assertLoadClass(MockLoader.class, classLoader); checkLoadClassNotAttempted(loader, MockLoader.class); assertTrue("Should have been filtered", filter.filtered); } public void testCustomLoaderBeforeGetResource() throws Exception { ClassLoaderSystem system = createClassLoaderSystem(); MockLoader loader = new MockLoader(); ClassLoaderDomain domain = system.createAndRegisterDomain("test", ParentPolicy.BEFORE, loader); domain.setUseLoadClassForParent(false); MockClassLoaderPolicy policy = createMockClassLoaderPolicy(); policy.setPathsAndPackageNames(MockLoader.class); ClassLoader classLoader = system.registerClassLoaderPolicy(domain, policy); assertLoadClass(MockLoader.class, classLoader, null, true); checkGetResource(loader, MockLoader.class); checkLoadClass(loader, MockLoader.class); } public void testCustomLoaderBeforeNotFoundGetResource() throws Exception { ClassLoaderSystem system = createClassLoaderSystem(); MockLoader loader = new MockLoader(); ClassLoaderDomain domain = system.createAndRegisterDomain("test", ParentPolicy.BEFORE, loader); domain.setUseLoadClassForParent(false); MockClassLoaderPolicy policy = createMockClassLoaderPolicy(); policy.setPathsAndPackageNames(ClassLoaderDomain.class); ClassLoader classLoader = system.registerClassLoaderPolicy(domain, policy); assertLoadClass(ClassLoaderDomain.class, classLoader); checkGetResource(loader, ClassLoaderDomain.class, BaseClassLoaderDomain.class, ClassLoaderDomainMBean.class, MBeanRegistration.class, Loader.class, Object.class); checkLoadClass(loader); } public void testCustomLoaderAfterNotReachedGetResource() throws Exception { ClassLoaderSystem system = createClassLoaderSystem(); MockLoader loader = new MockLoader(); ClassLoaderDomain domain = system.createAndRegisterDomain("test", ParentPolicy.AFTER, loader); domain.setUseLoadClassForParent(false); MockClassLoaderPolicy policy = createMockClassLoaderPolicy(); policy.setPathsAndPackageNames(MockLoader.class, Loader.class); ClassLoader classLoader = system.registerClassLoaderPolicy(domain, policy); assertLoadClass(MockLoader.class, classLoader); checkGetResource(loader); checkLoadClass(loader); } public void testCustomLoaderAfterReachedGetResource() throws Exception { ClassLoaderSystem system = createClassLoaderSystem(); MockLoader loader = new MockLoader(); ClassLoaderDomain domain = system.createAndRegisterDomain("test", ParentPolicy.AFTER, loader); domain.setUseLoadClassForParent(false); MockClassLoaderPolicy policy = createMockClassLoaderPolicy(); ClassLoader classLoader = system.registerClassLoaderPolicy(domain, policy); assertLoadClass(MockLoader.class, classLoader, null, true); checkGetResource(loader, MockLoader.class); checkLoadClass(loader, MockLoader.class); } public void testCustomLoaderFilteredGetResource() throws Exception { ClassLoaderSystem system = createClassLoaderSystem(); MockLoader loader = new MockLoader(); NoMatchClassFilter filter = new NoMatchClassFilter(MockLoader.class); ParentPolicy parentPolicy = new ParentPolicy(filter, ClassFilter.NOTHING); ClassLoaderDomain domain = system.createAndRegisterDomain("test", parentPolicy, loader); domain.setUseLoadClassForParent(false); MockClassLoaderPolicy policy = createMockClassLoaderPolicy(); policy.setPathsAndPackageNames(MockLoader.class, Loader.class); ClassLoader classLoader = system.registerClassLoaderPolicy(domain, policy); assertLoadClass(MockLoader.class, classLoader); checkGetResource(loader); checkLoadClass(loader); assertTrue("Should have been filtered", filter.filtered); } protected void checkGetResource(MockLoader loader, Class... classes) { if (classes == null || classes.length == 0) { assertEmpty(loader.getResources); return; } Set resourcePaths = new HashSet(); for (Class clazz : classes) resourcePaths.add(ClassLoaderUtils.classNameToPath(clazz.getName())); assertEquals(resourcePaths, loader.getResource); } protected void checkLoadClass(MockLoader loader, Class... classes) { if (classes == null || classes.length == 0) { assertEmpty(loader.loadClass); return; } Set classNames = new HashSet(); for (Class clazz : classes) classNames.add(clazz.getName()); assertEquals(classNames, loader.loadClass); } protected void checkLoadClassNotAttempted(MockLoader loader, Class clazz) { assertFalse("Didn't expect " + clazz.getName() + " in " + loader.loadClass, loader.loadClass.contains(clazz.getName())); } protected void checkLoadClassAttempted(MockLoader loader, Class clazz) { assertTrue("Expected " + clazz.getName() + " in " + loader.loadClass, loader.loadClass.contains(clazz.getName())); } } ././@LongLink0000000000000000000000000000015500000000000011566 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloader/src/test/java/org/jboss/test/classloader/domain/support/libjboss-classloader-java-2.0.6.GA.orig/classloader/src/test/java/org/jboss/test/classloader/domain/0000755000175000017500000000000011620043421033327 5ustar twernertwerner././@LongLink0000000000000000000000000000020200000000000011557 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloader/src/test/java/org/jboss/test/classloader/domain/support/MatchClassFilter.javalibjboss-classloader-java-2.0.6.GA.orig/classloader/src/test/java/org/jboss/test/classloader/domain/0000644000175000017500000000404010741370313033335 0ustar twernertwerner/* * JBoss, Home of Professional Open Source. * Copyright 2007, Red Hat Middleware LLC, and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.test.classloader.domain.support; import org.jboss.classloader.plugins.ClassLoaderUtils; import org.jboss.classloader.spi.filter.ClassFilter; /** * MatchClassFilter. * * @author Adrian Brock * @version $Revision: 1.1 $ */ public class MatchClassFilter implements ClassFilter { String className; public boolean filtered = false; public MatchClassFilter(Class clazz) { this.className = clazz.getName(); } public boolean matchesClassName(String className) { if (this.className.equals(className)) filtered = true; return true; } public boolean matchesResourcePath(String resourcePath) { if (ClassLoaderUtils.classNameToPath(this.className).equals(resourcePath)) filtered = true; return true; } public boolean matchesPackageName(String packageName) { if (ClassLoaderUtils.getClassPackageName(this.className).equals(packageName)) filtered = true; return true; } } ././@LongLink0000000000000000000000000000020400000000000011561 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloader/src/test/java/org/jboss/test/classloader/domain/support/NoMatchClassFilter.javalibjboss-classloader-java-2.0.6.GA.orig/classloader/src/test/java/org/jboss/test/classloader/domain/0000644000175000017500000000416110741370313033341 0ustar twernertwerner/* * JBoss, Home of Professional Open Source. * Copyright 2007, Red Hat Middleware LLC, and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.test.classloader.domain.support; import org.jboss.classloader.plugins.ClassLoaderUtils; import org.jboss.classloader.spi.filter.ClassFilter; /** * NoMatchClassFilter. * * @author Adrian Brock * @version $Revision: 1.1 $ */ public class NoMatchClassFilter implements ClassFilter { String className; public boolean filtered = false; public NoMatchClassFilter(Class clazz) { this.className = clazz.getName(); } public boolean matchesClassName(String className) { if (this.className.equals(className)) { filtered = true; return false; } return true; } public boolean matchesResourcePath(String resourcePath) { if (ClassLoaderUtils.classNameToPath(this.className).equals(resourcePath)) { filtered = true; return false; } return true; } public boolean matchesPackageName(String packageName) { if (ClassLoaderUtils.getClassPackageName(this.className).equals(packageName)) return false; return true; } } ././@LongLink0000000000000000000000000000017400000000000011567 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloader/src/test/java/org/jboss/test/classloader/domain/support/MockLoader.javalibjboss-classloader-java-2.0.6.GA.orig/classloader/src/test/java/org/jboss/test/classloader/domain/0000644000175000017500000000462411032646441033347 0ustar twernertwerner/* * JBoss, Home of Professional Open Source. * Copyright 2007, Red Hat Middleware LLC, and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.test.classloader.domain.support; import java.io.IOException; import java.net.URL; import java.util.HashSet; import java.util.Set; import org.jboss.classloader.spi.Loader; /** * CustomLoader. * * @author Adrian Brock * @version $Revision: 1.1 $ */ public class MockLoader implements Loader { private boolean doLoadClass; public Set getResource = new HashSet(); public Set getResources = new HashSet(); public Set loadClass = new HashSet(); public MockLoader() { this(true); } public MockLoader(boolean doLoadClass) { this.doLoadClass = doLoadClass; } public URL getResource(String name) { getResource.add(name); return getClass().getClassLoader().getResource(name); } public void getResources(String name, Set urls) throws IOException { // Nothing } public Class loadClass(String className) { loadClass.add(className); if (doLoadClass == false) return null; try { return getClass().getClassLoader().loadClass(className); } catch (ClassNotFoundException e) { return null; } } public Package getPackage(String name) { return null; } public void getPackages(Set packages) { // Nothing } } ././@LongLink0000000000000000000000000000015000000000000011561 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloader/src/test/java/org/jboss/test/classloader/bootstrap/libjboss-classloader-java-2.0.6.GA.orig/classloader/src/test/java/org/jboss/test/classloader/bootstr0000755000175000017500000000000011620043421033475 5ustar twernertwerner././@LongLink0000000000000000000000000000015500000000000011566 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloader/src/test/java/org/jboss/test/classloader/bootstrap/test/libjboss-classloader-java-2.0.6.GA.orig/classloader/src/test/java/org/jboss/test/classloader/bootstr0000755000175000017500000000000011620043421033475 5ustar twernertwerner././@LongLink0000000000000000000000000000021700000000000011565 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloader/src/test/java/org/jboss/test/classloader/bootstrap/test/ModifiedBootstrapUnitTestCase.javalibjboss-classloader-java-2.0.6.GA.orig/classloader/src/test/java/org/jboss/test/classloader/bootstr0000644000175000017500000000704310741370313033511 0ustar twernertwerner/* * JBoss, Home of Professional Open Source. * Copyright 2007, Red Hat Middleware LLC, and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.test.classloader.bootstrap.test; import java.lang.reflect.Constructor; import java.lang.reflect.Method; import java.util.List; import javax.naming.Context; import junit.framework.Test; import org.jboss.classloader.spi.ClassLoaderDomain; import org.jboss.classloader.spi.ClassLoaderSystem; import org.jboss.classloader.test.support.MockClassLoaderPolicy; import org.jboss.test.classloader.AbstractClassLoaderTestWithSecurity; import org.jboss.test.classloader.bootstrap.support.TestClass; /** * ModifiedBootstrapUnitTestCase. * * @author Adrian Brock * @version $Revision: 1.1 $ */ public class ModifiedBootstrapUnitTestCase extends AbstractClassLoaderTestWithSecurity { public static Test suite() { return suite(ModifiedBootstrapUnitTestCase.class); } public ModifiedBootstrapUnitTestCase(String name) { super(name); } public void testJavaLangObject() throws Exception { testBootstrapClass(Object.class); } public void testJavaUtilList() throws Exception { testBootstrapClass(List.class); } public void testJavaxNamingContext() throws Exception { testBootstrapClass(Context.class); } public void testClassLoaderDomain() throws Exception { testNotBootstrapClass(ClassLoaderDomain.class); } public void testReflection() throws Exception { ClassLoaderSystem system = createClassLoaderSystemWithModifiedBootstrap(); MockClassLoaderPolicy policy = createMockClassLoaderPolicy(); policy.setPathsAndPackageNames(TestClass.class); ClassLoader classLoader = system.registerClassLoaderPolicy(policy); Class clazz = assertLoadClass(TestClass.class, classLoader); Constructor constructor = clazz.getConstructor((Class[]) null); Object object = constructor.newInstance((Object[]) null); Method method = clazz.getMethod("doSomething", (Class[]) null); Object result = method.invoke(object, (Object[]) null); assertEquals(classLoader, result); } protected void testBootstrapClass(Class clazz) throws Exception { ClassLoader classLoader = createClassLoaderSystemWithModifiedBootstrapAndMockClassLoader(); assertLoadClass(clazz, classLoader, clazz.getClassLoader(), true); } protected void testNotBootstrapClass(Class clazz) throws Exception { ClassLoader classLoader = createClassLoaderSystemWithModifiedBootstrapAndMockClassLoader(); assertLoadClassFail(clazz, classLoader); } } ././@LongLink0000000000000000000000000000017700000000000011572 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloader/src/test/java/org/jboss/test/classloader/bootstrap/BootstrapTestSuite.javalibjboss-classloader-java-2.0.6.GA.orig/classloader/src/test/java/org/jboss/test/classloader/bootstr0000644000175000017500000000354610614350067033520 0ustar twernertwerner/* * JBoss, Home of Professional Open Source. * Copyright 2007, Red Hat Middleware LLC, and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.test.classloader.bootstrap; import junit.framework.Test; import junit.framework.TestSuite; import junit.textui.TestRunner; import org.jboss.test.classloader.bootstrap.test.ModifiedBootstrapUnitTestCase; /** * Bootstrap Test Suite. * * @author Adrian Brock * @version $Revision: 37459 $ */ public class BootstrapTestSuite extends TestSuite { /** * For running the testsuite from the command line * * @param args the command line args */ public static void main(String[] args) { TestRunner.run(suite()); } /** * Create the testsuite * * @return the testsuite */ public static Test suite() { TestSuite suite = new TestSuite("Bootstrap Tests"); suite.addTest(ModifiedBootstrapUnitTestCase.suite()); return suite; } } ././@LongLink0000000000000000000000000000016000000000000011562 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloader/src/test/java/org/jboss/test/classloader/bootstrap/support/libjboss-classloader-java-2.0.6.GA.orig/classloader/src/test/java/org/jboss/test/classloader/bootstr0000755000175000017500000000000011620043421033475 5ustar twernertwerner././@LongLink0000000000000000000000000000017600000000000011571 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloader/src/test/java/org/jboss/test/classloader/bootstrap/support/TestClass.javalibjboss-classloader-java-2.0.6.GA.orig/classloader/src/test/java/org/jboss/test/classloader/bootstr0000644000175000017500000000331210741370313033504 0ustar twernertwerner/* * JBoss, Home of Professional Open Source. * Copyright 2007, Red Hat Middleware LLC, and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.test.classloader.bootstrap.support; import java.lang.reflect.Constructor; import java.lang.reflect.Method; /** * TestClass. * * @author Adrian Brock * @version $Revision: 1.1 $ */ public class TestClass { public Object doSomething() throws Exception { Constructor constructor = getClass().getConstructor((Class[]) null); Object object = constructor.newInstance((Object[]) null); Method method = getClass().getMethod("doSomethingElse", (Class[]) null); return method.invoke(object, (Object[]) null); } public ClassLoader doSomethingElse() { return getClass().getClassLoader(); } } libjboss-classloader-java-2.0.6.GA.orig/classloader/src/test/java/org/jboss/test/classloader/old/0000755000175000017500000000000011620043422032637 5ustar twernertwerner././@LongLink0000000000000000000000000000014700000000000011567 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloader/src/test/java/org/jboss/test/classloader/old/test/libjboss-classloader-java-2.0.6.GA.orig/classloader/src/test/java/org/jboss/test/classloader/old/tes0000755000175000017500000000000011620043422033353 5ustar twernertwerner././@LongLink0000000000000000000000000000021000000000000011556 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloader/src/test/java/org/jboss/test/classloader/old/test/ConcurrentLoaderUnitTestCase.javalibjboss-classloader-java-2.0.6.GA.orig/classloader/src/test/java/org/jboss/test/classloader/old/tes0000644000175000017500000001354010741370313033365 0ustar twernertwerner/* * JBoss, Home of Professional Open Source. * Copyright 2007, Red Hat Middleware LLC, and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.test.classloader.old.test; import java.util.HashSet; import java.util.Timer; import java.util.TimerTask; import java.util.Vector; import junit.framework.Test; import org.jboss.classloader.spi.ClassLoaderSystem; import org.jboss.classloader.test.support.MockClassLoaderPolicy; import org.jboss.test.classloader.AbstractClassLoaderTestWithSecurity; import org.jboss.test.classloader.old.support.Support; /** * ConcurrentLoaderUnitTestCase. * * @author Adrian Brock * @author Scott.Stark@jboss.org * @version $Revision: 1.1 $ */ public class ConcurrentLoaderUnitTestCase extends AbstractClassLoaderTestWithSecurity { public Object lock = new Object (); public final static int MAX_CLASSES = 10; public final static int NUMBER_OF_LOADING = 10; public final static int NUMBER_OF_THREADS = 20; private HashSet> classes = new HashSet>(); private Vector loaders = new Vector(); private Timer newInstanceTimer; private int doneCount; private ClassLoader cl; public static Test suite() { return suite(ConcurrentLoaderUnitTestCase.class); } public ConcurrentLoaderUnitTestCase(String name) { super(name); } public void testConcurrentLoad() throws Exception { ClassLoaderSystem system = createClassLoaderSystemWithModifiedBootstrap(); MockClassLoaderPolicy policy = createMockClassLoaderPolicy(); policy.setPaths(Support.class); cl = system.registerClassLoaderPolicy(policy); getLog().debug("Creating " + NUMBER_OF_THREADS + " threads..."); newInstanceTimer = new Timer(true); newInstanceTimer.scheduleAtFixedRate(new NewInstanceTask(), 0, 100); doneCount = 0; for (int t = 0; t < NUMBER_OF_THREADS; t ++) { Loader loader = new Loader (t); loader.start(); loaders.add(loader); } getLog().debug("All threads created"); Thread.sleep(1000); synchronized(lock) { lock.notifyAll(); } getLog().debug("Unlocked all Loader threads"); synchronized(lock) { while( doneCount < NUMBER_OF_THREADS ) { lock.wait(); } getLog().debug("Loader doneCount=" + doneCount); } getLog().debug("All Loaders are done"); newInstanceTimer.cancel(); for (Loader loader : loaders) { if (loader.error != null) failure("Error in loader: ", loader.error); } } class NewInstanceTask extends TimerTask { public void run() { int size = classes.size(); Class[] theClasses = new Class[size]; classes.toArray(theClasses); getLog().trace("NewInstanceTask, creating " + size + " instances"); for (int c = 0; c < theClasses.length; ++c) { try { Class clazz = theClasses[c]; Object obj = clazz.newInstance(); getLog().trace("Created instance=" + obj); } catch(Throwable t) { getLog().error("Error instantiating class " + theClasses[c], t); } } } } class Loader extends Thread { int classid = 0; Throwable error; public Loader (int classid) { super("ConcurrentLoader - Thread #" + classid); this.classid = classid; } public void run () { int modId = classid % MAX_CLASSES; String className = Support.class.getPackage().getName() + ".AnyClass" + modId; synchronized(lock) { try { getLog().debug("Thread ready: " + classid); lock.wait(); } catch (Exception e) { getLog().error("Error during wait", e); } } getLog().trace("loading class... " + className); for (int i = 0; i < NUMBER_OF_LOADING; ++i) { getLog().trace("loading class with id " + classid + " for the " + i + "th time"); try { getLog().trace("before load..."); long sleep = (long) (500 * Math.random()); Thread.sleep(sleep); Class clazz = cl.loadClass(className); classes.add(clazz); Object obj = clazz.newInstance(); getLog().trace("Class " + className + " loaded, obj=" + obj); } catch (Throwable e) { getLog().debug("Failed to load class and create instance", e); error = e; } } getLog().debug("...Done loading classes. " + classid); synchronized( lock ) { doneCount++; lock.notify(); } } } } ././@LongLink0000000000000000000000000000021000000000000011556 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloader/src/test/java/org/jboss/test/classloader/old/test/CircularityErrorUnitTestCase.javalibjboss-classloader-java-2.0.6.GA.orig/classloader/src/test/java/org/jboss/test/classloader/old/tes0000644000175000017500000001165310741370313033370 0ustar twernertwerner/* * JBoss, Home of Professional Open Source. * Copyright 2007, Red Hat Middleware LLC, and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.test.classloader.old.test; import java.net.URL; import java.util.concurrent.CountDownLatch; import junit.framework.Test; import org.jboss.classloader.plugins.ClassLoaderUtils; import org.jboss.classloader.spi.ClassLoaderSystem; import org.jboss.classloader.test.support.MockClassLoaderPolicy; import org.jboss.test.classloader.AbstractClassLoaderTest; import org.jboss.test.classloader.old.support.Derived; import org.jboss.test.classloader.old.support.Support; /** * CircularityErrorUnitTestCase. * * @author Adrian Brock * @author Simone.Bordet@hp.com * @author Scott.Stark@jboss.org * @version $Revision: 1.1 $ */ public class CircularityErrorUnitTestCase extends AbstractClassLoaderTest { private CountDownLatch waiting = new CountDownLatch(1); private Throwable sawError; public static Test suite() { return suite(CircularityErrorUnitTestCase.class); } public CircularityErrorUnitTestCase(String name) { super(name); } public void testClassCircularityError() throws Exception { // The scenario is this one: // Thread1 asks classloader1 to load class Derived // Thread2 triggers a loadClassInternal for classloader1 to load class Base // Thread2 is put in sleep by the ULR since we are loading Derived // Thread1 triggers a loadClassInternal for classloader1 to load class Base // Thread1 throws ClassCircularityError ClassLoaderSystem system = createClassLoaderSystemWithModifiedBootstrap(); final ClassLoader cl = system.registerClassLoaderPolicy(new TestClassLoaderPolicy()); Class cls = assertLoadClass(Support.class, cl); Thread thread1 = new Thread(new Runnable() { public void run() { // Be sure thread2 is waiting try { Thread.sleep(1000); } catch (InterruptedException x) { } try { getLog().debug("Thread " + Thread.currentThread() + " loading..."); assertLoadClass(Derived.class, cl); getLog().debug("Thread " + Thread.currentThread() + " loading done !"); } catch (Throwable t) { sawError = t; } } }, "CircularityErrorThread"); thread1.start(); getLog().debug("Thread " + Thread.currentThread() + " waiting..."); waiting.await(); getLog().debug("Thread " + Thread.currentThread() + " woken up !"); // Ask this thread to trigger a loadClassInternal directly; the thread will be put to sleep // but the JVM has already registered the fact that // it wants to load the class, in this case class Base cls.newInstance(); thread1.join(); // The ClassCircularityError thrown should allow the call above to complete if (sawError != null) failure("Unexpected error", sawError); } public class TestClassLoaderPolicy extends MockClassLoaderPolicy { public TestClassLoaderPolicy() { setPaths(Support.class); } @Override public URL getResource(String name) { getLog().debug(Thread.currentThread() + " is now asked to load class: " + name); if (name.equals(ClassLoaderUtils.classNameToPath(Derived.class.getName()))) { waiting.countDown(); // Wait to trigger ClassCircularityError // Do not release the lock on the classloader try { getLog().debug("Loading " + name + ", waiting..."); Thread.sleep(2000); getLog().debug("Loading " + name + " end wait"); } catch (InterruptedException x) { getLog().debug("Sleep was interrupted", x); } } return super.getResource(name); } } } ././@LongLink0000000000000000000000000000017600000000000011571 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloader/src/test/java/org/jboss/test/classloader/old/test/LoaderUnitTestCase.javalibjboss-classloader-java-2.0.6.GA.orig/classloader/src/test/java/org/jboss/test/classloader/old/tes0000644000175000017500000000552010615651036033370 0ustar twernertwerner/* * JBoss, Home of Professional Open Source. * Copyright 2007, Red Hat Middleware LLC, and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.test.classloader.old.test; import junit.framework.Test; import org.jboss.classloader.spi.ClassLoaderSystem; import org.jboss.classloader.test.support.MockClassLoaderPolicy; import org.jboss.test.classloader.AbstractClassLoaderTestWithSecurity; import org.jboss.test.classloader.old.support.Support; /** * LoaderUnitTestCase. * * @author Adrian Brock * @author Scott.Stark@jboss.org * @version $Revision: 1.1 $ */ public class LoaderUnitTestCase extends AbstractClassLoaderTestWithSecurity { public static Test suite() { return suite(LoaderUnitTestCase.class); } public LoaderUnitTestCase(String name) { super(name); } public void testInterruptThread() throws Exception { ClassLoaderSystem system = createClassLoaderSystemWithModifiedBootstrap(); MockClassLoaderPolicy policy = createMockClassLoaderPolicy(); policy.setPaths(Support.class); final ClassLoader cl = system.registerClassLoaderPolicy(policy); // Set our interrupted flag getLog().debug("Setting interrupt flag"); Thread.currentThread().interrupt(); try { assertLoadClass(Support.class, cl); } finally { assertTrue("Interrupted state not restored", Thread.currentThread().interrupted()); } } public void testLoadingArrayClass() throws Exception { ClassLoaderSystem system = createClassLoaderSystemWithModifiedBootstrap(); MockClassLoaderPolicy policy = createMockClassLoaderPolicy(); policy.setPaths(Support.class); ClassLoader cl = system.registerClassLoaderPolicy(policy); assertLoadClass("[Ljava.lang.String;", cl, null); assertLoadClass("[L" + Support.class.getName() + ";", cl); assertLoadClass("[[L" + Support.class.getName() + ";", cl); } } ././@LongLink0000000000000000000000000000020400000000000011561 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloader/src/test/java/org/jboss/test/classloader/old/test/CircularLoadUnitTestCase.javalibjboss-classloader-java-2.0.6.GA.orig/classloader/src/test/java/org/jboss/test/classloader/old/tes0000644000175000017500000002762710741370313033400 0ustar twernertwerner/* * JBoss, Home of Professional Open Source. * Copyright 2007, Red Hat Middleware LLC, and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.test.classloader.old.test; import java.lang.reflect.Constructor; import java.lang.reflect.Method; import junit.framework.Test; import org.jboss.classloader.spi.ClassLoaderSystem; import org.jboss.classloader.test.support.MockClassLoaderPolicy; import org.jboss.test.classloader.AbstractClassLoaderTestWithSecurity; import org.jboss.test.classloader.old.support.Base; import org.jboss.test.classloader.old.support.Class0; import org.jboss.test.classloader.old.support.Class1; import org.jboss.test.classloader.old.support.Class2; import org.jboss.test.classloader.old.support.Derived; import org.jboss.test.classloader.old.support.LoginInfo; import org.jboss.test.classloader.old.support.Support; import org.jboss.test.classloader.old.support.UserOfBase; import org.jboss.test.classloader.old.support.UserOfLoginInfo; import org.jboss.test.classloader.old.support.UserOfUsrMgr; import org.jboss.test.classloader.old.support.UsrMgr; /** * CircularLoadUnitTestCase. * * @author Adrian Brock * @author Simone.Bordet@hp.com * @author Scott.Stark@jboss.org * @version $Revision: 1.1 $ */ public class CircularLoadUnitTestCase extends AbstractClassLoaderTestWithSecurity { public CircularLoadUnitTestCase(String name) { super(name); } public static Test suite() { return suite(CircularLoadUnitTestCase.class); } public void testLinkageError() throws Exception { ClassLoaderSystem system = createClassLoaderSystemWithModifiedBootstrap(); MockClassLoaderPolicy le0 = createMockClassLoaderPolicy("le0"); le0.setPathsAndPackageNames(Base.class); le0.setImportAll(true); le0.setIncluded(Base.class, UserOfBase.class); ClassLoader cl0 = system.registerClassLoaderPolicy(le0); MockClassLoaderPolicy le1 = createMockClassLoaderPolicy("le1"); le1.setPathsAndPackageNames(Base.class); le1.setImportAll(true); le1.setIncluded(Base.class, Support.class); ClassLoader cl1 = system.registerClassLoaderPolicy(le1); MockClassLoaderPolicy all = createMockClassLoaderPolicy("all"); all.setPackageNames(Base.class); all.setImportAll(true); ClassLoader cl2 = system.registerClassLoaderPolicy(all); try { // Load Base assertLoadClass(Base.class, cl2, cl0); // Load and create an instance of the UserOfBase class Class userOfBaseClass = assertLoadClass(UserOfBase.class, cl0); Constructor ctor0 = userOfBaseClass.getConstructor((Class[]) null); Object userOfBase = ctor0.newInstance((Object[]) null); // Load and create an instance of the Support class Class supportClass = assertLoadClass(Support.class, cl1); Constructor ctor1 = supportClass.getConstructor((Class[]) null); Object support = ctor1.newInstance((Object[]) null); // Now invoke UserOfBase.testBase(Support) Class[] sig = { supportClass }; Method testBase = userOfBaseClass.getMethod("testBase", sig); getLog().info(testBase.toString()); Object[] args = { support }; testBase.invoke(userOfBase, args); } catch(Throwable t) { failure("Failed", t); } } public void testPackageProtected() throws Exception { ClassLoaderSystem system = createClassLoaderSystemWithModifiedBootstrap(); MockClassLoaderPolicy mock = createMockClassLoaderPolicy(); mock.setPathsAndPackageNames(Base.class); mock.setIncluded(LoginInfo.class, UsrMgr.class, UserOfUsrMgr.class, UserOfLoginInfo.class); ClassLoader cl = system.registerClassLoaderPolicy(mock); getLog().info("Begin testPackageProtected"); try { // Load and create an instance of the UserOfLoginInfo class Class c0 = assertLoadClass(UserOfLoginInfo.class, cl); Class[] ctorsig0 = {String.class, String.class}; Constructor ctor0 = c0.getConstructor(ctorsig0); Object[] args0 = {"jduke", "theduke"}; ctor0.newInstance(args0); // Load and create an instance of the UserOfUsrMgr class Class c1 = assertLoadClass(UserOfUsrMgr.class, cl); Class[] ctorsig1 = {String.class, String.class}; Constructor ctor1 = c1.getConstructor(ctorsig1); Object[] args1 = {"jduke", "theduke"}; Object o1 = ctor1.newInstance(args1); // Now invoke UserOfUsrMgr.changePassword(char[] password) char[] password = "theduke2".toCharArray(); Class[] sig = {password.getClass()}; Method changePassword = c1.getMethod("changePassword", sig); getLog().info(changePassword.toString()); Object[] args = {password}; changePassword.invoke(o1, args); } catch(Exception e) { failure("Failed", e); } } public void testDuplicateClass() throws Exception { ClassLoaderSystem system = createClassLoaderSystemWithModifiedBootstrap(); MockClassLoaderPolicy any0 = createMockClassLoaderPolicy("any0"); any0.setPathsAndPackageNames(Support.class); any0.setImportAll(true); any0.setIncluded(Base.class, Class0.class, Class2.class); ClassLoader cl0 = system.registerClassLoaderPolicy(any0); MockClassLoaderPolicy any1 = createMockClassLoaderPolicy("any1"); any1.setPathsAndPackageNames(Support.class); any1.setImportAll(true); any1.setIncluded(Class0.class, Class2.class); ClassLoader cl1 = system.registerClassLoaderPolicy(any1); assertLoadClass(Class0.class, cl0); assertLoadClass(Class2.class, cl1, cl0); Class base = assertLoadClass(Base.class, cl0); Method run = base.getMethod("run", (Class[]) null); run.invoke(null, (Object[]) null); } public void testUCLOwner() throws Exception { ClassLoaderSystem system = createClassLoaderSystemWithModifiedBootstrap(); MockClassLoaderPolicy j0 = createMockClassLoaderPolicy("j0"); j0.setPathsAndPackageNames(Support.class); j0.setImportAll(true); j0.setIncluded(Class0.class); ClassLoader cl0 = system.registerClassLoaderPolicy(j0); MockClassLoaderPolicy j1 = createMockClassLoaderPolicy("j1"); j1.setPathsAndPackageNames(Support.class); j1.setImportAll(true); j1.setIncluded(Class2.class); ClassLoader cl1 = system.registerClassLoaderPolicy(j1); // Request a class that does not exist LoadThread t0 = new LoadThread(Support.class, cl0, "testUCLOwner.T0", true); t0.start(); // Join the thread t0.join(5000); assertNull("T0 failed as no class should have been found, loadedClass="+t0.loadedClass, t0.loadedClass); assertNotNull("T0 failed as no class should have been found, loadedClass="+t0.loadedClass, t0.loadError); checkThrowable(ClassNotFoundException.class, t0.loadError); LoadThread t1 = new LoadThread(Class2.class, cl1, "testUCLOwner.T1"); t1.start(); // Join the thread t1.join(5000); if (t1.loadError != null) failure("T1 failed to load Class2" , t1.loadError); assertNotNull("T1 failed to load Class2", t1.loadedClass); } public void testMissingSuperClass() throws Exception { ClassLoaderSystem system = createClassLoaderSystemWithModifiedBootstrap(); MockClassLoaderPolicy j0 = createMockClassLoaderPolicy("j0"); j0.setPathsAndPackageNames(Support.class); j0.setImportAll(true); j0.setIncluded(Class0.class); ClassLoader cl0 = system.registerClassLoaderPolicy(j0); MockClassLoaderPolicy j3 = createMockClassLoaderPolicy("j3"); j3.setPathsAndPackageNames(Support.class); j3.setImportAll(true); j3.setIncluded(Derived.class); system.registerClassLoaderPolicy(j3); LoadThread t0 = new LoadThread(Derived.class, cl0, "testMissingSuperClass.T0"); t0.start(); // Join the thread t0.join(5000); assertNull("T0 failed as no class should have been found, loadedClass="+t0.loadedClass, t0.loadedClass); checkThrowable(NoClassDefFoundError.class, t0.loadError); } public void testLoading() throws Exception { ClassLoaderSystem system = createClassLoaderSystemWithModifiedBootstrap(); MockClassLoaderPolicy j0 = createMockClassLoaderPolicy("j0"); j0.setPathsAndPackageNames(Support.class); j0.setImportAll(true); j0.setIncluded(Class0.class); ClassLoader cl0 = system.registerClassLoaderPolicy(j0); MockClassLoaderPolicy j1 = createMockClassLoaderPolicy("j1"); j1.setPathsAndPackageNames(Support.class); j1.setImportAll(true); j1.setIncluded(Class1.class); ClassLoader cl1 = system.registerClassLoaderPolicy(j1); MockClassLoaderPolicy j2 = createMockClassLoaderPolicy("j2"); j2.setPathsAndPackageNames(Support.class); j2.setImportAll(true); j2.setIncluded(Class2.class); ClassLoader cl2 = system.registerClassLoaderPolicy(j2); LoadThread t0 = new LoadThread(Class2.class, cl0, cl2, "testLoading.T0"); LoadThread t1 = new LoadThread(Class0.class, cl1, cl0, "testLoading.T1"); LoadThread t2 = new LoadThread(Class1.class, cl2, cl1, "testLoading.T2"); t0.start(); t1.start(); t2.start(); // Join the threads t0.join(); if (t0.loadError != null) failure("T0 failed", t0.loadError); assertNotNull("T0 failed", t0.loadedClass); t1.join(5000); if (t1.loadError != null) failure("T1 failed", t1.loadError); assertNotNull("T1 failed", t1.loadedClass); t2.join(5000); if (t2.loadError != null) failure("T2 failed", t2.loadError); assertNotNull("T2 failed", t2.loadedClass); } class LoadThread extends Thread { String classname; ClassLoader loader; ClassLoader expected; Class loadedClass; Throwable loadError; boolean fails; LoadThread(Class reference, ClassLoader loader, String name) { this(reference, loader, loader, name, false); } LoadThread(Class reference, ClassLoader loader, String name, boolean fails) { this(reference, loader, loader, name, fails); } LoadThread(Class reference, ClassLoader loader, ClassLoader expected, String name) { this(reference, loader, expected, name, false); } LoadThread(Class reference, ClassLoader loader, ClassLoader expected, String name, boolean fails) { super(name); this.classname = reference.getName(); this.loader = loader; this.expected = expected; this.fails = fails; } public void run() { try { if (fails) loader.loadClass(classname); else loadedClass = assertLoadClass(classname, loader, expected); } catch(Throwable t) { loadError = t; } } } } ././@LongLink0000000000000000000000000000016300000000000011565 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloader/src/test/java/org/jboss/test/classloader/old/OldTestSuite.javalibjboss-classloader-java-2.0.6.GA.orig/classloader/src/test/java/org/jboss/test/classloader/old/Old0000644000175000017500000000426510614350067033317 0ustar twernertwerner/* * JBoss, Home of Professional Open Source. * Copyright 2007, Red Hat Middleware LLC, and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.test.classloader.old; import org.jboss.test.classloader.old.test.CircularLoadUnitTestCase; import org.jboss.test.classloader.old.test.CircularityErrorUnitTestCase; import org.jboss.test.classloader.old.test.ConcurrentLoaderUnitTestCase; import org.jboss.test.classloader.old.test.LoaderUnitTestCase; import junit.framework.Test; import junit.framework.TestSuite; import junit.textui.TestRunner; /** * Old Test Suite. * * @author Adrian Brock * @version $Revision: 37459 $ */ public class OldTestSuite extends TestSuite { /** * For running the testsuite from the command line * * @param args the command line args */ public static void main(String[] args) { TestRunner.run(suite()); } /** * Create the testsuite * * @return the testsuite */ public static Test suite() { TestSuite suite = new TestSuite("OldTests"); suite.addTest(CircularityErrorUnitTestCase.suite()); suite.addTest(CircularLoadUnitTestCase.suite()); suite.addTest(ConcurrentLoaderUnitTestCase.suite()); suite.addTest(LoaderUnitTestCase.suite()); return suite; } } ././@LongLink0000000000000000000000000000015200000000000011563 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloader/src/test/java/org/jboss/test/classloader/old/support/libjboss-classloader-java-2.0.6.GA.orig/classloader/src/test/java/org/jboss/test/classloader/old/sup0000755000175000017500000000000011620043422033367 5ustar twernertwerner././@LongLink0000000000000000000000000000017000000000000011563 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloader/src/test/java/org/jboss/test/classloader/old/support/AnyClass0.javalibjboss-classloader-java-2.0.6.GA.orig/classloader/src/test/java/org/jboss/test/classloader/old/sup0000644000175000017500000000242110614350067033400 0ustar twernertwerner/* * JBoss, Home of Professional Open Source. * Copyright 2007, Red Hat Middleware LLC, and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.test.classloader.old.support; /** * AnyClass. * * @author Adrian Brock * @author Sacha Labourey. * @version $Revision: 1.1 $ */ public class AnyClass0 { } ././@LongLink0000000000000000000000000000017000000000000011563 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloader/src/test/java/org/jboss/test/classloader/old/support/AnyClass6.javalibjboss-classloader-java-2.0.6.GA.orig/classloader/src/test/java/org/jboss/test/classloader/old/sup0000644000175000017500000000242110614350067033400 0ustar twernertwerner/* * JBoss, Home of Professional Open Source. * Copyright 2007, Red Hat Middleware LLC, and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.test.classloader.old.support; /** * AnyClass. * * @author Adrian Brock * @author Sacha Labourey. * @version $Revision: 1.1 $ */ public class AnyClass6 { } ././@LongLink0000000000000000000000000000017000000000000011563 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloader/src/test/java/org/jboss/test/classloader/old/support/AnyClass9.javalibjboss-classloader-java-2.0.6.GA.orig/classloader/src/test/java/org/jboss/test/classloader/old/sup0000644000175000017500000000242110614350067033400 0ustar twernertwerner/* * JBoss, Home of Professional Open Source. * Copyright 2007, Red Hat Middleware LLC, and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.test.classloader.old.support; /** * AnyClass. * * @author Adrian Brock * @author Sacha Labourey. * @version $Revision: 1.1 $ */ public class AnyClass9 { } ././@LongLink0000000000000000000000000000017300000000000011566 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloader/src/test/java/org/jboss/test/classloader/old/support/UserOfUsrMgr.javalibjboss-classloader-java-2.0.6.GA.orig/classloader/src/test/java/org/jboss/test/classloader/old/sup0000644000175000017500000000275110614350067033406 0ustar twernertwerner/* * JBoss, Home of Professional Open Source. * Copyright 2007, Red Hat Middleware LLC, and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.test.classloader.old.support; /** * UserOfUsrMgr. * * @author Scott.Stark@jboss.org * @author Adrian Brock * @version $Revision: 1.1 $ */ public class UserOfUsrMgr { LoginInfo info; public UserOfUsrMgr(String username, String password) { info = new LoginInfo(username, password.toCharArray()); } public void changePassword(char[] password) { UsrMgr.changeUserPassword(info, password); } } ././@LongLink0000000000000000000000000000016500000000000011567 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloader/src/test/java/org/jboss/test/classloader/old/support/Class2.javalibjboss-classloader-java-2.0.6.GA.orig/classloader/src/test/java/org/jboss/test/classloader/old/sup0000644000175000017500000000254610614350067033410 0ustar twernertwerner/* * JBoss, Home of Professional Open Source. * Copyright 2007, Red Hat Middleware LLC, and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.test.classloader.old.support; /** * Class2. * * @author Scott.Stark@jboss.org * @author Adrian Brock * @version $Revision: 1.1 $ */ public class Class2 { /** Creates a new instance of Class0 */ public Class2() { } public Class0 get0() { return new Class0(); } } ././@LongLink0000000000000000000000000000016500000000000011567 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloader/src/test/java/org/jboss/test/classloader/old/support/Class0.javalibjboss-classloader-java-2.0.6.GA.orig/classloader/src/test/java/org/jboss/test/classloader/old/sup0000644000175000017500000000244510614350067033406 0ustar twernertwerner/* * JBoss, Home of Professional Open Source. * Copyright 2007, Red Hat Middleware LLC, and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.test.classloader.old.support; /** * Class0. * * @author Scott.Stark@jboss.org * @author Adrian Brock * @version $Revision: 1.1 $ */ public class Class0 { /** Creates a new instance of Class0 */ public Class0() { } } ././@LongLink0000000000000000000000000000017100000000000011564 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloader/src/test/java/org/jboss/test/classloader/old/support/UserOfBase.javalibjboss-classloader-java-2.0.6.GA.orig/classloader/src/test/java/org/jboss/test/classloader/old/sup0000644000175000017500000000242210615651036033402 0ustar twernertwerner/* * JBoss, Home of Professional Open Source. * Copyright 2007, Red Hat Middleware LLC, and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.test.classloader.old.support; /** * UserOfBase. * * @author Scott.Stark@jboss.org * @author Adrian Brock * @version $Revision: 1.1 $ */ public class UserOfBase { public void testBase(Support s) { } } ././@LongLink0000000000000000000000000000016500000000000011567 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloader/src/test/java/org/jboss/test/classloader/old/support/UsrMgr.javalibjboss-classloader-java-2.0.6.GA.orig/classloader/src/test/java/org/jboss/test/classloader/old/sup0000644000175000017500000000252110614350067033401 0ustar twernertwerner/* * JBoss, Home of Professional Open Source. * Copyright 2007, Red Hat Middleware LLC, and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.test.classloader.old.support; /** * UsrMgr. * * @author Scott.Stark@jboss.org * @author Adrian Brock * @version $Revision: 1.1 $ */ public class UsrMgr { public static void changeUserPassword(LoginInfo info, char[] password) { info.password = password; } } ././@LongLink0000000000000000000000000000017000000000000011563 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloader/src/test/java/org/jboss/test/classloader/old/support/AnyClass1.javalibjboss-classloader-java-2.0.6.GA.orig/classloader/src/test/java/org/jboss/test/classloader/old/sup0000644000175000017500000000242110614350067033400 0ustar twernertwerner/* * JBoss, Home of Professional Open Source. * Copyright 2007, Red Hat Middleware LLC, and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.test.classloader.old.support; /** * AnyClass. * * @author Adrian Brock * @author Sacha Labourey. * @version $Revision: 1.1 $ */ public class AnyClass1 { } ././@LongLink0000000000000000000000000000017000000000000011563 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloader/src/test/java/org/jboss/test/classloader/old/support/AnyClass7.javalibjboss-classloader-java-2.0.6.GA.orig/classloader/src/test/java/org/jboss/test/classloader/old/sup0000644000175000017500000000242110614350067033400 0ustar twernertwerner/* * JBoss, Home of Professional Open Source. * Copyright 2007, Red Hat Middleware LLC, and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.test.classloader.old.support; /** * AnyClass. * * @author Adrian Brock * @author Sacha Labourey. * @version $Revision: 1.1 $ */ public class AnyClass7 { } ././@LongLink0000000000000000000000000000016300000000000011565 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloader/src/test/java/org/jboss/test/classloader/old/support/Base.javalibjboss-classloader-java-2.0.6.GA.orig/classloader/src/test/java/org/jboss/test/classloader/old/sup0000644000175000017500000000242010615651036033400 0ustar twernertwerner/* * JBoss, Home of Professional Open Source. * Copyright 2007, Red Hat Middleware LLC, and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.test.classloader.old.support; /** * Base. * * @author Scott.Stark@jboss.org * @author Adrian Brock * @version $Revision: 1.1 $ */ public class Base { public static void run() throws Exception { } } ././@LongLink0000000000000000000000000000017000000000000011563 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloader/src/test/java/org/jboss/test/classloader/old/support/AnyClass2.javalibjboss-classloader-java-2.0.6.GA.orig/classloader/src/test/java/org/jboss/test/classloader/old/sup0000644000175000017500000000242110614350067033400 0ustar twernertwerner/* * JBoss, Home of Professional Open Source. * Copyright 2007, Red Hat Middleware LLC, and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.test.classloader.old.support; /** * AnyClass. * * @author Adrian Brock * @author Sacha Labourey. * @version $Revision: 1.1 $ */ public class AnyClass2 { } ././@LongLink0000000000000000000000000000017600000000000011571 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloader/src/test/java/org/jboss/test/classloader/old/support/UserOfLoginInfo.javalibjboss-classloader-java-2.0.6.GA.orig/classloader/src/test/java/org/jboss/test/classloader/old/sup0000644000175000017500000000260710614350067033406 0ustar twernertwerner/* * JBoss, Home of Professional Open Source. * Copyright 2007, Red Hat Middleware LLC, and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.test.classloader.old.support; /** * UserOfLoginInfo. * * @author Scott.Stark@jboss.org * @author Adrian Brock * @version $Revision: 1.1 $ */ public class UserOfLoginInfo { LoginInfo info; public UserOfLoginInfo(String username, String password) { info = new LoginInfo(username, password.toCharArray()); } } ././@LongLink0000000000000000000000000000017000000000000011563 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloader/src/test/java/org/jboss/test/classloader/old/support/AnyClass3.javalibjboss-classloader-java-2.0.6.GA.orig/classloader/src/test/java/org/jboss/test/classloader/old/sup0000644000175000017500000000242110614350067033400 0ustar twernertwerner/* * JBoss, Home of Professional Open Source. * Copyright 2007, Red Hat Middleware LLC, and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.test.classloader.old.support; /** * AnyClass. * * @author Adrian Brock * @author Sacha Labourey. * @version $Revision: 1.1 $ */ public class AnyClass3 { } ././@LongLink0000000000000000000000000000016500000000000011567 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloader/src/test/java/org/jboss/test/classloader/old/support/Class1.javalibjboss-classloader-java-2.0.6.GA.orig/classloader/src/test/java/org/jboss/test/classloader/old/sup0000644000175000017500000000237210614350067033405 0ustar twernertwerner/* * JBoss, Home of Professional Open Source. * Copyright 2007, Red Hat Middleware LLC, and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.test.classloader.old.support; /** * Class1. * * @author Scott.Stark@jboss.org * @author Adrian Brock * @version $Revision: 1.1 $ */ public class Class1 { public Class1() { } } ././@LongLink0000000000000000000000000000016600000000000011570 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloader/src/test/java/org/jboss/test/classloader/old/support/Derived.javalibjboss-classloader-java-2.0.6.GA.orig/classloader/src/test/java/org/jboss/test/classloader/old/sup0000644000175000017500000000235410614350067033405 0ustar twernertwerner/* * JBoss, Home of Professional Open Source. * Copyright 2007, Red Hat Middleware LLC, and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.test.classloader.old.support; /** * Derived. * * @author Scott.Stark@jboss.org * @author Adrian Brock * @version $Revision: 1.1 $ */ public class Derived extends Base { } ././@LongLink0000000000000000000000000000017000000000000011563 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloader/src/test/java/org/jboss/test/classloader/old/support/LoginInfo.javalibjboss-classloader-java-2.0.6.GA.orig/classloader/src/test/java/org/jboss/test/classloader/old/sup0000644000175000017500000000270410614350067033404 0ustar twernertwerner/* * JBoss, Home of Professional Open Source. * Copyright 2007, Red Hat Middleware LLC, and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.test.classloader.old.support; /** * LoginInfo. * * @author Scott.Stark@jboss.org * @author Adrian Brock * @version $Revision: 1.1 $ */ public class LoginInfo { protected String username = "jduke"; protected char[] password = "theduke".toCharArray(); public LoginInfo(String username, char[] password) { this.username = username; this.password = password; } } ././@LongLink0000000000000000000000000000017000000000000011563 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloader/src/test/java/org/jboss/test/classloader/old/support/AnyClass8.javalibjboss-classloader-java-2.0.6.GA.orig/classloader/src/test/java/org/jboss/test/classloader/old/sup0000644000175000017500000000242110614350067033400 0ustar twernertwerner/* * JBoss, Home of Professional Open Source. * Copyright 2007, Red Hat Middleware LLC, and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.test.classloader.old.support; /** * AnyClass. * * @author Adrian Brock * @author Sacha Labourey. * @version $Revision: 1.1 $ */ public class AnyClass8 { } ././@LongLink0000000000000000000000000000017000000000000011563 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloader/src/test/java/org/jboss/test/classloader/old/support/AnyClass5.javalibjboss-classloader-java-2.0.6.GA.orig/classloader/src/test/java/org/jboss/test/classloader/old/sup0000644000175000017500000000242110614350067033400 0ustar twernertwerner/* * JBoss, Home of Professional Open Source. * Copyright 2007, Red Hat Middleware LLC, and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.test.classloader.old.support; /** * AnyClass. * * @author Adrian Brock * @author Sacha Labourey. * @version $Revision: 1.1 $ */ public class AnyClass5 { } ././@LongLink0000000000000000000000000000016600000000000011570 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloader/src/test/java/org/jboss/test/classloader/old/support/Support.javalibjboss-classloader-java-2.0.6.GA.orig/classloader/src/test/java/org/jboss/test/classloader/old/sup0000644000175000017500000000247110614350067033405 0ustar twernertwerner/* * JBoss, Home of Professional Open Source. * Copyright 2007, Red Hat Middleware LLC, and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.test.classloader.old.support; /** * Support. * * @author Scott.Stark@jboss.org * @author Adrian Brock * @version $Revision: 1.1 $ */ public class Support { private Base base = new Base(); public Base getBase() { return base; } } ././@LongLink0000000000000000000000000000017000000000000011563 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloader/src/test/java/org/jboss/test/classloader/old/support/AnyClass4.javalibjboss-classloader-java-2.0.6.GA.orig/classloader/src/test/java/org/jboss/test/classloader/old/sup0000644000175000017500000000242110614350067033400 0ustar twernertwerner/* * JBoss, Home of Professional Open Source. * Copyright 2007, Red Hat Middleware LLC, and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.test.classloader.old.support; /** * AnyClass. * * @author Adrian Brock * @author Sacha Labourey. * @version $Revision: 1.1 $ */ public class AnyClass4 { } libjboss-classloader-java-2.0.6.GA.orig/classloader/src/main/0000755000175000017500000000000011620043422023723 5ustar twernertwernerlibjboss-classloader-java-2.0.6.GA.orig/classloader/src/main/java/0000755000175000017500000000000011620043422024644 5ustar twernertwernerlibjboss-classloader-java-2.0.6.GA.orig/classloader/src/main/java/org/0000755000175000017500000000000011620043422025433 5ustar twernertwernerlibjboss-classloader-java-2.0.6.GA.orig/classloader/src/main/java/org/jboss/0000755000175000017500000000000011620043422026553 5ustar twernertwernerlibjboss-classloader-java-2.0.6.GA.orig/classloader/src/main/java/org/jboss/classloader/0000755000175000017500000000000011620043422031047 5ustar twernertwernerlibjboss-classloader-java-2.0.6.GA.orig/classloader/src/main/java/org/jboss/classloader/test/0000755000175000017500000000000011620043422032026 5ustar twernertwerner././@LongLink0000000000000000000000000000014600000000000011566 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloader/src/main/java/org/jboss/classloader/test/support/libjboss-classloader-java-2.0.6.GA.orig/classloader/src/main/java/org/jboss/classloader/test/support0000755000175000017500000000000011620043422033463 5ustar twernertwerner././@LongLink0000000000000000000000000000020200000000000011557 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloader/src/main/java/org/jboss/classloader/test/support/IsolatedClassLoaderTest.javalibjboss-classloader-java-2.0.6.GA.orig/classloader/src/main/java/org/jboss/classloader/test/support0000644000175000017500000001224410651711042033473 0ustar twernertwerner/* * JBoss, Home of Professional Open Source. * Copyright 2007, Red Hat Middleware LLC, and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.classloader.test.support; import junit.framework.Test; import org.jboss.classloader.spi.ClassLoaderSystem; import org.jboss.test.AbstractTestCaseWithSetup; import org.jboss.test.AbstractTestDelegate; /** * IsolatedClassLoaderTest. * * @author Adrian Brock * @version $Revision: 1.1 $ */ public abstract class IsolatedClassLoaderTest extends AbstractTestCaseWithSetup { // The last helper private static IsolatedClassLoaderTestHelper helper; /** * Get the delegate * * @param clazz the test class * @return the delegate */ public static AbstractTestDelegate getDelegate(Class clazz) { return new AbstractTestDelegate(clazz); } /** * Create a test with just test's package visible * and the default parent packages * * It imports nothing * * @param clazz the test class * @return the test */ public static Test suite(Class clazz) { return suite(clazz, false); } /** * Create a test with just test's package visible * and the default parent packages * * It exports everything * * @param clazz the test class * @param importAll whether to import all * @return the test */ public static Test suite(Class clazz, boolean importAll) { return suite(clazz, importAll, new Class[0]); } /** * Create a test with test's package visible and the packages * of the classes listed with the default parent packages * * It exports everything * It imports nothing * * @param clazz the test class * @param packages the classes in packages that should also be included * @return the test */ public static Test suite(Class clazz, Class... packages) { return suite(clazz, false, packages); } /** * Create a test with test's package visible and the packages * of the classes listed * * It exports everything * * @param clazz the test class * @param importAll whether to import all * @param packages the classes in packages that should also be included * @return the test */ public static Test suite(Class clazz, boolean importAll, Class... packages) { helper = new IsolatedClassLoaderTestHelper(); Class newClass = helper.initializeClassLoader(clazz, importAll, packages); // Create the test based on the isolated class return AbstractTestCaseWithSetup.suite(newClass); } @Override protected void setUp() throws Exception { super.setUp(); configureLogging(); } /** * Create a new IsolatedClassLoaderTest. * * @param name the test name */ public IsolatedClassLoaderTest(String name) { super(name); } /** * Get the classloader system, this will be configured with * a domain called TEST that includes the test case's classloader * * @return the classloader */ public static ClassLoaderSystem getClassLoaderSystem() { return helper.getSystem(); } /** * Create a classloader * * It exports everything * It imports everything * * @param name the name * @param packages the packages * @return the classloader * @throws Exception for any error */ protected static ClassLoader createClassLoader(String name, String... packages) throws Exception { return createClassLoader(name, true, packages); } /** * Create a classloader * * It exports everything * * @param name the name * @param importAll whether to import all * @param packages the packages * @return the classloader * @throws Exception for any error */ protected static ClassLoader createClassLoader(String name, boolean importAll, String... packages) throws Exception { return helper.createClassLoader(name, importAll, packages); } /** * Unregister a classloader * * @param classLoader the classloader * @throws Exception for any error */ protected static void unregisterClassLoader(ClassLoader classLoader) throws Exception { helper.unregisterClassLoader(classLoader); } } ././@LongLink0000000000000000000000000000021000000000000011556 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloader/src/main/java/org/jboss/classloader/test/support/IsolatedClassLoaderTestHelper.javalibjboss-classloader-java-2.0.6.GA.orig/classloader/src/main/java/org/jboss/classloader/test/support0000644000175000017500000004050310741370313033474 0ustar twernertwerner/* * JBoss, Home of Professional Open Source * Copyright 2006, JBoss Inc., and individual contributors as indicated * by the @authors tag. See the copyright.txt in the distribution for a * full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.classloader.test.support; import java.security.AccessController; import java.security.PrivilegedAction; import java.util.ArrayList; import java.util.HashSet; import java.util.List; import java.util.Set; import java.util.StringTokenizer; import junit.extensions.TestSetup; import junit.framework.Test; import org.jboss.classloader.plugins.filter.CombiningClassFilter; import org.jboss.classloader.plugins.system.DefaultClassLoaderSystem; import org.jboss.classloader.spi.ClassLoaderDomain; import org.jboss.classloader.spi.ClassLoaderPolicy; import org.jboss.classloader.spi.ClassLoaderSystem; import org.jboss.classloader.spi.DelegateLoader; import org.jboss.classloader.spi.Loader; import org.jboss.classloader.spi.ParentPolicy; import org.jboss.classloader.spi.filter.ClassFilter; import org.jboss.classloader.spi.filter.FilteredDelegateLoader; import org.jboss.classloader.spi.filter.PackageClassFilter; import org.jboss.logging.Logger; import org.jboss.test.AbstractTestCaseWithSetup; import org.jboss.test.logging.LoggingPlugin; import org.jboss.test.security.PolicyPlugin; /** * IsolatedClassLoaderTestHelper. * * @author Adrian Brock * @version $Revision: 1.1 $ */ public class IsolatedClassLoaderTestHelper { /** The classloader system */ private ClassLoaderSystem system; /** The classLoader domain */ private ClassLoaderDomain domain; /** The classLoader policy */ private ClassLoaderPolicy policy; /** * Get the domain. * * @return the domain. */ public ClassLoaderDomain getDomain() { return domain; } /** * Get the system. * * @return the system. */ public ClassLoaderSystem getSystem() { return system; } /** * Get the policy. * * @return the policy. */ public ClassLoaderPolicy getPolicy() { return policy; } /** * Set the policy. * * @param policy the policy. */ public void setPolicy(ClassLoaderPolicy policy) { this.policy = policy; } /** * Get the packages that should not be isolated * (and by transience their dependent classes, e.g. log4j in the classpath)

* * NOTE: The transient packages cannot be used directly by the test * unless explicity mentioned in this list. * * The list can be expanded by using the jboss.test.parent.pkgs system property with a * comma-separated list of package names, e.g.
* -Djboss.test.parent.pkgs=org.jboss.package1, org.jboss.package2 * * @return the test support packages */ public static Set getParentPackages() { Set result = new HashSet(); result.add(Test.class.getPackage().getName()); result.add(TestSetup.class.getPackage().getName()); result.add(AbstractTestCaseWithSetup.class.getPackage().getName()); result.add(Logger.class.getPackage().getName()); result.add(LoggingPlugin.class.getPackage().getName()); result.add(PolicyPlugin.class.getPackage().getName()); result.add(ClassLoaderSystem.class.getPackage().getName()); result.add(IsolatedClassLoaderTest.class.getPackage().getName()); String pkgString = AccessController.doPrivileged(new PrivilegedAction() { public String run() { return System.getProperty("jboss.test.parent.pkgs"); }} ); if (pkgString != null) { StringTokenizer tok = new StringTokenizer(pkgString, ","); while(tok.hasMoreTokens()) { String pkg = tok.nextToken(); result.add(pkg.trim()); } } return result; } /** * Initialize the classloader system * * @param clazz the original clazz * @param importAll whether to import all * @param packages the reference classes for the packages * @return the clazz loaded from the new classloading system */ public Class initializeClassLoader(Class clazz, boolean importAll, Class... packages) { MockClassLoaderPolicy policy = new MockClassLoaderPolicy(); Set> classes = new HashSet>(); classes.add(clazz); for (Class c : packages) classes.add(c); policy.setImportAll(importAll); policy.setPathsAndPackageNames(classes.toArray(new Class[classes.size()])); return initializeClassLoader(clazz, policy); } /** * Initialize the classloader system * * @param clazz the original clazz * @param policy the policy * @return the clazz loaded from the new classloading system */ public Class initializeClassLoader(Class clazz, ClassLoaderPolicy policy) { ClassLoaderSystem system = new DefaultClassLoaderSystem(); return initializeClassLoader(clazz, system, policy, getParentPackages()); } /** * Initialize the classloader system * * @param clazz the original clazz * @param system the system * @param policy the policy * @return the clazz loaded from the new classloading system */ public Class initializeClassLoader(Class clazz, ClassLoaderSystem system, ClassLoaderPolicy policy) { return initializeClassLoader(clazz, system, policy, getParentPackages()); } /** * Initialize the classloader system * * @param clazz the original clazz * @param system the system * @param policy the policy * @param parentPackages the parentPackages * @return the clazz loaded from the new classloading system */ public Class initializeClassLoader(Class clazz, ClassLoaderSystem system, ClassLoaderPolicy policy, Set parentPackages) { String[] parentPkgs = parentPackages.toArray(new String[parentPackages.size()]); return initializeClassLoader(clazz, system, policy, parentPkgs); } /** * Initialize the classloader system * * @param clazz the original clazz * @param system the system * @param policy the policy * @param parentPackages the parentPackages * @return the clazz loaded from the new classloading system */ public Class initializeClassLoader(Class clazz, ClassLoaderSystem system, ClassLoaderPolicy policy, String... parentPackages) { // The parent filter PackageClassFilter filter = new PackageClassFilter(parentPackages); filter.setIncludeJava(true); return initializeClassLoader(clazz, system, filter, ClassFilter.NOTHING, policy); } /** * Initialize the classloader system * * @param clazz the original clazz * @param parentFilter the parent filter * @param importAll whether to import all * @param packages the reference classes for the packages * @return the clazz loaded from the new classloading system */ public Class initializeClassLoader(Class clazz, ClassFilter parentFilter, boolean importAll, Class... packages) { MockClassLoaderPolicy policy = new MockClassLoaderPolicy(); Set> classes = new HashSet>(); classes.add(clazz); for (Class c : packages) classes.add(c); policy.setImportAll(importAll); policy.setPathsAndPackageNames(classes.toArray(new Class[classes.size()])); return initializeClassLoader(clazz, parentFilter, policy); } /** * Initialize the classloader system * * @param clazz the original clazz * @param parentFilter the parent filter * @param policy the policy * @return the clazz loaded from the new classloading system */ public Class initializeClassLoader(Class clazz, ClassFilter parentFilter, ClassLoaderPolicy policy) { ClassLoaderSystem system = new DefaultClassLoaderSystem(); return initializeClassLoader(clazz, system, parentFilter, policy); } /** * Initialize the classloader system * * @param clazz the original clazz * @param system the system * @param parentFilter the parent filter * @param policy the policy * @return the clazz loaded from the new classloading system */ public Class initializeClassLoader(Class clazz, ClassLoaderSystem system, ClassFilter parentFilter, ClassLoaderPolicy policy) { Set parentPackages = getParentPackages(); String[] parentPkgs = parentPackages.toArray(new String[parentPackages.size()]); PackageClassFilter filter = new PackageClassFilter(parentPkgs); filter.setIncludeJava(true); CombiningClassFilter beforeFilter = CombiningClassFilter.create(filter, parentFilter); ParentPolicy parentPolicy = new ParentPolicy(beforeFilter, ClassFilter.NOTHING); return initializeClassLoader(clazz, system, parentPolicy, policy); } /** * Initialize the classloader system * * @param clazz the original clazz * @param system the system * @param beforeFilter the before filter * @param afterFilter the after filter * @param policy the policy * @return the clazz loaded from the new classloading system */ public Class initializeClassLoader(Class clazz, ClassLoaderSystem system, ClassFilter beforeFilter, ClassFilter afterFilter, ClassLoaderPolicy policy) { ParentPolicy parentPolicy = new ParentPolicy(beforeFilter, afterFilter); return initializeClassLoader(clazz, system, parentPolicy, policy); } /** * Initialize the classloader system * * @param clazz the original clazz * @param system the system * @param parentPolicy the parent policy * @param policy the policy * @return the clazz loaded from the new classloading system */ public Class initializeClassLoader(Class clazz, ClassLoaderSystem system, ParentPolicy parentPolicy, ClassLoaderPolicy policy) { ClassLoaderDomain domain = system.createAndRegisterDomain("TEST", parentPolicy); return initializeClassLoader(clazz, system, domain, policy); } /** * Initialize the classloader system * * @param clazz the original clazz * @param system the system * @param domain the domain * @param policy the policy * @return the clazz loaded from the new classloading system */ public Class initializeClassLoader(Class clazz, ClassLoaderSystem system, ClassLoaderDomain domain, ClassLoaderPolicy policy) { // Remember some information this.system = system; this.domain = domain; this.policy = policy; // Create the classloader ClassLoader classLoader = system.registerClassLoaderPolicy(domain, policy); // Load the class from the isolated classloader try { clazz = classLoader.loadClass(clazz.getName()); } catch (ClassNotFoundException e) { throw new RuntimeException("Unable to load test class in isolated classloader " + clazz, e); } return clazz; } /** * Create a classloader * * It exports everything * * @param name the name * @param importAll whether to import all * @param packages the packages * @return the classloader * @throws Exception for any error */ public ClassLoader createClassLoader(String name, boolean importAll, String... packages) throws Exception { MockClassLoaderPolicy policy = MockClassLoaderHelper.createMockClassLoaderPolicy(name); policy.setImportAll(importAll); policy.setPathsAndPackageNames(packages); return createClassLoader(policy); } /** * Create a classloader * * @param policy the policy * @return the classloader * @throws Exception for any error */ public ClassLoader createClassLoader(MockClassLoaderPolicy policy) throws Exception { ClassLoaderDomain domain = getDomain(); return createClassLoader(domain, policy); } /** * Create a classloader * * @param domainName the domainName * @param policy the policy * @return the classloader * @throws Exception for any error */ public ClassLoader createClassLoader(String domainName, MockClassLoaderPolicy policy) throws Exception { ClassLoaderSystem system = getSystem(); ClassLoaderDomain domain = system.getDomain(domainName); return createClassLoader(domain, policy); } /** * Create a classloader * * @param domain the domain * @param policy the policy * @return the classloader * @throws Exception for any error */ public ClassLoader createClassLoader(ClassLoaderDomain domain, MockClassLoaderPolicy policy) throws Exception { ClassLoaderSystem system = getSystem(); return MockClassLoaderHelper.registerMockClassLoader(system, domain, policy); } /** * Unregister a classloader * * @param classLoader the classloader * @throws Exception for any error */ public void unregisterClassLoader(ClassLoader classLoader) throws Exception { ClassLoaderSystem system = getSystem(); system.unregisterClassLoader(classLoader); } /** * Create the default delegate loader * * @return the loaders */ public List createDefaultDelegates() { return createDelegates(getPolicy()); } /** * Create delegate loaders from policies * * @param policies the policies * @return the loaders */ public List createDelegates(ClassLoaderPolicy... policies) { List delegates = new ArrayList(); for (ClassLoaderPolicy policy : policies) delegates.add(new FilteredDelegateLoader(policy)); return delegates; } /** * Create a scoped classloader domain using the test domain as parent * using the parent first policy * * @param name the name * @return the domain */ public ClassLoaderDomain createScopedClassLoaderDomainParentFirst(String name) { return createScopedClassLoaderDomain(name, ParentPolicy.BEFORE, getDomain()); } /** * Create a scoped classloader domain using the test domain as parent * using the parent last policy * * @param name the name * @return the domain */ public ClassLoaderDomain createScopedClassLoaderDomainParentLast(String name) { return createScopedClassLoaderDomain(name, ParentPolicy.AFTER_BUT_JAVA_BEFORE, getDomain()); } /** * Create a scoped classloader domain using the test domain as parent * * @param name the name * @param parentPolicy the parent policy * @return the domain */ public ClassLoaderDomain createScopedClassLoaderDomain(String name, ParentPolicy parentPolicy) { return createScopedClassLoaderDomain(name, parentPolicy, getDomain()); } /** * Create a scoped classloader domain * * @param name the name * @param parentPolicy the parent policy * @param parent the parent * @return the domain */ public ClassLoaderDomain createScopedClassLoaderDomain(String name, ParentPolicy parentPolicy, Loader parent) { ClassLoaderSystem system = getSystem(); return system.createAndRegisterDomain(name, parentPolicy, parent); } /** * Unregister a domain * * @param name the domain name */ public void unregisterDomain(String name) { ClassLoaderSystem system = getSystem(); ClassLoaderDomain domain = system.getDomain(name); if (domain == null) throw new IllegalStateException("Domain is not registered: " + name); system.unregisterDomain(domain); } } ././@LongLink0000000000000000000000000000020000000000000011555 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloader/src/main/java/org/jboss/classloader/test/support/MockClassLoaderPolicy.javalibjboss-classloader-java-2.0.6.GA.orig/classloader/src/main/java/org/jboss/classloader/test/support0000644000175000017500000003102710766222252033502 0ustar twernertwerner/* * JBoss, Home of Professional Open Source. * Copyright 2007, Red Hat Middleware LLC, and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.classloader.test.support; import java.io.IOException; import java.net.URL; import java.security.AccessController; import java.security.PrivilegedAction; import java.security.ProtectionDomain; import java.util.Arrays; import java.util.Enumeration; import java.util.Hashtable; import java.util.List; import java.util.Set; import javax.management.MalformedObjectNameException; import javax.management.ObjectName; import org.jboss.classloader.plugins.ClassLoaderUtils; import org.jboss.classloader.plugins.filter.PatternClassFilter; import org.jboss.classloader.spi.ClassLoaderPolicy; import org.jboss.classloader.spi.DelegateLoader; import org.jboss.classloader.spi.PackageInformation; import org.jboss.classloader.spi.filter.ClassFilter; /** * MockClassLoaderPolicy.

* * @author Adrian Brock * @version $Revision: 1.1 $ */ public class MockClassLoaderPolicy extends ClassLoaderPolicy { /** The logical name of the policy */ private String name; /** The prefix */ private String prefix = ""; /** The delegates */ private List delegates; /** The paths */ private String[] paths; /** The included resources */ private String[] included; /** The excluded resources */ private String[] excluded; /** The exported package names */ private String[] packageNames; /** Whether to import all */ private boolean importAll; /** The non JDK classes filter */ private ClassFilter nonJDKFilter; /** * Create a new MockClassLoaderPolicy filtering org.jboss.* classes * with logical name "mock" */ public MockClassLoaderPolicy() { this(null); } /** * Create a new MockClassLoaderPolicy filtering org.jboss.* classes * * @param name the logical name of the policy */ public MockClassLoaderPolicy(String name) { this(name, new String[] { "org\\.jboss\\..+" }, new String[] { "org/jboss/.+" }, new String[] { "org\\.jboss", "org\\.jboss\\..*" }); } /** * Create a new MockClassLoaderPolicy filtering org.jboss.* classes * * @param name the name * @param classPatterns the class patterns * @param resourcePatterns the resourcePatterns * @param packagePatterns the packagePatterns */ public MockClassLoaderPolicy(String name, String[] classPatterns, String[] resourcePatterns, String[] packagePatterns) { this(name, new PatternClassFilter(classPatterns, resourcePatterns, packagePatterns)); } /** * Create a new MockClassLoaderPolicy filtering the given patterns * * @param name the logical name of the policy * @param nonJDKFilter the filter for nonJDK classes * @throws IllegalArgumentException for a null filter */ public MockClassLoaderPolicy(String name, ClassFilter nonJDKFilter) { if (name == null) name = "mock"; this.name = name; if (nonJDKFilter == null) throw new IllegalArgumentException("Null filter"); this.nonJDKFilter = nonJDKFilter; } public String getName() { return name; } @Override public List getDelegates() { return delegates; } /** * Set the delegates * * @param delegates the delegate imports */ public void setDelegates(List delegates) { this.delegates = delegates; } /** * Get the prefix. * * @return the prefix. */ public String getPrefix() { return prefix; } /** * Set the prefix. * * @param prefix the prefix. */ public void setPrefix(String prefix) { this.prefix = prefix; } /** * Get the paths to expose * * @return the paths */ public String[] getPaths() { return paths; } /** * Set the path to expose * * @param path the path */ public void setPath(String path) { setPaths(path); } /** * Set the paths to expose * * @param paths the paths to expose */ public void setPaths(String... paths) { this.paths = paths; } /** * Set the paths to expose * * @param classes the classes to reference to determine the package paths */ public void setPaths(Class... classes) { if (classes == null) { paths = null; return; } paths = new String[classes.length]; for (int i = 0; i < classes.length; ++i) paths[i] = ClassLoaderUtils.packageNameToPath(classes[i].getName()); } @Override public String[] getPackageNames() { return packageNames; } /** * Set the exported package names * * @param packageNames the exported packages */ public void setPackageNames(String... packageNames) { this.packageNames = packageNames; } /** * Set the exported package names * * @param classes the classes to reference to determine the package names */ public void setPackageNames(Class... classes) { if (classes == null) { packageNames = null; return; } packageNames = new String[classes.length]; for (int i = 0; i < classes.length; ++i) packageNames[i] = ClassLoaderUtils.getClassPackageName(classes[i].getName()); } /** * Set the included classes * * @param included the classes to include from the paths */ public void setIncluded(String... included) { this.included = included; } /** * Set the included classes * * @param classes the classes to include from the paths */ public void setIncluded(Class... classes) { if (classes == null) { included = null; return; } included = new String[classes.length]; for (int i = 0; i < classes.length; ++i) included[i] = ClassLoaderUtils.classNameToPath(classes[i].getName()); } /** * Set the excluded classes * * @param excluded the classes to include from the paths */ public void setExcluded(String... excluded) { this.excluded = excluded; } /** * Set the excluded classes * * @param classes the classes to exclude from the paths */ public void setExcluded(Class... classes) { if (classes == null) { excluded = null; return; } excluded = new String[classes.length]; for (int i = 0; i < classes.length; ++i) excluded[i] = ClassLoaderUtils.classNameToPath(classes[i].getName()); } /** * Set the paths and the exported package names * * @param classes the classes to reference */ public void setPathsAndPackageNames(Class... classes) { setPaths(classes); setPackageNames(classes); } /** * Set the paths and the exported package names * * @param packages the packages */ public void setPathsAndPackageNames(String... packages) { if (packages == null) { paths = null; packageNames = null; return; } paths = new String[packages.length]; for (int i = 0; i < packages.length; ++i) paths[i] = packages[i].replace('.', '/'); setPackageNames(packages); } @Override public boolean isImportAll() { return importAll; } /** * Set the importAll. * * @param importAll the importAll. */ public void setImportAll(boolean importAll) { this.importAll = importAll; } @Override public URL getResource(String path) { if (paths == null) return null; if (excluded != null) { for (String excludedPath : excluded) { if (excludedPath.equals(path)) return null; } } if (included != null) { boolean include = false; for (String includedPath : included) { if (includedPath.equals(path)) { include = true; break; } } if (include == false) return null; } for (int i = 0; i < paths.length; ++i) { if (path.startsWith(paths[i])) return getClass().getClassLoader().getResource(prefix + path); } return null; } @Override public void getResources(String path, Set urls) throws IOException { if (paths == null) return; if (excluded != null) { for (String excludedPath : excluded) { if (excludedPath.equals(path)) return; } } if (included != null) { boolean include = false; for (String includedPath : included) { if (includedPath.equals(path)) { include = true; break; } } if (include == false) return; } ClassLoader parent = getClass().getClassLoader(); for (int i = 0; i < paths.length; ++i) { if (path.startsWith(paths[i])) { Enumeration enumeration = parent.getResources(prefix + path); while (enumeration.hasMoreElements()) urls.add(enumeration.nextElement()); } } } @Override protected ProtectionDomain getProtectionDomain(String className, String path) { final Class clazz; try { clazz = getClass().getClassLoader().loadClass(className); } catch (ClassNotFoundException e) { throw new Error("Could not load class: " + className, e); } return AccessController.doPrivileged(new PrivilegedAction() { public ProtectionDomain run() { return clazz.getProtectionDomain(); } }, getAccessControlContext()); } @Override public PackageInformation getPackageInformation(String packageName) { PackageInformation pi = new PackageInformation(packageName); pi.implTitle = name; return pi; } /* * Overridden to not expose classes in the nonJDKFilter * this is so we don't expose classes from the classpath * that we haven't explicitly declared in the policy */ @Override protected ClassLoader isJDKRequest(String name) { if (nonJDKFilter.matchesClassName(name)) return null; return super.isJDKRequest(name); } @Override public ObjectName getObjectName() { try { Hashtable properties = new Hashtable(); properties.put("name", "'" + name + "'"); properties.put("domain", "\"" + getDomainName() + "\""); return ObjectName.getInstance("jboss.classloader", properties); } catch (MalformedObjectNameException e) { throw new Error("Error creating object name", e); } } @Override public void toLongString(StringBuilder builder) { builder.append(" name=").append(name); if (prefix.length() > 0) builder.append(" prefix=").append(prefix); if (paths != null) builder.append(" paths=").append(Arrays.asList(paths)); if (included != null) builder.append(" included=").append(Arrays.asList(included)); if (excluded != null) builder.append(" excluded=").append(Arrays.asList(excluded)); super.toLongString(builder); } @Override public String toString() { return name; } } ././@LongLink0000000000000000000000000000020000000000000011555 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloader/src/main/java/org/jboss/classloader/test/support/MockClassLoaderHelper.javalibjboss-classloader-java-2.0.6.GA.orig/classloader/src/main/java/org/jboss/classloader/test/support0000644000175000017500000002024110760772456033510 0ustar twernertwerner/* * JBoss, Home of Professional Open Source. * Copyright 2007, Red Hat Middleware LLC, and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.classloader.test.support; import java.security.AccessController; import java.security.PrivilegedAction; import org.jboss.classloader.plugins.system.DefaultClassLoaderSystem; import org.jboss.classloader.spi.ClassLoaderDomain; import org.jboss.classloader.spi.ClassLoaderSystem; import org.jboss.classloader.spi.Loader; import org.jboss.classloader.spi.ParentPolicy; /** * MockClassLoaderHelper

* * WARNING. This class/package should be excluded from the release * * @author Adrian Brock * @version $Revision: 1.1 $ */ public class MockClassLoaderHelper { /** * Create a mock classloading system

* * No security problem. A user can create their own classloader system, so what? * * @return the new classloading system */ public static ClassLoaderSystem createMockClassLoaderSystem() { return new DefaultClassLoaderSystem(); } /** * Create a mock classloader policy with the given name * * @param name the name * @return the policy */ public static MockClassLoaderPolicy createMockClassLoaderPolicy(final String name) { return AccessController.doPrivileged(new PrivilegedAction() { public MockClassLoaderPolicy run() { return new MockClassLoaderPolicy(name); } }); } /** * Create and register a mock classloader policy

* * No security problem here. The user needs access to a ClassLoaderSystem * to register a classloader with it. * * @param system the system * @param domain the domain * @param name the name * @return the classloader */ public static ClassLoader createAndRegisterMockClassLoader(final ClassLoaderSystem system, final ClassLoaderDomain domain, final String name) { return AccessController.doPrivileged(new PrivilegedAction() { public ClassLoader run() { MockClassLoaderPolicy policy = new MockClassLoaderPolicy(name); if (domain == null) return system.registerClassLoaderPolicy(policy); else return system.registerClassLoaderPolicy(domain, policy); } }); } /** * Create and register a mock classloader policy

* * No security problem here. The user needs access to a ClassLoaderSystem * to register a classloader with it. * * @param system the system * @param domainName the domain name * @param name the name * @return the classloader */ public static ClassLoader createAndRegisterMockClassLoader(final ClassLoaderSystem system, final String domainName, final String name) { return AccessController.doPrivileged(new PrivilegedAction() { public ClassLoader run() { MockClassLoaderPolicy policy = new MockClassLoaderPolicy(name); return system.registerClassLoaderPolicy(domainName, policy); } }); } /** * Create and register a mock classloader policy

* * No security problem here. The user needs access to a ClassLoaderSystem * to register a classloader with it. * * @param system the system * @param domainName the domain name * @param parentPolicy the parent policy * @param name the name * @return the classloader */ public static ClassLoader createAndRegisterMockClassLoader(final ClassLoaderSystem system, final String domainName, final ParentPolicy parentPolicy, final String name) { return AccessController.doPrivileged(new PrivilegedAction() { public ClassLoader run() { MockClassLoaderPolicy policy = new MockClassLoaderPolicy(name); return system.registerClassLoaderPolicy(domainName, parentPolicy, policy); } }); } /** * Create and register a mock classloader policy

* * No security problem here. The user needs access to a ClassLoaderSystem * to register a classloader with it. * * @param system the system * @param domainName the domain name * @param parentPolicy the parent policy * @param parentDomainName the parent domain name * @param name the name * @return the classloader */ public static ClassLoader createAndRegisterMockClassLoader(final ClassLoaderSystem system, final String domainName, final ParentPolicy parentPolicy, final String parentDomainName, final String name) { return AccessController.doPrivileged(new PrivilegedAction() { public ClassLoader run() { MockClassLoaderPolicy policy = new MockClassLoaderPolicy(name); return system.registerClassLoaderPolicy(domainName, parentPolicy, parentDomainName, policy); } }); } /** * Create and register a mock classloader policy

* * No security problem here. The user needs access to a ClassLoaderSystem * to register a classloader with it. * * @param system the system * @param domainName the domain name * @param parentPolicy the parent policy * @param parent the parent loader * @param name the name * @return the classloader */ public static ClassLoader createAndRegisterMockClassLoader(final ClassLoaderSystem system, final String domainName, final ParentPolicy parentPolicy, final Loader parent, final String name) { return AccessController.doPrivileged(new PrivilegedAction() { public ClassLoader run() { MockClassLoaderPolicy policy = new MockClassLoaderPolicy(name); return system.registerClassLoaderPolicy(domainName, parentPolicy, parent, policy); } }); } /** * Register a mock classloader policy

* * No security problem here. The user needs access to a ClassLoaderSystem * to register a classloader with it. * * @param system the system * @param domain the domain * @param policy the policy * @return the classloader */ public static ClassLoader registerMockClassLoader(final ClassLoaderSystem system, final ClassLoaderDomain domain, final MockClassLoaderPolicy policy) { return AccessController.doPrivileged(new PrivilegedAction() { public ClassLoader run() { if (domain == null) return system.registerClassLoaderPolicy(policy); else return system.registerClassLoaderPolicy(domain, policy); } }); } /** * Check whether a class has the expected classloader * * @param clazz the class * @param expected the expected classloader * @return true when it has the expected classloader */ public static boolean isExpectedClassLoader(final Class clazz, final ClassLoader expected) { ClassLoader classLoader = AccessController.doPrivileged(new PrivilegedAction() { public ClassLoader run() { return clazz.getClassLoader(); } }); if (classLoader == null) return expected == null; return classLoader.equals(expected); } } libjboss-classloader-java-2.0.6.GA.orig/classloader/src/main/java/org/jboss/classloader/plugins/0000755000175000017500000000000011620043422032530 5ustar twernertwerner././@LongLink0000000000000000000000000000015000000000000011561 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloader/src/main/java/org/jboss/classloader/plugins/filter/libjboss-classloader-java-2.0.6.GA.orig/classloader/src/main/java/org/jboss/classloader/plugins/filt0000755000175000017500000000000011620043422033407 5ustar twernertwerner././@LongLink0000000000000000000000000000020000000000000011555 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloader/src/main/java/org/jboss/classloader/plugins/filter/JavaOnlyClassFilter.javalibjboss-classloader-java-2.0.6.GA.orig/classloader/src/main/java/org/jboss/classloader/plugins/filt0000644000175000017500000000357010741370313033423 0ustar twernertwerner/* * JBoss, Home of Professional Open Source. * Copyright 2007, Red Hat Middleware LLC, and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.classloader.plugins.filter; /** * A class filter that only delegates standard java classes * * @author Adrian Brock * @version $Revision: 1.1 $ */ public class JavaOnlyClassFilter extends PatternClassFilter { /** The singleton instance */ public static final JavaOnlyClassFilter INSTANCE = new JavaOnlyClassFilter(); /** * Create a new JavaOnlyClassFilter. */ private JavaOnlyClassFilter() { super(new String[] { "java\\..+", "javax\\..+" }, new String[] { "java/.+", "javax/.+" }, new String[] { "java", "java\\..*", "javax", "javax\\..*" }); } public String toString() { return "JAVA_ONLY"; } @Override public void setIncludeJava(boolean includeJava) { throw new UnsupportedOperationException("This class is immutable"); } } ././@LongLink0000000000000000000000000000020100000000000011556 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloader/src/main/java/org/jboss/classloader/plugins/filter/CombiningClassFilter.javalibjboss-classloader-java-2.0.6.GA.orig/classloader/src/main/java/org/jboss/classloader/plugins/filt0000644000175000017500000000706510755315541033435 0ustar twernertwerner/* * JBoss, Home of Professional Open Source * Copyright 2006, JBoss Inc., and individual contributors as indicated * by the @authors tag. See the copyright.txt in the distribution for a * full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.classloader.plugins.filter; import org.jboss.classloader.spi.filter.ClassFilter; /** * CombiningClassFilter. * * @author Adrian Brock * @version $Revision: 1.1 $ */ public class CombiningClassFilter implements ClassFilter { /** Whether it is an "and" filter */ private boolean and = false; /** The filters */ private ClassFilter[] filters; /** * Create a new CombiningClassFilter. * * @param filters the filters * @return the filter * @throws IllegalArgumentException for null filters */ public static CombiningClassFilter create(ClassFilter... filters) { return new CombiningClassFilter(false, filters); } /** * Create a new CombiningClassFilter. * * @param and whether it is an "and" filter * @param filters the filters * @return the filter * @throws IllegalArgumentException for null filters */ public static CombiningClassFilter create(boolean and, ClassFilter... filters) { return new CombiningClassFilter(and, filters); } /** * Create a new CombiningClassFilter. * * @param and whether it is an "and" filter * @param filters the filters * @throws IllegalArgumentException for null filters */ public CombiningClassFilter(boolean and, ClassFilter[] filters) { if (filters == null) throw new IllegalArgumentException("Null filters"); this.and = and; this.filters = filters; } public boolean matchesClassName(String className) { for (ClassFilter filter : filters) { if (filter.matchesClassName(className)) return true; else if (and) return false; } return false; } public boolean matchesResourcePath(String resourcePath) { for (ClassFilter filter : filters) { if (filter.matchesResourcePath(resourcePath)) return true; else if (and) return false; } return false; } public boolean matchesPackageName(String packageName) { for (ClassFilter filter : filters) { if (filter.matchesPackageName(packageName)) return true; else if (and) return false; } return false; } @Override public String toString() { StringBuilder builder = new StringBuilder(); for (int i = 0; i < filters.length; ++i) { builder.append(filters[i]); if (i < filters.length-1) builder.append(", "); } return builder.toString(); } } ././@LongLink0000000000000000000000000000020200000000000011557 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloader/src/main/java/org/jboss/classloader/plugins/filter/EverythingClassFilter.javalibjboss-classloader-java-2.0.6.GA.orig/classloader/src/main/java/org/jboss/classloader/plugins/filt0000644000175000017500000000360710741370313033424 0ustar twernertwerner/* * JBoss, Home of Professional Open Source. * Copyright 2007, Red Hat Middleware LLC, and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.classloader.plugins.filter; import org.jboss.classloader.spi.filter.ClassFilter; /** * A class filter that matches everything * * @author Adrian Brock * @version $Revision: 1.1 $ */ public class EverythingClassFilter implements ClassFilter { /** The singleton instance */ public static final EverythingClassFilter INSTANCE = new EverythingClassFilter(); /** * Create a new EverythingClassFilter. */ private EverythingClassFilter() { // Singleton } public boolean matchesClassName(String className) { return true; } public boolean matchesResourcePath(String resourcePath) { return true; } public boolean matchesPackageName(String packageName) { return true; } @Override public String toString() { return ""; } } ././@LongLink0000000000000000000000000000017700000000000011572 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloader/src/main/java/org/jboss/classloader/plugins/filter/PatternClassFilter.javalibjboss-classloader-java-2.0.6.GA.orig/classloader/src/main/java/org/jboss/classloader/plugins/filt0000644000175000017500000001262410741370313033423 0ustar twernertwerner/* * JBoss, Home of Professional Open Source. * Copyright 2007, Red Hat Middleware LLC, and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.classloader.plugins.filter; import java.util.Arrays; import java.util.regex.Matcher; import java.util.regex.Pattern; import org.jboss.classloader.spi.filter.ClassFilter; /** * A class filter using regular expressions * * @author Adrian Brock * @version $Revision: 1.1 $ */ public class PatternClassFilter implements ClassFilter { /** The class patterns as regular expressions */ private Pattern[] classPatterns; /** The resource patterns as regular expressions */ private Pattern[] resourcePatterns; /** The package patterns as regular expressions */ private Pattern[] packagePatterns; /** Whether to include java */ private boolean includeJava = false; /** * Create a new PatternClassFilter. * * @param classPatterns the class patterns * @param resourcePatterns the resource patterns * @param packagePatterns the package patterns * @throws IllegalArgumentException for a null pattern */ public PatternClassFilter(String[] classPatterns, String[] resourcePatterns, String[] packagePatterns) { if (classPatterns == null) throw new IllegalArgumentException("Null patterns"); this.classPatterns = new Pattern[classPatterns.length]; for (int i = 0; i < classPatterns.length; ++i) { if (classPatterns[i] == null) throw new IllegalArgumentException("Null pattern in " + Arrays.asList(classPatterns)); this.classPatterns[i] = Pattern.compile(classPatterns[i]); } if (resourcePatterns == null) { this.resourcePatterns = this.classPatterns; return; } this.resourcePatterns = new Pattern[resourcePatterns.length]; for (int i = 0; i < resourcePatterns.length; ++i) { if (resourcePatterns[i] == null) throw new IllegalArgumentException("Null pattern in " + Arrays.asList(resourcePatterns)); this.resourcePatterns[i] = Pattern.compile(resourcePatterns[i]); } if (packagePatterns == null) { this.packagePatterns = this.classPatterns; return; } this.packagePatterns = new Pattern[packagePatterns.length]; for (int i = 0; i < packagePatterns.length; ++i) { if (packagePatterns[i] == null) throw new IllegalArgumentException("Null pattern in " + Arrays.asList(packagePatterns)); this.packagePatterns[i] = Pattern.compile(packagePatterns[i]); } } /** * Get the includeJava. * * @return the includeJava. */ public boolean isIncludeJava() { return includeJava; } /** * Set the includeJava. * * @param includeJava the includeJava. */ public void setIncludeJava(boolean includeJava) { this.includeJava = includeJava; } public boolean matchesClassName(String className) { if (className == null) return false; for (int i = 0; i < classPatterns.length; ++i) { Matcher matcher = classPatterns[i].matcher(className); if (matcher.matches()) return true; } if (includeJava == false) return false; return JavaOnlyClassFilter.INSTANCE.matchesClassName(className); } public boolean matchesResourcePath(String resourcePath) { if (resourcePath == null) return false; for (int i = 0; i < resourcePatterns.length; ++i) { Matcher matcher = resourcePatterns[i].matcher(resourcePath); if (matcher.matches()) return true; } if (includeJava == false) return false; return JavaOnlyClassFilter.INSTANCE.matchesResourcePath(resourcePath); } public boolean matchesPackageName(String packageName) { if (packageName == null) return false; for (int i = 0; i < packagePatterns.length; ++i) { Matcher matcher = packagePatterns[i].matcher(packageName); if (matcher.matches()) return true; } if (includeJava == false) return false; return JavaOnlyClassFilter.INSTANCE.matchesPackageName(packageName); } @Override public String toString() { StringBuilder builder = new StringBuilder(); builder.append(Arrays.asList(classPatterns)); if (isIncludeJava()) builder.append(" "); return builder.toString(); } } ././@LongLink0000000000000000000000000000017700000000000011572 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloader/src/main/java/org/jboss/classloader/plugins/filter/NothingClassFilter.javalibjboss-classloader-java-2.0.6.GA.orig/classloader/src/main/java/org/jboss/classloader/plugins/filt0000644000175000017500000000356510741370313033427 0ustar twernertwerner/* * JBoss, Home of Professional Open Source. * Copyright 2007, Red Hat Middleware LLC, and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.classloader.plugins.filter; import org.jboss.classloader.spi.filter.ClassFilter; /** * A class filter that matches nothing * * @author Adrian Brock * @version $Revision: 1.1 $ */ public class NothingClassFilter implements ClassFilter { /** The singleton instance */ public static final NothingClassFilter INSTANCE = new NothingClassFilter(); /** * Create a new NothingClassFilter. */ private NothingClassFilter() { // Singleton } public boolean matchesClassName(String className) { return false; } public boolean matchesResourcePath(String resourcePath) { return false; } public boolean matchesPackageName(String packageName) { return false; } @Override public String toString() { return ""; } } ././@LongLink0000000000000000000000000000020600000000000011563 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloader/src/main/java/org/jboss/classloader/plugins/filter/NothingButJavaClassFilter.javalibjboss-classloader-java-2.0.6.GA.orig/classloader/src/main/java/org/jboss/classloader/plugins/filt0000644000175000017500000000353710741370313033426 0ustar twernertwerner/* * JBoss, Home of Professional Open Source. * Copyright 2007, Red Hat Middleware LLC, and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.classloader.plugins.filter; /** * A class filter that only delegates java.* classes * * @author Adrian Brock * @version $Revision: 1.1 $ */ public class NothingButJavaClassFilter extends PatternClassFilter { /** The singleton instance */ public static final NothingButJavaClassFilter INSTANCE = new NothingButJavaClassFilter(); /** * Create a new JavaOnlyClassFilter. */ private NothingButJavaClassFilter() { super(new String[] { "java\\..+" }, new String[] { "java/.+" }, new String[] { "java", "java\\..*" }); } public String toString() { return "NOTHING_BUT_JAVA"; } @Override public void setIncludeJava(boolean includeJava) { throw new UnsupportedOperationException("This class is immutable"); } } ././@LongLink0000000000000000000000000000015000000000000011561 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloader/src/main/java/org/jboss/classloader/plugins/system/libjboss-classloader-java-2.0.6.GA.orig/classloader/src/main/java/org/jboss/classloader/plugins/syst0000755000175000017500000000000011620043422033453 5ustar twernertwerner././@LongLink0000000000000000000000000000020500000000000011562 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloader/src/main/java/org/jboss/classloader/plugins/system/DefaultClassLoaderSystem.javalibjboss-classloader-java-2.0.6.GA.orig/classloader/src/main/java/org/jboss/classloader/plugins/syst0000644000175000017500000000273310614350067033472 0ustar twernertwerner/* * JBoss, Home of Professional Open Source. * Copyright 2007, Red Hat Middleware LLC, and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.classloader.plugins.system; import org.jboss.classloader.spi.ClassLoaderDomain; import org.jboss.classloader.spi.ClassLoaderSystem; /** * DefaultClassLoaderSystem. * * @author Adrian Brock * @version $Revision: 1.1 $ */ public class DefaultClassLoaderSystem extends ClassLoaderSystem { @Override protected ClassLoaderDomain createDomain(String name) { return new ClassLoaderDomain(name); } } ././@LongLink0000000000000000000000000000020500000000000011562 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloader/src/main/java/org/jboss/classloader/plugins/system/ClassLoaderSystemBuilder.javalibjboss-classloader-java-2.0.6.GA.orig/classloader/src/main/java/org/jboss/classloader/plugins/syst0000644000175000017500000000461710616435067033503 0ustar twernertwerner/* * JBoss, Home of Professional Open Source. * Copyright 2007, Red Hat Middleware LLC, and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.classloader.plugins.system; import java.security.AccessController; import java.security.PrivilegedAction; import org.jboss.classloader.spi.ClassLoaderSystem; /** * ClassLoaderSystemBuilder. * * @author Adrian Brock * @version $Revision: 1.1 $ */ public class ClassLoaderSystemBuilder { /** The singleton */ private static final ClassLoaderSystem singleton; static { singleton = AccessController.doPrivileged(new PrivilegedAction() { public ClassLoaderSystem run() { String className = System.getProperty(ClassLoaderSystem.class.getName(), DefaultClassLoaderSystem.class.getName()); try { Class clazz = Thread.currentThread().getContextClassLoader().loadClass(className); Object result = clazz.newInstance(); return ClassLoaderSystem.class.cast(result); } catch (RuntimeException e) { throw e; } catch (Exception e) { throw new Error("Unexpected error loading ClassLoaderSystem " + className, e); } } }); } /** * Get the classloader system singleton * * @return the singleton */ public static ClassLoaderSystem get() { return singleton; } } ././@LongLink0000000000000000000000000000016600000000000011570 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloader/src/main/java/org/jboss/classloader/plugins/ClassLoaderUtils.javalibjboss-classloader-java-2.0.6.GA.orig/classloader/src/main/java/org/jboss/classloader/plugins/Clas0000644000175000017500000002035711104654535033356 0ustar twernertwerner/* * JBoss, Home of Professional Open Source. * Copyright 2007, Red Hat Middleware LLC, and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.classloader.plugins; import java.io.ByteArrayOutputStream; import java.io.IOException; import java.io.InputStream; import java.security.AccessController; import java.security.CodeSource; import java.security.PrivilegedAction; import java.security.ProtectionDomain; /** * ClassLoaderUtils. * * @author Adrian Brock * @author Ales Justin * @version $Revision: 1.1 $ */ public class ClassLoaderUtils { /** * Check the class name makes sense * * @param className the class name * @throws ClassNotFoundException for a malformed class name */ public static final void checkClassName(final String className) throws ClassNotFoundException { if (className == null) throw new ClassNotFoundException("Null class name"); if (className.trim().length() == 0) throw new ClassNotFoundException("Empty class name '" + className + "'"); } /** * Convert a class name into a path * * @param className the class name * @return the path */ public static final String classNameToPath(final String className) { if (className == null) throw new IllegalArgumentException("Null className"); return className.replace('.', '/') + ".class"; } /** * Convert a class into a path * * @param clazz the class * @return the path */ public static final String classNameToPath(final Class clazz) { if (clazz == null) throw new IllegalArgumentException("Null class"); return classNameToPath(clazz.getName()); } /** * Convert a resource name to a class name * * @param resourceName the resource name * @return the class name or null if it is not a class */ public static final String resourceNameToClassName(String resourceName) { if (resourceName.endsWith(".class") == false) return null; resourceName = resourceName.substring(0, resourceName.length()-6); return resourceName.replace('/', '.'); } /** * Convert a class's package name into a path * * @param className the class name * @return the path */ public static final String packageNameToPath(final String className) { String packageName = getClassPackageName(className); return packageName.replace('.', '/'); } /** * Get the package name for a class * * @param className the class name * @return the package name or the empty string if there is no package */ public static final String getClassPackageName(final String className) { int end = className.lastIndexOf('.'); if (end == -1) return ""; return className.substring(0, end); } /** * Get the package name for a class * * @param className the class name * @return the package name or the empty string if there is no package */ public static final String getResourcePackageName(final String className) { int i = className.lastIndexOf('/'); if (i == -1) return ""; return className.substring(0, i).replace('/', '.'); } /** * Load bytecode from a stream * * @param name the class name * @param is the input stream * @return the byte code */ public static final byte[] loadByteCode(String name, final InputStream is) { try { return readBytes(is); } catch (IOException e) { throw new RuntimeException("Unable to load class byte code " + name, e); } finally { try { is.close(); } catch (IOException e) { // pointless } } } /** * Load bytes from a stream * * @param is the input stream * @return the bytes * @throws IOException for any error */ public static final byte[] loadBytes(final InputStream is) throws IOException { try { return readBytes(is); } finally { try { is.close(); } catch (IOException e) { // pointless } } } /** * Read bytes. * Doesn't close inputstream. * * @param is the input stream * @return the bytes * @throws IOException for any error * @throws IllegalArgumentException for null is parameter */ protected static final byte[] readBytes(final InputStream is) throws IOException { if (is == null) throw new IllegalArgumentException("Null input stream."); ByteArrayOutputStream baos = new ByteArrayOutputStream(); byte[] tmp = new byte[1024]; int read ; while ((read = is.read(tmp)) >= 0) { baos.write(tmp, 0, read); } return baos.toByteArray(); } /** * Formats the class as a string * * @param clazz the class * @return the string */ public static final String classToString(final Class clazz) { if (clazz == null) return "null"; StringBuilder builder = new StringBuilder(); classToString(clazz, builder); return builder.toString(); } /** * Formats a class into a string builder * * @param clazz the class * @param builder the builder */ public static final void classToString(final Class clazz, StringBuilder builder) { if (clazz == null) { builder.append("null"); return; } builder.append(clazz); builder.append('{'); ClassLoader cl = getClassLoader(clazz); builder.append("cl=").append(cl); builder.append(" codeSource="); builder.append(getCodeSource(clazz)); builder.append("}"); } /** * Get the classloader for a class * * @param clazz the class * @return the classloader or null if it doesn't have one */ private static final ClassLoader getClassLoader(final Class clazz) { SecurityManager sm = System.getSecurityManager(); if (sm == null) return clazz.getClassLoader(); return AccessController.doPrivileged(new PrivilegedAction() { public ClassLoader run() { return clazz.getClassLoader(); } }); } /** * Get the protected domain for a class * * @param clazz the class * @return the protected domain or null if it doesn't have one */ private static final ProtectionDomain getProtectionDomain(final Class clazz) { SecurityManager sm = System.getSecurityManager(); if (sm == null) return clazz.getProtectionDomain(); return AccessController.doPrivileged(new PrivilegedAction() { public ProtectionDomain run() { return clazz.getProtectionDomain(); } }); } /** * Get the code source for a class * * @param clazz the class * @return the code source or null if it doesn't have one */ private static final CodeSource getCodeSource(final Class clazz) { ProtectionDomain protectionDomain = getProtectionDomain(clazz); if (protectionDomain == null) return null; return protectionDomain.getCodeSource(); } } ././@LongLink0000000000000000000000000000014500000000000011565 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloader/src/main/java/org/jboss/classloader/plugins/jdk/libjboss-classloader-java-2.0.6.GA.orig/classloader/src/main/java/org/jboss/classloader/plugins/jdk/0000755000175000017500000000000011620043422033300 5ustar twernertwerner././@LongLink0000000000000000000000000000017400000000000011567 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloader/src/main/java/org/jboss/classloader/plugins/jdk/AbstractJDKChecker.javalibjboss-classloader-java-2.0.6.GA.orig/classloader/src/main/java/org/jboss/classloader/plugins/jdk/0000644000175000017500000001103110741370313033303 0ustar twernertwerner/* * JBoss, Home of Professional Open Source. * Copyright 2007, Red Hat Middleware LLC, and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.classloader.plugins.jdk; import java.security.AccessController; import java.security.PrivilegedAction; import java.util.Set; import java.util.concurrent.CopyOnWriteArraySet; import org.jboss.classloader.spi.base.BaseClassLoader; import org.jboss.classloader.spi.base.BaseClassLoaderDomain; import org.jboss.classloader.spi.base.BaseClassLoaderPolicy; import org.jboss.classloader.spi.jdk.JDKChecker; /** * AbstractJDKChecker. * * @author Adrian Brock * @version $Revision: 1.1 $ */ public class AbstractJDKChecker implements JDKChecker { /** The hack to the security manager */ private static final Hack hack; /** Classes in the classpath that should be excluded: FOR TESTING ONLY */ private static Set> excluded = new CopyOnWriteArraySet>(); static { hack = AccessController.doPrivileged(new PrivilegedAction() { public Hack run() { return new Hack(); } }); } /** * Whether the class is excluded * * @param clazz the class * @return whether the class is excluded */ public boolean isExcluded(Class clazz) { // No excludes if (excluded.isEmpty()) return false; for (Class exclude : excluded) { if (exclude.isAssignableFrom(clazz)) return true; } // Not excluded return false; } /** * The excluded classes * * @return the excluded classes */ public static Set> getExcluded() { SecurityManager sm = System.getSecurityManager(); if (sm != null) sm.checkCreateClassLoader(); return excluded; } public boolean isJDKRequest(String name) { Class requesting = getRequestingClass(hack.getClassContext()); return isJDKRequestingClass(name, requesting); } /** * Get the requesting class * * @param stack the class stack * @return the requesting class */ protected Class getRequestingClass(Class[] stack) { for (Class clazz : stack) { if (Hack.class.isAssignableFrom(clazz) == false && JDKChecker.class.isAssignableFrom(clazz) == false && BaseClassLoaderDomain.class.isAssignableFrom(clazz) == false && BaseClassLoaderPolicy.class.isAssignableFrom(clazz) == false && ClassLoader.class.isAssignableFrom(clazz) == false && Class.class.isAssignableFrom(clazz) == false) { return clazz; } } throw new RuntimeException("Should not be here!"); } /** * Whether the requesting class is from the JDK

* * The default implementation returns true if the requesting class is not loaded from a * {@link BaseClassLoader} * * @param name the name of the class being loaded * @param requesting the requesting class * @return true it is from the JDK */ protected boolean isJDKRequestingClass(String name, Class requesting) { if (isExcluded(requesting)) return false; ClassLoader cl = requesting.getClassLoader(); if (cl == null) return true; return (cl instanceof BaseClassLoader == false); } /** * Extend the security manager so we can get access to the stacktrace */ private static class Hack extends SecurityManager { @Override public Class[] getClassContext() { return super.getClassContext(); } } } ././@LongLink0000000000000000000000000000015000000000000011561 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloader/src/main/java/org/jboss/classloader/plugins/loader/libjboss-classloader-java-2.0.6.GA.orig/classloader/src/main/java/org/jboss/classloader/plugins/load0000755000175000017500000000000011620043422033370 5ustar twernertwerner././@LongLink0000000000000000000000000000020700000000000011564 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloader/src/main/java/org/jboss/classloader/plugins/loader/ClassLoaderToLoaderAdapter.javalibjboss-classloader-java-2.0.6.GA.orig/classloader/src/main/java/org/jboss/classloader/plugins/load0000644000175000017500000001443611137575176033425 0ustar twernertwerner/* * JBoss, Home of Professional Open Source. * Copyright 2007, Red Hat Middleware LLC, and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.classloader.plugins.loader; import java.io.IOException; import java.lang.reflect.Method; import java.net.URL; import java.security.AccessControlContext; import java.security.AccessController; import java.security.PrivilegedAction; import java.security.PrivilegedActionException; import java.security.PrivilegedExceptionAction; import java.util.Enumeration; import java.util.Set; import org.jboss.classloader.spi.Loader; import org.jboss.classloader.spi.base.BaseClassLoaderSource; import org.jboss.logging.Logger; /** * ClassLoaderToLoaderAdapter. * * @author Adrian Brock * @version $Revision: 1.1 $ */ public class ClassLoaderToLoaderAdapter extends BaseClassLoaderSource implements Loader { /** The log */ private static final Logger log = Logger.getLogger(ClassLoaderToLoaderAdapter.class); /** The access control context of the creator of this adapter */ private AccessControlContext accessControlContext; /** The get package method */ private static Method getPackage; /** The get packages method */ private static Method getPackages; static { AccessController.doPrivileged(new PrivilegedAction() { public Object run() { try { getPackage = ClassLoader.class.getDeclaredMethod("getPackage", String.class); getPackage.setAccessible(true); } catch (Exception e) { log.warn("Unable to set accessible on ClassLoader.getPackage()", e); } try { getPackages = ClassLoader.class.getDeclaredMethod("getPackages"); getPackages.setAccessible(true); } catch (Exception e) { log.warn("Unable to set accessible on ClassLoader.getPackages()", e); } return null; } }); } /** * Create a new ClassLoaderToLoaderAdapter. * * @param classLoader the classloader */ public ClassLoaderToLoaderAdapter(ClassLoader classLoader) { super(classLoader); accessControlContext = AccessController.getContext(); } public URL getResource(final String name) { final ClassLoader classLoader = getClassLoader(); URL url; SecurityManager sm = System.getSecurityManager(); if (sm != null) { url = AccessController.doPrivileged(new PrivilegedAction() { public URL run() { return classLoader.getResource(name); } }, accessControlContext); } else { url = classLoader.getResource(name); } if (log.isTraceEnabled()) { if (url != null) log.trace("Resource " + name + " found in " + classLoader); else log.trace("Resource " + name + " NOT found in " + classLoader); } return url; } public void getResources(final String name, Set urls) throws IOException { final ClassLoader classLoader = getClassLoader(); Enumeration enumeration; SecurityManager sm = System.getSecurityManager(); if (sm != null) { try { enumeration = AccessController.doPrivileged(new PrivilegedExceptionAction>() { public Enumeration run() throws Exception { return classLoader.getResources(name); } }, accessControlContext); } catch (PrivilegedActionException e) { Exception e1 = e.getException(); if (e1 instanceof RuntimeException) throw (RuntimeException) e1; if (e1 instanceof IOException) throw (IOException) e1; IOException e2 = new IOException("Unexpected error"); e2.initCause(e1); throw e2; } } else { enumeration = classLoader.getResources(name); } while (enumeration.hasMoreElements()) urls.add(enumeration.nextElement()); } public Class loadClass(String className) { final ClassLoader classLoader = getClassLoader(); try { return Class.forName(className, false, classLoader); } catch (ClassNotFoundException e) { return null; } } public Package getPackage(String name) { final ClassLoader classLoader = getClassLoader(); if (getPackage == null) return null; try { return (Package) getPackage.invoke(classLoader, name); } catch (Exception e) { log.warn("Unexpected error retrieving package " + name + " from classloader " + classLoader, e); return null; } } public void getPackages(Set packages) { final ClassLoader classLoader = getClassLoader(); if (getPackages == null) return; try { getPackages.invoke(classLoader); } catch (Exception e) { log.warn("Unexpected error retrieving packages from classloader " + classLoader, e); } } @Override public String toString() { return getClassLoader().toString(); } } libjboss-classloader-java-2.0.6.GA.orig/classloader/src/main/java/org/jboss/classloader/spi/0000755000175000017500000000000011620043423031643 5ustar twernertwerner././@LongLink0000000000000000000000000000017000000000000011563 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloader/src/main/java/org/jboss/classloader/spi/ClassLoaderSystemMBean.javalibjboss-classloader-java-2.0.6.GA.orig/classloader/src/main/java/org/jboss/classloader/spi/ClassLoa0000644000175000017500000000270010760647753033312 0ustar twernertwerner/* * JBoss, Home of Professional Open Source * Copyright 2007, JBoss Inc., and individual contributors as indicated * by the @authors tag. See the copyright.txt in the distribution for a * full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.classloader.spi; import java.util.Set; import javax.management.ObjectName; /** * ClassLoaderSystemMBean. * * @author Adrian Brock * @version $Revision: 1.1 $ */ public interface ClassLoaderSystemMBean { /** * Get the domains * * @return the domains */ Set getDomains(); /** * Get the domain names * * @return the domain names */ Set getDomainNames(); } ././@LongLink0000000000000000000000000000016000000000000011562 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloader/src/main/java/org/jboss/classloader/spi/DelegateLoader.javalibjboss-classloader-java-2.0.6.GA.orig/classloader/src/main/java/org/jboss/classloader/spi/Delegate0000644000175000017500000000340310761270232033305 0ustar twernertwerner/* * JBoss, Home of Professional Open Source. * Copyright 2007, Red Hat Middleware LLC, and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.classloader.spi; import org.jboss.classloader.spi.base.BaseDelegateLoader; /** * DelegateLoader. * * @author Adrian Brock * @version $Revision: 1.1 $ */ public class DelegateLoader extends BaseDelegateLoader implements Loader { /** * Create a new DelegateLoader. * * @param delegate the delegate * @throws IllegalArgumentException for a null delegate */ public DelegateLoader(ClassLoaderPolicy delegate) { super(delegate); } /** * Create a new DelegateLoader. * * @param factory the factory * @throws IllegalArgumentException for a null delegate */ public DelegateLoader(ClassLoaderPolicyFactory factory) { super(factory); } } ././@LongLink0000000000000000000000000000015600000000000011567 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloader/src/main/java/org/jboss/classloader/spi/ParentPolicy.javalibjboss-classloader-java-2.0.6.GA.orig/classloader/src/main/java/org/jboss/classloader/spi/ParentPo0000644000175000017500000000750411113041551033321 0ustar twernertwerner/* * JBoss, Home of Professional Open Source. * Copyright 2007, Red Hat Middleware LLC, and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.classloader.spi; import org.jboss.classloader.spi.filter.ClassFilter; /** * ParentPolicy * * @author Adrian Brock * @version $Revision: 1.1 $ */ public class ParentPolicy { /** Standard Java Delegation */ public static final ParentPolicy BEFORE = new ParentPolicy(ClassFilter.EVERYTHING, ClassFilter.NOTHING, "BEFORE"); /** Servlet style */ public static final ParentPolicy AFTER = new ParentPolicy(ClassFilter.NOTHING_BUT_JAVA, ClassFilter.EVERYTHING, "AFTER"); /** Standard Java Delegation for java classes */ public static final ParentPolicy BEFORE_BUT_JAVA_ONLY = new ParentPolicy(ClassFilter.JAVA_ONLY, ClassFilter.NOTHING, "BEFORE_BUT_JAVA_ONLY"); /** Java and Javax classes before, everything else after */ public static final ParentPolicy AFTER_BUT_JAVA_BEFORE = new ParentPolicy(ClassFilter.JAVA_ONLY, ClassFilter.EVERYTHING, "AFTER_BUT_JAVA_BEFORE"); /** Java classes before, everything else after */ public static final ParentPolicy AFTER_BUT_ONLY_JAVA_BEFORE = new ParentPolicy(ClassFilter.NOTHING_BUT_JAVA, ClassFilter.EVERYTHING, "AFTER_BUT_JAVA_BEFORE"); /** The before filter */ private ClassFilter beforeFilter; /** The after filter */ private ClassFilter afterFilter; /** A description of the policy */ private String description; /** * Create a new ParentPolicy. * * @param beforeFilter the before filter * @param afterFilter the after filter * @throws IllegalArgumentException for a null parameter */ public ParentPolicy(ClassFilter beforeFilter, ClassFilter afterFilter) { this(beforeFilter, afterFilter, null); } /** * Create a new ParentPolicy. * * @param beforeFilter the before filter * @param afterFilter the after filter * @param description of the policy * @throws IllegalArgumentException for a null parameter */ public ParentPolicy(ClassFilter beforeFilter, ClassFilter afterFilter, String description) { if (beforeFilter == null) throw new IllegalArgumentException("Null beforeFilter"); if (afterFilter == null) throw new IllegalArgumentException("Null afterFilter"); this.beforeFilter = beforeFilter; this.afterFilter = afterFilter; this.description = description; if (description == null) this.description = "(before=" + beforeFilter + " after=" + afterFilter + ")"; } /** * Get the beforeFilter. * * @return the beforeFilter. */ public ClassFilter getBeforeFilter() { return beforeFilter; } /** * Get the afterFilter. * * @return the afterFilter. */ public ClassFilter getAfterFilter() { return afterFilter; } @Override public String toString() { return description; } } ././@LongLink0000000000000000000000000000016400000000000011566 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloader/src/main/java/org/jboss/classloader/spi/PackageInformation.javalibjboss-classloader-java-2.0.6.GA.orig/classloader/src/main/java/org/jboss/classloader/spi/PackageI0000644000175000017500000001072210614350067033243 0ustar twernertwerner/* * JBoss, Home of Professional Open Source. * Copyright 2007, Red Hat Middleware LLC, and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.classloader.spi; import java.net.URL; import java.util.jar.Attributes; import java.util.jar.Manifest; import java.util.jar.Attributes.Name; /** * PackageInformation. * * @author Adrian Brock * @version $Revision: 1.1 $ */ public class PackageInformation { /** The package name */ public String packageName; /** The specification title */ public String specTitle; /** The specification version */ public String specVersion; /** The specification vendor */ public String specVendor; /** The implementation title */ public String implTitle; /** The implementation version */ public String implVersion; /** The implementation vendor */ public String implVendor; /** The seal base url */ public URL sealBase; /** * Create a new PackageInformation. * * @param packageName the package name * @throws IllegalArgumentException for a null parameter */ public PackageInformation(String packageName) { this(packageName, null, null); } /** * Create a new PackageInformation from a manifest * * @param packageName the package name * @param manifest the manifest * @throws IllegalArgumentException for a null package name */ public PackageInformation(String packageName, Manifest manifest) { this(packageName, manifest, null); } /** * Create a new PackageInformation from a manifest * * @param packageName the package name * @param manifest the manifest * @param seal the url to seal * @throws IllegalArgumentException for a null package name */ public PackageInformation(String packageName, Manifest manifest, URL seal) { if (packageName == null) throw new IllegalArgumentException("Null package name"); if (manifest != null) { String path = packageName.replace('.', '/').concat("/"); String sealed = null; Attributes attributes = manifest.getAttributes(path); if (attributes != null) { specTitle = attributes.getValue(Name.SPECIFICATION_TITLE); specVersion = attributes.getValue(Name.SPECIFICATION_VERSION); specVendor = attributes.getValue(Name.SPECIFICATION_VENDOR); implTitle = attributes.getValue(Name.IMPLEMENTATION_TITLE); implVersion = attributes.getValue(Name.IMPLEMENTATION_VERSION); implVendor = attributes.getValue(Name.IMPLEMENTATION_VENDOR); sealed = attributes.getValue(Name.SEALED); } attributes = manifest.getMainAttributes(); if (attributes != null) { if (specTitle == null) { specTitle = attributes.getValue(Name.SPECIFICATION_TITLE); specVersion = attributes.getValue(Name.SPECIFICATION_VERSION); specVendor = attributes.getValue(Name.SPECIFICATION_VENDOR); } if (implTitle == null) { implTitle = attributes.getValue(Name.IMPLEMENTATION_TITLE); implVersion = attributes.getValue(Name.IMPLEMENTATION_VERSION); implVendor = attributes.getValue(Name.IMPLEMENTATION_VENDOR); } if (sealed == null) sealed = attributes.getValue(Name.SEALED); } if (seal != null && "true".equalsIgnoreCase(sealed)) sealBase = seal; } } } libjboss-classloader-java-2.0.6.GA.orig/classloader/src/main/java/org/jboss/classloader/spi/filter/0000755000175000017500000000000011620043423033130 5ustar twernertwerner././@LongLink0000000000000000000000000000016400000000000011566 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloader/src/main/java/org/jboss/classloader/spi/filter/ClassFilter.javalibjboss-classloader-java-2.0.6.GA.orig/classloader/src/main/java/org/jboss/classloader/spi/filter/C0000644000175000017500000000464410741370313033251 0ustar twernertwerner/* * JBoss, Home of Professional Open Source. * Copyright 2007, Red Hat Middleware LLC, and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.classloader.spi.filter; import org.jboss.classloader.plugins.filter.EverythingClassFilter; import org.jboss.classloader.plugins.filter.JavaOnlyClassFilter; import org.jboss.classloader.plugins.filter.NothingButJavaClassFilter; import org.jboss.classloader.plugins.filter.NothingClassFilter; /** * ClassFilter. * * @author Adrian Brock * @version $Revision: 1.1 $ */ public interface ClassFilter { /** Match evertything */ ClassFilter EVERYTHING = EverythingClassFilter.INSTANCE; /** Match nothing */ ClassFilter NOTHING = NothingClassFilter.INSTANCE; /** Match nothing */ ClassFilter NOTHING_BUT_JAVA = NothingButJavaClassFilter.INSTANCE; /** Java Only */ ClassFilter JAVA_ONLY = JavaOnlyClassFilter.INSTANCE; /** * Whether the class name matches the filter * * @param className the class name * @return true when it matches the filter */ boolean matchesClassName(String className); /** * Whether the resource name matches the filter * * @param resourcePath the resource path * @return true when it matches the filter */ boolean matchesResourcePath(String resourcePath); /** * Whether the package name matches the filter * * @param packageName the package path * @return true when it matches the filter */ boolean matchesPackageName(String packageName); } ././@LongLink0000000000000000000000000000017300000000000011566 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloader/src/main/java/org/jboss/classloader/spi/filter/PackageClassFilter.javalibjboss-classloader-java-2.0.6.GA.orig/classloader/src/main/java/org/jboss/classloader/spi/filter/P0000644000175000017500000001266210755315422033272 0ustar twernertwerner/* * JBoss, Home of Professional Open Source. * Copyright 2007, Red Hat Middleware LLC, and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.classloader.spi.filter; import java.util.ArrayList; import java.util.Arrays; import java.util.List; import java.util.StringTokenizer; import org.jboss.classloader.plugins.filter.PatternClassFilter; /** * A class filter using regular expressions * * @author Adrian Brock * @version $Revision: 1.1 $ */ public class PackageClassFilter extends PatternClassFilter { /** The patterns as regular expressions */ private String[] packageNames; /** * Convert package names to class patterns * * @param packageNames the package names * @return the patterns */ private static String[] convertPackageNamesToClassPatterns(String[] packageNames) { if (packageNames == null) throw new IllegalArgumentException("Null package names"); String[] patterns = new String[packageNames.length]; for (int i = 0; i < packageNames.length; ++i) { if (packageNames[i] == null) throw new IllegalArgumentException("Null package name in " + Arrays.asList(packageNames)); if (packageNames[i].length() == 0) // Base package - it is a match if there is no . in the class name patterns[i] = "[^.]*"; else // Escape the dots in the package and match anything that has a single dot followed by non-dots patterns[i] = packageNames[i].replace(".", "\\.") + "\\.[^.]+"; } return patterns; } /** * Convert package names to resource patterns * * @param packageNames the package names * @return the patterns */ private static String[] convertPackageNamesToResourcePatterns(String[] packageNames) { if (packageNames == null) throw new IllegalArgumentException("Null package names"); String[] patterns = new String[packageNames.length]; for (int i = 0; i < packageNames.length; ++i) { if (packageNames[i] == null) throw new IllegalArgumentException("Null package name in " + Arrays.asList(packageNames)); if (packageNames[i].length() == 0) // Base package - it is a match if there is no / in the path patterns[i] = "[^/]*"; else // Replace the dots with slashs and match non slashes after that patterns[i] = packageNames[i].replace(".", "/") + "/[^/]+"; } return patterns; } /** * Create a package class filter

* * Creates the filter from a comma seperated list * * @param string the string * @return the filter */ public static PackageClassFilter createPackageClassFilterFromString(String string) { StringTokenizer tokenizer = new StringTokenizer(string, ","); List packages = new ArrayList(); while (tokenizer.hasMoreTokens()) packages.add(tokenizer.nextToken()); return createPackageClassFilter(packages); } /** * Create a new package class filter * * @param packageNames the package names * @return the filter * @throws IllegalArgumentException for null packageNames */ public static PackageClassFilter createPackageClassFilter(String... packageNames) { return new PackageClassFilter(packageNames); } /** * Create a new package class filter * * @param packageNames the package names * @return the filter * @throws IllegalArgumentException for null packageNames */ public static PackageClassFilter createPackageClassFilter(List packageNames) { String[] packages; if (packageNames == null) packages = new String[0]; else packages = packageNames.toArray(new String[packageNames.size()]); return new PackageClassFilter(packages); } /** * Create a new PackageClassFilter. * * @param packageNames the packageNames * @throws IllegalArgumentException for null packageNames */ public PackageClassFilter(String[] packageNames) { super(convertPackageNamesToClassPatterns(packageNames), convertPackageNamesToResourcePatterns(packageNames), packageNames); this.packageNames = packageNames; } @Override public String toString() { StringBuilder builder = new StringBuilder(); builder.append(Arrays.asList(packageNames)); if (isIncludeJava()) builder.append(" "); return builder.toString(); } } ././@LongLink0000000000000000000000000000020400000000000011561 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloader/src/main/java/org/jboss/classloader/spi/filter/RecursivePackageClassFilter.javalibjboss-classloader-java-2.0.6.GA.orig/classloader/src/main/java/org/jboss/classloader/spi/filter/R0000644000175000017500000001521211143034455033262 0ustar twernertwerner/* * JBoss, Home of Professional Open Source. * Copyright 2007, Red Hat Middleware LLC, and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.classloader.spi.filter; import java.util.ArrayList; import java.util.Arrays; import java.util.List; import java.util.StringTokenizer; import org.jboss.classloader.plugins.filter.PatternClassFilter; /** * A class filter using regular expressions that includes subpackages * * @author Adrian Brock * @version $Revision: 1.1 $ */ public class RecursivePackageClassFilter extends PatternClassFilter { private static final String[] EVERYTHING_PATTERN = { ".*" }; /** The patterns as regular expressions */ private String[] packageNames; /** * Convert package names to class patterns * * @param packageNames the package names * @return the patterns */ private static String[] convertPackageNamesToClassPatterns(String[] packageNames) { if (packageNames == null) throw new IllegalArgumentException("Null package names"); String[] patterns = new String[packageNames.length]; for (int i = 0; i < packageNames.length; ++i) { if (packageNames[i] == null) throw new IllegalArgumentException("Null package name in " + Arrays.asList(packageNames)); if (packageNames[i].length() == 0) // Base package - match everything return EVERYTHING_PATTERN; else // Escape the dots in the package and match anything that starts with a dot patterns[i] = packageNames[i].replace(".", "\\.") + "\\..+"; } return patterns; } /** * Convert package names to resource patterns * * @param packageNames the package names * @return the patterns */ private static String[] convertPackageNamesToResourcePatterns(String[] packageNames) { if (packageNames == null) throw new IllegalArgumentException("Null package names"); String[] patterns = new String[packageNames.length]; for (int i = 0; i < packageNames.length; ++i) { if (packageNames[i] == null) throw new IllegalArgumentException("Null package name in " + Arrays.asList(packageNames)); if (packageNames[i].length() == 0) // Base package - match everything return EVERYTHING_PATTERN; else // Replace the dots with slashs and match anything that begins with a slash patterns[i] = packageNames[i].replace(".", "/") + "/.+"; } return patterns; } /** * Convert package names to package patterns * * @param packageNames the package names * @return the patterns */ private static String[] convertPackageNamesToPackagePatterns(String[] packageNames) { if (packageNames == null) throw new IllegalArgumentException("Null package names"); String[] patterns = new String[2 * packageNames.length]; int j = 0; for (int i = 0; i < packageNames.length; ++i) { if (packageNames[i] == null) throw new IllegalArgumentException("Null package name in " + Arrays.asList(packageNames)); if (packageNames[i].length() == 0) { // Base package - match everything return EVERYTHING_PATTERN; } else { // Use the package name patterns[j++] = packageNames[i]; // And anything that begins with a dot patterns[j++] = packageNames[i] + "\\..*"; } } return patterns; } /** * Create a recursive package class filter

* * Creates the filter from a comma seperated list * * @param string the string * @return the filter */ public static RecursivePackageClassFilter createRecursivePackageClassFilterFromString(String string) { StringTokenizer tokenizer = new StringTokenizer(string, ","); List packages = new ArrayList(); while (tokenizer.hasMoreTokens()) packages.add(tokenizer.nextToken()); return createRecursivePackageClassFilter(packages); } /** * Create a new recursive package class filter * * @param packageNames the package names * @return the filter * @throws IllegalArgumentException for null packageNames */ public static RecursivePackageClassFilter createRecursivePackageClassFilter(String... packageNames) { return new RecursivePackageClassFilter(packageNames); } /** * Create a new recursive package class filter * * @param packageNames the package names * @return the filter * @throws IllegalArgumentException for null packageNames */ public static RecursivePackageClassFilter createRecursivePackageClassFilter(List packageNames) { String[] packages; if (packageNames == null) packages = new String[0]; else packages = packageNames.toArray(new String[packageNames.size()]); return new RecursivePackageClassFilter(packages); } /** * Create a new RecursivePackageClassFilter. * * @param packageNames the packageNames * @throws IllegalArgumentException for null packageNames */ public RecursivePackageClassFilter(String[] packageNames) { super(convertPackageNamesToClassPatterns(packageNames), convertPackageNamesToResourcePatterns(packageNames), convertPackageNamesToPackagePatterns(packageNames)); this.packageNames = packageNames; } @Override public String toString() { StringBuilder builder = new StringBuilder(); builder.append(Arrays.asList(packageNames)); if (isIncludeJava()) builder.append(" "); return builder.toString(); } } ././@LongLink0000000000000000000000000000017700000000000011572 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloader/src/main/java/org/jboss/classloader/spi/filter/FilteredDelegateLoader.javalibjboss-classloader-java-2.0.6.GA.orig/classloader/src/main/java/org/jboss/classloader/spi/filter/F0000644000175000017500000001355110761277455033270 0ustar twernertwerner/* * JBoss, Home of Professional Open Source. * Copyright 2007, Red Hat Middleware LLC, and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.classloader.spi.filter; import java.io.IOException; import java.net.URL; import java.util.HashSet; import java.util.Set; import org.jboss.classloader.spi.ClassLoaderPolicy; import org.jboss.classloader.spi.ClassLoaderPolicyFactory; import org.jboss.classloader.spi.DelegateLoader; import org.jboss.logging.Logger; /** * FilteredDelegateLoader. * * @author Adrian Brock * @version $Revision: 1.1 $ */ public class FilteredDelegateLoader extends DelegateLoader { /** The log */ private static final Logger log = Logger.getLogger(FilteredDelegateLoader.class); /** The filter */ private ClassFilter filter; /** * Create a new FilteredDelegateLoader that does not filter * * @param delegate the delegate classloading policy * @throws IllegalArgumentException for a null parameter */ public FilteredDelegateLoader(ClassLoaderPolicy delegate) { this(delegate, ClassFilter.EVERYTHING); } /** * Create a new FilteredDelegateLoader. * * @param delegate the delegate classloading policy * @param filter the filter * @throws IllegalArgumentException for a null parameter */ public FilteredDelegateLoader(ClassLoaderPolicy delegate, ClassFilter filter) { super(delegate); if (filter == null) throw new IllegalArgumentException("Null filter"); this.filter = filter; } /** * Create a new FilteredDelegateLoader that does not filter * * @param factory the factory * @throws IllegalArgumentException for a null parameter */ public FilteredDelegateLoader(ClassLoaderPolicyFactory factory) { this(factory, ClassFilter.EVERYTHING); } /** * Create a new FilteredDelegateLoader. * * @param factory the factory * @param filter the filter * @throws IllegalArgumentException for a null parameter */ public FilteredDelegateLoader(ClassLoaderPolicyFactory factory, ClassFilter filter) { super(factory); if (filter == null) throw new IllegalArgumentException("Null filter"); this.filter = filter; } /** * Get the filter. * * @return the filter. */ public ClassFilter getFilter() { return filter; } /** * Set the filter * * @param filter the filter */ protected void setFilter(ClassFilter filter) { if (filter == null) filter = ClassFilter.EVERYTHING; else this.filter = filter; } @Override public Class loadClass(String className) { boolean trace = log.isTraceEnabled(); if (filter.matchesClassName(className)) { if (trace) log.trace(this + " " + className + " matches class filter=" + filter); return super.loadClass(className); } if (trace) log.trace(this + " " + className + " does NOT match class filter=" + filter); return null; } public URL getResource(String name) { boolean trace = log.isTraceEnabled(); if (filter.matchesResourcePath(name)) { if (trace) log.trace(this + " " + name + " matches resource filter=" + filter); return super.getResource(name); } if (trace) log.trace(this + " " + name + " does NOT match resource filter=" + filter); return null; } public void getResources(String name, Set urls) throws IOException { boolean trace = log.isTraceEnabled(); if (filter.matchesResourcePath(name)) { if (trace) log.trace(this + " " + name + " matches filter=" + filter); super.getResources(name, urls); } if (trace) log.trace(this + " " + name + " does NOT match filter=" + filter); } public Package getPackage(String name) { boolean trace = log.isTraceEnabled(); if (filter.matchesPackageName(name)) { if (trace) log.trace(this + " " + name + " matches package filter=" + filter); return super.getPackage(name); } if (trace) log.trace(this + " " + name + " does NOT match package filter=" + filter); return null; } public void getPackages(Set packages) { boolean trace = log.isTraceEnabled(); Set allPackages = new HashSet(); super.getPackages(allPackages); for (Package pkge : allPackages) { if (filter.matchesPackageName(pkge.getName())) { if (trace) log.trace(this + " " + pkge + " matches package filter=" + filter); packages.add(pkge); } else if (trace) log.trace(this + " pkge=" + pkge + " does NOT match package filter=" + filter); } } @Override protected void toLongString(StringBuilder builder) { builder.append(" filter=").append(getFilter()); } } ././@LongLink0000000000000000000000000000020300000000000011560 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloader/src/main/java/org/jboss/classloader/spi/filter/LazyFilteredDelegateLoader.javalibjboss-classloader-java-2.0.6.GA.orig/classloader/src/main/java/org/jboss/classloader/spi/filter/L0000644000175000017500000000371110761301356033257 0ustar twernertwerner/* * JBoss, Home of Professional Open Source. * Copyright 2007, Red Hat Middleware LLC, and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.classloader.spi.filter; import org.jboss.classloader.spi.ClassLoaderPolicy; import org.jboss.classloader.spi.ClassLoaderPolicyFactory; /** * LazyFilteredDelegateLoader. * * @author Adrian Brock * @version $Revision: 1.1 $ */ public class LazyFilteredDelegateLoader extends FilteredDelegateLoader { /** * Create a new FilteredDelegateLoader that does not filter * * @param factory the factory * @throws IllegalArgumentException for a null parameter */ public LazyFilteredDelegateLoader(ClassLoaderPolicyFactory factory) { super(factory, ClassFilter.EVERYTHING); } @Override protected void initialise(ClassLoaderPolicy policy) { String[] packageNames = policy.getPackageNames(); if (packageNames != null) { ClassFilter filter = PackageClassFilter.createPackageClassFilter(packageNames); setFilter(filter); } } } ././@LongLink0000000000000000000000000000017000000000000011563 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloader/src/main/java/org/jboss/classloader/spi/ClassLoaderDomainMBean.javalibjboss-classloader-java-2.0.6.GA.orig/classloader/src/main/java/org/jboss/classloader/spi/ClassLoa0000644000175000017500000001023111042050234033260 0ustar twernertwerner/* * JBoss, Home of Professional Open Source * Copyright 2007, JBoss Inc., and individual contributors as indicated * by the @authors tag. See the copyright.txt in the distribution for a * full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.classloader.spi; import java.io.IOException; import java.net.URL; import java.util.List; import java.util.Map; import java.util.Set; import javax.management.ObjectName; /** * ClassLoaderSystemMBean. * * @author Adrian Brock * @version $Revision: 1.1 $ */ public interface ClassLoaderDomainMBean { /** * Get the classloader system * * @return the system */ ObjectName getSystem(); /** * Get the name. * * @return the name. */ String getName(); /** * Get the parent policy name * * @return the parent policy name. */ String getParentPolicyName(); /** * Get the parent * * @return the parent. */ ObjectName getParentDomain(); /** * Get the parent * * @return the parent. */ String getParentDomainName(); /** * Get the classloaders * * @return the classloaders */ List listClassLoaders(); /** * Get the exporting classloaders * * @return a map of packages to classloaders */ Map> listExportingClassLoaders(); /** * Get the classloaders export a package * * @param packageName the package name * @return the classloaders */ List listExportingClassLoaders(String packageName); /** * Load a class * * @param name the class name * @return the class * @throws ClassNotFoundException when the class is not found */ Class loadClass(String name) throws ClassNotFoundException; /** * Get resources * * @param name the name of the resource * @return the resource urls * @throws IOException for any error */ Set loadResources(String name) throws IOException; /** * Find the classloader for a class * * @param name the class name * @return the classloader or null if it is not loaded by a managed classloader * @throws ClassNotFoundException when the class is not found */ ObjectName findClassLoaderForClass(String name) throws ClassNotFoundException; /** * Show the class cache * * @return a map of class name to a loader description */ Map listClassCache(); /** * Show the class blacklist * * @return a set of class names */ Set listClassBlackList(); /** * Show the resource cache * * @return a map of resource name to urls */ Map listResourceCache(); /** * Show the resource blacklist * * @return a set of resource names */ Set listResourceBlackList(); /** * Get the number of classes black listed * * @return the size */ int getClassBlackListSize(); /** * Get the number of classes cached * * @return the size */ int getClassCacheSize(); /** * Get the number of resources black listed * * @return the size */ int getResourceBlackListSize(); /** * Get the number of resource cached * * @return the size */ int getResourceCacheSize(); /** * Flush the caches */ void flushCaches(); } ././@LongLink0000000000000000000000000000015000000000000011561 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloader/src/main/java/org/jboss/classloader/spi/Loader.javalibjboss-classloader-java-2.0.6.GA.orig/classloader/src/main/java/org/jboss/classloader/spi/Loader.j0000644000175000017500000000411510741370313033231 0ustar twernertwerner/* * JBoss, Home of Professional Open Source. * Copyright 2007, Red Hat Middleware LLC, and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.classloader.spi; import java.io.IOException; import java.net.URL; import java.util.Set; /** * Loader. * * @author Adrian Brock * @version $Revision: 1.1 $ */ public interface Loader { /** * Load a class * * @param className the class name * @return the class or null if not found */ Class loadClass(String className); /** * Get a resource * * @param name the resource name * @return the url or null if not found */ URL getResource(String name); /** * Get resources * * @param name the resource name * @param urls the list of urls to add to * @throws IOException for any error */ void getResources(String name, Set urls) throws IOException; /** * Get a package * * @param name the package name * @return the package */ Package getPackage(String name); /** * Get all the packages visible from this loader * * @param packages the packages */ void getPackages(Set packages); } ././@LongLink0000000000000000000000000000016300000000000011565 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloader/src/main/java/org/jboss/classloader/spi/ClassLoaderDomain.javalibjboss-classloader-java-2.0.6.GA.orig/classloader/src/main/java/org/jboss/classloader/spi/ClassLoa0000644000175000017500000005304111042050234033266 0ustar twernertwerner/* * JBoss, Home of Professional Open Source. * Copyright 2007, Red Hat Middleware LLC, and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.classloader.spi; import java.io.IOException; import java.net.URL; import java.security.AccessController; import java.security.PrivilegedAction; import java.util.ArrayList; import java.util.HashMap; import java.util.HashSet; import java.util.List; import java.util.Map; import java.util.Set; import java.util.Map.Entry; import javax.management.MBeanRegistration; import javax.management.MBeanServer; import javax.management.ObjectName; import org.jboss.classloader.plugins.loader.ClassLoaderToLoaderAdapter; import org.jboss.classloader.spi.base.BaseClassLoaderDomain; import org.jboss.classloader.spi.filter.ClassFilter; import org.jboss.classloading.spi.RealClassLoader; import org.jboss.logging.Logger; /** * ClassLoaderDomain. * * @author Adrian Brock * @version $Revision: 1.1 $ */ public class ClassLoaderDomain extends BaseClassLoaderDomain implements Loader, ClassLoaderDomainMBean, MBeanRegistration { /** The log */ private static final Logger log = Logger.getLogger(ClassLoaderDomain.class); /** The name of the domain */ private String name; /** The parent classloading rules */ private ParentPolicy parentPolicy = ParentPolicy.BEFORE; /** The parent */ private Loader parent; /** The MBeanServer */ private MBeanServer mbeanServer; /** The object name */ private ObjectName objectName; /** Whether to use load class for the parent */ private boolean useLoadClassForParent = false; /** * Create a new ClassLoaderDomain with the {@link ParentPolicy#BEFORE} loading rules. * * @param name the name of the domain * @throws IllegalArgumentException for a null name */ public ClassLoaderDomain(String name) { if (name == null) throw new IllegalArgumentException("Null name"); this.name = name; fixUpParent(); } /** * Get the name. * * @return the name. */ public String getName() { return name; } /** * Get the object name * * @return the object name */ public ObjectName getObjectName() { return objectName; } /** * Get the parent policy * * @return the parent policy. */ public ParentPolicy getParentPolicy() { return parentPolicy; } /** * Set the parentPolicy. * * @param parentPolicy the parentPolicy. * @throws IllegalArgumentException for a null parent policy */ public void setParentPolicy(ParentPolicy parentPolicy) { if (parentPolicy == null) throw new IllegalArgumentException("Null parent policy"); this.parentPolicy = parentPolicy; } public String getParentPolicyName() { return parentPolicy.toString(); } /** * Get the parent * * @return the parent. */ public Loader getParent() { return parent; } /** * Set the parent. * * @param parent the parent. */ public void setParent(Loader parent) { this.parent = parent; fixUpParent(); } /** * Get the useLoadClassForParent. * * @return the useLoadClassForParent. */ public boolean isUseLoadClassForParent() { return useLoadClassForParent; } /** * Set the useLoadClassForParent. * * @param useLoadClassForParent the useLoadClassForParent. */ public void setUseLoadClassForParent(boolean useLoadClassForParent) { this.useLoadClassForParent = useLoadClassForParent; } public ObjectName getParentDomain() { if (parent == null || parent instanceof ClassLoaderDomain == false) return null; ClassLoaderDomain parentDomain = (ClassLoaderDomain) parent; return parentDomain.getObjectName(); } public String getParentDomainName() { if (parent == null || parent instanceof ClassLoaderDomain == false) return null; ClassLoaderDomain parentDomain = (ClassLoaderDomain) parent; return parentDomain.getName(); } public ObjectName getSystem() { ClassLoaderSystem system = (ClassLoaderSystem) getClassLoaderSystem(); if (system == null) return null; return system.getObjectName(); } public List listClassLoaders() { List result = new ArrayList(); for (ClassLoader cl : super.getAllClassLoaders()) { if (cl instanceof RealClassLoader) result.add(((RealClassLoader) cl).getObjectName()); } return result; } public Map> listExportingClassLoaders() { HashMap> result = new HashMap>(); for (Entry> entry : getClassLoadersByPackage().entrySet()) { List names = new ArrayList(); for (ClassLoader cl : entry.getValue()) { if (cl instanceof RealClassLoader) names.add(((RealClassLoader) cl).getObjectName()); } result.put(entry.getKey(), names); } return result; } public List listExportingClassLoaders(String packageName) { if (packageName == null) throw new IllegalArgumentException("Null package name"); List result = new ArrayList(); for (ClassLoader cl : getClassLoaders(packageName)) { if (cl instanceof RealClassLoader) result.add(((RealClassLoader) cl).getObjectName()); } return result; } public ObjectName findClassLoaderForClass(String name) throws ClassNotFoundException { final Class clazz = loadClass(null, name, true); if (clazz == null) return null; ClassLoader cl = AccessController.doPrivileged(new PrivilegedAction() { public ClassLoader run() { return clazz.getClassLoader(); } }); if (cl != null && cl instanceof RealClassLoader) return ((RealClassLoader) cl).getObjectName(); return null; } public Set loadResources(String name) throws IOException { HashSet result = new HashSet(); getResources(name, result); return result; } /** * For subclasses to add information for toLongString() * * @param builder the builder */ protected void toLongString(StringBuilder builder) { builder.append("name=").append(getName()); builder.append(" parentPolicy=").append(getParentPolicy()); builder.append(" parent="); Loader parent = getParent(); if (parent != null) builder.append(parent); else builder.append(getParentClassLoader()); } @Override public String toString() { StringBuilder builder = new StringBuilder(); builder.append(getClass().getSimpleName()); builder.append("@").append(Integer.toHexString(System.identityHashCode(this))); builder.append("{").append(name).append('}'); return builder.toString(); } @Override protected Class loadClassBefore(String name) { boolean trace = log.isTraceEnabled(); ClassFilter filter = getParentPolicy().getBeforeFilter(); if (filter.matchesClassName(name)) { if (trace) log.trace(this + " " + name + " matches parent beforeFilter=" + filter); return loadClassFromParent(name); } if (trace) log.trace(this + " " + name + " does NOT match parent beforeFilter=" + filter); return null; } @Override protected Class loadClassAfter(String name) { boolean trace = log.isTraceEnabled(); ClassFilter filter = getParentPolicy().getAfterFilter(); if (filter.matchesClassName(name)) { if (trace) log.trace(this + " " + name + " matches parent afterFilter=" + filter); return loadClassFromParent(name); } if (trace) log.trace(this + " " + name + " does NOT match parent afterFilter=" + filter); return null; } /** * Try to find a load a from the parent * * @param name the name * @return the class if found */ protected Class loadClassFromParent(String name) { Loader parentLoader = getParent(); boolean trace = log.isTraceEnabled(); if (parentLoader == null) { if (trace) log.trace(this + " not loading from non-existant parent"); return null; } if (trace) log.trace(this + " load class from parent " + name + " parent=" + parent); // Recurse into parent domains return parentLoader.loadClass(name); } @Override protected Loader findBeforeLoader(String name) { boolean trace = log.isTraceEnabled(); ClassFilter filter = getParentPolicy().getBeforeFilter(); if (filter.matchesResourcePath(name)) { if (trace) log.trace(this + " " + name + " matches parent beforeFilter=" + filter); return findLoaderFromParent(name); } if (trace) log.trace(this + " " + name + " does NOT match parent beforeFilter=" + filter); return null; } @Override protected Loader findAfterLoader(String name) { boolean trace = log.isTraceEnabled(); ClassFilter filter = getParentPolicy().getAfterFilter(); if (filter.matchesResourcePath(name)) { if (trace) log.trace(this + " " + name + " matches parent afterFilter=" + filter); return findLoaderFromParent(name); } if (trace) log.trace(this + " " + name + " does NOT match parent afterFilter=" + filter); return null; } /** * Try to find a loader from the parent * * @param name the name * @return the loader if found */ protected Loader findLoaderFromParent(String name) { Loader parentLoader = getParent(); boolean trace = log.isTraceEnabled(); if (parentLoader == null) { if (trace) log.trace(this + " not loading from non-existant parent"); return null; } if (trace) log.trace(this + " load from parent " + name + " parent=" + parent); // Recurse into parent domains if (parentLoader instanceof ClassLoaderDomain) { ClassLoaderDomain parentDomain = (ClassLoaderDomain) parentLoader; return parentDomain.findLoader(name); } // A normal loader if (parentLoader.getResource(name) != null) return parentLoader; return null; } @Override protected URL beforeGetResource(String name) { boolean trace = log.isTraceEnabled(); ClassFilter filter = getParentPolicy().getBeforeFilter(); if (filter.matchesResourcePath(name)) { if (trace) log.trace(this + " " + name + " matches parent beforeFilter=" + filter); return getResourceFromParent(name); } if (trace) log.trace(this + " " + name + " does NOT match parent beforeFilter=" + filter); return null; } @Override protected URL afterGetResource(String name) { boolean trace = log.isTraceEnabled(); ClassFilter filter = getParentPolicy().getAfterFilter(); if (filter.matchesResourcePath(name)) { if (trace) log.trace(this + " " + name + " matches parent afterFilter=" + filter); return getResourceFromParent(name); } if (trace) log.trace(this + " " + name + " does NOT match parent afterFilter=" + filter); return null; } /** * Try to get a resource from the parent * * @param name the name * @return the url if found */ protected URL getResourceFromParent(String name) { Loader parentLoader = getParent(); boolean trace = log.isTraceEnabled(); if (parentLoader == null) { if (trace) log.trace(this + " not getting resource from non-existant parent"); return null; } if (trace) log.trace(this + " get resource from parent " + name + " parent=" + parentLoader); URL result = parentLoader.getResource(name); if (trace) { if (result != null) log.trace(this + " got resource from parent " + name + " parent=" + parentLoader + " " + result); else log.trace(this + " resource not found in parent " + name + " parent=" + parentLoader); } return result; } @Override protected void beforeGetResources(String name, Set urls) throws IOException { boolean trace = log.isTraceEnabled(); ClassFilter filter = getParentPolicy().getBeforeFilter(); if (filter.matchesResourcePath(name)) { if (trace) log.trace(this + " " + name + " matches parent beforeFilter=" + filter); getResourcesFromParent(name, urls); } else if (trace) log.trace(this + " " + name + " does NOT match parent beforeFilter=" + filter); } @Override protected void afterGetResources(String name, Set urls) throws IOException { boolean trace = log.isTraceEnabled(); ClassFilter filter = getParentPolicy().getAfterFilter(); if (filter.matchesResourcePath(name)) { if (trace) log.trace(this + " " + name + " matches parent afterFilter=" + filter); getResourcesFromParent(name, urls); } else if (trace) log.trace(this + " " + name + " does NOT match parent afterFilter=" + filter); } /** * Try to get resources from the parent * * @param name the name * @param urls the urls to add to * @throws IOException for any error */ protected void getResourcesFromParent(String name, Set urls) throws IOException { Loader parentLoader = getParent(); boolean trace = log.isTraceEnabled(); if (parentLoader == null) { if (trace) log.trace(this + " not getting resources from non-existant parent"); return; } if (trace) log.trace(this + " get resources from parent " + name + " parent=" + parentLoader); parentLoader.getResources(name, urls); } @Override protected Package beforeGetPackage(String name) { boolean trace = log.isTraceEnabled(); ClassFilter filter = getParentPolicy().getBeforeFilter(); if (filter.matchesPackageName(name)) { if (trace) log.trace(this + " " + name + " matches parent beforeFilter=" + filter); return getPackageFromParent(name); } if (trace) log.trace(this + " " + name + " does NOT match parent beforeFilter=" + filter); return null; } @Override protected Package afterGetPackage(String name) { boolean trace = log.isTraceEnabled(); ClassFilter filter = getParentPolicy().getAfterFilter(); if (filter.matchesPackageName(name)) { if (trace) log.trace(this + " " + name + " matches parent afterFilter=" + filter); return getPackageFromParent(name); } if (trace) log.trace(this + " " + name + " does NOT match parent afterFilter=" + filter); return null; } /** * Try to get a package from the parent * * @param name the name * @return the package if found */ protected Package getPackageFromParent(String name) { Loader parentLoader = getParent(); boolean trace = log.isTraceEnabled(); if (parentLoader == null) { if (trace) log.trace(this + " not getting package from non-existant parent"); return null; } if (trace) log.trace(this + " get package from parent " + name + " parent=" + parentLoader); Package result = parentLoader.getPackage(name); if (trace) { if (result != null) log.trace(this + " got package from parent " + name + " parent=" + parentLoader + " " + result); else log.trace(this + " package not found in parent " + name + " parent=" + parentLoader); } return result; } @Override protected void beforeGetPackages(Set packages) { ClassFilter filter = getParentPolicy().getBeforeFilter(); getPackagesFromParent(packages, filter); } @Override protected void afterGetPackages(Set packages) { ClassFilter filter = getParentPolicy().getAfterFilter(); getPackagesFromParent(packages, filter); } /** * Try to get packages from the parent * * @param packages the packages to add to * @param filter the filter */ protected void getPackagesFromParent(Set packages, ClassFilter filter) { Loader parentLoader = getParent(); boolean trace = log.isTraceEnabled(); if (parentLoader == null) { if (trace) log.trace(this + " not getting packages from non-existant parent"); return; } if (trace) log.trace(this + " get packages from parent=" + parentLoader + " filter=" + filter); Set parentPackages = new HashSet(); parentLoader.getPackages(parentPackages); for (Package parentPackage : parentPackages) { if (filter.matchesPackageName(parentPackage.getName())) { if (trace) log.trace(this + " parentPackage=" + parentPackage + " matches filter=" + filter); packages.add(parentPackage); } else if (trace) log.trace(this + " parentPackage=" + parentPackage + " does NOT match filter=" + filter); } } /** * Fixup the parent to the our classloader as parent if we don't have an explicit one */ private void fixUpParent() { try { if (parent == null) { final ClassLoader classLoader = getParentClassLoader(); if (classLoader != null) { parent = AccessController.doPrivileged(new PrivilegedAction() { public Loader run() { return new ClassLoaderToLoaderAdapter(classLoader); } }); } } } finally { setUseLoadClassForParent(parent instanceof ClassLoaderDomain == false); } } public ObjectName preRegister(MBeanServer server, ObjectName name) throws Exception { this.mbeanServer = server; this.objectName = name; return name; } public void postRegister(Boolean registrationDone) { if (registrationDone) { // Register any classloaders that were added before we were registered in the MBeanServer for (ClassLoader cl : getAllClassLoaders()) registerClassLoaderMBean(cl); } else { postDeregister(); } } public void preDeregister() throws Exception { // Unregister any remaining classloaders from the MBeanServer for (ClassLoader cl : getAllClassLoaders()) unregisterClassLoaderMBean(cl); } public void postDeregister() { this.mbeanServer = null; this.objectName = null; } @Override protected void afterRegisterClassLoader(ClassLoader classLoader, ClassLoaderPolicy policy) { registerClassLoaderMBean(classLoader); } @Override protected void beforeUnregisterClassLoader(ClassLoader classLoader, ClassLoaderPolicy policy) { unregisterClassLoaderMBean(classLoader); } /** * Register a classloader with the MBeanServer * * @param cl the classloader */ protected void registerClassLoaderMBean(ClassLoader cl) { if (mbeanServer == null) return; if (cl instanceof RealClassLoader) { ObjectName name = ((RealClassLoader) cl).getObjectName(); try { mbeanServer.registerMBean(cl, name); } catch (Exception e) { log.warn("Error registering classloader: " + cl, e); } } } /** * Unregister a classloader from the MBeanServer * * @param cl the classloader */ protected void unregisterClassLoaderMBean(ClassLoader cl) { if (mbeanServer == null) return; if (cl instanceof RealClassLoader) { ObjectName name = ((RealClassLoader) cl).getObjectName(); try { mbeanServer.unregisterMBean(name); } catch (Exception e) { log.warn("Error unregistering classloader: " + cl, e); } } } } ././@LongLink0000000000000000000000000000016300000000000011565 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloader/src/main/java/org/jboss/classloader/spi/ClassLoaderPolicy.javalibjboss-classloader-java-2.0.6.GA.orig/classloader/src/main/java/org/jboss/classloader/spi/ClassLoa0000644000175000017500000001767511063454005033312 0ustar twernertwerner/* * JBoss, Home of Professional Open Source. * Copyright 2007, Red Hat Middleware LLC, and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.classloader.spi; import java.io.IOException; import java.io.InputStream; import java.net.URL; import java.security.AccessController; import java.security.PrivilegedAction; import java.security.ProtectionDomain; import java.util.Arrays; import java.util.Collections; import java.util.List; import java.util.Set; import javax.management.MalformedObjectNameException; import javax.management.ObjectName; import org.jboss.classloader.spi.base.BaseClassLoaderPolicy; import org.jboss.classloader.spi.filter.FilteredDelegateLoader; import org.jboss.classloader.spi.filter.PackageClassFilter; import org.jboss.classloader.spi.jdk.JDKChecker; import org.jboss.classloader.spi.jdk.JDKCheckerFactory; import org.jboss.logging.Logger; /** * ClassLoader policy. * * @author Adrian Brock * @version $Revision: 1.1 $ */ public abstract class ClassLoaderPolicy extends BaseClassLoaderPolicy { /** The log */ private static final Logger log = Logger.getLogger(ClassLoaderPolicy.class); /** * Get the delegate loader for exported stuff

* * By default this uses {@link #getPackageNames()} to create a {@link FilteredDelegateLoader} * * @return the delegate loader */ public DelegateLoader getExported() { String[] packageNames = getPackageNames(); if (packageNames == null) return null; return new FilteredDelegateLoader(this, PackageClassFilter.createPackageClassFilter(packageNames)); } /** * Get the exported packages

* * Provides a hint for indexing

* * No packages are exported by default

* * The returned package names can be null to indicate * nothing is exported, but if an array is returned * it should not include a null package element. * * @return the package names */ public String[] getPackageNames() { return null; } /** * Get the delegate loaders for imported stuff

* * There are no imports by default

* * NOTE: Protected access for security reasons * * @return the delegate loaders */ protected List getDelegates() { return Collections.emptyList(); } /** * Whether to import all exports from other classloaders in the domain

* * False by default * * @return true to import all */ protected boolean isImportAll() { return false; } /** * Whether to cache

* * True by default * * @return true to cache */ protected boolean isCacheable() { return true; } /** * Whether to cache misses

* * True by default * * @return true to cache misses */ protected boolean isBlackListable() { return true; } /** * Get the resource * * @param path the path * @return the url or null if not found */ public abstract URL getResource(String path); /** * Get the resource as a stream

* * Uses {@link #getResource(String)} by default * * @param path the path * @return the stream or null if not found */ public InputStream getResourceAsStream(String path) { URL url = getResource(path); if (url != null) { try { return url.openStream(); } catch (IOException e) { log.debug("Unable to open URL: " + url + " for path " + path + " from " + toLongString()); } } return null; } /** * Get resources * * @param name the resource name * @param urls the list of urls to add to * @throws IOException for any error */ public abstract void getResources(String name, Set urls) throws IOException; /** * Get the protection domain

* * By default there is no protection domain

* * NOTE: Protected access for security reasons * * @param className the class name * @param path the path * @return the protection domain */ protected ProtectionDomain getProtectionDomain(String className, String path) { return null; } /** * Get the package information

* * There is no package information by default * * @param packageName the package information * @return the information or null if there is none */ public PackageInformation getPackageInformation(String packageName) { return null; } /** * Get the package information for a class

* * The default is to invoke getPackageInformation for the class's package * * @param className name the class name * @param packageName the package information * @return the information or null if there is none */ public PackageInformation getClassPackageInformation(String className, String packageName) { return getPackageInformation(packageName); } /** * Check whether this a request from the jdk if it is return the relevant classloader

* * By default this uses the {@Link JDKCheckerFactory} and returns the system classloader if true. * * @param name the class name * @return the classloader */ protected ClassLoader isJDKRequest(String name) { JDKChecker checker = JDKCheckerFactory.getChecker(); if (checker.isJDKRequest(name)) return getSystemClassLoader(); return null; } @Override public ObjectName getObjectName() { try { String name = getName(); if (name != null && name.trim().length() > 0) return ObjectName.getInstance("jboss.classloader", "id", "\"" + name + "\""); return ObjectName.getInstance("jboss.classloader", "id", "" + System.identityHashCode(this)); } catch (MalformedObjectNameException e) { throw new Error("Error creating object name", e); } } @Override protected void toLongString(StringBuilder builder) { builder.append(" delegates=").append(getDelegates()); String[] packageNames = getPackageNames(); if (packageNames != null) builder.append(" exported=").append(Arrays.asList(packageNames)); boolean importAll = isImportAll(); if (importAll) builder.append(" "); } /** * Get the system classloader * * @return the classloader */ private ClassLoader getSystemClassLoader() { SecurityManager sm = System.getSecurityManager(); if (sm == null) return ClassLoader.getSystemClassLoader(); return AccessController.doPrivileged(GetSystemClassLoader.INSTANCE, getAccessControlContext()); } /** * GetSystemClassLoader. */ private static class GetSystemClassLoader implements PrivilegedAction { private static GetSystemClassLoader INSTANCE = new GetSystemClassLoader(); public ClassLoader run() { return ClassLoader.getSystemClassLoader(); } } } libjboss-classloader-java-2.0.6.GA.orig/classloader/src/main/java/org/jboss/classloader/spi/jdk/0000755000175000017500000000000011620043423032413 5ustar twernertwerner././@LongLink0000000000000000000000000000016000000000000011562 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloader/src/main/java/org/jboss/classloader/spi/jdk/JDKChecker.javalibjboss-classloader-java-2.0.6.GA.orig/classloader/src/main/java/org/jboss/classloader/spi/jdk/JDKC0000644000175000017500000000273210615454241033064 0ustar twernertwerner/* * JBoss, Home of Professional Open Source. * Copyright 2007, Red Hat Middleware LLC, and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.classloader.spi.jdk; /** * Used to check whether the classloading request is from the jdk

* * This is a hack because of broken behaviour by the JDKs where they assume * they can load their own classes from any classloader. */ public interface JDKChecker { /** * Check wether this is a request from the JDK * * @param name the class name * @return true when from the JDK */ boolean isJDKRequest(String name); } ././@LongLink0000000000000000000000000000016700000000000011571 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloader/src/main/java/org/jboss/classloader/spi/jdk/JDKCheckerFactory.javalibjboss-classloader-java-2.0.6.GA.orig/classloader/src/main/java/org/jboss/classloader/spi/jdk/JDKC0000644000175000017500000000575111042332055033061 0ustar twernertwerner/* * JBoss, Home of Professional Open Source. * Copyright 2007, Red Hat Middleware LLC, and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.classloader.spi.jdk; import java.security.AccessController; import java.security.PrivilegedAction; import org.jboss.classloader.plugins.jdk.AbstractJDKChecker; /** * JDKCheckerFactory. * * * @author Adrian Brock * @version $Revision: 1.1 $ */ public class JDKCheckerFactory { /** The checker */ private static final JDKChecker checker; static { checker = AccessController.doPrivileged(new PrivilegedAction() { public JDKChecker run() { // Decide what default checker to use based on the JDK (not implemented - YAGNI?) String defaultChecker = AbstractJDKChecker.class.getName(); String className = System.getProperty(JDKChecker.class.getName(), defaultChecker); try { Class clazz; try { clazz = Thread.currentThread().getContextClassLoader().loadClass(className); } catch (ClassNotFoundException e) { try { clazz = getClass().getClassLoader().loadClass(className); } catch (ClassNotFoundException ignored) { throw e; } } Object result = clazz.newInstance(); return JDKChecker.class.cast(result); } catch (RuntimeException e) { throw e; } catch (Exception e) { throw new Error("Unexpected error loading JDKChecker " + className, e); } } }); } /** * Retrieve the checker for the JDK we are running on * * @return the checker */ public static JDKChecker getChecker() { if (checker == null) return new AbstractJDKChecker(); return checker; } } libjboss-classloader-java-2.0.6.GA.orig/classloader/src/main/java/org/jboss/classloader/spi/base/0000755000175000017500000000000011620043423032555 5ustar twernertwerner././@LongLink0000000000000000000000000000017400000000000011567 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloader/src/main/java/org/jboss/classloader/spi/base/BaseClassLoaderPolicy.javalibjboss-classloader-java-2.0.6.GA.orig/classloader/src/main/java/org/jboss/classloader/spi/base/Bas0000644000175000017500000002574711173151646033236 0ustar twernertwerner/* * JBoss, Home of Professional Open Source. * Copyright 2007, Red Hat Middleware LLC, and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.classloader.spi.base; import java.security.AccessControlContext; import java.security.AccessController; import java.security.ProtectionDomain; import java.util.ArrayList; import java.util.Collections; import java.util.List; import javax.management.ObjectName; import org.jboss.classloader.spi.ClassLoaderDomain; import org.jboss.classloader.spi.DelegateLoader; import org.jboss.classloader.spi.translator.TranslatorUtils; import org.jboss.logging.Logger; import org.jboss.util.loading.Translator; /** * Base ClassLoader policy.

* * This class hides some of the implementation details and allows * package access to the protected methods. * * @author Adrian Brock * @author Ales Justin * @version $Revision: 1.1 $ */ public abstract class BaseClassLoaderPolicy { /** The log */ private static final Logger log = Logger.getLogger(BaseClassLoaderPolicy.class); /** The classloader for this policy */ private volatile BaseClassLoader classLoader; /** The domain for this policy */ private volatile BaseClassLoaderDomain domain; /** The access control context for this policy */ private AccessControlContext access; /** The translators */ private List translators; /** * Create a new BaseClassLoaderPolicy. * * @throws SecurityException if the caller does not have permission to create a classloader */ public BaseClassLoaderPolicy() { SecurityManager sm = System.getSecurityManager(); if (sm != null) sm.checkCreateClassLoader(); access = AccessController.getContext(); } /** * Get the access control context for this policy * * @return the access control context */ protected AccessControlContext getAccessControlContext() { return access; } /** * Get the delegate loader for exported stuff

* * NOTE: Protected access for security reasons * * @return the delegate loader */ protected abstract DelegateLoader getExported(); /** * Get a simple name for the classloader * * @return the name */ protected String getName() { return ""; } /** * Get the exported packages

* * Provides a hint for indexing * * @return the package names */ public abstract String[] getPackageNames(); /** * Get the delegate loaders for imported stuff

* * NOTE: Protected access for security reasons * * @return the delegate loaders */ protected abstract List getDelegates(); /** * Whether to import all exports from other classloaders in the domain * * @return true to import all */ protected abstract boolean isImportAll(); /** * Get the protection domain

* * NOTE: Defined as protected here for security reasons * * @param className the class name * @param path the path * @return the protection domain */ protected abstract ProtectionDomain getProtectionDomain(String className, String path); /** * Transform the byte code

* * By default, this delegates to the domain * * @param className the class name * @param byteCode the byte code * @param protectionDomain the protection domain * @return the transformed byte code * @throws Exception for any error */ protected byte[] transform(String className, byte[] byteCode, ProtectionDomain protectionDomain) throws Exception { byte[] result = byteCode; BaseClassLoaderDomain domain = getClassLoaderDomain(); if (domain != null) result = domain.transform(getClassLoader(), className, result, protectionDomain); ClassLoader classLoader = getClassLoaderUnchecked(); if (classLoader != null) result = TranslatorUtils.applyTranslatorsOnTransform(translators, classLoader, className, result, protectionDomain); return result; } /** * Whether to cache

* * @return true to cache */ protected abstract boolean isCacheable(); /** * Whether to cache misses

* * @return true to cache misses */ protected abstract boolean isBlackListable(); /** * Get the object name the classloader is registered in the MBeanServer with * * @return the object name */ public abstract ObjectName getObjectName(); /** * Check whether this a request from the jdk if it is return the relevant classloader * * @param name the class name * @return the classloader */ protected abstract ClassLoader isJDKRequest(String name); /** * A long version of toString() * * @return the long string */ public String toLongString() { StringBuilder builder = new StringBuilder(); builder.append(getClass().getSimpleName()); builder.append("@").append(Integer.toHexString(System.identityHashCode(this))); builder.append("{"); String name = getName(); if (name != null) builder.append("name=").append(name).append(" "); builder.append("domain="); if (domain == null) builder.append("null"); else builder.append(domain.toLongString()); toLongString(builder); builder.append('}'); return builder.toString(); } /** * For subclasses to add information for toLongString() * * @param builder the builder */ protected void toLongString(StringBuilder builder) { } @Override public String toString() { StringBuilder builder = new StringBuilder(); builder.append(getClass().getSimpleName()); builder.append("@").append(Integer.toHexString(System.identityHashCode(this))); builder.append("{").append(getName()).append("}"); return builder.toString(); } /** * Get the classloader domain name * * @return the domain */ public String getDomainName() { if (domain == null) return null; return ((ClassLoaderDomain) domain).getName(); } /** * Get the classloader domain * * @return the domain */ BaseClassLoaderDomain getClassLoaderDomain() { return domain; } /** * Set the classloader domain * * @param domain the domain * @throws IllegalStateException if the policy already has a domain */ void setClassLoaderDomain(BaseClassLoaderDomain domain) { if (this.domain != null) throw new IllegalStateException("Policy already has a domain " + this); this.domain = domain; } /** * Unset the classloader domain * * @param domain the domain * @throws IllegalStateException if the policy is not part of that domain */ void unsetClassLoaderDomain(BaseClassLoaderDomain domain) { if (this.domain != domain) throw new IllegalStateException("Policy is not a part of the domain " + this + " domain=" + domain); shutdownPolicy(); this.domain = null; } /** * Get the classloader * * @return the classloader */ synchronized BaseClassLoader getClassLoader() { if (classLoader == null) throw new IllegalStateException("No classloader associated with policy therefore it is no longer registered " + toLongString()); return classLoader; } /** * Get the classloader * * @return the classloader */ synchronized BaseClassLoader getClassLoaderUnchecked() { return classLoader; } /** * Set the classloader

* * NOTE: Package private for security reasons * * @param classLoader the classloader * @throws IllegalStateException if the classloader is already set */ synchronized void setClassLoader(BaseClassLoader classLoader) { if (this.classLoader != null) throw new IllegalStateException("Policy already has a classloader previous=" + classLoader); this.classLoader = classLoader; } /** * Shutdown the policy

* * The default implementation removes and shutdowns the classloader */ synchronized protected void shutdownPolicy() { log.debug(toString() + " shutdown!"); BaseClassLoader classLoader = this.classLoader; this.classLoader = null; TranslatorUtils.applyTranslatorsAtUnregister(translators, classLoader); classLoader.shutdownClassLoader(); } /** * Cleans the entry with the given name from the blackList * * @param name the name of the resource to clear from the blackList */ protected void clearBlackList(String name) { if (domain != null) { domain.clearBlackList(name); } } /** * Get the policy's translators. * * @return the translators */ public List getTranslators() { if (translators == null || translators.isEmpty()) return Collections.emptyList(); else return Collections.unmodifiableList(translators); } /** * Set the translators. * * @param translators the translators */ public synchronized void setTranslators(List translators) { this.translators = translators; } /** * Add the translator. * * @param translator the translator to add * @throws IllegalArgumentException for null translator */ public synchronized void addTranslator(Translator translator) { if (translator == null) throw new IllegalArgumentException("Null translator"); if (translators == null) translators = new ArrayList(); translators.add(translator); } /** * Remove the translator. * * @param translator the translator to remove * @throws IllegalArgumentException for null translator */ public synchronized void removeTranslator(Translator translator) { if (translator == null) throw new IllegalArgumentException("Null translator"); if (translators != null) translators.remove(translator); } } ././@LongLink0000000000000000000000000000017500000000000011570 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloader/src/main/java/org/jboss/classloader/spi/base/ClassLoaderInformation.javalibjboss-classloader-java-2.0.6.GA.orig/classloader/src/main/java/org/jboss/classloader/spi/base/Cla0000644000175000017500000001766011143027354033216 0ustar twernertwerner/* * JBoss, Home of Professional Open Source. * Copyright 2007, Red Hat Middleware LLC, and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.classloader.spi.base; import java.net.URL; import java.util.List; import java.util.Map; import java.util.concurrent.ConcurrentHashMap; import org.jboss.classloader.spi.DelegateLoader; import org.jboss.classloader.spi.Loader; /** * ClassLoaderInformation. * * @author Adrian Brock * @version $Revision: 1.1 $ */ public class ClassLoaderInformation { /** The classloader */ private BaseClassLoader classLoader; /** The policy */ private BaseClassLoaderPolicy policy; /** The order */ private int order; /** The delegates */ private List delegates; /** The exports of the classloader */ private BaseDelegateLoader exported; /** The class cache */ private Map classCache; /** The class black list */ private Map classBlackList; /** The resource cache */ private Map resourceCache; /** The resource black list */ private Map resourceBlackList; /** * Create a new ClassLoaderInformation. * * @param classLoader the classloader * @param policy the policy * @param order the added order * @throws IllegalArgumentException for a null parameter */ public ClassLoaderInformation(BaseClassLoader classLoader, BaseClassLoaderPolicy policy, int order) { if (classLoader == null) throw new IllegalArgumentException("Null classloader"); if (policy == null) throw new IllegalArgumentException("Null policy"); this.classLoader = classLoader; this.policy = policy; this.order = order; this.exported = policy.getExported(); this.delegates = policy.getDelegates(); boolean canCache = policy.isCacheable(); boolean canBlackList = policy.isBlackListable(); if (delegates != null && delegates.isEmpty() == false) { for (DelegateLoader delegate : delegates) { if (delegate == null) throw new IllegalStateException(policy + " null delegate in " + delegates); BaseDelegateLoader baseDelegate = delegate; BaseClassLoaderPolicy delegatePolicy = baseDelegate.getPolicy(); if (delegatePolicy == null || delegatePolicy.isCacheable() == false) canCache = false; if (delegatePolicy == null || delegatePolicy.isBlackListable() == false) canBlackList = false; } } if (canCache) { classCache = new ConcurrentHashMap(); resourceCache = new ConcurrentHashMap(); } if (canBlackList) { classBlackList = new ConcurrentHashMap(); resourceBlackList = new ConcurrentHashMap(); } } /** * Flush the caches */ public void flushCaches() { if (classCache != null) classCache.clear(); if (classBlackList != null) classBlackList.clear(); if (resourceCache != null) resourceCache.clear(); if (resourceBlackList != null) resourceBlackList.clear(); } /** * Get the classLoader. * * @return the classLoader. */ public BaseClassLoader getClassLoader() { return classLoader; } /** * Get the policy. * * @return the policy. */ public BaseClassLoaderPolicy getPolicy() { return policy; } /** * Get the order. * * @return the order. */ public int getOrder() { return order; } /** * Get the exported. * * @return the exported. */ public BaseDelegateLoader getExported() { return exported; } /** * Get the delegates. * * @return the delegates. */ public List getDelegates() { return delegates; } /** * Get the cached loader for a class * * @param name the class name * @return any cached loader */ public Loader getCachedLoader(String name) { Map classCache = this.classCache; if (classCache != null) return classCache.get(name); return null; } /** * Cache a loader for a class * * @param name the class name * @param loader the cached loader */ public void cacheLoader(String name, Loader loader) { Map classCache = this.classCache; if (classCache != null) classCache.put(name, loader); } /** * Check whether this is a black listed class * * @param name the class name * @return true when black listed */ public boolean isBlackListedClass(String name) { Map classBlackList = this.classBlackList; if (classBlackList != null) return classBlackList.containsKey(name); return false; } /** * Blacklist a class * * @param name the class name to black list */ public void blackListClass(String name) { Map classBlackList = this.classBlackList; if (classBlackList != null) classBlackList.put(name, name); } /** * Get the cached url for a resource * * @param name the resource name * @return any cached url */ public URL getCachedResource(String name) { Map resourceCache = this.resourceCache; if (resourceCache != null) return resourceCache.get(name); return null; } /** * Cache a url for a resource * * @param name the resource name * @param url the cached url */ public void cacheResource(String name, URL url) { Map resourceCache = this.resourceCache; if (resourceCache != null) resourceCache.put(name, url); } /** * Check whether this is a black listed resource * * @param name the resource name * @return true when black listed */ public boolean isBlackListedResource(String name) { Map resourceBlackList = this.resourceBlackList; if (resourceBlackList != null) return resourceBlackList.containsKey(name); return false; } /** * Blacklist a resource * * @param name the resource name to black list */ public void blackListResource(String name) { Map resourceBlackList = this.resourceBlackList; if (resourceBlackList != null) resourceBlackList.put(name, name); } /** * Cleans the entry with the given name from the blackList * * @param name the name of the resource to clear from the blackList */ public void clearBlackList(String name) { if (classBlackList != null) classBlackList.remove(name); if (resourceBlackList != null) resourceBlackList.remove(name); } @Override public String toString() { return policy.toString(); } } ././@LongLink0000000000000000000000000000017400000000000011567 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloader/src/main/java/org/jboss/classloader/spi/base/BaseClassLoaderSystem.javalibjboss-classloader-java-2.0.6.GA.orig/classloader/src/main/java/org/jboss/classloader/spi/base/Bas0000644000175000017500000001647310651427350033230 0ustar twernertwerner/* * JBoss, Home of Professional Open Source. * Copyright 2007, Red Hat Middleware LLC, and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.classloader.spi.base; import java.security.AccessController; import java.security.PrivilegedAction; import java.security.ProtectionDomain; import org.jboss.classloader.spi.ClassLoaderPolicy; /** * Base ClassLoaderSystem. * * @author Adrian Brock * @version $Revision: 1.1 $ */ public abstract class BaseClassLoaderSystem { /** * A long version of toString() * * @return the long string */ public String toLongString() { StringBuilder builder = new StringBuilder(); builder.append(getClass().getSimpleName()); builder.append("@").append(Integer.toHexString(System.identityHashCode(this))); builder.append("{"); toLongString(builder); builder.append('}'); return builder.toString(); } /** * For subclasses to add information for toLongString() * * @param builder the builder */ protected void toLongString(StringBuilder builder) { } @Override public String toString() { StringBuilder builder = new StringBuilder(); builder.append(getClass().getSimpleName()); builder.append("@").append(Integer.toHexString(System.identityHashCode(this))); return builder.toString(); } /** * Register a domain * * @param domain the domain to register * @throws IllegalArgumentException for a null domain */ protected void registerDomain(BaseClassLoaderDomain domain) { if (domain == null) throw new IllegalArgumentException("Null domain"); domain.setClassLoaderSystem(this); } /** * Unregister a domain * * @param domain the domain to unregister * @throws IllegalArgumentException for a null domain */ protected void unregisterDomain(BaseClassLoaderDomain domain) { if (domain == null) throw new IllegalArgumentException("Null domain"); domain.setClassLoaderSystem(null); } /** * Register a policy with a domain * * @param domain the domain * @param policy the policy * @return the classloader * @throws IllegalArgumentException if a parameter is null * @throws IllegalStateException if the policy is already registered with a domain */ protected ClassLoader registerClassLoaderPolicy(final BaseClassLoaderDomain domain, final ClassLoaderPolicy policy) { if (domain == null) throw new IllegalArgumentException("Null domain"); if (policy == null) throw new IllegalArgumentException("Null policy"); return AccessController.doPrivileged(new PrivilegedAction() { public BaseClassLoader run() { BaseClassLoader classLoader = createClassLoader(policy); beforeRegisterClassLoader(classLoader); domain.registerClassLoader(classLoader); afterRegisterClassLoader(classLoader); return classLoader; } }, policy.getAccessControlContext()); } /** * Unregister a policy with a domain * * @param policy the policy * @throws IllegalArgumentException if a parameter is null * @throws IllegalStateException if the policy is not registered with the domain */ protected void unregisterClassLoaderPolicy(ClassLoaderPolicy policy) { if (policy == null) throw new IllegalArgumentException("Null policy"); BaseClassLoaderPolicy basePolicy = policy; BaseClassLoader classLoader = basePolicy.getClassLoader(); if (classLoader == null) throw new IllegalStateException("Policy has no associated classloader, it is therefore not registered with a domain. " + policy.toLongString()); BaseClassLoaderDomain domain = basePolicy.getClassLoaderDomain(); if (domain == null) throw new IllegalStateException("Policy has no domain " + policy.toLongString()); beforeUnregisterClassLoader(classLoader); domain.unregisterClassLoader(classLoader); afterUnregisterClassLoader(classLoader); } /** * Unregister a policy with a domain * * @param classLoader the class loader * @throws IllegalArgumentException if a parameter is null * @throws IllegalStateException if the policy is not registered with the domain */ protected void unregisterClassLoader(ClassLoader classLoader) { if (classLoader == null) throw new IllegalArgumentException("Null classLoader"); if (classLoader instanceof BaseClassLoader == false) throw new IllegalStateException("ClassLoader is not the correct type and therefore not registered: " + classLoader); BaseClassLoader baseClassLoader = (BaseClassLoader) classLoader; unregisterClassLoaderPolicy(baseClassLoader.getPolicy()); } /** * Create a classloader for the given policy * * @param policy the policy * @return the classloader * @throws IllegalArgumentException for a null policy */ protected BaseClassLoader createClassLoader(ClassLoaderPolicy policy) { return new BaseClassLoader(policy); } /** * Before register classloader * * @param classLoader the classloader */ protected void beforeRegisterClassLoader(ClassLoader classLoader) { // Nothing } /** * After register classloader * * @param classLoader the classloader */ protected void afterRegisterClassLoader(ClassLoader classLoader) { // Nothing } /** * Before unregister classloader * * @param classLoader the classloader */ protected void beforeUnregisterClassLoader(ClassLoader classLoader) { // Nothing } /** * After unregister classloader * * @param classLoader the classloader */ protected void afterUnregisterClassLoader(ClassLoader classLoader) { // Nothing } /** * Transform the byte code

* * By default this does nothing * * @param classLoader the classLoader * @param className the class name * @param byteCode the byte code * @param protectionDomain the protection domain * @return the transformed byte code * @throws Exception for any error */ protected byte[] transform(ClassLoader classLoader, String className, byte[] byteCode, ProtectionDomain protectionDomain) throws Exception { return byteCode; } } ././@LongLink0000000000000000000000000000017400000000000011567 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloader/src/main/java/org/jboss/classloader/spi/base/BaseClassLoaderDomain.javalibjboss-classloader-java-2.0.6.GA.orig/classloader/src/main/java/org/jboss/classloader/spi/base/Bas0000644000175000017500000013702211200016574033213 0ustar twernertwerner/* * JBoss, Home of Professional Open Source. * Copyright 2007, Red Hat Middleware LLC, and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.classloader.spi.base; import java.io.IOException; import java.net.URL; import java.security.ProtectionDomain; 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.Set; import java.util.Map.Entry; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.CopyOnWriteArrayList; import org.jboss.classloader.plugins.ClassLoaderUtils; import org.jboss.classloader.spi.ClassLoaderPolicy; import org.jboss.classloader.spi.DelegateLoader; import org.jboss.classloader.spi.Loader; import org.jboss.logging.Logger; /** * BaseClassLoaderDomain.

* * This class hides some of the implementation details and allows * package access to the protected methods. * * @author Adrian Brock * @version $Revision: 1.1 $ */ public abstract class BaseClassLoaderDomain implements Loader { /** The log */ private static final Logger log = Logger.getLogger(BaseClassLoaderDomain.class); /** The classloader system to which we belong */ private BaseClassLoaderSystem system; /** The classloaders in the order they were registered */ private List classLoaders = new CopyOnWriteArrayList(); /** The classloader information by classloader */ private Map infos = new ConcurrentHashMap(); /** The classloaders by package name */ private Map> classLoadersByPackageName = new ConcurrentHashMap>(); /** The global class cache */ private Map globalClassCache = new ConcurrentHashMap(); /** The global class black list */ private Map globalClassBlackList = new ConcurrentHashMap(); /** The global resource cache */ private Map globalResourceCache = new ConcurrentHashMap(); /** The global resource black list */ private Map globalResourceBlackList = new ConcurrentHashMap(); /** Keep track of the added order */ private int order = 0; /** * Flush the internal caches */ public void flushCaches() { globalClassCache.clear(); globalClassBlackList.clear(); globalResourceCache.clear(); globalResourceBlackList.clear(); for (ClassLoaderInformation info : classLoaders) info.flushCaches(); } public int getClassBlackListSize() { return globalClassBlackList.size(); } public int getClassCacheSize() { return globalClassCache.size(); } public int getResourceBlackListSize() { return globalClassBlackList.size(); } public int getResourceCacheSize() { return globalClassCache.size(); } public Set listClassBlackList() { return Collections.unmodifiableSet(globalClassBlackList.keySet()); } public Map listClassCache() { Map result = new HashMap(globalClassCache.size()); for (Map.Entry entry : globalClassCache.entrySet()) result.put(entry.getKey(), entry.getValue().toString()); return result; } public Set listResourceBlackList() { return Collections.unmodifiableSet(globalResourceBlackList.keySet()); } public Map listResourceCache() { return Collections.unmodifiableMap(globalResourceCache); } /** * Get the classloader system * * @return the classloader system */ protected synchronized BaseClassLoaderSystem getClassLoaderSystem() { return system; } /** * Get the classloader system * * @param system the classloader system */ synchronized void setClassLoaderSystem(BaseClassLoaderSystem system) { if (system == null) shutdownDomain(); this.system = system; } /** * Shutdown the domain

* * The default implementation just unregisters all classloaders */ protected void shutdownDomain() { log.debug(toString() + " shutdown!"); // Unregister all classloaders while (true) { Iterator iterator = classLoaders.iterator(); if (iterator.hasNext() == false) break; while (iterator.hasNext()) { ClassLoaderInformation info = iterator.next(); if (info != null) unregisterClassLoader(info.getClassLoader()); } } flushCaches(); } /** * Whether the domain has classloaders * * @return true when the domain has classloaders */ public boolean hasClassLoaders() { return classLoaders.isEmpty() == false; } /** * Whether to use load class for parent * * @return true to load class on the parent loader */ public abstract boolean isUseLoadClassForParent(); /** * Transform the byte code

* * By default, this delegates to the classloader system * * @param classLoader the classloader * @param className the class name * @param byteCode the byte code * @param protectionDomain the protection domain * @return the transformed byte code * @throws Exception for any error */ protected byte[] transform(ClassLoader classLoader, String className, byte[] byteCode, ProtectionDomain protectionDomain) throws Exception { BaseClassLoaderSystem system = getClassLoaderSystem(); if (system != null) return system.transform(classLoader, className, byteCode, protectionDomain); return byteCode; } /** * Load a class from the domain * * @param classLoader the classloader * @param name the class name * @param allExports whether we should look at all exports * @return the class * @throws ClassNotFoundException for any error */ protected Class loadClass(BaseClassLoader classLoader, String name, boolean allExports) throws ClassNotFoundException { boolean trace = log.isTraceEnabled(); String path = ClassLoaderUtils.classNameToPath(name); // JBCL-101 TODO need to rework the blacklist //checkClassBlackList(classLoader, name, path, allExports, true); boolean findInParent = (isUseLoadClassForParent() == false); // Should we directly load from the parent? if (findInParent == false) { Class clazz = loadClassBefore(name); if (clazz != null) { globalClassCache.put(path, new ClassCacheItem(clazz)); return clazz; } } Loader loader = findLoader(classLoader, path, allExports, findInParent); if (loader != null) { Thread thread = Thread.currentThread(); ClassLoadingTask task = new ClassLoadingTask(name, classLoader, thread); ClassLoaderManager.scheduleTask(task, loader, false); Class result = ClassLoaderManager.process(thread, task); ClassCacheItem item = globalClassCache.get(path); if (item != null) item.clazz = result; return result; } // Should we directly load from the parent? if (findInParent == false) { Class clazz = loadClassAfter(name); if (clazz != null) { globalClassCache.put(path, new ClassCacheItem(clazz)); return clazz; } } // Finally see whether this is the JDK assuming it can load its classes from any classloader if (classLoader != null) { BaseClassLoaderPolicy policy = classLoader.getPolicy(); ClassLoader hack = policy.isJDKRequest(name); if (hack != null) { if (trace) log.trace(this + " trying to load " + name + " using hack " + hack); Class result = Class.forName(name, false, hack); if (result != null) { if (trace) log.trace(this + " loaded from hack " + hack + " " + ClassLoaderUtils.classToString(result)); globalClassCache.put(path, new ClassCacheItem(result)); return result; } } } // Didn't find it return null; } /** * Find a loader for a class * * @param name the class resource name * @return the loader */ protected Loader findLoader(String name) { return findLoader(null, name, true, true); } /** * Find a loader for a class * * @param classLoader the classloader * @param name the class resource name * @param allExports whether we should look at all exports * @param findInParent should we try the parent * @return the loader */ Loader findLoader(BaseClassLoader classLoader, String name, boolean allExports, boolean findInParent) { boolean trace = log.isTraceEnabled(); if (trace) log.trace(this + " findLoader " + name + " classLoader=" + classLoader + " allExports=" + allExports + " findInParent=" + findInParent); if (getClassLoaderSystem() == null) throw new IllegalStateException("Domain is not registered with a classloader system: " + toLongString()); // Try the before attempt (e.g. from the parent) Loader loader = null; if (findInParent) loader = findBeforeLoader(name); if (loader != null) return loader; // Work out the rules ClassLoaderInformation info = null; BaseClassLoaderPolicy policy; if (classLoader != null) { info = infos.get(classLoader); policy = classLoader.getPolicy(); if (policy.isImportAll()) allExports = true; } // Next we try the old "big ball of mud" model if (allExports) { loader = findLoaderInExports(classLoader, name, trace); if (loader != null) return loader; } else if (trace) log.trace(this + " not loading " + name + " from all exports"); // Next we try the imports if (info != null) { loader = findLoaderInImports(info, name, trace); if (loader != null) return loader; } // Next use any requesting classloader, this will look at everything not just what it exports if (classLoader != null) { if (trace) log.trace(this + " trying to load " + name + " from requesting " + classLoader); if (classLoader.getResourceLocally(name) != null) return classLoader.getLoader(); } // Try the after attempt (e.g. from the parent) if (findInParent) return findAfterLoader(name); return null; } /** * Load a resource from the domain * * @param classLoader the classloader * @param name the resource name * @param allExports whether we should look at all exports * @return the url */ URL getResource(BaseClassLoader classLoader, String name, boolean allExports) { boolean trace = log.isTraceEnabled(); // Try the classloader first if (classLoader != null) { if (trace) log.trace(this + " trying to get resource " + name + " from requesting " + classLoader); URL result = classLoader.getResourceLocally(name); if (result != null) { if (trace) log.trace(this + " got resource from requesting " + classLoader + " " + result); return result; } } if (getClassLoaderSystem() == null) throw new IllegalStateException("Domain is not registered with a classloader system: " + toLongString()); // Try the before attempt URL result = beforeGetResource(name); if (result != null) return result; // Work out the rules ClassLoaderInformation info = null; BaseClassLoaderPolicy policy; if (classLoader != null) { policy = classLoader.getPolicy(); info = infos.get(classLoader); if (policy.isImportAll()) allExports = true; } // Next we try the old "big ball of mud" model if (allExports) { result = getResourceFromExports(classLoader, name, trace); if (result != null) return result; } else if (trace) log.trace(this + " not getting resource " + name + " from all exports"); // Next we try the imports if (info != null) { result = getResourceFromImports(info, name, trace); if (result != null) return result; } // Try the after attempt result = afterGetResource(name); if (result != null) return result; // Didn't find it return null; } /** * Load resources from the domain * * @param classLoader the classloader * @param name the resource name * @param allExports whether we should look at all exports * @param urls the urls to add to * @throws IOException for any error */ void getResources(BaseClassLoader classLoader, String name, Set urls, boolean allExports) throws IOException { boolean trace = log.isTraceEnabled(); if (getClassLoaderSystem() == null) throw new IllegalStateException("Domain is not registered with a classloader system: " + toLongString()); // Try the before attempt beforeGetResources(name, urls); // Work out the rules ClassLoaderInformation info = null; BaseClassLoaderPolicy policy; if (classLoader != null) { policy = classLoader.getPolicy(); info = infos.get(classLoader); if (policy.isImportAll()) allExports = true; } // Next we try the old "big ball of mud" model if (allExports) getResourcesFromExports(classLoader, name, urls, trace); else if (trace) log.trace(this + " not getting resource " + name + " from all exports"); // Next we try the imports if (info != null) getResourcesFromImports(info, name, urls, trace); // Finally use any requesting classloader if (classLoader != null) { if (trace) log.trace(this + " trying to get resources " + name + " from requesting " + classLoader); classLoader.getResourcesLocally(name, urls); } // Try the after attempt afterGetResources(name, urls); } /** * Load a package from the domain * * @param classLoader the classloader * @param name the resource name * @param allExports whether we should look at all exports * @return the package */ Package getPackage(BaseClassLoader classLoader, String name, boolean allExports) { boolean trace = log.isTraceEnabled(); if (getClassLoaderSystem() == null) throw new IllegalStateException("Domain is not registered with a classloader system: " + toLongString()); // Try the before attempt Package result = beforeGetPackage(name); if (result != null) return result; // Work out the rules ClassLoaderInformation info = null; BaseClassLoaderPolicy policy; if (classLoader != null) { policy = classLoader.getPolicy(); info = infos.get(classLoader); if (policy.isImportAll()) allExports = true; } // Next we try the old "big ball of mud" model if (allExports) { result = getPackageFromExports(classLoader, name, trace); if (result != null) return result; } else if (trace) log.trace(this + " not getting package " + name + " from all exports"); // Next we try the imports if (info != null) { result = getPackageFromImports(info, name, trace); if (result != null) return result; } // Finally use any requesting classloader if (classLoader != null) { if (trace) log.trace(this + " trying to get package " + name + " from requesting " + classLoader); result = classLoader.getPackageLocally(name); if (result != null) { if (trace) log.trace(this + " got package from requesting " + classLoader + " " + result); return result; } } // Try the after attempt result = afterGetPackage(name); if (result != null) return result; // Didn't find it return null; } /** * Load packages from the domain * * @param classLoader the classloader * @param packages the packages to add to * @param allExports whether we should look at all exports */ void getPackages(BaseClassLoader classLoader, Set packages, boolean allExports) { boolean trace = log.isTraceEnabled(); if (getClassLoaderSystem() == null) throw new IllegalStateException("Domain is not registered with a classloader system: " + toLongString()); // Try the before attempt beforeGetPackages(packages); // Work out the rules ClassLoaderInformation info = null; BaseClassLoaderPolicy policy; if (classLoader != null) { policy = classLoader.getPolicy(); info = infos.get(classLoader); if (policy.isImportAll()) allExports = true; } // Next we try the old "big ball of mud" model if (allExports) getPackagesFromExports(classLoader, packages, trace); else if (trace) log.trace(this + " not getting packages from all exports"); // Next we try the imports if (info != null) getPackagesFromImports(info, packages, trace); // Finally use any requesting classloader if (classLoader != null) { if (trace) log.trace(this + " trying to get packages from requesting " + classLoader); classLoader.getPackagesLocally(packages); } // Try the after attempt afterGetPackages(packages); } /** * Find a loader for class in exports * * @param classLoader the classloader * @param name the class resource name * @param trace whether trace is enabled * @return the loader */ private Loader findLoaderInExports(BaseClassLoader classLoader, String name, boolean trace) { ClassCacheItem item = globalClassCache.get(name); if (item != null) { Loader loader = item.loader; if (loader != null) { if (trace) log.trace(this + " found loader " + loader + " in global class cache " + name); return loader; } } if (globalClassBlackList.containsKey(name)) { if (trace) log.trace(this + " class is black listed " + name); return null; } boolean canCache = true; boolean canBlackList = true; String packageName = ClassLoaderUtils.getResourcePackageName(name); List list = classLoadersByPackageName.get(packageName); if (trace) log.trace(this + " trying to load " + name + " from all exports of package " + packageName + " " + list); if (list != null && list.isEmpty() == false) { for (ClassLoaderInformation info : list) { BaseDelegateLoader exported = info.getExported(); // See whether the policies allow caching/blacklisting BaseClassLoaderPolicy loaderPolicy = exported.getPolicy(); if (loaderPolicy == null || loaderPolicy.isCacheable() == false) canCache = false; if (loaderPolicy == null || loaderPolicy.isBlackListable() == false) canBlackList = false; if (exported.getResource(name) != null) { if (canCache) globalClassCache.put(name, new ClassCacheItem(exported)); return exported; } } } // Here is not found in the exports so can we blacklist it? if (canBlackList) globalClassBlackList.put(name, name); return null; } /** * Load a resource from the exports * * @param classLoader the classloader * @param name the resource name * @param trace whether trace is enabled * @return the url */ private URL getResourceFromExports(BaseClassLoader classLoader, String name, boolean trace) { URL result = globalResourceCache.get(name); if (result != null) { if (trace) log.trace(this + " got resource from cache " + name); } if (globalResourceBlackList.containsKey(name)) { if (trace) log.trace(this + " resource is black listed, not looking at exports " + name); return null; } boolean canCache = true; boolean canBlackList = true; String packageName = ClassLoaderUtils.getResourcePackageName(name); List list = classLoadersByPackageName.get(packageName); if (trace) log.trace(this + " trying to get resource " + name + " from all exports " + list); if (list != null && list.isEmpty() == false) { for (ClassLoaderInformation info : list) { BaseDelegateLoader loader = info.getExported(); // See whether the policies allow caching/blacklisting BaseClassLoaderPolicy loaderPolicy = loader.getPolicy(); if (loaderPolicy == null || loaderPolicy.isCacheable() == false) canCache = false; if (loaderPolicy == null || loaderPolicy.isBlackListable() == false) canBlackList = false; result = loader.getResource(name); if (result != null) { if (canCache) globalResourceCache.put(name, result); return result; } } } // Here is not found in the exports so can we blacklist it? if (canBlackList) globalResourceBlackList.put(name, name); return null; } /** * Load resources from the exports * * @param classLoader the classloader * @param name the resource name * @param urls the urls to add to * @param trace whether trace is enabled * @throws IOException for any error */ void getResourcesFromExports(BaseClassLoader classLoader, String name, Set urls, boolean trace) throws IOException { String packageName = ClassLoaderUtils.getResourcePackageName(name); List list = classLoadersByPackageName.get(packageName); if (trace) log.trace(this + " trying to get resources " + name + " from all exports " + list); if (list != null && list.isEmpty() == false) { for (ClassLoaderInformation info : list) { BaseDelegateLoader loader = info.getExported(); loader.getResources(name, urls); } } } /** * Load a package from the exports * * @param classLoader the classloader * @param name the package name * @param trace whether trace is enabled * @return the package */ private Package getPackageFromExports(BaseClassLoader classLoader, String name, boolean trace) { List list = classLoadersByPackageName.get(name); if (trace) log.trace(this + " trying to get package " + name + " from all exports " + list); if (list != null && list.isEmpty() == false) { for (ClassLoaderInformation info : list) { BaseDelegateLoader loader = info.getExported(); Package result = loader.getPackage(name); if (result != null) return result; } } return null; } /** * Load packages from the exports * * @param classLoader the classloader * @param packages the packages to add to * @param trace whether trace is enabled */ void getPackagesFromExports(BaseClassLoader classLoader, Set packages, boolean trace) { List list = classLoaders; if (trace) log.trace(this + " trying to get all packages from all exports " + list); if (list != null && list.isEmpty() == false) { for (ClassLoaderInformation info : list) { BaseDelegateLoader loader = info.getExported(); loader.getPackages(packages); } } } /** * Find a loader for a class in imports * * @param info the classloader information * @param name the class resource name * @param trace whether trace is enabled * @return the loader */ Loader findLoaderInImports(ClassLoaderInformation info, String name, boolean trace) { List delegates = info.getDelegates(); if (delegates == null || delegates.isEmpty()) { if (trace) log.trace(this + " not loading " + name + " from imports it has no delegates"); return null; } Loader loader = info.getCachedLoader(name); if (loader != null) { if (trace) log.trace(this + " found in import cache " + name); return loader; } if (info.isBlackListedClass(name)) { if (trace) log.trace(this + " class is black listed in imports " + name); return null; } for (DelegateLoader delegate : delegates) { if (trace) log.trace(this + " trying to load " + name + " from import " + delegate + " for " + info.getClassLoader()); if (delegate.getResource(name) != null) { info.cacheLoader(name, delegate); return delegate; } } info.blackListClass(name); return null; } /** * Load a resource from the imports * * @param info the classloader information * @param name the resource name * @param trace whether trace is enabled * @return the url */ private URL getResourceFromImports(ClassLoaderInformation info, String name, boolean trace) { List delegates = info.getDelegates(); if (delegates == null || delegates.isEmpty()) { if (trace) log.trace(this + " not getting resource " + name + " from imports it has no delegates"); return null; } URL url = info.getCachedResource(name); if (url != null) { if (trace) log.trace(this + " found resource in import cache " + name); return url; } if (info.isBlackListedResource(name)) { if (trace) log.trace(this + " resource is black listed in imports " + name); return null; } if (trace) log.trace(this + " trying to get resource " + name + " from imports " + delegates + " for " + info.getClassLoader()); for (DelegateLoader delegate : delegates) { URL result = delegate.getResource(name); if (result != null) { info.cacheResource(name, result); return result; } } info.blackListResource(name); return null; } /** * Load resources from the imports * * @param info the classloader info * @param name the resource name * @param urls the urls to add to * @param trace whether trace is enabled * @throws IOException for any error */ void getResourcesFromImports(ClassLoaderInformation info, String name, Set urls, boolean trace) throws IOException { List delegates = info.getDelegates(); if (delegates == null || delegates.isEmpty()) { if (trace) log.trace(this + " not getting resource " + name + " from imports it has no delegates"); return; } if (trace) log.trace(this + " trying to get resources " + name + " from imports " + delegates + " for " + info.getClassLoader()); for (DelegateLoader delegate : delegates) delegate.getResources(name, urls); } /** * Load a package from the imports * * @param info the classloader information * @param name the pacakge name * @param trace whether trace is enabled * @return the package */ private Package getPackageFromImports(ClassLoaderInformation info, String name, boolean trace) { List delegates = info.getDelegates(); if (delegates == null || delegates.isEmpty()) { if (trace) log.trace(this + " not getting package " + name + " from imports it has no delegates"); return null; } if (trace) log.trace(this + " trying to get package " + name + " from imports " + delegates + " for " + info.getClassLoader()); for (DelegateLoader delegate : delegates) { Package result = delegate.getPackage(name); if (result != null) return result; } return null; } /** * Load packages from the imports * * @param info the classloader info * @param packages the packages to add to * @param trace whether trace is enabled */ void getPackagesFromImports(ClassLoaderInformation info, Set packages, boolean trace) { List delegates = info.getDelegates(); if (delegates == null || delegates.isEmpty()) { if (trace) log.trace(this + " not getting all packages from imports it has no delegates"); return; } if (trace) log.trace(this + " trying to get all pacakges from imports " + delegates + " for " + info.getClassLoader()); for (DelegateLoader delegate : delegates) delegate.getPackages(packages); } /** * Invoked before classloading is attempted to allow a preload attempt, e.g. from the parent * * @param name the class name * @return the loader if found or null otherwise */ protected abstract Class loadClassBefore(String name); /** * Invoked after classloading is attempted to allow a postload attempt, e.g. from the parent * * @param name the class name * @return the loader if found or null otherwise */ protected abstract Class loadClassAfter(String name); /** * Invoked before classloading is attempted to allow a preload attempt, e.g. from the parent * * @param name the class resource name * @return the loader if found or null otherwise */ protected abstract Loader findBeforeLoader(String name); /** * Invoked after classloading is attempted to allow a postload attempt, e.g. from the parent * * @param name the class resource name * @return the loader if found or null otherwise */ protected abstract Loader findAfterLoader(String name); /** * Invoked before getResources is attempted to allow a preload attempt, e.g. from the parent * * @param name the resource name * @param urls the urls to add to * @throws IOException for any error */ protected abstract void beforeGetResources(String name, Set urls) throws IOException; /** * Invoked after getResources is attempted to allow a postload attempt, e.g. from the parent * * @param name the resource name * @param urls the urls to add to * @throws IOException for any error */ protected abstract void afterGetResources(String name, Set urls) throws IOException; /** * Invoked before getResource is attempted to allow a preload attempt, e.g. from the parent * * @param name the resource name * @return the url if found or null otherwise */ protected abstract URL beforeGetResource(String name); /** * Invoked after getResource is attempted to allow a postload attempt, e.g. from the parent * * @param name the resource name * @return the url if found or null otherwise */ protected abstract URL afterGetResource(String name); /** * Invoked before getPackages is attempted to allow a preload attempt, e.g. from the parent * * @param packages the packages to add to */ protected abstract void beforeGetPackages(Set packages); /** * Invoked after getPackages is attempted to allow a postload attempt, e.g. from the parent * * @param packages the packages to add to */ protected abstract void afterGetPackages(Set packages); /** * Invoked before getPackage is attempted to allow a preload attempt, e.g. from the parent * * @param name the package name * @return the package if found or null otherwise */ protected abstract Package beforeGetPackage(String name); /** * Invoked after getPackage is attempted to allow a postload attempt, e.g. from the parent * * @param name the package name * @return the url if found or null otherwise */ protected abstract Package afterGetPackage(String name); public Class loadClass(String name) { try { return loadClass(null, name, true); } catch (ClassNotFoundException e) { return null; } } /** * Load a class from the domain * * @param classLoader the classloader * @param name the class name * @return the class * @throws ClassNotFoundException for any error */ Class loadClass(BaseClassLoader classLoader, String name) throws ClassNotFoundException { return loadClass(classLoader, name, false); } public URL getResource(String name) { return getResource(null, name, true); } /** * Get a resource from the domain * * @param classLoader the classloader * @param name the resource name * @return the url */ URL getResource(BaseClassLoader classLoader, String name) { return getResource(classLoader, name, false); } public void getResources(String name, Set urls) throws IOException { getResources(null, name, urls, true); } /** * Get a resource from the domain * * @param classLoader the classloader * @param name the resource name * @param urls the urls to add to * @throws IOException for any error */ void getResources(BaseClassLoader classLoader, String name, Set urls) throws IOException { getResources(classLoader, name, urls, false); } public Package getPackage(String name) { return getPackage(null, name, true); } /** * Get a package from the specified classloader * * @param classLoader the classloader * @param name the package name * @return the package */ Package getPackage(BaseClassLoader classLoader, String name) { return getPackage(classLoader, name, false); } public void getPackages(Set packages) { getPackages(null, packages, true); } /** * Get the packages from a specified classloader * * @param classLoader the classloader * @param packages the packages */ void getPackages(BaseClassLoader classLoader, Set packages) { getPackages(classLoader, packages, false); } /** * A long version of toString() * * @return the long string */ public String toLongString() { StringBuilder builder = new StringBuilder(); builder.append(getClass().getSimpleName()); builder.append("@").append(Integer.toHexString(System.identityHashCode(this))); builder.append("{"); toLongString(builder); builder.append('}'); return builder.toString(); } /** * For subclasses to add information for toLongString() * * @param builder the builder */ protected void toLongString(StringBuilder builder) { } /** * Invoked before adding a classloader policy * * @param classLoader the classloader * @param policy the classloader policy */ protected void beforeRegisterClassLoader(ClassLoader classLoader, ClassLoaderPolicy policy) { // nothing } /** * Invoked after adding a classloader policy * * @param classLoader the classloader * @param policy the classloader policy */ protected void afterRegisterClassLoader(ClassLoader classLoader, ClassLoaderPolicy policy) { // nothing } /** * Invoked before adding a classloader policy * * @param classLoader the classloader * @param policy the classloader policy */ protected void beforeUnregisterClassLoader(ClassLoader classLoader, ClassLoaderPolicy policy) { // nothing } /** * Invoked after adding a classloader policy * * @param classLoader the classloader * @param policy the classloader policy */ protected void afterUnregisterClassLoader(ClassLoader classLoader, ClassLoaderPolicy policy) { // nothing } /** * Get the parent classloader * * @return the parent classloader */ protected ClassLoader getParentClassLoader() { return getClass().getClassLoader(); } /** * Register a classloader * * @param classLoader the classloader */ void registerClassLoader(BaseClassLoader classLoader) { log.debug(this + " registerClassLoader " + classLoader.toString()); if (getClassLoaderSystem() == null) throw new IllegalStateException("Domain is not registered with a classloader system: " + toLongString()); ClassLoaderPolicy policy = classLoader.getPolicy(); BaseDelegateLoader exported = policy.getExported(); if (exported != null && exported.getPolicy() == null) throw new IllegalStateException("The exported delegate " + exported + " is too lazy for " + policy.toLongString()); try { beforeRegisterClassLoader(classLoader, policy); } catch (Throwable t) { log.warn("Error in beforeRegisterClassLoader: " + this + " classLoader=" + classLoader.toLongString(), t); } BaseClassLoaderPolicy basePolicy = classLoader.getPolicy(); basePolicy.setClassLoaderDomain(this); synchronized (classLoaders) { // Create the information ClassLoaderInformation info = new ClassLoaderInformation(classLoader, policy, order++); classLoaders.add(info); infos.put(classLoader, info); // Index the packages String[] packageNames = policy.getPackageNames(); if (packageNames != null && info.getExported() != null) { for (String packageName : packageNames) { List list = classLoadersByPackageName.get(packageName); if (list == null) { list = new CopyOnWriteArrayList(); classLoadersByPackageName.put(packageName, list); } list.add(info); log.trace("Registered " + policy + " as providing package=" + packageName); } } flushCaches(); } try { afterRegisterClassLoader(classLoader, classLoader.getPolicy()); } catch (Throwable t) { log.warn("Error in afterRegisterClassLoader: " + this + " classLoader=" + classLoader.toLongString(), t); } } /** * Remove a classloader * * @param classLoader the classloader */ void unregisterClassLoader(BaseClassLoader classLoader) { log.debug(this + " unregisterClassLoader " + classLoader.toString()); try { beforeUnregisterClassLoader(classLoader, classLoader.getPolicy()); } catch (Throwable t) { log.warn("Error in beforeUnegisterClassLoader: " + this + " classLoader=" + classLoader.toLongString(), t); } BaseClassLoaderPolicy policy = classLoader.getPolicy(); policy.unsetClassLoaderDomain(this); synchronized (classLoaders) { // Remove the classloader ClassLoaderInformation info = infos.remove(classLoader); classLoaders.remove(info); // Remove the package index String[] packageNames = policy.getPackageNames(); if (packageNames != null && info.getExported() != null) { for (String packageName : packageNames) { List list = classLoadersByPackageName.get(packageName); if (list != null) { list.remove(info); log.trace("Unregistered " + policy + " as providing package=" + packageName); if (list.isEmpty()) classLoadersByPackageName.remove(packageName); } } } flushCaches(); } try { afterUnregisterClassLoader(classLoader, classLoader.getPolicy()); } catch (Throwable t) { log.warn("Error in afterUnegisterClassLoader: " + this + " classLoader=" + classLoader.toLongString(), t); } } /** * Get all the classloaders * * @return the list of classloaders */ protected List getAllClassLoaders() { List result = new ArrayList(); for (ClassLoaderInformation info : classLoaders) result.add(info.getClassLoader()); return result; } /** * Get a map of packages to classloader * * @return a map of packages to a list of classloaders for that package */ protected Map> getClassLoadersByPackage() { HashMap> result = new HashMap>(); for (Entry> entry : classLoadersByPackageName.entrySet()) { List cls = new ArrayList(); for (ClassLoaderInformation info : entry.getValue()) cls.add(info.getClassLoader()); result.put(entry.getKey(), cls); } return result; } protected List getClassLoaders(String packageName) { if (packageName == null) throw new IllegalArgumentException("Null package name"); List result = new ArrayList(); List infos = classLoadersByPackageName.get(packageName); if (infos != null) { for (ClassLoaderInformation info : infos) result.add(info.getClassLoader()); } return result; } /** * Check the class cache * * @param classLoader the reference classloader (possibly null) * @param name the name of the class * @param path the path of the class resource * @param allExports whether to look at all exports * @return the class if cached */ Class checkClassCache(BaseClassLoader classLoader, String name, String path, boolean allExports) { if (allExports) { ClassCacheItem item = globalClassCache.get(path); if (item != null) { if (log.isTraceEnabled()) log.trace("Found " + name + " in global cache"); return item.clazz; } } return null; } /** * Check the class blacklist * * @param classLoader the classloader (possibly null) * @param name the name * @param path the path of the class resource * @param allExports whether to look at all exports * @param failIfBlackListed true if a blacklisted class should * result in ClassNotFoundException; false * if a null return value is acceptable * @throws ClassNotFoundException when the class is blacklisted */ void checkClassBlackList(BaseClassLoader classLoader, String name, String path, boolean allExports, boolean failIfBlackListed) throws ClassNotFoundException { if (allExports) { if (failIfBlackListed && globalClassBlackList.containsKey(path)) { if (log.isTraceEnabled()) log.trace("Found " + name + " in global blacklist"); throw new ClassNotFoundException(name + " not found - blacklisted"); } } } /** * Check the cache and blacklist * * @param classLoader the classloader (possibly null) * @param name the name * @param path the path of the class resource * @param allExports whether to look at all exports * @param failIfBlackListed true if a blacklisted class should * result in ClassNotFoundException; false * if a null return value is acceptable * @return the class when found in the cache * @throws ClassNotFoundException when the class is blacklisted and * failIfBlackListed is true */ protected Class checkClassCacheAndBlackList(BaseClassLoader classLoader, String name, String path, boolean allExports, boolean failIfBlackListed) throws ClassNotFoundException { if (path == null) path = ClassLoaderUtils.classNameToPath(name); Class result = checkClassCache(classLoader, name, path, allExports); if (result != null) return result; checkClassBlackList(classLoader, name, path, allExports, failIfBlackListed); return null; } /** * Cleans the entry with the given name from the blackList * * @param name the name of the resource to clear from the blackList */ protected void clearBlackList(String name) { if (globalClassBlackList != null) { globalClassBlackList.remove(name); } if (globalResourceBlackList != null) { globalResourceBlackList.remove(name); } // Need to clear the import caches as well List infos = classLoaders; for (ClassLoaderInformation info : infos) info.clearBlackList(name); } /** * ClassCacheItem. */ class ClassCacheItem { Loader loader; Class clazz; public ClassCacheItem(Loader loader) { this.loader = loader; } public ClassCacheItem(Class clazz) { this.clazz = clazz; } @Override public String toString() { if (loader != null) return loader.toString(); return null; } } } ././@LongLink0000000000000000000000000000016600000000000011570 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloader/src/main/java/org/jboss/classloader/spi/base/BaseClassLoader.javalibjboss-classloader-java-2.0.6.GA.orig/classloader/src/main/java/org/jboss/classloader/spi/base/Bas0000644000175000017500000010046711177660204033226 0ustar twernertwerner/* * JBoss, Home of Professional Open Source. * Copyright 2007, Red Hat Middleware LLC, and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.classloader.spi.base; import java.io.IOException; import java.io.InputStream; import java.net.URL; import java.security.AccessController; import java.security.CodeSource; import java.security.PrivilegedAction; import java.security.PrivilegedActionException; import java.security.PrivilegedExceptionAction; import java.security.ProtectionDomain; import java.security.SecureClassLoader; import java.util.ArrayList; import java.util.Collections; import java.util.Enumeration; import java.util.HashSet; import java.util.List; import java.util.Map; import java.util.Set; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.TimeUnit; import java.util.concurrent.locks.ReentrantLock; import javax.management.ObjectName; import org.jboss.classloader.plugins.ClassLoaderUtils; import org.jboss.classloader.spi.ClassLoaderDomain; import org.jboss.classloader.spi.ClassLoaderPolicy; import org.jboss.classloader.spi.DelegateLoader; import org.jboss.classloader.spi.Loader; import org.jboss.classloader.spi.PackageInformation; import org.jboss.classloading.spi.RealClassLoader; import org.jboss.logging.Logger; import org.jboss.util.collection.Iterators; /** * BaseClassLoader. * * @author Adrian Brock * @version $Revision: 1.1 $ */ public class BaseClassLoader extends SecureClassLoader implements BaseClassLoaderMBean, RealClassLoader { /** The log */ private static final Logger log = Logger.getLogger(BaseClassLoader.class); /** The lock object */ private ReentrantLock lock = new ReentrantLock(true); /** The policy for this classloader */ private ClassLoaderPolicy policy; /** Our Loader front end */ private DelegateLoader loader; /** The loaded classes */ private Map loadedClasses = new ConcurrentHashMap(); /** Our resource cache */ private Map resourceCache; /** Our black list */ private Map blackList; /** A cached version of toLongString() */ private String cachedToString; /** * Create a new ClassLoader with no parent. * * @param policy the policy * @throws IllegalArgumentException for a null policy * @throws IllegalStateException if the policy is already associated with a classloader */ public BaseClassLoader(ClassLoaderPolicy policy) { super(null); if (policy == null) throw new IllegalArgumentException("Null policy"); this.policy = policy; BaseClassLoaderPolicy basePolicy = policy; basePolicy.setClassLoader(this); loader = new DelegateLoader(policy); if (basePolicy.isCacheable()) resourceCache = new ConcurrentHashMap(); if (basePolicy.isBlackListable()) blackList = new ConcurrentHashMap(); log.debug("Created " + this + " with policy " + policy.toLongString()); } public ObjectName getObjectName() { return policy.getObjectName(); } public ObjectName getClassLoaderDomain() { BaseClassLoaderPolicy basePolicy = policy; ClassLoaderDomain domain = (ClassLoaderDomain) basePolicy.getClassLoaderDomain(); return domain.getObjectName(); } public String getName() { return policy.getName(); } public boolean isBlackListable() { BaseClassLoaderPolicy basePolicy = policy; return basePolicy.isBlackListable(); } public boolean isCacheable() { BaseClassLoaderPolicy basePolicy = policy; return basePolicy.isCacheable(); } public boolean isImportAll() { BaseClassLoaderPolicy basePolicy = policy; return basePolicy.isImportAll(); } public Set listExportedPackages() { HashSet result = new HashSet(); String[] packageNames = policy.getPackageNames(); if (packageNames != null) Collections.addAll(result, packageNames); return result; } public List listImports() { ArrayList result = new ArrayList(); BaseClassLoaderPolicy basePolicy = policy; List delegates = basePolicy.getDelegates(); if (delegates != null) { for (DelegateLoader delegate : delegates) { BaseDelegateLoader baseDelegate = delegate; BaseClassLoaderPolicy otherPolicy = baseDelegate.getPolicy(); if (otherPolicy != null) result.add(otherPolicy.getObjectName()); } } return result; } public String listPolicyDetails() { return policy.toLongString(); } public ObjectName findClassLoaderForClass(String name) throws ClassNotFoundException { final Class clazz = loadClass(name); if (clazz == null) return null; ClassLoader cl = AccessController.doPrivileged(new PrivilegedAction() { public ClassLoader run() { return clazz.getClassLoader(); } }); if (cl != null && cl instanceof RealClassLoader) return ((RealClassLoader) cl).getObjectName(); return null; } public Set listLoadedClasses() { return Collections.unmodifiableSet(loadedClasses.keySet()); } public Set listLoadedResourceNames() { if (resourceCache == null) return Collections.emptySet(); return new HashSet(resourceCache.keySet()); } public Set listLoadedResources() { if (resourceCache == null) return Collections.emptySet(); return new HashSet(resourceCache.values()); } /** * Get the policy. * * @return the policy. */ ClassLoaderPolicy getPolicy() { return policy; } /** * Get the loader. * * @return the loader. */ DelegateLoader getLoader() { return loader; } @Override protected Package getPackage(String name) { boolean trace = log.isTraceEnabled(); if (trace) log.trace(this + " getPackage " + name); if (name == null) return null; // Did we already load this package? Package result = super.getPackage(name); if (result != null && trace) log.trace(this + " already loaded package " + name + " " + result.getName()); // Not already loaded use the domain if (result == null) { BaseClassLoaderPolicy basePolicy = policy; BaseClassLoaderDomain domain = basePolicy.getClassLoaderDomain(); if (domain == null) return null; if (trace) log.trace(this + " getPackage " + name + " domain=" + domain); result = domain.getPackage(this, name); } // Still not found if (result == null) { if (trace) log.trace(this + " package not found " + name); } return result; } @Override protected Package[] getPackages() { BaseClassLoaderPolicy basePolicy = policy; BaseClassLoaderDomain domain = basePolicy.getClassLoaderDomain(); if (domain == null) return super.getPackages(); boolean trace = log.isTraceEnabled(); if (trace) log.trace(this + " getPackages domain=" + domain); Set packages = new HashSet(); domain.getPackages(this, packages); return packages.toArray(new Package[packages.size()]); } /** * Get a package locally * * @param name the package name * @return the package */ Package getPackageLocally(String name) { return super.getPackage(name); } /** * Get the packages locally * * @param packages the packages */ void getPackagesLocally(Set packages) { Package[] pkgs = super.getPackages(); for (Package pkg : pkgs) packages.add(pkg); } /** * Check to see if the class is already loaded * * @param name the name of the class * @param trace whether trace is enabled * @return the class is if it is already loaded, null otherwise */ protected Class isLoadedClass(String name, boolean trace) { Class result = findLoadedClass(name); if (result != null) { // Has this classloader been undeployed? ClassLoader otherClassLoader = getClassLoader(result); if (otherClassLoader != null && otherClassLoader != this && otherClassLoader instanceof RealClassLoader) { RealClassLoader rcl = (RealClassLoader) otherClassLoader; // Ignore when undeployed if (rcl.isValid() == false) { if (trace) log.trace(this + " ignoring already loaded class from undeployed classloader " + ClassLoaderUtils.classToString(result)); result = null; } } } if (result != null && trace) log.trace(this + " already loaded class " + ClassLoaderUtils.classToString(result)); return result; } /** * Check the cache and blacklist * * @param name the name of the class * @param failIfBlackListed true if a blacklisted class should * result in ClassNotFoundException; false * if a null return value is acceptable * @param trace whether trace is enabled * @return the class is if it is already loaded, null otherwise * @throws ClassNotFoundException when the class is blacklisted and * failIfBlackListed is true */ protected Class checkCacheAndBlackList(String name, boolean failIfBlackListed, boolean trace) throws ClassNotFoundException { BaseClassLoaderPolicy basePolicy = policy; BaseClassLoaderDomain domain = basePolicy.getClassLoaderDomain(); if (domain == null) return null; return domain.checkClassCacheAndBlackList(this, name, null, basePolicy.isImportAll(), false); } /** * Find the classloader for a class but don't load the class * * @param className the class name * @return the classloader * @throws ClassNotFoundException if the class is not found * @throws IllegalStateException if the classloader is not installed * @throws SecurityException if the called doesn't have the getClassLoader runtime permission */ public ClassLoader findClassLoader(String className) throws ClassNotFoundException { SecurityManager sm = System.getSecurityManager(); if (sm != null) sm.checkPermission(new RuntimePermission("getClassLoader")); BaseClassLoaderPolicy basePolicy = policy; BaseClassLoaderDomain domain = basePolicy.getClassLoaderDomain(); if (domain == null) throw new IllegalStateException(this + " classLoader is not connected to a domain (probably undeployed?) for class " + getName()); ClassLoaderUtils.checkClassName(className); String path = ClassLoaderUtils.classNameToPath(className); Loader loader = domain.findLoader(this, path, basePolicy.isImportAll(), true); if (loader == null) throw new ClassNotFoundException("Class " + className + " not found from " + this); // This is a bit ugly but we can't abstract this behind an interface because // that would make the methods public if (loader instanceof BaseClassLoaderSource) return ((BaseClassLoaderSource) loader).getClassLoader(); if (loader instanceof BaseDelegateLoader) return ((BaseDelegateLoader) loader).getPolicy().getClassLoader(); return null; } @Override protected Class loadClass(String name, boolean resolve) throws ClassNotFoundException { boolean trace = log.isTraceEnabled(); if (trace) log.trace(this + " loadClass " + name + " resolve=" + resolve); // Validate the class name makes sense ClassLoaderUtils.checkClassName(name); // Did we already load this class? Class result = isLoadedClass(name, trace); // If this is an array, use Class.forName() to resolve it if (result == null && name.charAt(0) == '[') { if (trace) log.trace(this + " resolving array class " + name + " using Class.forName()"); result = Class.forName(name, true, this); if (trace) log.trace(this + " resolved array " + ClassLoaderUtils.classToString(result)); } if (result != null) return result; result = checkCacheAndBlackList(name, false, trace); if (result != null) return result; synchronized (this) { // Not already loaded use the domain if (result == null) result = loadClassFromDomain(name, trace); // Still not found if (result == null) { if (trace) log.trace(this + " class not found " + name); throw new ClassNotFoundException(name + " from " + toLongString()); } // Link the class if requested if (resolve) { if (trace) log.trace(this + " resolveClass " + ClassLoaderUtils.classToString(result)); resolveClass(result); } return result; } } @Override public URL getResource(String name) { BaseClassLoaderPolicy basePolicy = policy; BaseClassLoaderDomain domain = basePolicy.getClassLoaderDomain(); boolean trace = log.isTraceEnabled(); if (trace) log.trace(this + " getResource " + name + " domain=" + domain); if (domain != null) return domain.getResource(this, name); return null; } @Override @SuppressWarnings("unchecked") protected Enumeration findResources(String name) throws IOException { Set resourceURLs = loadResources(name); return Iterators.toEnumeration(resourceURLs.iterator()); } public Set loadResources(String name) throws IOException { BaseClassLoaderPolicy basePolicy = policy; BaseClassLoaderDomain domain = basePolicy.getClassLoaderDomain(); boolean trace = log.isTraceEnabled(); if (trace) log.trace(this + " findResources " + name + " domain=" + domain); Set resourceURLs = new HashSet(); if (domain != null) domain.getResources(this, name, resourceURLs); return resourceURLs; } /** * Try to load the class locally * * @param name the class name * @return the class */ Class loadClassLocally(String name) { return loadClassLocally(name, log.isTraceEnabled()); } /** * Try to load the class locally * * @param name the class name * @param trace whether trace is enabled * @return the class if found */ synchronized Class loadClassLocally(final String name, final boolean trace) { if (trace) log.trace(this + " load class locally " + name); // This is really a double check but the request may not have entered through loadClass on this classloader Class result = isLoadedClass(name, trace); if (result != null) return result; // Look for the resource final String resourcePath = ClassLoaderUtils.classNameToPath(name); result = AccessController.doPrivileged(new PrivilegedAction>() { public Class run() { InputStream is = policy.getResourceAsStream(resourcePath); if (is == null) { if (trace) BaseClassLoader.log.trace(BaseClassLoader.this + " resource not found locally " + resourcePath + " for " + name); return null; } // Load the bytecode byte[] byteCode = ClassLoaderUtils.loadByteCode(name, is); // Let the policy do things before we define the class BaseClassLoaderPolicy basePolicy = policy; ProtectionDomain protectionDomain = basePolicy.getProtectionDomain(name, resourcePath); try { byte[] transformed = policy.transform(name, byteCode, protectionDomain); if (transformed != null) byteCode = transformed; } catch (Throwable t) { throw new RuntimeException("Unexpected error transforming class " + name, t); } // Create the package if necessary URL codeSourceURL = null; if (protectionDomain != null) { CodeSource codeSource = protectionDomain.getCodeSource(); if (codeSource != null) codeSourceURL = codeSource.getLocation(); } definePackage(name, codeSourceURL); // Finally we can define the class Class result; if (protectionDomain != null) result = defineClass(name, byteCode, 0, byteCode.length, protectionDomain); else result = defineClass(name, byteCode, 0, byteCode.length); if (trace) BaseClassLoader.log.trace(BaseClassLoader.this + " loaded class locally " + ClassLoaderUtils.classToString(result)); return result; } }, policy.getAccessControlContext()); loadedClasses.put(name, name); return result; } /** * Try to find the resource locally * * @param name the resource name * @return the url if found */ public URL getResourceLocally(String name) { return getResourceLocally(name, log.isTraceEnabled()); } /** * Try to find the resource locally * * @param name the resource name * @param trace whether trace is enabled * @return the URL if found */ URL getResourceLocally(final String name, final boolean trace) { if (trace) log.trace(this + " get resource locally " + name); // Do we already know the answer? if (resourceCache != null) { URL url = resourceCache.get(name); if (url != null) { if (trace) log.trace(this + " got resource from cache " + name); return url; } } // Is this resource blacklisted? if (blackList != null && blackList.containsKey(name)) { if (trace) log.trace(this + " resource is blacklisted " + name); return null; } // Ask the policy for the resource URL result = AccessController.doPrivileged(new PrivilegedAction() { public URL run() { // Look for the resource URL result = policy.getResource(name); if (result == null) { if (trace) BaseClassLoader.log.trace(BaseClassLoader.this + " resource not found locally " + name); return null; } if (trace) BaseClassLoader.log.trace(BaseClassLoader.this + " got resource locally " + name); return result; } }, policy.getAccessControlContext()); // Cache what we found if (resourceCache != null && result != null) resourceCache.put(name, result); // Blacklist when not found if (blackList != null && result == null) blackList.put(name, name); return result; } /** * Try to find the resource locally * * @param name the resource name * @param urls the urls to add to * @throws IOException for any error */ void getResourcesLocally(String name, Set urls) throws IOException { getResourcesLocally(name, urls, log.isTraceEnabled()); } /** * Try to find the resources locally * * @param name the resource name * @param urls the urls to add to * @param trace whether trace is enabled * @throws IOException for any error */ void getResourcesLocally(final String name, final Set urls, boolean trace) throws IOException { if (trace) log.trace(this + " get resources locally " + name); // Look for the resources try { AccessController.doPrivileged(new PrivilegedExceptionAction() { public Object run() throws Exception { policy.getResources(name, urls); return null; } }, policy.getAccessControlContext()); } catch (PrivilegedActionException e) { Exception e1 = e.getException(); if (e1 instanceof RuntimeException) throw (RuntimeException) e1; if (e1 instanceof IOException) throw (IOException) e1; IOException e2 = new IOException("Unexpected error"); e2.initCause(e1); throw e2; } } /** * Define the package for the class if not already done * * @param className the class name * @param codeSourceURL the code source url */ protected void definePackage(String className, URL codeSourceURL) { String packageName = ClassLoaderUtils.getClassPackageName(className); if (packageName.length() == 0) return; // Ask the policy for the information PackageInformation pi = policy.getClassPackageInformation(className, packageName); // Already defined? Package pkge = getPackage(packageName); if (pkge != null) { // Check sealing if (pkge.isSealed()) { // Are we trying to add outside the seal? if (codeSourceURL == null || pkge.isSealed(codeSourceURL) == false) throw new SecurityException("Sealing violation for package " + packageName); } // Can we seal now? else if (pi != null && pi.sealBase != null) { throw new SecurityException("Can't seal package " + packageName +" it is already loaded"); } return; } try { if (pi != null) definePackage(packageName, pi.specTitle, pi.specVersion, pi.specVendor, pi.implTitle, pi.implVersion, pi.implVendor, pi.sealBase); else definePackage(packageName, null, null, null, null, null, null, null); if (log.isTraceEnabled()) log.trace(this + " defined package: " + packageName); } catch (IllegalArgumentException alreadyDone) { // The package has already been defined } } /** * Try to load the class from the domain * * @param name the class name * @param trace whether trace is enabled * @return the class if found in the parent * @throws ClassNotFoundException for any error */ protected Class loadClassFromDomain(String name, boolean trace) throws ClassNotFoundException { // Because of the broken classloading in the Sun JDK we need to // serialize access to the classloader. // Additionally, acquiring the lock on the policy for this classloader // ensures that we don't race with somebody undeploying the classloader // which could cause leaks acquireLockFairly(trace); try { // Here we have synchronized with the policy BaseClassLoaderPolicy basePolicy = policy; BaseClassLoaderDomain domain = basePolicy.getClassLoaderDomain(); if (trace) log.trace(this + " load from domain " + name + " domain=" + domain); // No domain, try to load the class locally // this could happen during undeployment of the classloader // where something needs a local class after it is has been unhooked from the system if (domain == null) { Class result = loadClassLocally(name, trace); // So this is almost certainly a classloader leak if (result == null) throw new IllegalStateException(this + " classLoader is not connected to a domain (probably undeployed?) for class " + name); return result; } // Ask the domain to load the class in the context of our classloader/policy Class result = domain.loadClass(this, name); if (result != null && trace) log.trace(this + " got class from domain " + ClassLoaderUtils.classToString(result)); return result; } finally { unlock(trace, true); } } public boolean isValid() { BaseClassLoaderPolicy basePolicy = policy; return basePolicy.getClassLoaderUnchecked() != null; } public Class getCachedClass(String name) { // TODO look in global and/or local cache return null; } public URL getCachedResource(String name) { // TODO look in global and/or local cache return null; } public int getResourceBlackListSize() { Map blackList = this.blackList; if (blackList == null) return 0; return blackList.size(); } public int getResourceCacheSize() { Map resourceCache = this.resourceCache; if (resourceCache == null) return 0; return resourceCache.size(); } public Set listResourceBlackList() { Map blackList = this.blackList; if (blackList == null) return Collections.emptySet(); return Collections.unmodifiableSet(blackList.keySet()); } public Map listResourceCache() { Map resourceCache = this.resourceCache; if (resourceCache == null) return Collections.emptyMap(); return Collections.unmodifiableMap(resourceCache); } public void clearBlackList() { if (blackList != null) { for (String name : blackList.keySet()) clearBlackList(name); } } public void clearBlackList(String name) { if (blackList != null) { boolean trace = log.isTraceEnabled(); if (trace) log.trace(this + " removing from blacklist " + name); blackList.remove(name); policy.clearBlackList(name); } } /** * A long version of the classloader * * @return the long string */ public String toLongString() { if (cachedToString != null) return cachedToString; StringBuilder builder = new StringBuilder(); builder.append(getClass().getSimpleName()); builder.append('@').append(Integer.toHexString(System.identityHashCode(this))); builder.append('{').append(getPolicy().toLongString()); toLongString(builder); builder.append('}'); cachedToString = builder.toString(); return cachedToString; } /** * Shutdown the classloader */ protected void shutdownClassLoader() { log.debug(toString() + " shutdown!"); if (resourceCache != null) resourceCache.clear(); if (blackList != null) blackList.clear(); cachedToString = null; } /** * For subclasses to add things to the long string * * @param builder the builder */ protected void toLongString(StringBuilder builder) { } @Override public String toString() { StringBuilder builder = new StringBuilder(); builder.append(getClass().getSimpleName()); builder.append('@').append(Integer.toHexString(System.identityHashCode(this))); builder.append("{").append(policy.getName()).append("}"); return builder.toString(); } /** * Attempt to lock, but don't wait * * @return true when the lock was obtained */ boolean attemptLock() { return attemptLock(log.isTraceEnabled()); } /** * Lock * * This method must be invoked with the monitor held */ void lock() { acquireLockFairly(log.isTraceEnabled()); } /** * Unlock * * @param rescheduleTasks whether to reschedule tasks */ void unlock(boolean rescheduleTasks) { unlock(log.isTraceEnabled(), rescheduleTasks); } /** * Attempt to get the lock but don't wait * * @param trace whether trace is enabled * @return true when obtained the lock */ private boolean attemptLock(boolean trace) { Thread thread = Thread.currentThread(); if (trace) log.trace(this + " attemptLock " + thread); boolean interrupted = Thread.interrupted(); boolean result = false; try { result = lock.tryLock(0, TimeUnit.MICROSECONDS); } catch (InterruptedException ignored) { interrupted = true; } finally { if (interrupted) thread.interrupt(); } if (trace) { if (result) log.trace(this + " locked " + thread + " holding=" + lock.getHoldCount()); else log.trace(this + " did NOT get the lock " + thread); } // We got the lock so we own it if (result && lock.getHoldCount() == 1) ClassLoaderManager.registerLoaderThread(this, thread); return result; } /** * Acquire the lock on the classloader fairly

* * This must be invoked with the monitor held * * @param trace whether trace is enabled */ private void acquireLockFairly(boolean trace) { Thread thread = Thread.currentThread(); if (trace) log.trace(this + " aquireLockFairly " + thread); boolean interrupted = Thread.interrupted(); int waits = 0; try { while (true) { try { if (lock.tryLock(0, TimeUnit.MICROSECONDS) == false) { // Two minutes should be long enough? if (waits++ == 12) throw new IllegalStateException("Waiting too long to get the classloader lock: " + this); // Wait 10 seconds if (trace) log.trace(this + " waiting for lock " + thread); this.wait(10000); } else { if (trace) log.trace(this + " aquiredLock " + thread + " holding=" + lock.getHoldCount()); break; } } catch (InterruptedException ignored) { interrupted = true; } } } finally { if (interrupted) thread.interrupt(); } if (lock.getHoldCount() == 1) ClassLoaderManager.registerLoaderThread(this, thread); } /** * Unlock * * @param trace whether trace is enabled * @param rescheduleTasks whether to reschedule tasks */ private void unlock(boolean trace, boolean rescheduleTasks) { Thread thread = Thread.currentThread(); if (trace) log.trace(this + " unlock " + thread + " holding=" + lock.getHoldCount()); synchronized (this) { lock.unlock(); if (lock.getHoldCount() == 0) { ClassLoaderManager.unregisterLoaderThread(this, thread, rescheduleTasks); notifyAll(); } } } /** * Get the classloader for a class * * @param clazz the class * @return the classloader or null if it doesn't have one */ private static final ClassLoader getClassLoader(final Class clazz) { SecurityManager sm = System.getSecurityManager(); if (sm == null) return clazz.getClassLoader(); return AccessController.doPrivileged(new PrivilegedAction() { public ClassLoader run() { return clazz.getClassLoader(); } }); } } ././@LongLink0000000000000000000000000000017100000000000011564 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloader/src/main/java/org/jboss/classloader/spi/base/ClassLoaderManager.javalibjboss-classloader-java-2.0.6.GA.orig/classloader/src/main/java/org/jboss/classloader/spi/base/Cla0000644000175000017500000003520611153603000033177 0ustar twernertwerner/* * JBoss, Home of Professional Open Source. * Copyright 2007, Red Hat Middleware LLC, and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.classloader.spi.base; import java.util.Collections; import java.util.HashMap; import java.util.LinkedList; import java.util.List; import java.util.Map; import java.util.WeakHashMap; import org.jboss.classloader.spi.Loader; import org.jboss.classloader.spi.base.ClassLoadingTask.ThreadTask; import org.jboss.logging.Logger; /** * ClassLoaderManager. * * @author Scott.Stark@jboss.org * @author Adrian Brock * @version $Revision: 1.1 $ */ public class ClassLoaderManager { /** The log */ private static Logger log = Logger.getLogger("org.jboss.detailed.classloader.ClassLoaderManager"); /** The maximum number of CCEs */ private static final int MAX_CCE = 10; /** The threads owning the classloader lock */ private static final Map loadClassThreads = new HashMap(); /** The classloading tasks by thread */ private static final Map> loadTasksByThread = Collections.synchronizedMap(new WeakHashMap>()); /** * Register a thread as owning the classloader * * @param classloader the classloader * @param thread the thread * @throws IllegalArgumentException for a null parameter */ static void registerLoaderThread(BaseClassLoader classloader, Thread thread) { boolean trace = log.isTraceEnabled(); synchronized (loadClassThreads) { Object previousThread = loadClassThreads.put(classloader, thread); if (trace) log.trace("registerLoaderThread, classloader=" + classloader + " thread=" + thread + " previousThread=" + previousThread); synchronized (loadTasksByThread) { List taskList = loadTasksByThread.get(thread); if (taskList == null) { taskList = Collections.synchronizedList(new LinkedList()); loadTasksByThread.put(thread, taskList); if (trace) log.trace("Created new task list for " + thread); } } loadClassThreads.notifyAll(); } } /** * Unregister ourselves as owning the classloader lock * * @param classLoader the classloader * @param thread the thread owning the classloader * @param rescheduleTasks whether to reschedule tasks */ public static void unregisterLoaderThread(BaseClassLoader classLoader, Thread thread, boolean rescheduleTasks) { boolean trace = log.isTraceEnabled(); if (trace) log.trace("unregisterLoaderThread, classloader=" + classLoader + " thread=" + thread + " rescheduleTasks=" + rescheduleTasks); // Unregister as the owning thread and notify any waiting threads synchronized (loadClassThreads) { loadClassThreads.remove(classLoader); loadClassThreads.notifyAll(); } // Any ThreadTasks associated with this thread must be reassigned if (rescheduleTasks) { List taskList = loadTasksByThread.get(thread); if (taskList != null) { synchronized (taskList) { while (taskList.isEmpty() == false) { ThreadTask threadTask = taskList.remove(0); ClassLoadingTask loadTask = threadTask.getLoadTask(); Thread requestingThread = loadTask.getRequestingThread(); if( trace ) log.trace("Reassigning task: " + threadTask+" to " + requestingThread); threadTask.setThread(null); // Insert the task into the front of requestingThread task list List toTaskList = loadTasksByThread.get(requestingThread); synchronized (toTaskList) { toTaskList.add(0, threadTask); loadTask.nextEvent(); toTaskList.notify(); } } } } } } /** * Process the classloading task * * @param thread the thread * @param task the task * @return the loaded class * @throws ClassNotFoundException for load exception */ static Class process(Thread thread, ClassLoadingTask task) throws ClassNotFoundException { while (task.getThreadTaskCount() != 0) { nextTask(thread, task); } Class loadedClass = task.getLoadedClass(); if (loadedClass == null) { Throwable loadException = task.getLoadException(); if (loadException instanceof ClassNotFoundException) throw (ClassNotFoundException) loadException; else if (loadException instanceof NoClassDefFoundError) throw (NoClassDefFoundError) loadException; else if (loadException != null) { log.warn("Unexpected error during load of:" + task.getClassName(), loadException); String msg = "Unexpected error during load of: "+ task.getClassName() + ", msg=" + loadException.getMessage(); throw new ClassNotFoundException(msg, loadException); } // Assert that loadedClass is not null else { throw new ClassNotFoundException("Failed to load class " + task.getClassName()); } } return loadedClass; } /** * Process the next task * * @param thread the thread * @param task the task */ private static void nextTask(Thread thread, ClassLoadingTask task) { boolean intr = Thread.interrupted(); try { boolean trace = log.isTraceEnabled(); if (trace) log.trace("Next task thread=" + thread + " task=" + task); List taskList = loadTasksByThread.get(thread); synchronized (taskList) { // There may not be any ThreadTasks while (taskList.isEmpty() && task.getThreadTaskCount() != 0 ) { /* There are no more tasks for the calling thread to execute, so the calling thread must wait until the task.threadTaskCount reaches 0 */ if (trace) log.trace("Begin nextTask(WAIT_ON_EVENT), task="+task); try { task.waitOnEvent(); taskList.wait(); if (trace) log.trace("nextTask(WAIT_ON_EVENT), notified, task="+task); } catch(InterruptedException e) { if( trace ) log.trace("nextTask(WAIT_ON_EVENT), interrupted, task="+task, e); intr = true; } } if (trace) log.trace("Continue nextTask(" + taskList.size()+"), task="+task); // See if the task is complete if (task.getThreadTaskCount() == 0) { task.finish(); log.trace("End nextTask(FINISHED), task="+task); return; } } ThreadTask threadTask = taskList.remove(0); ClassLoadingTask loadTask = threadTask.getLoadTask(); if (trace) log.trace("Begin nextTask(" + taskList.size() + "), loadTask=" + loadTask); try { Thread taskThread = threadTask.getThread(); if (taskThread == null) { /* This is a task that has been reassigned back to the original requesting thread ClassLoadingTask, so a new ThreadTask must be scheduled. */ if (trace) log.trace("Rescheduling threadTask=" + threadTask); scheduleTask(loadTask, threadTask.getLoader(), true); } else { if (trace) log.trace("Running threadTask=" + threadTask); threadTask.run(); } } catch (Throwable e) { if (trace) log.trace("Run failed with exception", e); boolean retry = e instanceof ClassCircularityError || e.getClass().equals(LinkageError.class); if (retry && loadTask.incrementNumCCE() < MAX_CCE) { /* Reschedule this task after all existing tasks to allow the current load tasks which are conflicting to complete. */ try { // Reschedule and update the loadTask.threadTaskCount scheduleTask(loadTask, threadTask.getLoader(), true); } catch (Throwable ex) { loadTask.setLoadError(ex); log.warn("Failed to reschedule task after CCE", ex); } if (trace) log.trace("Post CCE state, loadTask=" + loadTask); } else { loadTask.setLoadError(e); } } finally { // Release any lock on the classloader if (threadTask.isReleaseInNextTask()) threadTask.getClassLoader().unlock(false); } // If the ThreadTasks are complete mark the ClassLoadingTask finished if (loadTask.getThreadTaskCount() == 0) { List loadTaskThreadTasks = loadTasksByThread.get(loadTask.getRequestingThread()); synchronized (loadTaskThreadTasks) { if( trace ) log.trace("Notifying task of thread completion, loadTask:"+loadTask); task.finish(); loadTaskThreadTasks.notify(); } } if (trace) log.trace("End nextTask(" + taskList.size()+ "), loadTask=" + loadTask); } finally { if (intr) Thread.currentThread().interrupt(); } } /** * Invoked to create a ThreadTask to assign a thread to the task of * loading the class of ClassLoadingTask. * * @param task the classloading task * @param loader the loader * @param reschedule a boolean indicating if this task is being rescheduled with another classloader */ static void scheduleTask(ClassLoadingTask task, Loader loader, boolean reschedule) { boolean trace = log.isTraceEnabled(); if (trace) log.trace("ScheduleTask task=" + task + " loader=" + loader + " reschedule=" + reschedule); Thread thread; boolean releaseInNextTask = false; ThreadTask subtask; List taskList; BaseClassLoader classLoader = null; if (loader instanceof BaseDelegateLoader) { BaseDelegateLoader delegateLoader = (BaseDelegateLoader) loader; BaseClassLoaderPolicy policy = delegateLoader.getPolicy(); if (policy == null) throw new IllegalStateException("Null policy for " + delegateLoader); classLoader = policy.getClassLoader(); } synchronized (loadClassThreads) { // Find the thread that owns the classloader if (classLoader == null) { thread = task.getRequestingThread(); synchronized (loadTasksByThread) { List list = loadTasksByThread.get(thread); if (list == null) { list = Collections.synchronizedList(new LinkedList()); loadTasksByThread.put(thread, list); if (trace) log.trace("Created new task list for " + thread); } } } else { thread = loadClassThreads.get(classLoader); } if (thread == null) { boolean interrupted = Thread.interrupted(); int waits = 0; try { // No thread, try to get the lock ourselves while (thread == null) { try { boolean gotLock = classLoader.attemptLock(); if (gotLock == false) { // Two minutes should be long enough? if (waits++ == 12) throw new IllegalStateException("Waiting too long to get the registration lock for classLoader " + classLoader); // Wait 10 seconds if (trace) log.trace(classLoader + " waiting for lock"); loadClassThreads.wait(10000); } else { releaseInNextTask = true; } } catch (InterruptedException ignored) { interrupted = true; } thread = loadClassThreads.get(classLoader); } } finally { if (interrupted) Thread.currentThread().interrupt(); } } // Now that we have the owner thread, create and assign the task subtask = task.newThreadTask(loader, thread, reschedule, releaseInNextTask); // Add the task to the owning thread taskList = loadTasksByThread.get(thread); synchronized (taskList) { taskList.add(subtask); taskList.notify(); if (trace) log.trace("scheduleTask(" + taskList.size() + "), created subtask: " + subtask); } } } } ././@LongLink0000000000000000000000000000017400000000000011567 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloader/src/main/java/org/jboss/classloader/spi/base/BaseClassLoaderSource.javalibjboss-classloader-java-2.0.6.GA.orig/classloader/src/main/java/org/jboss/classloader/spi/base/Bas0000644000175000017500000000327311137575176033234 0ustar twernertwerner/* * JBoss, Home of Professional Open Source * Copyright 2007, JBoss Inc., and individual contributors as indicated * by the @authors tag. See the copyright.txt in the distribution for a * full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.classloader.spi.base; /** * BaseClassLoaderSource. * * @author Adrian Brock * @version $Revision: 1.1 $ */ public class BaseClassLoaderSource { /** The classloader */ private ClassLoader classLoader; /** * Create a new BaseClassLoaderSource. * * @param classLoader the classloader */ public BaseClassLoaderSource(ClassLoader classLoader) { if (classLoader == null) throw new IllegalArgumentException("Null classLoader"); this.classLoader = classLoader; } /** * Get the classloader * * @return the classloader */ protected ClassLoader getClassLoader() { return classLoader; } } ././@LongLink0000000000000000000000000000017300000000000011566 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloader/src/main/java/org/jboss/classloader/spi/base/BaseClassLoaderMBean.javalibjboss-classloader-java-2.0.6.GA.orig/classloader/src/main/java/org/jboss/classloader/spi/base/Bas0000644000175000017500000001046611042050234033210 0ustar twernertwerner/* * JBoss, Home of Professional Open Source. * Copyright 2007, Red Hat Middleware LLC, and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.classloader.spi.base; import java.io.IOException; import java.net.URL; import java.util.List; import java.util.Map; import java.util.Set; import javax.management.ObjectName; /** * BaseClassLoaderMBean. * * @author Adrian Brock * @version $Revision: 1.1 $ */ public interface BaseClassLoaderMBean { /** * Get the classloader domain * * @return the domain */ ObjectName getClassLoaderDomain(); /** * Get the name of the classloader * * @return the name */ String getName(); /** * Whether to import all exports from other classloaders in the domain * * @return true to import all */ boolean isImportAll(); /** * Whether to cache< * * @return true to cache */ boolean isCacheable(); /** * Whether to cache misses * * @return true to cache misses */ boolean isBlackListable(); /** * Whether the classloader is still valid * * @return true when still valid */ boolean isValid(); /** * Get the exported packages * * @return the exported packages */ Set listExportedPackages(); /** * Get the imports of this classloader * * @return the imports */ List listImports(); /** * Get the policy as a string * * @return the policy string */ String listPolicyDetails(); /** * Get the loaded classes * * @return the loaded classes */ Set listLoadedClasses(); /** * Get the loaded resource names * * @return the loaded resources names */ Set listLoadedResourceNames(); /** * Get the loaded resources * * @return the loaded resources */ Set listLoadedResources(); /** * Load a class * * @param name the class name * @return the class * @throws ClassNotFoundException when the class is not found */ Class loadClass(String name) throws ClassNotFoundException; /** * Get resources * * @param name the name of the resource * @return the resource urls * @throws IOException for any error */ Set loadResources(String name) throws IOException; /** * Find the classloader for a class * * @param name the class name * @return the classloader or null if it is not loaded by a managed classloader * @throws ClassNotFoundException when the class is not found */ ObjectName findClassLoaderForClass(String name) throws ClassNotFoundException; /** * Show the resource cache * * @return a map of resource name to urls */ Map listResourceCache(); /** * Show the resource blacklist * * @return a set of resource names */ Set listResourceBlackList(); /** * Get the number of resources black listed * * @return the size */ int getResourceBlackListSize(); /** * Get the number of resource cached * * @return the size */ int getResourceCacheSize(); /** * Clear the black list */ void clearBlackList(); /** * Clear an entry from the black list * * @param name the name of the entry to remove */ void clearBlackList(String name); } ././@LongLink0000000000000000000000000000016700000000000011571 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloader/src/main/java/org/jboss/classloader/spi/base/ClassLoadingTask.javalibjboss-classloader-java-2.0.6.GA.orig/classloader/src/main/java/org/jboss/classloader/spi/base/Cla0000644000175000017500000002770311147526661033226 0ustar twernertwerner/* * JBoss, Home of Professional Open Source. * Copyright 2007, Red Hat Middleware LLC, and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.classloader.spi.base; import java.io.PrintWriter; import java.io.StringWriter; import java.security.AccessController; import java.security.CodeSource; import java.security.PrivilegedAction; import java.security.ProtectionDomain; import org.jboss.classloader.plugins.ClassLoaderUtils; import org.jboss.classloader.spi.Loader; import org.jboss.logging.Logger; /** * ClassLoadingTask. * * @author Scott.Stark@jboss.org * @author Adrian Brock * @version $Revision: 1.1 $ */ class ClassLoadingTask { /** The log */ protected static Logger log = Logger.getLogger("org.jboss.detailed.classloader.ClassLoadingTask"); /** * TaskState. */ enum TaskState { /** Found the classloader */ FOUND_CLASS_LOADER, /** Next event */ NEXT_EVENT, /** Waiting on event */ WAIT_EVENT, /** Finished */ FINISHED, } /** The class name */ private String className; /** The reques thread */ private Thread requestingThread; /** The requesting classloader */ private ClassLoader classLoader; /** The loaded class */ private Class loadedClass; /** The error during the load */ private Throwable loadException; /** The number of ThreadTasks remaining */ private int threadTaskCount; /** The state of the requestingThread */ private TaskState state; /** The Logger trace level flag */ private boolean trace = log.isTraceEnabled(); /** The number of class circularity errors */ private int numCCE; /** * Create a new ClassLoadingTask. * * @param className the class name * @param classLoader the requesting the classloader * @param requestingThread the requesting thread */ ClassLoadingTask(String className, ClassLoader classLoader, Thread requestingThread) { this.className = className; this.requestingThread = requestingThread; this.classLoader = classLoader; } /** * Get the className. * * @return the className. */ String getClassName() { return className; } /** * Get the loadedClass. * * @return the loadedClass. */ synchronized Class getLoadedClass() { return loadedClass; } /** * Get the loadException. * * @return the loadException. */ synchronized Throwable getLoadException() { return loadException; } /** * Get the numCCE. * * @return the numCCE. */ synchronized int incrementNumCCE() { return numCCE; } /** * Get the requestingThread. * * @return the requestingThread. */ Thread getRequestingThread() { return requestingThread; } /** * Get the state. * * @return the state. */ synchronized TaskState getState() { return state; } /** * Set the task into the finished state * * @param loadedClass the loaded class */ synchronized void finish(Class loadedClass) { this.loadedClass = loadedClass; state = TaskState.FINISHED; } /** * Set the task into the found classloader state */ synchronized void foundClassLoader() { state = TaskState.FOUND_CLASS_LOADER; } /** * Set the task into the finished state */ synchronized void finish() { state = TaskState.FINISHED; } /** * Set the task into the wait on event state */ synchronized void waitOnEvent() { state = TaskState.WAIT_EVENT; } /** * Set the task into the next event state */ synchronized void nextEvent() { state = TaskState.NEXT_EVENT; } /** * Get the threadTaskCount. * * @return the threadTaskCount. */ synchronized int getThreadTaskCount() { return threadTaskCount; } @Override public String toString() { StringBuilder builder = new StringBuilder(); builder.append(getClass().getSimpleName()); builder.append('@').append(Integer.toHexString(System.identityHashCode(this))); builder.append('{'); builder.append("className=").append(className); builder.append(" requestingThread=").append(requestingThread); builder.append(" requestingClassLoader: ").append(classLoader); if (loadedClass != null) { builder.append(" loadedClass="); ClassLoaderUtils.classToString(loadedClass, builder); } if (loadException != null) builder.append(" loadException: ").append(loadException); builder.append(" threadTaskCount: ").append(threadTaskCount); builder.append(" state: ").append(state); if (numCCE > 0) builder.append(", #CCE: ").append(numCCE); builder.append('}'); if( trace && loadException != null ) { StringWriter sw = new StringWriter(); PrintWriter pw = new PrintWriter(sw); loadException.printStackTrace(pw); builder.append("loadException details:\n"); builder.append(sw.toString()); } return builder.toString(); } /** * Creaqte a new thread task * * @param loader the loader * @param thread the thread * @param reschedule whether this is a reschedule * @param releaseInNextTask whether to release in the next task * @return the thread task */ synchronized ThreadTask newThreadTask(Loader loader, Thread thread, boolean reschedule, boolean releaseInNextTask) { // Only update the threadTaskCount if this is not a reschedule if (reschedule == false) ++threadTaskCount; return new ThreadTask(loader, thread, releaseInNextTask); } /** * Set the load exception * * @param t the throwable */ synchronized void setLoadError(Throwable t) { --threadTaskCount; if (trace) log.trace("setLoadedError, error="+t); loadException = t; } /** * This is called from run on success or failure to mark the end * of the load attempt. This must decrement the threadTaskCount or * the ClassLoadingTask will never complete. * * @param theClass the loaded class */ private synchronized void setLoadedClass(Class theClass) { --threadTaskCount; if (trace) log.trace("setLoadedClass, theClass=" + theClass); // Warn about duplicate classes if (this.loadedClass != null && theClass != null) { StringBuilder builder = new StringBuilder(); builder.append("Duplicate class found: ").append(className).append('\n'); ProtectionDomain pd = getProtectionDomain(loadedClass); CodeSource cs = pd != null ? pd.getCodeSource() : null; builder.append("Current CS: ").append(cs).append('\n'); pd = getProtectionDomain(theClass); cs = pd != null ? pd.getCodeSource() : null; builder.append("Duplicate CS: ").append(cs); log.warn(builder.toString()); } // Accept the first class if (theClass != null && loadedClass == null) this.loadedClass = theClass; } /** * Thread Task */ class ThreadTask { /** The loader */ private Loader loader; /** The thread that owns the ucl monitor */ private Thread thread; /** Whether to release in the next task */ private boolean releaseInNextTask; /** * Create a new ThreadTask. * * @param loader the loader * @param thread the thread * @param releaseInNextTask whether to release in the next task */ ThreadTask(Loader loader, Thread thread, boolean releaseInNextTask) { this.loader = loader; this.thread = thread; this.releaseInNextTask = releaseInNextTask; } /** * Get the className. * * @return the className. */ String getClassName() { return className; } /** * Get the loadedClass. * * @return the loadedClass. */ Class getLoadedClass() { return loadedClass; } @Override public String toString() { StringBuilder builder = new StringBuilder(); builder.append("{thread=").append(thread); builder.append(" loader=").append(loader); builder.append(" requestingThread=").append(requestingThread); builder.append(" releaseInNextTask=").append(releaseInNextTask); builder.append("}"); return builder.toString(); } /** * Get the classloading task * * @return the classloading task */ ClassLoadingTask getLoadTask() { return ClassLoadingTask.this; } /** * Get the loader. * * @return the loader. */ Loader getLoader() { return loader; } /** * Get the classloader for this task * * @return the classloader */ BaseClassLoader getClassLoader() { if (loader instanceof BaseDelegateLoader) { BaseDelegateLoader delegateLoader = (BaseDelegateLoader) loader; BaseClassLoaderPolicy policy = delegateLoader.getPolicy(); if (policy == null) throw new IllegalStateException("Null classloader policy for " + loader); return policy.getClassLoader(); } return null; } /** * Get the thread. * * @return the thread. */ synchronized Thread getThread() { return thread; } /** * Set the thread. * * @param thread the thread. */ synchronized void setThread(Thread thread) { this.thread = thread; } /** * Get the releaseInNextTask. * * @return the releaseInNextTask. */ boolean isReleaseInNextTask() { return releaseInNextTask; } /** * Run the class load * * @throws ClassNotFoundException */ void run() throws ClassNotFoundException { if (loadedClass == null) { Class theClass = loader.loadClass(className); setLoadedClass(theClass); } else if (trace) { log.trace("Already found class(" + loadedClass + "), skipping load class"); } } } /** * Get the protection domain for a class * * @param clazz the class * @return the protected domain or null if it doesn't have one */ private static final ProtectionDomain getProtectionDomain(final Class clazz) { SecurityManager sm = System.getSecurityManager(); if (sm == null) return clazz.getProtectionDomain(); return AccessController.doPrivileged(new PrivilegedAction() { public ProtectionDomain run() { return clazz.getProtectionDomain(); } }); } } ././@LongLink0000000000000000000000000000017100000000000011564 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloader/src/main/java/org/jboss/classloader/spi/base/BaseDelegateLoader.javalibjboss-classloader-java-2.0.6.GA.orig/classloader/src/main/java/org/jboss/classloader/spi/base/Bas0000644000175000017500000001446011042050234033206 0ustar twernertwerner/* * JBoss, Home of Professional Open Source. * Copyright 2007, Red Hat Middleware LLC, and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.classloader.spi.base; import java.io.IOException; import java.net.URL; import java.util.Set; import org.jboss.classloader.spi.ClassLoaderPolicy; import org.jboss.classloader.spi.ClassLoaderPolicyFactory; import org.jboss.classloader.spi.Loader; import org.jboss.logging.Logger; /** * Base DelegateLoader. * * @author Adrian Brock * @version $Revision: 1.1 $ */ public class BaseDelegateLoader implements Loader { /** The log */ private static final Logger log = Logger.getLogger(BaseDelegateLoader.class); /** The delegate loader policy */ private volatile BaseClassLoaderPolicy delegate; /** The policy factory */ private ClassLoaderPolicyFactory factory; /** * Create a new BaseDelegateLoader. * * @param delegate the delegate * @throws IllegalArgumentException for a null delegate */ public BaseDelegateLoader(BaseClassLoaderPolicy delegate) { if (delegate == null) throw new IllegalArgumentException("Null delegate"); this.delegate = delegate; } /** * Create a new BaseDelegateLoader. * * @param factory the factory * @throws IllegalArgumentException for a null factory */ public BaseDelegateLoader(ClassLoaderPolicyFactory factory) { if (factory == null) throw new IllegalArgumentException("Null factory"); this.factory = factory; } BaseClassLoaderPolicy getPolicy() { BaseClassLoaderPolicy delegate = this.delegate; if (delegate == null) { try { delegate = factory.createClassLoaderPolicy(); if (delegate == null) { log.trace("Factory did not create a delegate: " + factory); } else { ClassLoaderPolicy policy = (ClassLoaderPolicy) delegate; initialise(policy); this.delegate = delegate; } } catch (Throwable t) { log.warn("Unexpected error creating policy from factory: " + factory, t); } } return delegate; } /** * Callback to initialise policy * * @param policy the policy */ protected void initialise(ClassLoaderPolicy policy) { // Nothing by default } BaseClassLoader getBaseClassLoader(String message, String context) { BaseClassLoader result = null; try { BaseClassLoaderPolicy policy = getPolicy(); if (policy != null) result = policy.getClassLoader(); } catch (IllegalStateException ignored) { } if (result == null) log.warn("Not " + message + context + " from policy that has no classLoader: " + toLongString()); return result; } public Class loadClass(String className) { BaseClassLoader classLoader = getBaseClassLoader("loading class ", className); if (classLoader != null) return classLoader.loadClassLocally(className); return null; } public URL getResource(String name) { BaseClassLoader classLoader = getBaseClassLoader("getting resource ", name); if (classLoader != null) return classLoader.getResourceLocally(name); return null; } public void getResources(String name, Set urls) throws IOException { BaseClassLoader classLoader = getBaseClassLoader("getting resources ", name); if (classLoader != null) classLoader.getResourcesLocally(name, urls); } public Package getPackage(String name) { BaseClassLoader classLoader = getBaseClassLoader("getting package ", name); if (classLoader != null) return classLoader.getPackageLocally(name); return null; } public void getPackages(Set packages) { BaseClassLoader classLoader; try { classLoader = delegate.getClassLoader(); } catch (IllegalStateException e) { log.warn("Not getting packages from policy that has no classLoader: " + toLongString()); return; } classLoader.getPackagesLocally(packages); } /** * A long version of toString() * * @return the long string */ public String toLongString() { StringBuilder builder = new StringBuilder(); builder.append(getClass().getSimpleName()); builder.append("@").append(Integer.toHexString(System.identityHashCode(this))); if (delegate != null) builder.append("{delegate=").append(delegate.toLongString()); else builder.append("{factory=").append(factory); toLongString(builder); builder.append('}'); return builder.toString(); } /** * For subclasses to add information for toLongString() * * @param builder the builder */ protected void toLongString(StringBuilder builder) { } @Override public String toString() { StringBuilder builder = new StringBuilder(); builder.append(getClass().getSimpleName()); builder.append("@").append(Integer.toHexString(System.identityHashCode(this))); if (delegate != null) builder.append("{delegate=").append(delegate); else builder.append("{factory=").append(factory); builder.append('}'); return builder.toString(); } } ././@LongLink0000000000000000000000000000017200000000000011565 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloader/src/main/java/org/jboss/classloader/spi/ClassLoaderPolicyFactory.javalibjboss-classloader-java-2.0.6.GA.orig/classloader/src/main/java/org/jboss/classloader/spi/ClassLoa0000644000175000017500000000247510761270232033304 0ustar twernertwerner/* * JBoss, Home of Professional Open Source * Copyright 2008, JBoss Inc., and individual contributors as indicated * by the @authors tag. See the copyright.txt in the distribution for a * full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.classloader.spi; /** * ClassLoaderPolicyFactory. * * @author Adrian Brock * @version $Revision: 1.1 $ */ public interface ClassLoaderPolicyFactory { /** * Create a classloader policy * * @return the classloader policy */ ClassLoaderPolicy createClassLoaderPolicy(); } ././@LongLink0000000000000000000000000000016300000000000011565 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloader/src/main/java/org/jboss/classloader/spi/ClassLoaderSystem.javalibjboss-classloader-java-2.0.6.GA.orig/classloader/src/main/java/org/jboss/classloader/spi/ClassLoa0000644000175000017500000005446411173151646033316 0ustar twernertwerner/* * JBoss, Home of Professional Open Source. * Copyright 2007, Red Hat Middleware LLC, and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.classloader.spi; import java.security.ProtectionDomain; import java.util.ArrayList; import java.util.HashMap; import java.util.HashSet; import java.util.Hashtable; import java.util.Iterator; import java.util.List; import java.util.Map; import java.util.Set; import java.util.Collections; import javax.management.MBeanRegistration; import javax.management.MBeanServer; import javax.management.MalformedObjectNameException; import javax.management.ObjectName; import org.jboss.classloader.plugins.system.ClassLoaderSystemBuilder; import org.jboss.classloader.spi.base.BaseClassLoaderSystem; import org.jboss.classloader.spi.translator.TranslatorUtils; import org.jboss.logging.Logger; import org.jboss.util.loading.Translator; /** * ClassLoaderSystem. * * @author Adrian Brock * @author Ales Justin * @version $Revision: 1.1 $ */ public abstract class ClassLoaderSystem extends BaseClassLoaderSystem implements ClassLoaderSystemMBean, MBeanRegistration { /** The log */ private static final Logger log = Logger.getLogger(ClassLoaderSystem.class); /** The name of the default domain */ public static final String DEFAULT_DOMAIN_NAME = "DefaultDomain"; /** The class loading system builder */ private static final ClassLoaderSystemBuilder builder = new ClassLoaderSystemBuilder(); /** The default domain */ private ClassLoaderDomain defaultDomain; /** The registered domains by name */ private Map registeredDomains = new HashMap(); /** Any translators */ private List translators; /** Whether the system is shutdown */ private boolean shutdown = false; /** The MBeanServer */ private MBeanServer mbeanServer; /** The object name */ private ObjectName objectName; /** * Get the classloading system instance * * @return the instance * @throws SecurityException if the caller does not have authority to create a classloader */ public static final ClassLoaderSystem getInstance() { SecurityManager sm = System.getSecurityManager(); if (sm != null) sm.checkCreateClassLoader(); return builder.get(); } /** * Get the default classloading domain * * @return the default domain */ public synchronized ClassLoaderDomain getDefaultDomain() { if (shutdown) throw new IllegalStateException("The classloader system is shutdown: " + toLongString()); // Already constructed if (defaultDomain != null) return defaultDomain; // See if explicitly registered defaultDomain = registeredDomains.get(DEFAULT_DOMAIN_NAME); if (defaultDomain != null) return defaultDomain; // Create it defaultDomain = createDefaultDomain(); // Register it internalRegisterDomain(DEFAULT_DOMAIN_NAME, defaultDomain); return defaultDomain; } /** * Create the default domain

* * By default this just invokes {@link #createDomain(String)} with {@link #DEFAULT_DOMAIN_NAME} * * @return the default domain */ protected ClassLoaderDomain createDefaultDomain() { return createDomain(DEFAULT_DOMAIN_NAME); } /** * Create a domain * * @param name the name of the domain * @return the domain * @throws IllegalArgumentException for a null name */ protected abstract ClassLoaderDomain createDomain(String name); /** * Create and register a domain * * @param name the name of the domain * @return the domain * @throws IllegalArgumentException for a null name * @throws IllegalStateException if there already is a domain with that name */ public ClassLoaderDomain createAndRegisterDomain(String name) { return createAndRegisterDomain(name, ParentPolicy.BEFORE, null); } /** * Create and register a domain with the given parent classloading policy * * @param name the name of the domain * @param parentPolicy the parent classloading policy * @return the domain * @throws IllegalArgumentException for a null name or policy * @throws IllegalStateException if there already is a domain with that name */ public ClassLoaderDomain createAndRegisterDomain(String name, ParentPolicy parentPolicy) { return createAndRegisterDomain(name, parentPolicy, null); } /** * Create and register a domain with the given parent classloading policy * * @param name the name of the domain * @param parentPolicy the parent classloading policy * @param parent the parent * @return the domain * @throws IllegalArgumentException for a null argument * @throws IllegalStateException if there already is a domain with that name */ public ClassLoaderDomain createAndRegisterDomain(String name, ParentPolicy parentPolicy, Loader parent) { ClassLoaderDomain result = createDomain(name); result.setParentPolicy(parentPolicy); result.setParent(parent); registerDomain(result); return result; } /** * Get a domain * * @param name the domain name * @return the domain * @throws IllegalArgumentException for a null name */ public synchronized ClassLoaderDomain getDomain(String name) { if (name == null) throw new IllegalArgumentException("Null name"); if (shutdown) throw new IllegalStateException("The classloader system is shutdown: " + toLongString()); ClassLoaderDomain result = registeredDomains.get(name); // See whether this is the default domain if (result == null && DEFAULT_DOMAIN_NAME.equals(name)) result = getDefaultDomain(); return result; } /** * Is a domain name registered * * @param name the domain name * @return true when the domain is registered * @throws IllegalArgumentException for a null name */ public boolean isRegistered(String name) { return getDomain(name) != null; } /** * Is a domain registered * * @param domain the domain * @return true when the domain is registered * @throws IllegalArgumentException for a null domain */ public boolean isDomainRegistered(ClassLoaderDomain domain) { if (domain == null) throw new IllegalArgumentException("Null domain"); return getDomain(domain.getName()) == domain; } /** * Register a domain * * @param domain the domain * @throws IllegalArgumentException for a null domain * @throws IllegalStateException if a domain is already registered with this name */ public synchronized void registerDomain(ClassLoaderDomain domain) { if (domain == null) throw new IllegalArgumentException("Null domain"); String name = domain.getName(); if (isRegistered(name)) throw new IllegalStateException("A domain is already registered with name " + name); internalRegisterDomain(name, domain); } /** * Do the registration * * @param name the name * @param domain the domain */ private void internalRegisterDomain(String name, ClassLoaderDomain domain) { if (shutdown) throw new IllegalStateException("The classloader system is shutdown: " + toLongString()); registeredDomains.put(name, domain); super.registerDomain(domain); registerDomainMBean(domain); log.debug(this + " registered domain=" + domain.toLongString()); } /** * Unregister a domain * * @param domain the domain * @throws IllegalArgumentException for a null domain or if you attempt to unregister the default domain * @throws IllegalStateException if a domain is not registered */ public synchronized void unregisterDomain(ClassLoaderDomain domain) { if (isDomainRegistered(domain) == false) throw new IllegalStateException("Domain is not registered " + domain); if (DEFAULT_DOMAIN_NAME.equals(domain.getName())) throw new IllegalArgumentException("Cannot unregister the default domain"); internalUnregisterDomain(domain); } /** * Unregister a domain * * @param domain the domain * @throws IllegalArgumentException for a null domain or if you attempt to unregister the default domain * @throws IllegalStateException if a domain is not registered */ private synchronized void internalUnregisterDomain(ClassLoaderDomain domain) { unregisterDomainMBean(domain); registeredDomains.remove(domain.getName()); super.unregisterDomain(domain); log.debug(this + " unregistered domain=" + domain.toLongString()); } /** * Register a policy with the default domain

* * Equivalent to {@link #registerClassLoaderPolicy(ClassLoaderDomain, ClassLoaderPolicy)} using * {@link #getDefaultDomain()} as the ClassLoaderDomain * * @param policy the policy * @return the classloader * @throws IllegalArgumentException if a parameter is null * @throws IllegalStateException if the policy is already registered with a domain */ public ClassLoader registerClassLoaderPolicy(ClassLoaderPolicy policy) { return registerClassLoaderPolicy(getDefaultDomain(), policy); } /** * Register a classloader policy, possibly constructing the domain with a BEFORE parent policy * * @param domainName the domain name * @param policy the classloader policy * @return the policy * @throws IllegalArgumentException for a null parameter */ public ClassLoader registerClassLoaderPolicy(String domainName, ClassLoaderPolicy policy) { return registerClassLoaderPolicy(domainName, ParentPolicy.BEFORE, (Loader) null, policy); } /** * Register a classloader policy, possibly constructing the domain * * @param domainName the domain name * @param parentPolicy the parent policy * @param policy the classloader policy * @return the policy * @throws IllegalArgumentException for a null parameter */ public ClassLoader registerClassLoaderPolicy(String domainName, ParentPolicy parentPolicy, ClassLoaderPolicy policy) { return registerClassLoaderPolicy(domainName, parentPolicy, (Loader) null, policy); } /** * Register a classloader policy, possibly constructing the domain * * @param domainName the domain name * @param parentPolicy the parent policy * @param parentDomainName the parent domain (can be null) * @param policy the classloader policy * @return the policy * @throws IllegalArgumentException for a null parameter * @throws IllegalStateException if the parent domain does not exist */ public ClassLoader registerClassLoaderPolicy(String domainName, ParentPolicy parentPolicy, String parentDomainName, ClassLoaderPolicy policy) { if (domainName == null) throw new IllegalArgumentException("Null domain name"); if (parentPolicy == null) throw new IllegalArgumentException("Null parent policy"); if (policy == null) throw new IllegalArgumentException("Null classloader policy"); ClassLoaderDomain domain; synchronized (this) { // See whether the domain already exists domain = getDomain(domainName); if (domain == null) { if (parentDomainName != null) { // See whether the parent domain exists ClassLoaderDomain parentDomain = getDomain(parentDomainName); if (parentDomain == null) throw new IllegalStateException("Parent domain: " + parentDomainName + " does not exist."); // Create the domain with a parent domain = createAndRegisterDomain(domainName, parentPolicy, parentDomain); } else { // Create a domain without a parent domain = createAndRegisterDomain(domainName, parentPolicy); } } } // Register the classloader policy in the domain return registerClassLoaderPolicy(domain, policy); } /** * Register a classloader policy, possibly constructing the domain * * @param domainName the domain name * @param parentPolicy the parent policy * @param parent the parent * @param policy the classloader policy * @return the policy * @throws IllegalArgumentException for a null parameter * @throws IllegalStateException if the parent domain does not exist */ public ClassLoader registerClassLoaderPolicy(String domainName, ParentPolicy parentPolicy, Loader parent, ClassLoaderPolicy policy) { if (domainName == null) throw new IllegalArgumentException("Null domain name"); if (parentPolicy == null) throw new IllegalArgumentException("Null parent policy"); if (policy == null) throw new IllegalArgumentException("Null classloader policy"); ClassLoaderDomain domain; synchronized (this) { // See whether the domain already exists domain = getDomain(domainName); if (domain == null) { // Create a domain without a parent domain = createAndRegisterDomain(domainName, parentPolicy, parent); } } // Register the classloader policy in the domain return registerClassLoaderPolicy(domain, policy); } /** * Register a policy with a domain * * @param domain the domain * @param policy the policy * @return the classloader * @throws IllegalArgumentException if a parameter is null * @throws IllegalStateException if the domain is not registered or if the policy is already registered with a domain */ public ClassLoader registerClassLoaderPolicy(ClassLoaderDomain domain, ClassLoaderPolicy policy) { if (isDomainRegistered(domain) == false) throw new IllegalStateException("Domain is not registered: " + domain); synchronized (this) { if (shutdown) throw new IllegalStateException("The classloader system is shutdown: " + toLongString()); } return super.registerClassLoaderPolicy(domain, policy); } /** * Unregister a policy from its domain * * @param policy the policy * @throws IllegalArgumentException if a parameter is null * @throws IllegalStateException if the policy is not registered with the default domain */ public void unregisterClassLoaderPolicy(ClassLoaderPolicy policy) { super.unregisterClassLoaderPolicy(policy); } /** * Unregister a classloader from its domain * * @param classLoader classLoader * @throws IllegalArgumentException if a parameter is null * @throws IllegalStateException if the policy is not registered with the default domain */ public void unregisterClassLoader(ClassLoader classLoader) { super.unregisterClassLoader(classLoader); } /** * Shutdown the classloader system

* * Unregisters all domains by default */ public synchronized void shutdown() { if (shutdown) return; log.debug(toLongString() + " SHUTDOWN!"); shutdown = true; while (true) { List domains = new ArrayList(registeredDomains.values()); Iterator iterator = domains.iterator(); if (iterator.hasNext() == false) break; while (iterator.hasNext()) { ClassLoaderDomain domain = iterator.next(); internalUnregisterDomain(domain); } } } /** * Get the translator. * * @return the translator. * @deprecated use translator list */ @Deprecated public Translator getTranslator() { if (translators == null || translators.isEmpty()) return null; return translators.get(0); } /** * Set the translator. * * @param translator the translator. * @deprecated use translator list */ @Deprecated public void setTranslator(Translator translator) { log.debug(this + " set translator to " + translator); if (translator != null) translators = Collections.singletonList(translator); else translators = null; } @Override protected byte[] transform(ClassLoader classLoader, String className, byte[] byteCode, ProtectionDomain protectionDomain) throws Exception { byte[] result = TranslatorUtils.applyTranslatorsOnTransform(translators, classLoader, className, byteCode, protectionDomain); return super.transform(classLoader, className, result, protectionDomain); } @Override protected void afterUnregisterClassLoader(ClassLoader classLoader) { try { TranslatorUtils.applyTranslatorsAtUnregister(translators, classLoader); } catch (Throwable t) { log.warn("Error unregistering classloader from translator " + classLoader, t); } } /** * Get the object name * * @return the object name */ public ObjectName getObjectName() { return objectName; } public ObjectName preRegister(MBeanServer server, ObjectName name) throws Exception { this.mbeanServer = server; this.objectName = name; return name; } public void postRegister(Boolean registrationDone) { if (registrationDone) { for (ClassLoaderDomain domain : registeredDomains.values()) registerDomainMBean(domain); } else { postDeregister(); } } public void preDeregister() throws Exception { for (ClassLoaderDomain domain : registeredDomains.values()) unregisterDomainMBean(domain); } public void postDeregister() { this.mbeanServer = null; this.objectName = null; } public Set getDomainNames() { return registeredDomains.keySet(); } public Set getDomains() { Set names = new HashSet(); for (ClassLoaderDomain domain : registeredDomains.values()) names.add(domain.getObjectName()); return names; } /** * Get an object name for the domain * * @param domain the domain * @return the object name */ protected ObjectName getObjectName(ClassLoaderDomain domain) { if (domain == null) throw new IllegalArgumentException("Null domain"); Hashtable properties = new Hashtable(); properties.put("domain", "\"" + domain.getName() + "\""); properties.put("system", "" + System.identityHashCode(this)); try { return ObjectName.getInstance("jboss.classloader", properties); } catch (MalformedObjectNameException e) { throw new RuntimeException("Unexpected error", e); } } /** * Register a domain with the MBeanServer * * @param domain the domain */ protected void registerDomainMBean(ClassLoaderDomain domain) { if (mbeanServer == null) return; try { ObjectName name = getObjectName(domain); mbeanServer.registerMBean(domain, name); } catch (Exception e) { log.warn("Error registering domain: " + domain, e); } } /** * Unregister a domain from the MBeanServer * * @param domain the domain */ protected void unregisterDomainMBean(ClassLoaderDomain domain) { if (mbeanServer == null) return; try { ObjectName name = getObjectName(domain); mbeanServer.unregisterMBean(name); } catch (Exception e) { log.warn("Error unregistering domain: " + domain, e); } } @Override protected void toLongString(StringBuilder builder) { if (shutdown) builder.append("SHUTDOWN! "); super.toLongString(builder); } /** * Get the policy's translators. * * @return the translators */ public List getTranslators() { if (translators == null || translators.isEmpty()) return Collections.emptyList(); else return Collections.unmodifiableList(translators); } /** * Set the translators. * * @param translators the translators */ public synchronized void setTranslators(List translators) { this.translators = translators; } /** * Add the translator. * * @param translator the translator to add * @throws IllegalArgumentException for null translator */ public synchronized void addTranslator(Translator translator) { if (translator == null) throw new IllegalArgumentException("Null translator"); if (translators == null) translators = new ArrayList(); translators.add(translator); } /** * Remove the translator. * * @param translator the translator to remove * @throws IllegalArgumentException for null translator */ public synchronized void removeTranslator(Translator translator) { if (translator == null) throw new IllegalArgumentException("Null translator"); if (translators != null) translators.remove(translator); } } ././@LongLink0000000000000000000000000000015000000000000011561 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloader/src/main/java/org/jboss/classloader/spi/translator/libjboss-classloader-java-2.0.6.GA.orig/classloader/src/main/java/org/jboss/classloader/spi/translat0000755000175000017500000000000011620043423033414 5ustar twernertwerner././@LongLink0000000000000000000000000000021400000000000011562 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloader/src/main/java/org/jboss/classloader/spi/translator/ClassFileTransformer2Translator.javalibjboss-classloader-java-2.0.6.GA.orig/classloader/src/main/java/org/jboss/classloader/spi/translat0000644000175000017500000000404511173151646033433 0ustar twernertwerner/* * JBoss, Home of Professional Open Source. * Copyright 2008, Red Hat Middleware LLC, and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.classloader.spi.translator; import java.lang.instrument.ClassFileTransformer; import java.security.ProtectionDomain; import org.jboss.util.loading.Translator; /** * ClassFileTransfomer to Translator bridge. * * @author Ales Justin */ public class ClassFileTransformer2Translator implements Translator { private ClassFileTransformer transformer; public ClassFileTransformer2Translator(ClassFileTransformer transformer) { if (transformer == null) throw new IllegalArgumentException("Null transformer"); this.transformer = transformer; } public byte[] transform(ClassLoader loader, String className, Class classBeingRedefined, ProtectionDomain protectionDomain, byte[] classfileBuffer) throws Exception { return transformer.transform(loader, className, classBeingRedefined, protectionDomain, classfileBuffer); } public void unregisterClassLoader(ClassLoader loader) { } }././@LongLink0000000000000000000000000000017400000000000011567 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloader/src/main/java/org/jboss/classloader/spi/translator/TranslatorUtils.javalibjboss-classloader-java-2.0.6.GA.orig/classloader/src/main/java/org/jboss/classloader/spi/translat0000644000175000017500000000742011173151646033433 0ustar twernertwerner/* * JBoss, Home of Professional Open Source. * Copyright 2008, Red Hat Middleware LLC, and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.classloader.spi.translator; import java.security.ProtectionDomain; import java.util.List; import java.util.ListIterator; import org.jboss.logging.Logger; import org.jboss.util.loading.Translator; /** * The translator utils/helper. * * @author Ales Justin */ public class TranslatorUtils { /** The log */ private static final Logger log = Logger.getLogger(TranslatorUtils.class); /** * Apply transformers on transform. * * @param translators the translators * @param classLoader the classloader * @param className the class name * @param byteCode the byte code * @param protectionDomain the protection domain * @return trabsformed bytes * @throws Exception for any error */ public static byte[] applyTranslatorsOnTransform(List translators, ClassLoader classLoader, String className, byte[] byteCode, ProtectionDomain protectionDomain) throws Exception { if (translators == null || translators.isEmpty()) return byteCode; boolean trace = log.isTraceEnabled(); byte[] result = byteCode; for (Translator translator : translators) { // sanity check if (translator == null) { if (trace) log.trace("Null translator, classLoader: " + classLoader + ", className: " + className); continue; } result = translator.transform(classLoader, className, null, protectionDomain, result); } return result; } /** * Apply translators on classloader unregister / policy shutdown. * * @param translators the translators * @param classLoader the policy's classloader */ public static void applyTranslatorsAtUnregister(List translators, ClassLoader classLoader) { if (translators != null && translators.isEmpty() == false) { boolean trace = log.isTraceEnabled(); // go in reverse order ListIterator iter = translators.listIterator(translators.size() - 1); while(iter.hasPrevious()) { Translator translator = iter.previous(); // sanity check if (translator == null) { if (trace) log.trace("Null translator, classLoader: " + classLoader); continue; } try { translator.unregisterClassLoader(classLoader); } catch (Exception e) { log.warn("Exception for translator " + translator + " on CL unregister: " + e); } } } } } libjboss-classloader-java-2.0.6.GA.orig/classloader/.settings/0000755000175000017500000000000011620043423024127 5ustar twernertwernerlibjboss-classloader-java-2.0.6.GA.orig/classloader/.settings/org.eclipse.jdt.core.prefs0000644000175000017500000000032010674774740031131 0ustar twernertwerner#Fri Sep 21 17:50:00 BST 2007 org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5 eclipse.preferences.version=1 org.eclipse.jdt.core.compiler.source=1.5 org.eclipse.jdt.core.compiler.compliance=1.5 libjboss-classloader-java-2.0.6.GA.orig/classloader/.project0000644000175000017500000000050611015015610023654 0ustar twernertwerner jboss-classloader JBoss ClassLoader org.eclipse.jdt.core.javabuilder org.eclipse.jdt.core.javanature libjboss-classloader-java-2.0.6.GA.orig/pom.xml0000644000175000017500000002446111202514647021250 0ustar twernertwerner 4.0.0 org.jboss jboss-parent 4 org.jboss.cl jboss-cl 2.0.6.GA pom JBoss ClassLoader Parent POM http://www.jboss.com/products/jbossmc JBoss ClassLoader scm:svn:http://anonsvn.jboss.org/repos/jbossas/projects/jboss-cl/tags/2.0.6.GA scm:svn:https://svn.jboss.org/repos/jbossas/projects/jboss-cl/tags/2.0.6.GA http://viewvc.jboss.org/cgi-bin/viewvc.cgi/jbossas/projects/jboss-cl/tags/2.0.6.GA classloader classloading classloading-vfs build 2.1.2.GA 2.1.0.CR8 2.0.6.GA 2.2.13.GA 2.0.5.GA 5.0.3.GA 2.0.1.GA 1.1.1.GA 4.4 3.10.0.GA ${microcontainer.outputDirectory} ${microcontainer.testOutputDirectory} ${artifactId} org.apache.maven.plugins maven-compiler-plugin 2.0.2 1.5 1.5 true true true org.apache.maven.plugins maven-release-plugin 2.0-beta-9 false https://svn.jboss.org/repos/jbossas/projects/jboss-cl/tags true maven-idea-plugin true org.apache.maven.plugins maven-jar-plugin 2.2 org.apache.maven.plugins maven-surefire-plugin 2.4.3 true org/jboss/test/**/*TestCase.java org.apache.maven.plugins maven-javadoc-plugin net.gleamynode.apiviz.APIviz net.gleamynode.apiviz apiviz 1.1.0 UTF-8 repository.jboss.org JBoss Repository default http://repository.jboss.org/maven2/ false snapshots.jboss.org JBoss Snapshots Repository default http://snapshots.jboss.org/maven2/ true false apiviz.release APIviz releases http://apiviz.googlecode.com/svn/site/repo/mvn/release true false org.apache.maven.plugins maven-project-info-reports-plugin dependencies issue-tracking license scm org.codehaus.mojo findbugs-maven-plugin 1.0.0 org.jboss.cl jboss-classloader ${project.version} org.jboss.cl jboss-classloading ${project.version} org.jboss.cl jboss-classloading-vfs ${project.version} org.jboss.man jboss-managed ${version.jboss.man} org.jboss.microcontainer jboss-dependency ${version.jboss.microcontainer} org.jboss.microcontainer jboss-kernel ${version.jboss.microcontainer} org.jboss jboss-common-core ${version.jboss.common.core} org.jboss.logging jboss-logging-spi ${version.jboss.logging.spi} org.jboss.integration jboss-classloading-spi ${version.jboss.classloading.spi} org.jboss jbossxb ${version.jbossxb} org.jboss jboss-vfs ${version.jboss.vfs} org.jboss.test jboss-test ${version.org.jboss.test} test junit junit ${version.junit} test javassist javassist ${version.javassist} test default true target/classes target/tests-classes eclipse process-test-resources maven-eclipse-plugin eclipse process-test-resources eclipse true ${microcontainer.outputDirectory} eclipse-target/classes eclipse-target/tests-classes libjboss-classloader-java-2.0.6.GA.orig/classloading/0000755000175000017500000000000011620043421022356 5ustar twernertwernerlibjboss-classloader-java-2.0.6.GA.orig/classloading/.classpath0000644000175000017500000001063311155514315024354 0ustar twernertwerner libjboss-classloader-java-2.0.6.GA.orig/classloading/pom.xml0000644000175000017500000000750711202514647023715 0ustar twernertwerner org.jboss.cl jboss-cl 2.0.6.GA 4.0.0 jboss-classloading jar JBoss ClassLoading http://www.jboss.org/jbossmc JBoss ClassLoading org.jboss jboss-common-core org.jboss.logging jboss-logging-spi org.jboss.cl jboss-classloader org.jboss.microcontainer jboss-dependency org.jboss jboss-common-core jboss jboss-common-logging-spi org.jboss.microcontainer jboss-kernel true org.jboss.microcontainer jboss-dependency org.jboss jboss-common-core jboss jboss-common-logging-spi org.jboss jbossxb org.jboss jbossxb true org.jboss jboss-reflect org.jboss jboss-common-core jboss jboss-common-logging-spi org.jboss.man jboss-managed true org.jboss jboss-reflect org.jboss jboss-common-core jboss jboss-common-logging-spi org.jboss.test jboss-test test junit junit test libjboss-classloader-java-2.0.6.GA.orig/classloading/src/0000755000175000017500000000000011620043420023144 5ustar twernertwernerlibjboss-classloader-java-2.0.6.GA.orig/classloading/src/test/0000755000175000017500000000000011620043417024131 5ustar twernertwernerlibjboss-classloader-java-2.0.6.GA.orig/classloading/src/test/resources/0000755000175000017500000000000011620043417026143 5ustar twernertwernerlibjboss-classloader-java-2.0.6.GA.orig/classloading/src/test/resources/org/0000755000175000017500000000000011620043417026732 5ustar twernertwernerlibjboss-classloader-java-2.0.6.GA.orig/classloading/src/test/resources/org/jboss/0000755000175000017500000000000011620043417030052 5ustar twernertwernerlibjboss-classloader-java-2.0.6.GA.orig/classloading/src/test/resources/org/jboss/test/0000755000175000017500000000000011620043417031031 5ustar twernertwerner././@LongLink0000000000000000000000000000014500000000000011565 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloading/src/test/resources/org/jboss/test/classloading/libjboss-classloader-java-2.0.6.GA.orig/classloading/src/test/resources/org/jboss/test/classloading/0000755000175000017500000000000011620043417033474 5ustar twernertwerner././@LongLink0000000000000000000000000000015600000000000011567 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloading/src/test/resources/org/jboss/test/classloading/metadata/libjboss-classloader-java-2.0.6.GA.orig/classloading/src/test/resources/org/jboss/test/classloading/0000755000175000017500000000000011620043417033474 5ustar twernertwerner././@LongLink0000000000000000000000000000016200000000000011564 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloading/src/test/resources/org/jboss/test/classloading/metadata/xml/libjboss-classloader-java-2.0.6.GA.orig/classloading/src/test/resources/org/jboss/test/classloading/0000755000175000017500000000000011620043417033474 5ustar twernertwerner././@LongLink0000000000000000000000000000016700000000000011571 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloading/src/test/resources/org/jboss/test/classloading/metadata/xml/test/libjboss-classloader-java-2.0.6.GA.orig/classloading/src/test/resources/org/jboss/test/classloading/0000755000175000017500000000000011620043420033466 5ustar twernertwerner././@LongLink0000000000000000000000000000021100000000000011557 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloading/src/test/resources/org/jboss/test/classloading/metadata/xml/test/ModuleExcluded.xmllibjboss-classloader-java-2.0.6.GA.orig/classloading/src/test/resources/org/jboss/test/classloading/0000644000175000017500000000023010756304141033474 0ustar twernertwerner ././@LongLink0000000000000000000000000000021500000000000011563 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloading/src/test/resources/org/jboss/test/classloading/metadata/xml/test/ImportVersionRange.xmllibjboss-classloader-java-2.0.6.GA.orig/classloading/src/test/resources/org/jboss/test/classloading/0000644000175000017500000000133510756304141033503 0ustar twernertwerner ././@LongLink0000000000000000000000000000022400000000000011563 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloading/src/test/resources/org/jboss/test/classloading/metadata/xml/test/ImportOnePackageVersioned.xmllibjboss-classloader-java-2.0.6.GA.orig/classloading/src/test/resources/org/jboss/test/classloading/0000644000175000017500000000034110756304141033477 0ustar twernertwerner ././@LongLink0000000000000000000000000000021600000000000011564 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloading/src/test/resources/org/jboss/test/classloading/metadata/xml/test/ImportThreePackages.xmllibjboss-classloader-java-2.0.6.GA.orig/classloading/src/test/resources/org/jboss/test/classloading/0000644000175000017500000000052110756304141033477 0ustar twernertwerner ././@LongLink0000000000000000000000000000022300000000000011562 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloading/src/test/resources/org/jboss/test/classloading/metadata/xml/test/ExportOneModuleVersioned.xmllibjboss-classloader-java-2.0.6.GA.orig/classloading/src/test/resources/org/jboss/test/classloading/0000644000175000017500000000033010756304141033475 0ustar twernertwerner ././@LongLink0000000000000000000000000000021000000000000011556 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloading/src/test/resources/org/jboss/test/classloading/metadata/xml/test/ModuleVersion.xmllibjboss-classloader-java-2.0.6.GA.orig/classloading/src/test/resources/org/jboss/test/classloading/0000644000175000017500000000024210756304141033477 0ustar twernertwerner ././@LongLink0000000000000000000000000000022300000000000011562 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloading/src/test/resources/org/jboss/test/classloading/metadata/xml/test/ExportOneModuleNoVersion.xmllibjboss-classloader-java-2.0.6.GA.orig/classloading/src/test/resources/org/jboss/test/classloading/0000644000175000017500000000031010756304141033473 0ustar twernertwerner ././@LongLink0000000000000000000000000000021500000000000011563 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloading/src/test/resources/org/jboss/test/classloading/metadata/xml/test/ImportThreeModules.xmllibjboss-classloader-java-2.0.6.GA.orig/classloading/src/test/resources/org/jboss/test/classloading/0000644000175000017500000000051610756304141033503 0ustar twernertwerner ././@LongLink0000000000000000000000000000021200000000000011560 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloading/src/test/resources/org/jboss/test/classloading/metadata/xml/test/UsesRequirement.xmllibjboss-classloader-java-2.0.6.GA.orig/classloading/src/test/resources/org/jboss/test/classloading/0000644000175000017500000000032110756304141033475 0ustar twernertwerner ././@LongLink0000000000000000000000000000022400000000000011563 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloading/src/test/resources/org/jboss/test/classloading/metadata/xml/test/ImportOnePackageNoVersion.xmllibjboss-classloader-java-2.0.6.GA.orig/classloading/src/test/resources/org/jboss/test/classloading/0000644000175000017500000000031110756304141033474 0ustar twernertwerner ././@LongLink0000000000000000000000000000021200000000000011560 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloading/src/test/resources/org/jboss/test/classloading/metadata/xml/test/ModuleBlackList.xmllibjboss-classloader-java-2.0.6.GA.orig/classloading/src/test/resources/org/jboss/test/classloading/0000644000175000017500000000024410756304141033501 0ustar twernertwerner ././@LongLink0000000000000000000000000000021500000000000011563 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloading/src/test/resources/org/jboss/test/classloading/metadata/xml/test/ModuleParentDomain.xmllibjboss-classloader-java-2.0.6.GA.orig/classloading/src/test/resources/org/jboss/test/classloading/0000644000175000017500000000026310756304141033502 0ustar twernertwerner ././@LongLink0000000000000000000000000000021500000000000011563 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloading/src/test/resources/org/jboss/test/classloading/metadata/xml/test/WildcardCapability.xmllibjboss-classloader-java-2.0.6.GA.orig/classloading/src/test/resources/org/jboss/test/classloading/0000644000175000017500000000054110756304141033501 0ustar twernertwerner ././@LongLink0000000000000000000000000000020700000000000011564 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloading/src/test/resources/org/jboss/test/classloading/metadata/xml/test/ModuleDomain.xmllibjboss-classloader-java-2.0.6.GA.orig/classloading/src/test/resources/org/jboss/test/classloading/0000644000175000017500000000024610756304141033503 0ustar twernertwerner ././@LongLink0000000000000000000000000000021100000000000011557 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloading/src/test/resources/org/jboss/test/classloading/metadata/xml/test/ModuleIncluded.xmllibjboss-classloader-java-2.0.6.GA.orig/classloading/src/test/resources/org/jboss/test/classloading/0000644000175000017500000000023010756304141033474 0ustar twernertwerner ././@LongLink0000000000000000000000000000021600000000000011564 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloading/src/test/resources/org/jboss/test/classloading/metadata/xml/test/ReExportRequirement.xmllibjboss-classloader-java-2.0.6.GA.orig/classloading/src/test/resources/org/jboss/test/classloading/0000644000175000017500000000043610756304141033504 0ustar twernertwerner ././@LongLink0000000000000000000000000000022400000000000011563 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloading/src/test/resources/org/jboss/test/classloading/metadata/xml/test/ExportOnePackageVersioned.xmllibjboss-classloader-java-2.0.6.GA.orig/classloading/src/test/resources/org/jboss/test/classloading/0000644000175000017500000000033110756304141033476 0ustar twernertwerner ././@LongLink0000000000000000000000000000022300000000000011562 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloading/src/test/resources/org/jboss/test/classloading/metadata/xml/test/ImportOneModuleNoVersion.xmllibjboss-classloader-java-2.0.6.GA.orig/classloading/src/test/resources/org/jboss/test/classloading/0000644000175000017500000000031010756304141033473 0ustar twernertwerner ././@LongLink0000000000000000000000000000021600000000000011564 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloading/src/test/resources/org/jboss/test/classloading/metadata/xml/test/OptionalRequirement.xmllibjboss-classloader-java-2.0.6.GA.orig/classloading/src/test/resources/org/jboss/test/classloading/0000644000175000017500000000043610756304141033504 0ustar twernertwerner ././@LongLink0000000000000000000000000000020600000000000011563 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloading/src/test/resources/org/jboss/test/classloading/metadata/xml/test/ModuleCache.xmllibjboss-classloader-java-2.0.6.GA.orig/classloading/src/test/resources/org/jboss/test/classloading/0000644000175000017500000000024010756304141033475 0ustar twernertwerner ././@LongLink0000000000000000000000000000020500000000000011562 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloading/src/test/resources/org/jboss/test/classloading/metadata/xml/test/ModuleName.xmllibjboss-classloader-java-2.0.6.GA.orig/classloading/src/test/resources/org/jboss/test/classloading/0000644000175000017500000000020410756304141033475 0ustar twernertwerner ././@LongLink0000000000000000000000000000021400000000000011562 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloading/src/test/resources/org/jboss/test/classloading/metadata/xml/test/ExportImportMixed.xmllibjboss-classloader-java-2.0.6.GA.orig/classloading/src/test/resources/org/jboss/test/classloading/0000644000175000017500000000105611173151646033507 0ustar twernertwerner ././@LongLink0000000000000000000000000000021200000000000011560 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloading/src/test/resources/org/jboss/test/classloading/metadata/xml/test/ModuleImportAll.xmllibjboss-classloader-java-2.0.6.GA.orig/classloading/src/test/resources/org/jboss/test/classloading/0000644000175000017500000000024410756304141033501 0ustar twernertwerner ././@LongLink0000000000000000000000000000023300000000000011563 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloading/src/test/resources/org/jboss/test/classloading/metadata/xml/test/ModuleJ2seClassLoadingCompliance.xmllibjboss-classloader-java-2.0.6.GA.orig/classloading/src/test/resources/org/jboss/test/classloading/0000644000175000017500000000024710756304141033504 0ustar twernertwerner ././@LongLink0000000000000000000000000000022300000000000011562 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloading/src/test/resources/org/jboss/test/classloading/metadata/xml/test/ImportOneModuleVersioned.xmllibjboss-classloader-java-2.0.6.GA.orig/classloading/src/test/resources/org/jboss/test/classloading/0000644000175000017500000000034010756304141033476 0ustar twernertwerner ././@LongLink0000000000000000000000000000021600000000000011564 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloading/src/test/resources/org/jboss/test/classloading/metadata/xml/test/WildcardRequirement.xmllibjboss-classloader-java-2.0.6.GA.orig/classloading/src/test/resources/org/jboss/test/classloading/0000644000175000017500000000053110756304141033500 0ustar twernertwerner ././@LongLink0000000000000000000000000000022400000000000011563 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloading/src/test/resources/org/jboss/test/classloading/metadata/xml/test/ExportOnePackageNoVersion.xmllibjboss-classloader-java-2.0.6.GA.orig/classloading/src/test/resources/org/jboss/test/classloading/0000644000175000017500000000031110756304141033474 0ustar twernertwerner ././@LongLink0000000000000000000000000000021200000000000011560 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloading/src/test/resources/org/jboss/test/classloading/metadata/xml/test/ModuleExportAll.xmllibjboss-classloader-java-2.0.6.GA.orig/classloading/src/test/resources/org/jboss/test/classloading/0000644000175000017500000000024310756304141033500 0ustar twernertwerner ././@LongLink0000000000000000000000000000021500000000000011563 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloading/src/test/resources/org/jboss/test/classloading/metadata/xml/test/DynamicRequirement.xmllibjboss-classloader-java-2.0.6.GA.orig/classloading/src/test/resources/org/jboss/test/classloading/0000644000175000017500000000043410761314167033507 0ustar twernertwerner ././@LongLink0000000000000000000000000000021700000000000011565 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloading/src/test/resources/org/jboss/test/classloading/metadata/xml/test/ModuleExcludedExport.xmllibjboss-classloader-java-2.0.6.GA.orig/classloading/src/test/resources/org/jboss/test/classloading/0000644000175000017500000000024410756304141033501 0ustar twernertwerner ././@LongLink0000000000000000000000000000021600000000000011564 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloading/src/test/resources/org/jboss/test/classloading/metadata/xml/test/ExportThreePackages.xmllibjboss-classloader-java-2.0.6.GA.orig/classloading/src/test/resources/org/jboss/test/classloading/0000644000175000017500000000047110756304141033503 0ustar twernertwerner ././@LongLink0000000000000000000000000000021500000000000011563 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloading/src/test/resources/org/jboss/test/classloading/metadata/xml/test/ExportThreeModules.xmllibjboss-classloader-java-2.0.6.GA.orig/classloading/src/test/resources/org/jboss/test/classloading/0000644000175000017500000000046610756304141033507 0ustar twernertwerner libjboss-classloader-java-2.0.6.GA.orig/classloading/src/test/java/0000755000175000017500000000000011620043416025051 5ustar twernertwernerlibjboss-classloader-java-2.0.6.GA.orig/classloading/src/test/java/org/0000755000175000017500000000000011620043416025640 5ustar twernertwernerlibjboss-classloader-java-2.0.6.GA.orig/classloading/src/test/java/org/jboss/0000755000175000017500000000000011620043416026760 5ustar twernertwernerlibjboss-classloader-java-2.0.6.GA.orig/classloading/src/test/java/org/jboss/test/0000755000175000017500000000000011620043416027737 5ustar twernertwernerlibjboss-classloader-java-2.0.6.GA.orig/classloading/src/test/java/org/jboss/test/classloading/0000755000175000017500000000000011620043417032403 5ustar twernertwerner././@LongLink0000000000000000000000000000017500000000000011570 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloading/src/test/java/org/jboss/test/classloading/AbstractClassLoadingTest.javalibjboss-classloader-java-2.0.6.GA.orig/classloading/src/test/java/org/jboss/test/classloading/Abstr0000644000175000017500000001356310756304141033414 0ustar twernertwerner/* * JBoss, Home of Professional Open Source. * Copyright 2008, Red Hat Middleware LLC, and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.test.classloading; import org.jboss.classloader.plugins.ClassLoaderUtils; import org.jboss.classloader.test.support.MockClassLoaderHelper; import org.jboss.classloading.spi.version.Version; import org.jboss.classloading.spi.version.VersionRange; import org.jboss.test.AbstractTestCaseWithSetup; import org.jboss.test.AbstractTestDelegate; /** * AbstractClassLoadingTest. * * @author Adrian Brock * @version $Revision: 1.1 $ */ public abstract class AbstractClassLoadingTest extends AbstractTestCaseWithSetup { public static AbstractTestDelegate getDelegate(Class clazz) { return new AbstractTestDelegate(clazz); } @Override protected void setUp() throws Exception { super.setUp(); configureLogging(); } public AbstractClassLoadingTest(String name) { super(name); } protected void assertVersion(Version version, int major, int minor, int micro) { assertVersion(version, major, minor, micro, null); } protected void assertVersion(Version version, int major, int minor, int micro, String qualifier) { assertNotNull(version); assertEquals(major, version.getMajor()); assertEquals(minor, version.getMinor()); assertEquals(micro, version.getMicro()); if (qualifier == null) assertEquals("", version.getQualifier()); else assertEquals(qualifier, version.getQualifier()); } protected void assertVersionRange(VersionRange range, Object low, Object high) { assertVersionRange(range, low, true, high, false); } protected void assertVersionRange(VersionRange range, Object low, boolean lowInclusive, Object high, boolean highInclusive) { assertNotNull(range); if (low == null) assertEquals(Version.DEFAULT_VERSION, range.getLow()); else assertEquals(low, range.getLow()); assertEquals(lowInclusive, range.isLowInclusive()); assertEquals(high, range.getHigh()); assertEquals(highInclusive, range.isHighInclusive()); } protected void assertClassLoader(Class clazz, ClassLoader expected) { if (expected == null) return; boolean result = MockClassLoaderHelper.isExpectedClassLoader(clazz, expected); assertTrue(ClassLoaderUtils.classToString(clazz) + " should have expected classloader=" + expected, result); } protected void assertClassEquality(Class expected, Class actual) { assertTrue("Should be the same " + ClassLoaderUtils.classToString(expected) +" and " + ClassLoaderUtils.classToString(actual), expected == actual); } protected void assertNoClassEquality(Class expected, Class actual) { assertTrue("Should NOT be the same " + ClassLoaderUtils.classToString(expected) +" and " + ClassLoaderUtils.classToString(actual), expected != actual); } protected Class assertLoadClass(Class reference, ClassLoader start) { return assertLoadClass(reference, start, start, false); } protected Class assertLoadClass(Class reference, ClassLoader start, boolean isReference) { return assertLoadClass(reference, start, start, isReference); } protected Class assertLoadClass(Class reference, ClassLoader start, ClassLoader expected) { return assertLoadClass(reference, start, expected, false); } protected Class assertLoadClass(Class reference, ClassLoader start, ClassLoader expected, boolean isReference) { Class result = assertLoadClass(reference.getName(), start, expected); if (isReference) assertClassEquality(reference, result); else assertNoClassEquality(reference, result); return result; } protected Class assertLoadClass(String name, ClassLoader start) { return assertLoadClass(name, start, start); } protected Class assertLoadClass(String name, ClassLoader start, ClassLoader expected) { Class result = null; try { result = start.loadClass(name); getLog().debug("Got class: " + ClassLoaderUtils.classToString(result) + " for " + name + " from " + start); } catch (ClassNotFoundException e) { failure("Did not expect CNFE for " + name + " from " + start, e); } assertClassLoader(result, expected); return result; } protected void assertLoadClassFail(Class reference, ClassLoader start) { assertLoadClassFail(reference.getName(), start); } protected void assertLoadClassFail(String name, ClassLoader start) { try { start.loadClass(name); fail("Should not be here!"); } catch (Exception expected) { checkThrowable(ClassNotFoundException.class, expected); } } protected void configureLogging() { //enableTrace("org.jboss.classloading"); } } ././@LongLink0000000000000000000000000000015100000000000011562 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloading/src/test/java/org/jboss/test/classloading/metadata/libjboss-classloader-java-2.0.6.GA.orig/classloading/src/test/java/org/jboss/test/classloading/metad0000755000175000017500000000000011620043417033416 5ustar twernertwerner././@LongLink0000000000000000000000000000015600000000000011567 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloading/src/test/java/org/jboss/test/classloading/metadata/test/libjboss-classloader-java-2.0.6.GA.orig/classloading/src/test/java/org/jboss/test/classloading/metad0000755000175000017500000000000011620043417033416 5ustar twernertwerner././@LongLink0000000000000000000000000000021500000000000011563 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloading/src/test/java/org/jboss/test/classloading/metadata/test/NameAndVersionUnitTestCase.javalibjboss-classloader-java-2.0.6.GA.orig/classloading/src/test/java/org/jboss/test/classloading/metad0000644000175000017500000001236010756304141033425 0ustar twernertwerner/* * JBoss, Home of Professional Open Source. * Copyright 2008, Red Hat Middleware LLC, and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.test.classloading.metadata.test; import junit.framework.Test; import org.jboss.classloading.spi.helpers.NameAndVersionSupport; import org.jboss.classloading.spi.version.Version; import org.jboss.test.classloading.AbstractClassLoadingTestWithSecurity; /** * NameAndVersionUnitTestCase. * * @author Adrian Brock * @version $Revision: 1.1 $ */ public class NameAndVersionUnitTestCase extends AbstractClassLoadingTestWithSecurity { public static Test suite() { return suite(NameAndVersionUnitTestCase.class); } public NameAndVersionUnitTestCase(String name) { super(name); } public void testConstructors() throws Exception { NameAndVersionSupport test = new NameAndVersionSupport(); assertNotNull(test.getName()); assertEquals(Version.DEFAULT_VERSION, test.getVersion()); test = new NameAndVersionSupport("test"); assertEquals("test", test.getName()); assertEquals(Version.DEFAULT_VERSION, test.getVersion()); test = new NameAndVersionSupport("test", "version"); assertEquals("test", test.getName()); assertEquals("version", test.getVersion()); try { fail("Should not be here for: " + new NameAndVersionSupport(null)); } catch (Throwable t) { checkDeepThrowable(IllegalArgumentException.class, t); } try { fail("Should not be here for: " + new NameAndVersionSupport(null, "version")); } catch (Throwable t) { checkDeepThrowable(IllegalArgumentException.class, t); } } public void testSetName() throws Exception { NameAndVersionSupport test = new NameAndVersionSupport(); assertNotNull(test.getName()); assertEquals(Version.DEFAULT_VERSION, test.getVersion()); test.setName("name"); assertEquals("name", test.getName()); assertEquals(Version.DEFAULT_VERSION, test.getVersion()); test = new NameAndVersionSupport(); try { test.setName(null); } catch (Throwable t) { checkDeepThrowable(IllegalArgumentException.class, t); } } public void testSetVersion() throws Exception { NameAndVersionSupport test = new NameAndVersionSupport(); assertNotNull(test.getName()); assertEquals(Version.DEFAULT_VERSION, test.getVersion()); test.setVersion("version"); assertNotNull(test.getName()); assertEquals("version", test.getVersion()); test.setVersion(null); assertNotNull(test.getName()); assertEquals(Version.DEFAULT_VERSION, test.getVersion()); } public void testEquals() throws Exception { testEquals("a", Version.DEFAULT_VERSION, "a", Version.DEFAULT_VERSION, true); testEquals("a", Version.DEFAULT_VERSION, "a", null, true); testEquals("a", Version.DEFAULT_VERSION, "a", "0.0.0", true); testEquals("b", "1.0.0", "b", "1.0.0", true); testEquals("a", Version.DEFAULT_VERSION, "b", Version.DEFAULT_VERSION, false); testEquals("a", "1.0.0", "a", Version.DEFAULT_VERSION, false); testEquals("a", "1.0.0", "a", "0.0.0", false); testEquals("a", "1.0.0", "a", "2.0.0", false); } public void testSerialization() throws Exception { NameAndVersionSupport test = new NameAndVersionSupport("a", Version.DEFAULT_VERSION); NameAndVersionSupport other = serializeDeserialize(test, NameAndVersionSupport.class); assertEquals(test, other); } protected void testEquals(String name1, Object version1, String name2, Object version2, boolean result) { NameAndVersionSupport test1 = new NameAndVersionSupport(name1, version1); NameAndVersionSupport test2 = new NameAndVersionSupport(name2, version2); if (result) { assertTrue("Expected " + test1 + ".equals(" + test2 + ") to be true", test1.equals(test2)); assertTrue("Expected " + test2 + ".equals(" + test1 + ") to be true", test2.equals(test1)); } else { assertFalse("Expected " + test1 + ".equals(" + test2 + ") to be false", test1.equals(test2)); assertFalse("Expected " + test2 + ".equals(" + test1 + ") to be false", test2.equals(test1)); } } } ././@LongLink0000000000000000000000000000022100000000000011560 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloading/src/test/java/org/jboss/test/classloading/metadata/test/PackageRequirementUnitTestCase.javalibjboss-classloader-java-2.0.6.GA.orig/classloading/src/test/java/org/jboss/test/classloading/metad0000644000175000017500000002310511035356200033416 0ustar twernertwerner/* * JBoss, Home of Professional Open Source. * Copyright 2008, Red Hat Middleware LLC, and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.test.classloading.metadata.test; import junit.framework.Test; import org.jboss.classloading.plugins.metadata.PackageRequirement; import org.jboss.classloading.plugins.metadata.UsesPackageRequirement; import org.jboss.classloading.spi.metadata.Requirement; import org.jboss.classloading.spi.version.VersionRange; import org.jboss.test.classloading.AbstractClassLoadingTestWithSecurity; import org.jboss.test.classloading.metadata.xml.support.TestRequirement; /** * PackageRequirementUnitTestCase. * * @author Adrian Brock * @version $Revision: 1.1 $ */ public class PackageRequirementUnitTestCase extends AbstractClassLoadingTestWithSecurity { public static Test suite() { return suite(PackageRequirementUnitTestCase.class); } public PackageRequirementUnitTestCase(String name) { super(name); } public void testConstructors() throws Exception { PackageRequirement test = new PackageRequirement(); assertNotNull(test.getName()); assertEquals(VersionRange.ALL_VERSIONS, test.getVersionRange()); test = new PackageRequirement("test"); assertEquals("test", test.getName()); assertEquals(VersionRange.ALL_VERSIONS, test.getVersionRange()); VersionRange range = new VersionRange("1.0.0", "2.0.0"); test = new PackageRequirement("test", range); assertEquals("test", test.getName()); assertEquals(range, test.getVersionRange()); try { fail("Should not be here for: " + new PackageRequirement(null)); } catch (Throwable t) { checkDeepThrowable(IllegalArgumentException.class, t); } try { fail("Should not be here for: " + new PackageRequirement(null, range)); } catch (Throwable t) { checkDeepThrowable(IllegalArgumentException.class, t); } } public void testSetName() throws Exception { PackageRequirement test = new PackageRequirement(); assertNotNull(test.getName()); assertEquals(VersionRange.ALL_VERSIONS, test.getVersionRange()); test.setName("name"); assertEquals("name", test.getName()); assertEquals(VersionRange.ALL_VERSIONS, test.getVersionRange()); test = new PackageRequirement(); try { test.setName(null); } catch (Throwable t) { checkDeepThrowable(IllegalArgumentException.class, t); } } public void testSetVersionRange() throws Exception { PackageRequirement test = new PackageRequirement(); assertNotNull(test.getName()); assertEquals(VersionRange.ALL_VERSIONS, test.getVersionRange()); VersionRange range = new VersionRange("1.0.0", "2.0.0"); test.setVersionRange(range); assertNotNull(test.getName()); assertEquals(range, test.getVersionRange()); test.setVersionRange(null); assertNotNull(test.getName()); assertEquals(VersionRange.ALL_VERSIONS, test.getVersionRange()); } public void testEquals() throws Exception { testEquals("a", VersionRange.ALL_VERSIONS, "a", VersionRange.ALL_VERSIONS, true); testEquals("a", VersionRange.ALL_VERSIONS, "a", null, true); VersionRange range1 = new VersionRange("1.0.0", true, "1.0.0", true); testEquals("b", range1, "b", range1, true); testEquals("a", VersionRange.ALL_VERSIONS, "b", VersionRange.ALL_VERSIONS, false); testEquals("a", range1, "a", VersionRange.ALL_VERSIONS, false); VersionRange range2 = new VersionRange("1.0.0", true, "2.0.0", true); testEquals("a", range1, "a", range2, false); } public void testIsConsistent() throws Exception { testIsConsistent("a", VersionRange.ALL_VERSIONS, "a", VersionRange.ALL_VERSIONS, true); testIsConsistent("a", VersionRange.ALL_VERSIONS, "a", null, true); testIsConsistent("a", null, "a", VersionRange.ALL_VERSIONS, true); testIsConsistent("a", "1.0.0", "2.0.0", "a", "1.0.0", "2.0.0", true); testIsConsistent("a", "1.0.0", "2.0.0", "a", "2.0.0", "2.0.0", true); testIsConsistent("a", "1.0.0", "2.0.0", "a", "1.0.0", "1.0.0", true); testIsConsistent("a", "1.0.0", "2.0.0", "b", "1.0.0", "2.0.0", true); testIsConsistent("a", "1.0.0", "2.0.0", "b", "0.0.1", "0.0.1", true); testIsConsistent("a", "1.0.0", "2.0.0", "b", "2.0.1", "2.0.1", true); testIsConsistent("a", "1.0.0", "2.0.0", "a", "0.0.1", "0.0.1", false); testIsConsistent("a", "1.0.0", "2.0.0", "a", "2.0.1", "2.0.1", false); testIsConsistentOther("a", "1.0.0", "2.0.0", "b", "1.0.0", "2.0.0", true); testIsConsistentOther("a", "1.0.0", "2.0.0", "b", "0.0.1", "0.0.1", true); testIsConsistentOther("a", "1.0.0", "2.0.0", "b", "2.0.1", "2.0.1", true); testIsConsistentOther("a", "1.0.0", "2.0.0", "a", "1.0.0", "2.0.0", true); testIsConsistentOther("a", "1.0.0", "2.0.0", "a", "0.0.1", "0.0.1", true); testIsConsistentOther("a", "1.0.0", "2.0.0", "a", "2.0.1", "2.0.1", true); testIsConsistentUses("a", "1.0.0", "2.0.0", "b", "1.0.0", "2.0.0", true); testIsConsistentUses("a", "1.0.0", "2.0.0", "b", "0.0.1", "0.0.1", true); testIsConsistentUses("a", "1.0.0", "2.0.0", "b", "2.0.1", "2.0.1", true); testIsConsistentUses("a", "1.0.0", "2.0.0", "a", "1.0.0", "2.0.0", true); testIsConsistentUses("a", "1.0.0", "2.0.0", "a", "0.0.1", "0.0.1", false); testIsConsistentUses("a", "1.0.0", "2.0.0", "a", "2.0.1", "2.0.1", false); } protected void testIsConsistent(String name1, String low1, String high1, String name2, String low2, String high2, boolean result) { VersionRange range1 = new VersionRange(low1, true, high1, true); VersionRange range2 = new VersionRange(low2, true, high2, true); testIsConsistent(name1, range1, name2, range2, result); testIsConsistent(name2, range2, name1, range1, result); } protected void testIsConsistentOther(String name1, String low1, String high1, String name2, String low2, String high2, boolean result) { VersionRange range1 = new VersionRange(low1, true, high1, true); VersionRange range2 = new VersionRange(low2, true, high2, true); PackageRequirement test1 = new PackageRequirement(name1, range1); TestRequirement test2 = new TestRequirement(name2, range2); testIsConsistent(test1, test2, result); testIsConsistent(test1, test2, result); } protected void testIsConsistentUses(String name1, String low1, String high1, String name2, String low2, String high2, boolean result) { VersionRange range1 = new VersionRange(low1, true, high1, true); VersionRange range2 = new VersionRange(low2, true, high2, true); PackageRequirement test1 = new PackageRequirement(name1, range1); UsesPackageRequirement test2 = new UsesPackageRequirement(name2, range2); testIsConsistent(test1, test2, result); testIsConsistent(test1, test2, result); } protected void testIsConsistent(String name1, VersionRange range1, String name2, VersionRange range2, boolean result) { PackageRequirement test1 = new PackageRequirement(name1, range1); PackageRequirement test2 = new PackageRequirement(name2, range2); testIsConsistent(test1, test2, result); } protected void testIsConsistent(Requirement test1, Requirement test2, boolean result) { if (result) assertTrue("Expected " + test1 + ".isConsistent(" + test2 + ") to be true", test1.isConsistent(test2)); else assertFalse("Expected " + test1 + ".isConsistent(" + test2 + ") to be false", test1.isConsistent(test2)); } public void testSerialization() throws Exception { PackageRequirement test = new PackageRequirement("a", VersionRange.ALL_VERSIONS); PackageRequirement other = serializeDeserialize(test, PackageRequirement.class); assertEquals(test, other); } protected void testEquals(String name1, VersionRange range1, String name2, VersionRange range2, boolean result) { PackageRequirement test1 = new PackageRequirement(name1, range1); PackageRequirement test2 = new PackageRequirement(name2, range2); if (result) { assertTrue("Expected " + test1 + ".equals(" + test2 + ") to be true", test1.equals(test2)); assertTrue("Expected " + test2 + ".equals(" + test1 + ") to be true", test2.equals(test1)); } else { assertFalse("Expected " + test1 + ".equals(" + test2 + ") to be false", test1.equals(test2)); assertFalse("Expected " + test2 + ".equals(" + test1 + ") to be false", test2.equals(test1)); } } } ././@LongLink0000000000000000000000000000022300000000000011562 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloading/src/test/java/org/jboss/test/classloading/metadata/test/CapabilitiesMetaDataUnitTestCase.javalibjboss-classloader-java-2.0.6.GA.orig/classloading/src/test/java/org/jboss/test/classloading/metad0000644000175000017500000001077110756304141033431 0ustar twernertwerner/* * JBoss, Home of Professional Open Source. * Copyright 2008, Red Hat Middleware LLC, and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.test.classloading.metadata.test; import java.util.ArrayList; import java.util.List; import junit.framework.Test; import org.jboss.classloading.spi.metadata.CapabilitiesMetaData; import org.jboss.classloading.spi.metadata.Capability; import org.jboss.classloading.spi.metadata.ClassLoadingMetaDataFactory; import org.jboss.test.classloading.AbstractClassLoadingTestWithSecurity; /** * CapabilitiesMetaDataUnitTestCase. * * @author Adrian Brock * @version $Revision: 1.1 $ */ public class CapabilitiesMetaDataUnitTestCase extends AbstractClassLoadingTestWithSecurity { public static Test suite() { return suite(CapabilitiesMetaDataUnitTestCase.class); } public CapabilitiesMetaDataUnitTestCase(String name) { super(name); } public void testConstructor() throws Exception { CapabilitiesMetaData metadata = new CapabilitiesMetaData(); assertNull(metadata.getCapabilities()); } public void testSetCapabilities() throws Exception { ClassLoadingMetaDataFactory factory = ClassLoadingMetaDataFactory.getInstance(); CapabilitiesMetaData metadata = new CapabilitiesMetaData(); assertNull(metadata.getCapabilities()); List list = new ArrayList(); list.add(factory.createModule("module", "1.0.0")); list.add(factory.createPackage("package", "1.0.0")); metadata.setCapabilities(list); assertEquals(list, metadata.getCapabilities()); } public void testAddCapabilities() throws Exception { ClassLoadingMetaDataFactory factory = ClassLoadingMetaDataFactory.getInstance(); CapabilitiesMetaData metadata = new CapabilitiesMetaData(); assertNull(metadata.getCapabilities()); List list = new ArrayList(); Capability capability = factory.createModule("module", "1.0.0"); metadata.addCapability(capability); list.add(capability); assertEquals(list, metadata.getCapabilities()); capability = factory.createPackage("module", "1.0.0"); metadata.addCapability(capability); list.add(capability); assertEquals(list, metadata.getCapabilities()); } public void testRemoveCapabilities() throws Exception { ClassLoadingMetaDataFactory factory = ClassLoadingMetaDataFactory.getInstance(); CapabilitiesMetaData metadata = new CapabilitiesMetaData(); assertNull(metadata.getCapabilities()); Capability module = factory.createModule("module", "1.0.0"); Capability pkge = factory.createPackage("module", "1.0.0"); List list = new ArrayList(); list.add(module); list.add(pkge); metadata.setCapabilities(list); metadata.removeCapability(module); list.remove(module); assertEquals(list, metadata.getCapabilities()); metadata.removeCapability(pkge); list.remove(pkge); assertEquals(list, metadata.getCapabilities()); } public void testSerialization() throws Exception { ClassLoadingMetaDataFactory factory = ClassLoadingMetaDataFactory.getInstance(); CapabilitiesMetaData test = new CapabilitiesMetaData(); test.addCapability(factory.createModule("module", "1.0.0")); test.addCapability(factory.createPackage("package", "1.0.0")); CapabilitiesMetaData other = serializeDeserialize(test, CapabilitiesMetaData.class); assertEquals(test.getCapabilities(), other.getCapabilities()); } } ././@LongLink0000000000000000000000000000022300000000000011562 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloading/src/test/java/org/jboss/test/classloading/metadata/test/RequirementsMetaDataUnitTestCase.javalibjboss-classloader-java-2.0.6.GA.orig/classloading/src/test/java/org/jboss/test/classloading/metad0000644000175000017500000001141710756304141033427 0ustar twernertwerner/* * JBoss, Home of Professional Open Source. * Copyright 2008, Red Hat Middleware LLC, and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.test.classloading.metadata.test; import java.util.ArrayList; import java.util.List; import junit.framework.Test; import org.jboss.classloading.spi.metadata.RequirementsMetaData; import org.jboss.classloading.spi.metadata.Requirement; import org.jboss.classloading.spi.metadata.ClassLoadingMetaDataFactory; import org.jboss.classloading.spi.version.VersionRange; import org.jboss.test.classloading.AbstractClassLoadingTestWithSecurity; /** * RequirementsMetaDataUnitTestCase. * * @author Adrian Brock * @version $Revision: 1.1 $ */ public class RequirementsMetaDataUnitTestCase extends AbstractClassLoadingTestWithSecurity { public static Test suite() { return suite(RequirementsMetaDataUnitTestCase.class); } public RequirementsMetaDataUnitTestCase(String name) { super(name); } public void testConstructor() throws Exception { RequirementsMetaData metadata = new RequirementsMetaData(); assertNull(metadata.getRequirements()); } public void testSetRequirements() throws Exception { ClassLoadingMetaDataFactory factory = ClassLoadingMetaDataFactory.getInstance(); RequirementsMetaData metadata = new RequirementsMetaData(); assertNull(metadata.getRequirements()); List list = new ArrayList(); list.add(factory.createRequireModule("module", new VersionRange("1.0.0"))); list.add(factory.createRequirePackage("package", new VersionRange("1.0.0"))); metadata.setRequirements(list); assertEquals(list, metadata.getRequirements()); } public void testAddRequirements() throws Exception { ClassLoadingMetaDataFactory factory = ClassLoadingMetaDataFactory.getInstance(); RequirementsMetaData metadata = new RequirementsMetaData(); assertNull(metadata.getRequirements()); List list = new ArrayList(); Requirement Requirement = factory.createRequireModule("module", new VersionRange("1.0.0")); metadata.addRequirement(Requirement); list.add(Requirement); assertEquals(list, metadata.getRequirements()); Requirement = factory.createRequirePackage("module", new VersionRange("1.0.0")); metadata.addRequirement(Requirement); list.add(Requirement); assertEquals(list, metadata.getRequirements()); } public void testRemoveRequirements() throws Exception { ClassLoadingMetaDataFactory factory = ClassLoadingMetaDataFactory.getInstance(); RequirementsMetaData metadata = new RequirementsMetaData(); assertNull(metadata.getRequirements()); Requirement module = factory.createRequireModule("module", new VersionRange("1.0.0")); Requirement pkge = factory.createRequirePackage("module", new VersionRange("1.0.0")); List list = new ArrayList(); list.add(module); list.add(pkge); metadata.setRequirements(list); metadata.removeRequirement(module); list.remove(module); assertEquals(list, metadata.getRequirements()); metadata.removeRequirement(pkge); list.remove(pkge); assertEquals(list, metadata.getRequirements()); } public void testSerialization() throws Exception { ClassLoadingMetaDataFactory factory = ClassLoadingMetaDataFactory.getInstance(); RequirementsMetaData test = new RequirementsMetaData(); test.addRequirement(factory.createRequireModule("module", new VersionRange("1.0.0"))); test.addRequirement(factory.createRequirePackage("package", new VersionRange("1.0.0"))); RequirementsMetaData other = serializeDeserialize(test, RequirementsMetaData.class); assertEquals(test.getRequirements(), other.getRequirements()); } } ././@LongLink0000000000000000000000000000022000000000000011557 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloading/src/test/java/org/jboss/test/classloading/metadata/test/ModuleRequirementUnitTestCase.javalibjboss-classloader-java-2.0.6.GA.orig/classloading/src/test/java/org/jboss/test/classloading/metad0000644000175000017500000002074111035356200033421 0ustar twernertwerner/* * JBoss, Home of Professional Open Source. * Copyright 2008, Red Hat Middleware LLC, and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.test.classloading.metadata.test; import junit.framework.Test; import org.jboss.classloading.plugins.metadata.ModuleRequirement; import org.jboss.classloading.spi.metadata.Requirement; import org.jboss.classloading.spi.version.VersionRange; import org.jboss.test.classloading.AbstractClassLoadingTestWithSecurity; import org.jboss.test.classloading.metadata.xml.support.TestRequirement; /** * ModuleRequirementUnitTestCase. * * @author Adrian Brock * @version $Revision: 1.1 $ */ public class ModuleRequirementUnitTestCase extends AbstractClassLoadingTestWithSecurity { public static Test suite() { return suite(ModuleRequirementUnitTestCase.class); } public ModuleRequirementUnitTestCase(String name) { super(name); } public void testConstructors() throws Exception { ModuleRequirement test = new ModuleRequirement(); assertNotNull(test.getName()); assertEquals(VersionRange.ALL_VERSIONS, test.getVersionRange()); test = new ModuleRequirement("test"); assertEquals("test", test.getName()); assertEquals(VersionRange.ALL_VERSIONS, test.getVersionRange()); VersionRange range = new VersionRange("1.0.0", "2.0.0"); test = new ModuleRequirement("test", range); assertEquals("test", test.getName()); assertEquals(range, test.getVersionRange()); try { fail("Should not be here for: " + new ModuleRequirement(null)); } catch (Throwable t) { checkDeepThrowable(IllegalArgumentException.class, t); } try { fail("Should not be here for: " + new ModuleRequirement(null, range)); } catch (Throwable t) { checkDeepThrowable(IllegalArgumentException.class, t); } } public void testSetName() throws Exception { ModuleRequirement test = new ModuleRequirement(); assertNotNull(test.getName()); assertEquals(VersionRange.ALL_VERSIONS, test.getVersionRange()); test.setName("name"); assertEquals("name", test.getName()); assertEquals(VersionRange.ALL_VERSIONS, test.getVersionRange()); test = new ModuleRequirement(); try { test.setName(null); } catch (Throwable t) { checkDeepThrowable(IllegalArgumentException.class, t); } } public void testSetVersionRange() throws Exception { ModuleRequirement test = new ModuleRequirement(); assertNotNull(test.getName()); assertEquals(VersionRange.ALL_VERSIONS, test.getVersionRange()); VersionRange range = new VersionRange("1.0.0", "2.0.0"); test.setVersionRange(range); assertNotNull(test.getName()); assertEquals(range, test.getVersionRange()); test.setVersionRange(null); assertNotNull(test.getName()); assertEquals(VersionRange.ALL_VERSIONS, test.getVersionRange()); } public void testIsConsistent() throws Exception { testIsConsistent("a", VersionRange.ALL_VERSIONS, "a", VersionRange.ALL_VERSIONS, true); testIsConsistent("a", VersionRange.ALL_VERSIONS, "a", null, true); testIsConsistent("a", null, "a", VersionRange.ALL_VERSIONS, true); testIsConsistent("a", "1.0.0", "2.0.0", "a", "1.0.0", "2.0.0", true); testIsConsistent("a", "1.0.0", "2.0.0", "a", "2.0.0", "2.0.0", true); testIsConsistent("a", "1.0.0", "2.0.0", "a", "1.0.0", "1.0.0", true); testIsConsistent("a", "1.0.0", "2.0.0", "b", "1.0.0", "2.0.0", true); testIsConsistent("a", "1.0.0", "2.0.0", "b", "0.0.1", "0.0.1", true); testIsConsistent("a", "1.0.0", "2.0.0", "b", "2.0.1", "2.0.1", true); testIsConsistent("a", "1.0.0", "2.0.0", "a", "0.0.1", "0.0.1", false); testIsConsistent("a", "1.0.0", "2.0.0", "a", "2.0.1", "2.0.1", false); testIsConsistentOther("a", "1.0.0", "2.0.0", "b", "1.0.0", "2.0.0", true); testIsConsistentOther("a", "1.0.0", "2.0.0", "b", "0.0.1", "0.0.1", true); testIsConsistentOther("a", "1.0.0", "2.0.0", "b", "2.0.1", "2.0.1", true); testIsConsistentOther("a", "1.0.0", "2.0.0", "a", "1.0.0", "2.0.0", true); testIsConsistentOther("a", "1.0.0", "2.0.0", "a", "0.0.1", "0.0.1", true); testIsConsistentOther("a", "1.0.0", "2.0.0", "a", "2.0.1", "2.0.1", true); } public void testEquals() throws Exception { testEquals("a", VersionRange.ALL_VERSIONS, "a", VersionRange.ALL_VERSIONS, true); testEquals("a", VersionRange.ALL_VERSIONS, "a", null, true); VersionRange range1 = new VersionRange("1.0.0", true, "1.0.0", true); testEquals("b", range1, "b", range1, true); testEquals("a", VersionRange.ALL_VERSIONS, "b", VersionRange.ALL_VERSIONS, false); testEquals("a", range1, "a", VersionRange.ALL_VERSIONS, false); VersionRange range2 = new VersionRange("1.0.0", true, "2.0.0", true); testEquals("a", range1, "a", range2, false); } public void testSerialization() throws Exception { ModuleRequirement test = new ModuleRequirement("a", VersionRange.ALL_VERSIONS); ModuleRequirement other = serializeDeserialize(test, ModuleRequirement.class); assertEquals(test, other); } protected void testEquals(String name1, VersionRange range1, String name2, VersionRange range2, boolean result) { ModuleRequirement test1 = new ModuleRequirement(name1, range1); ModuleRequirement test2 = new ModuleRequirement(name2, range2); if (result) { assertTrue("Expected " + test1 + ".equals(" + test2 + ") to be true", test1.equals(test2)); assertTrue("Expected " + test2 + ".equals(" + test1 + ") to be true", test2.equals(test1)); } else { assertFalse("Expected " + test1 + ".equals(" + test2 + ") to be false", test1.equals(test2)); assertFalse("Expected " + test2 + ".equals(" + test1 + ") to be false", test2.equals(test1)); } } protected void testIsConsistent(String name1, String low1, String high1, String name2, String low2, String high2, boolean result) { VersionRange range1 = new VersionRange(low1, true, high1, true); VersionRange range2 = new VersionRange(low2, true, high2, true); testIsConsistent(name1, range1, name2, range2, result); testIsConsistent(name2, range2, name1, range1, result); } protected void testIsConsistentOther(String name1, String low1, String high1, String name2, String low2, String high2, boolean result) { VersionRange range1 = new VersionRange(low1, true, high1, true); VersionRange range2 = new VersionRange(low2, true, high2, true); ModuleRequirement test1 = new ModuleRequirement(name1, range1); TestRequirement test2 = new TestRequirement(name2, range2); testIsConsistent(test1, test2, result); testIsConsistent(test1, test2, result); } protected void testIsConsistent(String name1, VersionRange range1, String name2, VersionRange range2, boolean result) { ModuleRequirement test1 = new ModuleRequirement(name1, range1); ModuleRequirement test2 = new ModuleRequirement(name2, range2); testIsConsistent(test1, test2, result); } protected void testIsConsistent(Requirement test1, Requirement test2, boolean result) { if (result) assertTrue("Expected " + test1 + ".isConsistent(" + test2 + ") to be true", test1.isConsistent(test2)); else assertFalse("Expected " + test1 + ".isConsistent(" + test2 + ") to be false", test1.isConsistent(test2)); } } ././@LongLink0000000000000000000000000000022300000000000011562 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloading/src/test/java/org/jboss/test/classloading/metadata/test/ClassLoadingMetaDataUnitTestCase.javalibjboss-classloader-java-2.0.6.GA.orig/classloading/src/test/java/org/jboss/test/classloading/metad0000644000175000017500000003477110756304141033437 0ustar twernertwerner/* * JBoss, Home of Professional Open Source. * Copyright 2008, Red Hat Middleware LLC, and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.test.classloading.metadata.test; import java.util.Collection; import java.util.Collections; import junit.framework.Test; import org.jboss.classloader.spi.filter.ClassFilter; import org.jboss.classloading.spi.metadata.CapabilitiesMetaData; import org.jboss.classloading.spi.metadata.Capability; import org.jboss.classloading.spi.metadata.ClassLoadingMetaData; import org.jboss.classloading.spi.metadata.ClassLoadingMetaDataFactory; import org.jboss.classloading.spi.metadata.ExportAll; import org.jboss.classloading.spi.metadata.Requirement; import org.jboss.classloading.spi.metadata.RequirementsMetaData; import org.jboss.classloading.spi.version.Version; import org.jboss.classloading.spi.version.VersionRange; import org.jboss.test.classloading.AbstractClassLoadingTestWithSecurity; /** * ClassLoadingMetaDataUnitTestCase. * * @author Adrian Brock * @version $Revision: 1.1 $ */ public class ClassLoadingMetaDataUnitTestCase extends AbstractClassLoadingTestWithSecurity { public static Test suite() { return suite(ClassLoadingMetaDataUnitTestCase.class); } public ClassLoadingMetaDataUnitTestCase(String name) { super(name); } public void testConstructor() throws Exception { ClassLoadingMetaData test = new ClassLoadingMetaData(); assertNotNull(test.getName()); assertEquals(Version.DEFAULT_VERSION, test.getVersion()); assertNull(test.getDomain()); assertNull(test.getParentDomain()); assertNull(test.getExportAll()); assertNull(test.getIncluded()); assertNull(test.getExcluded()); assertNull(test.getExcludedExport()); assertNull(test.getIncludedPackages()); assertNull(test.getExcludedPackages()); assertNull(test.getExcludedExportPackages()); assertFalse(test.isImportAll()); assertTrue(test.isJ2seClassLoadingCompliance()); assertNull(test.getCapabilities().getCapabilities()); assertNull(test.getRequirements().getRequirements()); } public void testSetName() throws Exception { ClassLoadingMetaData test = new ClassLoadingMetaData(); assertNotNull(test.getName()); test.setName("test"); assertEquals("test", test.getName()); try { test.setName(null); } catch (Throwable t) { checkDeepThrowable(IllegalArgumentException.class, t); } ClassLoadingMetaData test2 = new ClassLoadingMetaData(); testEquals(test, test2, false); test2.setName("test"); testEquals(test, test2, true); } public void testSetVersion() throws Exception { ClassLoadingMetaData test = new ClassLoadingMetaData(); assertEquals(Version.DEFAULT_VERSION, test.getVersion()); test.setVersion("1.0.0"); assertEquals("1.0.0", test.getVersion()); test.setVersion(null); assertEquals(Version.DEFAULT_VERSION, test.getVersion()); test.setVersion("1.0.0"); ClassLoadingMetaData test2 = new ClassLoadingMetaData(); testEquals(test, test2, false); test2.setVersion("1.0.0"); testEquals(test, test2, true); } public void testSetDomain() throws Exception { ClassLoadingMetaData test = new ClassLoadingMetaData(); assertNull(test.getDomain()); test.setDomain("test"); assertEquals("test", test.getDomain()); ClassLoadingMetaData test2 = new ClassLoadingMetaData(); testEquals(test, test2, false); test2.setDomain("test"); testEquals(test, test2, true); } public void testSetParentDomain() throws Exception { ClassLoadingMetaData test = new ClassLoadingMetaData(); assertNull(test.getParentDomain()); test.setParentDomain("test"); assertEquals("test", test.getParentDomain()); ClassLoadingMetaData test2 = new ClassLoadingMetaData(); testEquals(test, test2, false); test2.setParentDomain("test"); testEquals(test, test2, true); } public void testSetExportAll() throws Exception { ClassLoadingMetaData test = new ClassLoadingMetaData(); assertNull(test.getExportAll()); test.setExportAll(ExportAll.ALL); assertEquals(ExportAll.ALL, test.getExportAll()); ClassLoadingMetaData test2 = new ClassLoadingMetaData(); testEquals(test, test2, false); test2.setExportAll(ExportAll.ALL); testEquals(test, test2, true); } public void testSetIncludedPackages() throws Exception { ClassLoadingMetaData test = new ClassLoadingMetaData(); assertNull(test.getIncludedPackages()); test.setIncludedPackages("Included"); assertEquals("Included", test.getIncludedPackages()); } public void testSetExcludedPackages() throws Exception { ClassLoadingMetaData test = new ClassLoadingMetaData(); assertNull(test.getExcludedPackages()); test.setExcludedPackages("Excluded"); assertEquals("Excluded", test.getExcludedPackages()); } public void testSetExcludedExportPackages() throws Exception { ClassLoadingMetaData test = new ClassLoadingMetaData(); assertNull(test.getExcludedExportPackages()); test.setExcludedExportPackages("ExcludedExport"); assertEquals("ExcludedExport", test.getExcludedExportPackages()); } public void testSetIncluded() throws Exception { ClassLoadingMetaData test = new ClassLoadingMetaData(); assertNull(test.getIncluded()); test.setIncluded(ClassFilter.EVERYTHING); assertEquals(ClassFilter.EVERYTHING, test.getIncluded()); } public void testSetExcluded() throws Exception { ClassLoadingMetaData test = new ClassLoadingMetaData(); assertNull(test.getExcluded()); test.setExcluded(ClassFilter.EVERYTHING); assertEquals(ClassFilter.EVERYTHING, test.getExcluded()); } public void testSetExcludedExport() throws Exception { ClassLoadingMetaData test = new ClassLoadingMetaData(); assertNull(test.getExcludedExport()); test.setExcludedExport(ClassFilter.EVERYTHING); assertEquals(ClassFilter.EVERYTHING, test.getExcludedExport()); } public void testGetIncluded() throws Exception { ClassLoadingMetaData test = new ClassLoadingMetaData(); assertNull(test.getIncluded()); test.setIncludedPackages("java.lang"); ClassFilter filter = test.getIncluded(); assertTrue(filter.matchesClassName(Object.class.getName())); assertFalse(filter.matchesClassName(Collection.class.getName())); test.setIncluded(ClassFilter.JAVA_ONLY); filter = test.getIncluded(); assertTrue(filter.matchesClassName(Object.class.getName())); assertFalse(filter.matchesClassName(Collection.class.getName())); test.setIncludedPackages(null); filter = test.getIncluded(); assertEquals(ClassFilter.JAVA_ONLY, filter); assertTrue(filter.matchesClassName(Object.class.getName())); assertTrue(filter.matchesClassName(Collection.class.getName())); } public void testGetExcluded() throws Exception { ClassLoadingMetaData test = new ClassLoadingMetaData(); assertNull(test.getExcluded()); test.setExcludedPackages("java.lang"); ClassFilter filter = test.getExcluded(); assertTrue(filter.matchesClassName(Object.class.getName())); assertFalse(filter.matchesClassName(Collection.class.getName())); test.setExcluded(ClassFilter.JAVA_ONLY); filter = test.getExcluded(); assertTrue(filter.matchesClassName(Object.class.getName())); assertFalse(filter.matchesClassName(Collection.class.getName())); test.setExcludedPackages(null); filter = test.getExcluded(); assertEquals(ClassFilter.JAVA_ONLY, filter); assertTrue(filter.matchesClassName(Object.class.getName())); assertTrue(filter.matchesClassName(Collection.class.getName())); } public void testGetExcludedExport() throws Exception { ClassLoadingMetaData test = new ClassLoadingMetaData(); assertNull(test.getExcludedExport()); test.setExcludedExportPackages("java.lang"); ClassFilter filter = test.getExcludedExport(); assertTrue(filter.matchesClassName(Object.class.getName())); assertFalse(filter.matchesClassName(Collection.class.getName())); test.setExcludedExport(ClassFilter.JAVA_ONLY); filter = test.getExcludedExport(); assertTrue(filter.matchesClassName(Object.class.getName())); assertFalse(filter.matchesClassName(Collection.class.getName())); test.setExcludedExportPackages(null); filter = test.getExcludedExport(); assertEquals(ClassFilter.JAVA_ONLY, filter); assertTrue(filter.matchesClassName(Object.class.getName())); assertTrue(filter.matchesClassName(Collection.class.getName())); } public void testSetImportAll() throws Exception { ClassLoadingMetaData test = new ClassLoadingMetaData(); assertFalse(test.isImportAll()); test.setImportAll(true); assertTrue(test.isImportAll()); ClassLoadingMetaData test2 = new ClassLoadingMetaData(); testEquals(test, test2, false); test2.setImportAll(true); testEquals(test, test2, true); } public void testJ2seClassLoadingComplaince() throws Exception { ClassLoadingMetaData test = new ClassLoadingMetaData(); assertTrue(test.isJ2seClassLoadingCompliance()); test.setJ2seClassLoadingCompliance(false); assertFalse(test.isJ2seClassLoadingCompliance()); ClassLoadingMetaData test2 = new ClassLoadingMetaData(); testEquals(test, test2, false); test2.setJ2seClassLoadingCompliance(false); testEquals(test, test2, true); } public void testCacheable() throws Exception { ClassLoadingMetaData test = new ClassLoadingMetaData(); assertTrue(test.isCacheable()); test.setCacheable(false); assertFalse(test.isCacheable()); ClassLoadingMetaData test2 = new ClassLoadingMetaData(); testEquals(test, test2, false); test2.setCacheable(false); testEquals(test, test2, true); } public void testBlackList() throws Exception { ClassLoadingMetaData test = new ClassLoadingMetaData(); assertTrue(test.isBlackListable()); test.setBlackListable(false); assertFalse(test.isBlackListable()); ClassLoadingMetaData test2 = new ClassLoadingMetaData(); testEquals(test, test2, false); test2.setBlackListable(false); testEquals(test, test2, true); } public void testCapabilities() throws Exception { ClassLoadingMetaDataFactory factory = ClassLoadingMetaDataFactory.getInstance(); ClassLoadingMetaData test = new ClassLoadingMetaData(); CapabilitiesMetaData capabilitiesMetaData = test.getCapabilities(); assertNull(capabilitiesMetaData.getCapabilities()); Capability capability = factory.createModule("test"); capabilitiesMetaData.addCapability(capability); assertEquals(Collections.singletonList(capability), capabilitiesMetaData.getCapabilities()); ClassLoadingMetaData test2 = new ClassLoadingMetaData(); testEquals(test, test2, false); test2.getCapabilities().addCapability(capability); testEquals(test, test2, true); } public void testRequirements() throws Exception { ClassLoadingMetaDataFactory factory = ClassLoadingMetaDataFactory.getInstance(); ClassLoadingMetaData test = new ClassLoadingMetaData(); RequirementsMetaData requirementsMetaData = test.getRequirements(); assertNull(requirementsMetaData.getRequirements()); Requirement requirement = factory.createRequireModule("test"); requirementsMetaData.addRequirement(requirement); assertEquals(Collections.singletonList(requirement), requirementsMetaData.getRequirements()); ClassLoadingMetaData test2 = new ClassLoadingMetaData(); testEquals(test, test2, false); test2.getRequirements().addRequirement(requirement); testEquals(test, test2, true); } public void testSerialization() throws Exception { ClassLoadingMetaDataFactory factory = ClassLoadingMetaDataFactory.getInstance(); ClassLoadingMetaData test = new ClassLoadingMetaData(); test.setName("test"); test.setVersion("1.0.0"); test.setDomain("domain"); test.setParentDomain("parent-domain"); test.setExportAll(ExportAll.ALL); test.setImportAll(true); test.setJ2seClassLoadingCompliance(false); test.getCapabilities().addCapability(factory.createModule("module", "1.0.0")); test.getCapabilities().addCapability(factory.createPackage("package", "1.0.0")); test.getRequirements().addRequirement(factory.createRequireModule("module", new VersionRange("1.0.0", "2.0.0"))); test.getRequirements().addRequirement(factory.createRequireModule("package", new VersionRange("1.0.0", "2.0.0"))); ClassLoadingMetaData other = serializeDeserialize(test, ClassLoadingMetaData.class); assertEquals(test, other); } protected void testEquals(ClassLoadingMetaData test1, ClassLoadingMetaData test2, boolean result) { if (result) { assertTrue("Expected " + test1 + ".equals(" + test2 + ") to be true", test1.equals(test2)); assertTrue("Expected " + test2 + ".equals(" + test1 + ") to be true", test2.equals(test1)); } else { assertFalse("Expected " + test1 + ".equals(" + test2 + ") to be false", test1.equals(test2)); assertFalse("Expected " + test2 + ".equals(" + test1 + ") to be false", test2.equals(test1)); } } } ././@LongLink0000000000000000000000000000021700000000000011565 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloading/src/test/java/org/jboss/test/classloading/metadata/test/ModuleCapabilityUnitTestCase.javalibjboss-classloader-java-2.0.6.GA.orig/classloading/src/test/java/org/jboss/test/classloading/metad0000644000175000017500000001223110756304141033422 0ustar twernertwerner/* * JBoss, Home of Professional Open Source. * Copyright 2008, Red Hat Middleware LLC, and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.test.classloading.metadata.test; import junit.framework.Test; import org.jboss.classloading.plugins.metadata.ModuleCapability; import org.jboss.classloading.spi.version.Version; import org.jboss.test.classloading.AbstractClassLoadingTestWithSecurity; /** * ModuleCapabilityUnitTestCase. * * @author Adrian Brock * @version $Revision: 1.1 $ */ public class ModuleCapabilityUnitTestCase extends AbstractClassLoadingTestWithSecurity { public static Test suite() { return suite(ModuleCapabilityUnitTestCase.class); } public ModuleCapabilityUnitTestCase(String name) { super(name); } public void testConstructors() throws Exception { ModuleCapability test = new ModuleCapability(); assertNotNull(test.getName()); assertEquals(Version.DEFAULT_VERSION, test.getVersion()); test = new ModuleCapability("test"); assertEquals("test", test.getName()); assertEquals(Version.DEFAULT_VERSION, test.getVersion()); test = new ModuleCapability("test", "version"); assertEquals("test", test.getName()); assertEquals("version", test.getVersion()); try { fail("Should not be here for: " + new ModuleCapability(null)); } catch (Throwable t) { checkDeepThrowable(IllegalArgumentException.class, t); } try { fail("Should not be here for: " + new ModuleCapability(null, "version")); } catch (Throwable t) { checkDeepThrowable(IllegalArgumentException.class, t); } } public void testSetName() throws Exception { ModuleCapability test = new ModuleCapability(); assertNotNull(test.getName()); assertEquals(Version.DEFAULT_VERSION, test.getVersion()); test.setName("name"); assertEquals("name", test.getName()); assertEquals(Version.DEFAULT_VERSION, test.getVersion()); test = new ModuleCapability(); try { test.setName(null); } catch (Throwable t) { checkDeepThrowable(IllegalArgumentException.class, t); } } public void testSetVersion() throws Exception { ModuleCapability test = new ModuleCapability(); assertNotNull(test.getName()); assertEquals(Version.DEFAULT_VERSION, test.getVersion()); test.setVersion("version"); assertNotNull(test.getName()); assertEquals("version", test.getVersion()); test.setVersion(null); assertNotNull(test.getName()); assertEquals(Version.DEFAULT_VERSION, test.getVersion()); } public void testEquals() throws Exception { testEquals("a", Version.DEFAULT_VERSION, "a", Version.DEFAULT_VERSION, true); testEquals("a", Version.DEFAULT_VERSION, "a", null, true); testEquals("a", Version.DEFAULT_VERSION, "a", "0.0.0", true); testEquals("b", "1.0.0", "b", "1.0.0", true); testEquals("a", Version.DEFAULT_VERSION, "b", Version.DEFAULT_VERSION, false); testEquals("a", "1.0.0", "a", Version.DEFAULT_VERSION, false); testEquals("a", "1.0.0", "a", "0.0.0", false); testEquals("a", "1.0.0", "a", "2.0.0", false); } public void testSerialization() throws Exception { ModuleCapability test = new ModuleCapability("a", Version.DEFAULT_VERSION); ModuleCapability other = serializeDeserialize(test, ModuleCapability.class); assertEquals(test, other); } protected void testEquals(String name1, Object version1, String name2, Object version2, boolean result) { ModuleCapability test1 = new ModuleCapability(name1, version1); ModuleCapability test2 = new ModuleCapability(name2, version2); if (result) { assertTrue("Expected " + test1 + ".equals(" + test2 + ") to be true", test1.equals(test2)); assertTrue("Expected " + test2 + ".equals(" + test1 + ") to be true", test2.equals(test1)); } else { assertFalse("Expected " + test1 + ".equals(" + test2 + ") to be false", test1.equals(test2)); assertFalse("Expected " + test2 + ".equals(" + test1 + ") to be false", test2.equals(test1)); } } } ././@LongLink0000000000000000000000000000023200000000000011562 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloading/src/test/java/org/jboss/test/classloading/metadata/test/ClassLoadingMetaDataFactoryUnitTestCase.javalibjboss-classloader-java-2.0.6.GA.orig/classloading/src/test/java/org/jboss/test/classloading/metad0000644000175000017500000002256010761314167033435 0ustar twernertwerner/* * JBoss, Home of Professional Open Source. * Copyright 2008, Red Hat Middleware LLC, and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.test.classloading.metadata.test; import junit.framework.Test; import org.jboss.classloading.plugins.metadata.ModuleCapability; import org.jboss.classloading.plugins.metadata.ModuleRequirement; import org.jboss.classloading.plugins.metadata.PackageCapability; import org.jboss.classloading.plugins.metadata.PackageRequirement; import org.jboss.classloading.plugins.metadata.UsesPackageRequirement; import org.jboss.classloading.spi.metadata.Capability; import org.jboss.classloading.spi.metadata.ClassLoadingMetaDataFactory; import org.jboss.classloading.spi.metadata.Requirement; import org.jboss.classloading.spi.version.VersionRange; import org.jboss.test.classloading.AbstractClassLoadingTestWithSecurity; /** * ClassLoadingMetaDataFactoryUnitTestCase. * * @author Adrian Brock * @version $Revision: 1.1 $ */ public class ClassLoadingMetaDataFactoryUnitTestCase extends AbstractClassLoadingTestWithSecurity { public static Test suite() { return suite(ClassLoadingMetaDataFactoryUnitTestCase.class); } public ClassLoadingMetaDataFactoryUnitTestCase(String name) { super(name); } public void testCreateModuleNoVersion() throws Exception { ClassLoadingMetaDataFactory factory = ClassLoadingMetaDataFactory.getInstance(); Capability test = factory.createModule("test"); assertEquals(new ModuleCapability("test"), test); } public void testCreateModuleVersioned() throws Exception { ClassLoadingMetaDataFactory factory = ClassLoadingMetaDataFactory.getInstance(); Capability test = factory.createModule("test", "1.0.0"); assertEquals(new ModuleCapability("test", "1.0.0"), test); } public void testCreatePackageNoVersion() throws Exception { ClassLoadingMetaDataFactory factory = ClassLoadingMetaDataFactory.getInstance(); Capability test = factory.createPackage("test"); assertEquals(new PackageCapability("test"), test); } public void testCreatePackageVersioned() throws Exception { ClassLoadingMetaDataFactory factory = ClassLoadingMetaDataFactory.getInstance(); Capability test = factory.createPackage("test", "1.0.0"); assertEquals(new PackageCapability("test", "1.0.0"), test); } public void testCreateRequireModuleNoVersion() throws Exception { ClassLoadingMetaDataFactory factory = ClassLoadingMetaDataFactory.getInstance(); Requirement test = factory.createRequireModule("test"); assertEquals(new ModuleRequirement("test"), test); } public void testCreateRequireModuleVersioned() throws Exception { ClassLoadingMetaDataFactory factory = ClassLoadingMetaDataFactory.getInstance(); VersionRange range = new VersionRange("1.0.0", "2.0.0"); Requirement test = factory.createRequireModule("test", range); assertEquals(new ModuleRequirement("test", range), test); } public void testCreateRequireModuleVersionedOptionalReExportDynamic() throws Exception { ClassLoadingMetaDataFactory factory = ClassLoadingMetaDataFactory.getInstance(); VersionRange range = new VersionRange("1.0.0", "2.0.0"); Requirement test = factory.createRequireModule("test", range, true, true, true); ModuleRequirement expected = new ModuleRequirement("test", range); expected.setOptional(true); expected.setReExport(true); expected.setDynamic(true); assertEquals(expected, test); } public void testCreateReExportModuleNoVersion() throws Exception { ClassLoadingMetaDataFactory factory = ClassLoadingMetaDataFactory.getInstance(); Requirement test = factory.createReExportModule("test"); ModuleRequirement expected = new ModuleRequirement("test"); expected.setReExport(true); assertEquals(expected, test); } public void testCreateReExportModuleVersioned() throws Exception { ClassLoadingMetaDataFactory factory = ClassLoadingMetaDataFactory.getInstance(); VersionRange range = new VersionRange("1.0.0", "2.0.0"); Requirement test = factory.createReExportModule("test", range); ModuleRequirement expected = new ModuleRequirement("test", range); expected.setReExport(true); assertEquals(expected, test); } public void testCreateReExportModuleVersionedOptional() throws Exception { ClassLoadingMetaDataFactory factory = ClassLoadingMetaDataFactory.getInstance(); VersionRange range = new VersionRange("1.0.0", "2.0.0"); Requirement test = factory.createReExportModule("test", range, true); ModuleRequirement expected = new ModuleRequirement("test", range); expected.setOptional(true); expected.setReExport(true); assertEquals(expected, test); } public void testCreateRequirePackageNoVersion() throws Exception { ClassLoadingMetaDataFactory factory = ClassLoadingMetaDataFactory.getInstance(); Requirement test = factory.createRequirePackage("test"); assertEquals(new PackageRequirement("test"), test); } public void testCreateRequirePackageVersioned() throws Exception { ClassLoadingMetaDataFactory factory = ClassLoadingMetaDataFactory.getInstance(); VersionRange range = new VersionRange("1.0.0", "2.0.0"); Requirement test = factory.createRequirePackage("test", range); assertEquals(new PackageRequirement("test", range), test); } public void testCreateRequirePackageVersionedOptionalReExportDynamic() throws Exception { ClassLoadingMetaDataFactory factory = ClassLoadingMetaDataFactory.getInstance(); VersionRange range = new VersionRange("1.0.0", "2.0.0"); Requirement test = factory.createRequirePackage("test", range, true, true, true); PackageRequirement expected = new PackageRequirement("test", range); expected.setOptional(true); expected.setReExport(true); expected.setDynamic(true); assertEquals(expected, test); } public void testCreateReExportPackageNoVersion() throws Exception { ClassLoadingMetaDataFactory factory = ClassLoadingMetaDataFactory.getInstance(); Requirement test = factory.createReExportPackage("test"); PackageRequirement expected = new PackageRequirement("test"); expected.setReExport(true); assertEquals(expected, test); } public void testCreateReExportPackageVersioned() throws Exception { ClassLoadingMetaDataFactory factory = ClassLoadingMetaDataFactory.getInstance(); VersionRange range = new VersionRange("1.0.0", "2.0.0"); Requirement test = factory.createReExportPackage("test", range); PackageRequirement expected = new PackageRequirement("test", range); expected.setReExport(true); assertEquals(expected, test); } public void testCreateReExportPackageVersionedOptional() throws Exception { ClassLoadingMetaDataFactory factory = ClassLoadingMetaDataFactory.getInstance(); VersionRange range = new VersionRange("1.0.0", "2.0.0"); Requirement test = factory.createReExportPackage("test", range, true); PackageRequirement expected = new PackageRequirement("test", range); expected.setOptional(true); expected.setReExport(true); assertEquals(expected, test); } public void testCreateUsesPackageNoVersion() throws Exception { ClassLoadingMetaDataFactory factory = ClassLoadingMetaDataFactory.getInstance(); Requirement test = factory.createUsesPackage("test"); UsesPackageRequirement expected = new UsesPackageRequirement("test"); assertEquals(expected, test); } public void testCreateUsesPackageVersioned() throws Exception { ClassLoadingMetaDataFactory factory = ClassLoadingMetaDataFactory.getInstance(); VersionRange range = new VersionRange("1.0.0", "2.0.0"); Requirement test = factory.createUsesPackage("test", range); UsesPackageRequirement expected = new UsesPackageRequirement("test", range); assertEquals(expected, test); } public void testCreateUsesPackageVersionedOptional() throws Exception { ClassLoadingMetaDataFactory factory = ClassLoadingMetaDataFactory.getInstance(); VersionRange range = new VersionRange("1.0.0", "2.0.0"); Requirement test = factory.createUsesPackage("test", range, true); UsesPackageRequirement expected = new UsesPackageRequirement("test", range); expected.setReExport(true); assertEquals(expected, test); } } ././@LongLink0000000000000000000000000000022200000000000011561 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloading/src/test/java/org/jboss/test/classloading/metadata/test/NameAndVersionRangeUnitTestCase.javalibjboss-classloader-java-2.0.6.GA.orig/classloading/src/test/java/org/jboss/test/classloading/metad0000644000175000017500000001310610756304141033424 0ustar twernertwerner/* * JBoss, Home of Professional Open Source. * Copyright 2008, Red Hat Middleware LLC, and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.test.classloading.metadata.test; import junit.framework.Test; import org.jboss.classloading.spi.helpers.NameAndVersionRangeSupport; import org.jboss.classloading.spi.version.VersionRange; import org.jboss.test.classloading.AbstractClassLoadingTestWithSecurity; /** * NameAndVersionRangeUnitTestCase. * * @author Adrian Brock * @version $Revision: 1.1 $ */ public class NameAndVersionRangeUnitTestCase extends AbstractClassLoadingTestWithSecurity { public static Test suite() { return suite(NameAndVersionRangeUnitTestCase.class); } public NameAndVersionRangeUnitTestCase(String name) { super(name); } public void testConstructors() throws Exception { NameAndVersionRangeSupport test = new NameAndVersionRangeSupport(); assertNotNull(test.getName()); assertEquals(VersionRange.ALL_VERSIONS, test.getVersionRange()); test = new NameAndVersionRangeSupport("test"); assertEquals("test", test.getName()); assertEquals(VersionRange.ALL_VERSIONS, test.getVersionRange()); VersionRange range = new VersionRange("1.0.0", "2.0.0"); test = new NameAndVersionRangeSupport("test", range); assertEquals("test", test.getName()); assertEquals(range, test.getVersionRange()); try { fail("Should not be here for: " + new NameAndVersionRangeSupport(null)); } catch (Throwable t) { checkDeepThrowable(IllegalArgumentException.class, t); } try { fail("Should not be here for: " + new NameAndVersionRangeSupport(null, range)); } catch (Throwable t) { checkDeepThrowable(IllegalArgumentException.class, t); } } public void testSetName() throws Exception { NameAndVersionRangeSupport test = new NameAndVersionRangeSupport(); assertNotNull(test.getName()); assertEquals(VersionRange.ALL_VERSIONS, test.getVersionRange()); test.setName("name"); assertEquals("name", test.getName()); assertEquals(VersionRange.ALL_VERSIONS, test.getVersionRange()); test = new NameAndVersionRangeSupport(); try { test.setName(null); } catch (Throwable t) { checkDeepThrowable(IllegalArgumentException.class, t); } } public void testSetVersionRange() throws Exception { NameAndVersionRangeSupport test = new NameAndVersionRangeSupport(); assertNotNull(test.getName()); assertEquals(VersionRange.ALL_VERSIONS, test.getVersionRange()); VersionRange range = new VersionRange("1.0.0", "2.0.0"); test.setVersionRange(range); assertNotNull(test.getName()); assertEquals(range, test.getVersionRange()); test.setVersionRange(null); assertNotNull(test.getName()); assertEquals(VersionRange.ALL_VERSIONS, test.getVersionRange()); } public void testEquals() throws Exception { testEquals("a", VersionRange.ALL_VERSIONS, "a", VersionRange.ALL_VERSIONS, true); testEquals("a", VersionRange.ALL_VERSIONS, "a", null, true); VersionRange range1 = new VersionRange("1.0.0", true, "1.0.0", true); testEquals("b", range1, "b", range1, true); testEquals("a", VersionRange.ALL_VERSIONS, "b", VersionRange.ALL_VERSIONS, false); testEquals("a", range1, "a", VersionRange.ALL_VERSIONS, false); VersionRange range2 = new VersionRange("1.0.0", true, "2.0.0", true); testEquals("a", range1, "a", range2, false); } public void testSerialization() throws Exception { NameAndVersionRangeSupport test = new NameAndVersionRangeSupport("a", VersionRange.ALL_VERSIONS); NameAndVersionRangeSupport other = serializeDeserialize(test, NameAndVersionRangeSupport.class); assertEquals(test, other); } protected void testEquals(String name1, VersionRange range1, String name2, VersionRange range2, boolean result) { NameAndVersionRangeSupport test1 = new NameAndVersionRangeSupport(name1, range1); NameAndVersionRangeSupport test2 = new NameAndVersionRangeSupport(name2, range2); if (result) { assertTrue("Expected " + test1 + ".equals(" + test2 + ") to be true", test1.equals(test2)); assertTrue("Expected " + test2 + ".equals(" + test1 + ") to be true", test2.equals(test1)); } else { assertFalse("Expected " + test1 + ".equals(" + test2 + ") to be false", test1.equals(test2)); assertFalse("Expected " + test2 + ".equals(" + test1 + ") to be false", test2.equals(test1)); } } } ././@LongLink0000000000000000000000000000022000000000000011557 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloading/src/test/java/org/jboss/test/classloading/metadata/test/PackageCapabilityUnitTestCase.javalibjboss-classloader-java-2.0.6.GA.orig/classloading/src/test/java/org/jboss/test/classloading/metad0000644000175000017500000001226110756304141033425 0ustar twernertwerner/* * JBoss, Home of Professional Open Source. * Copyright 2008, Red Hat Middleware LLC, and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.test.classloading.metadata.test; import junit.framework.Test; import org.jboss.classloading.plugins.metadata.PackageCapability; import org.jboss.classloading.spi.version.Version; import org.jboss.test.classloading.AbstractClassLoadingTestWithSecurity; /** * PackageCapabilityUnitTestCase. * * @author Adrian Brock * @version $Revision: 1.1 $ */ public class PackageCapabilityUnitTestCase extends AbstractClassLoadingTestWithSecurity { public static Test suite() { return suite(PackageCapabilityUnitTestCase.class); } public PackageCapabilityUnitTestCase(String name) { super(name); } public void testConstructors() throws Exception { PackageCapability test = new PackageCapability(); assertNotNull(test.getName()); assertEquals(Version.DEFAULT_VERSION, test.getVersion()); test = new PackageCapability("test"); assertEquals("test", test.getName()); assertEquals(Version.DEFAULT_VERSION, test.getVersion()); test = new PackageCapability("test", "version"); assertEquals("test", test.getName()); assertEquals("version", test.getVersion()); try { fail("Should not be here for: " + new PackageCapability(null)); } catch (Throwable t) { checkDeepThrowable(IllegalArgumentException.class, t); } try { fail("Should not be here for: " + new PackageCapability(null, "version")); } catch (Throwable t) { checkDeepThrowable(IllegalArgumentException.class, t); } } public void testSetName() throws Exception { PackageCapability test = new PackageCapability(); assertNotNull(test.getName()); assertEquals(Version.DEFAULT_VERSION, test.getVersion()); test.setName("name"); assertEquals("name", test.getName()); assertEquals(Version.DEFAULT_VERSION, test.getVersion()); test = new PackageCapability(); try { test.setName(null); } catch (Throwable t) { checkDeepThrowable(IllegalArgumentException.class, t); } } public void testSetVersion() throws Exception { PackageCapability test = new PackageCapability(); assertNotNull(test.getName()); assertEquals(Version.DEFAULT_VERSION, test.getVersion()); test.setVersion("version"); assertNotNull(test.getName()); assertEquals("version", test.getVersion()); test.setVersion(null); assertNotNull(test.getName()); assertEquals(Version.DEFAULT_VERSION, test.getVersion()); } public void testEquals() throws Exception { testEquals("a", Version.DEFAULT_VERSION, "a", Version.DEFAULT_VERSION, true); testEquals("a", Version.DEFAULT_VERSION, "a", null, true); testEquals("a", Version.DEFAULT_VERSION, "a", "0.0.0", true); testEquals("b", "1.0.0", "b", "1.0.0", true); testEquals("a", Version.DEFAULT_VERSION, "b", Version.DEFAULT_VERSION, false); testEquals("a", "1.0.0", "a", Version.DEFAULT_VERSION, false); testEquals("a", "1.0.0", "a", "0.0.0", false); testEquals("a", "1.0.0", "a", "2.0.0", false); } public void testSerialization() throws Exception { PackageCapability test = new PackageCapability("a", Version.DEFAULT_VERSION); PackageCapability other = serializeDeserialize(test, PackageCapability.class); assertEquals(test, other); } protected void testEquals(String name1, Object version1, String name2, Object version2, boolean result) { PackageCapability test1 = new PackageCapability(name1, version1); PackageCapability test2 = new PackageCapability(name2, version2); if (result) { assertTrue("Expected " + test1 + ".equals(" + test2 + ") to be true", test1.equals(test2)); assertTrue("Expected " + test2 + ".equals(" + test1 + ") to be true", test2.equals(test1)); } else { assertFalse("Expected " + test1 + ".equals(" + test2 + ") to be false", test1.equals(test2)); assertFalse("Expected " + test2 + ".equals(" + test1 + ") to be false", test2.equals(test1)); } } } ././@LongLink0000000000000000000000000000024000000000000011561 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloading/src/test/java/org/jboss/test/classloading/metadata/test/ManagedObjectClassLoadingMetaDataUnitTestCase.javalibjboss-classloader-java-2.0.6.GA.orig/classloading/src/test/java/org/jboss/test/classloading/metad0000644000175000017500000002310411173151646033427 0ustar twernertwerner/* * JBoss, Home of Professional Open Source. * Copyright 2008, Red Hat Middleware LLC, and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.test.classloading.metadata.test; import java.util.Arrays; import java.util.List; import java.util.Set; import junit.framework.Test; import org.jboss.classloading.spi.metadata.CapabilitiesMetaData; import org.jboss.classloading.spi.metadata.ClassLoadingMetaData; import org.jboss.classloading.spi.metadata.ClassLoadingMetaDataFactory; import org.jboss.classloading.spi.metadata.ExportAll; import org.jboss.classloading.spi.metadata.RequirementsMetaData; import org.jboss.classloading.spi.version.Version; import org.jboss.managed.api.ManagedObject; import org.jboss.managed.api.ManagedProperty; import org.jboss.managed.api.factory.ManagedObjectFactory; import org.jboss.metatype.api.types.MetaType; import org.jboss.metatype.api.types.MetaTypeFactory; import org.jboss.metatype.api.values.MetaValue; import org.jboss.metatype.api.values.MetaValueFactory; import org.jboss.test.BaseTestCase; /** * ManagedObjectClassLoadingMetaDataUnitTestCase. * * @author Adrian Brock * @version $Revision: 1.1 $ */ public class ManagedObjectClassLoadingMetaDataUnitTestCase extends BaseTestCase { private ManagedObjectFactory moFactory = ManagedObjectFactory.getInstance(); private MetaTypeFactory mtFactory = MetaTypeFactory.getInstance(); private MetaValueFactory mvFactory = MetaValueFactory.getInstance(); public static Test suite() { return suite(ManagedObjectClassLoadingMetaDataUnitTestCase.class); } public ManagedObjectClassLoadingMetaDataUnitTestCase(String name) { super(name); } protected ManagedObject assertManagedObject(ClassLoadingMetaData test) { ManagedObject result = moFactory.initManagedObject(test, null, null); assertNotNull(result); List expectedProperties = Arrays.asList("name", "version", "domain", "parentDomain", "exportAll", "included", "excluded", "excludedExport", "importAll", "parentFirst", "cache", "blackList", "capabilities", "requirements"); Set actualProperties = result.getPropertyNames(); for (String expected : expectedProperties) { if (actualProperties.contains(expected) == false) fail("Expected property: " + expected); } for (String actual : actualProperties) { if (expectedProperties.contains(actual) == false) fail("Did not expect property: " + actual); } return result; } protected ManagedProperty assertManagedProperty(ManagedObject mo, String name, MetaType metaType, MetaValue metaValue) { ManagedProperty property = mo.getProperty(name); assertNotNull("No property " + name, property); assertEquals(metaType, property.getMetaType()); assertEquals(metaValue, property.getValue()); return property; } protected ManagedProperty assertManagedProperty(ManagedObject mo, String name, Class type, T value) { MetaType metaType = mtFactory.resolve(type); MetaValue metaValue = null; if (value != null) metaValue = mvFactory.create(value); return assertManagedProperty(mo, name, metaType, metaValue); } public void testConstructor() throws Exception { ClassLoadingMetaData test = new ClassLoadingMetaData(); ManagedObject mo = assertManagedObject(test); assertManagedProperty(mo, "name", String.class, ""); assertManagedProperty(mo, "version", Version.class, Version.DEFAULT_VERSION); assertManagedProperty(mo, "domain", String.class, null); assertManagedProperty(mo, "parentDomain", String.class, null); assertManagedProperty(mo, "exportAll", ExportAll.class, null); assertManagedProperty(mo, "included", String.class, null); assertManagedProperty(mo, "excluded", String.class, null); assertManagedProperty(mo, "excludedExport", String.class, null); assertManagedProperty(mo, "importAll", boolean.class, false); assertManagedProperty(mo, "parentFirst", boolean.class, true); assertManagedProperty(mo, "capabilities", CapabilitiesMetaData.class, new CapabilitiesMetaData()); assertManagedProperty(mo, "requirements", RequirementsMetaData.class, new RequirementsMetaData()); } public void testSetName() throws Exception { ClassLoadingMetaData test = new ClassLoadingMetaData(); test.setName("test"); ManagedObject mo = assertManagedObject(test); assertManagedProperty(mo, "name", String.class, "test"); } public void testSetVersion() throws Exception { ClassLoadingMetaData test = new ClassLoadingMetaData(); test.setVersion("1.0.0"); ManagedObject mo = assertManagedObject(test); assertManagedProperty(mo, "version", Version.class, Version.parseVersion("1.0.0")); } public void testSetDomain() throws Exception { ClassLoadingMetaData test = new ClassLoadingMetaData(); test.setDomain("domain"); ManagedObject mo = assertManagedObject(test); assertManagedProperty(mo, "domain", String.class, "domain"); } public void testSetParentDomain() throws Exception { ClassLoadingMetaData test = new ClassLoadingMetaData(); test.setParentDomain("parentDomain"); ManagedObject mo = assertManagedObject(test); assertManagedProperty(mo, "parentDomain", String.class, "parentDomain"); } public void testSetExportAll() throws Exception { ClassLoadingMetaData test = new ClassLoadingMetaData(); test.setExportAll(ExportAll.ALL); ManagedObject mo = assertManagedObject(test); assertManagedProperty(mo, "exportAll", ExportAll.class, ExportAll.ALL); } public void testSetIncludedPackages() throws Exception { ClassLoadingMetaData test = new ClassLoadingMetaData(); test.setIncludedPackages("Included"); ManagedObject mo = assertManagedObject(test); assertManagedProperty(mo, "included", String.class, "Included"); } public void testSetExcludedPackages() throws Exception { ClassLoadingMetaData test = new ClassLoadingMetaData(); test.setExcludedPackages("Excluded"); ManagedObject mo = assertManagedObject(test); assertManagedProperty(mo, "excluded", String.class, "Excluded"); } public void testSetExcludedExportPackages() throws Exception { ClassLoadingMetaData test = new ClassLoadingMetaData(); test.setExcludedExportPackages("ExcludedExport"); ManagedObject mo = assertManagedObject(test); assertManagedProperty(mo, "excludedExport", String.class, "ExcludedExport"); } public void testSetImportAll() throws Exception { ClassLoadingMetaData test = new ClassLoadingMetaData(); test.setImportAll(true); ManagedObject mo = assertManagedObject(test); assertManagedProperty(mo, "importAll", boolean.class, true); } public void testJ2seClassLoadingComplaince() throws Exception { ClassLoadingMetaData test = new ClassLoadingMetaData(); test.setJ2seClassLoadingCompliance(false); ManagedObject mo = assertManagedObject(test); assertManagedProperty(mo, "parentFirst", boolean.class, false); } public void testCacheable() throws Exception { ClassLoadingMetaData test = new ClassLoadingMetaData(); test.setCacheable(false); ManagedObject mo = assertManagedObject(test); assertManagedProperty(mo, "cache", boolean.class, false); } public void testBlackList() throws Exception { ClassLoadingMetaData test = new ClassLoadingMetaData(); test.setBlackListable(false); ManagedObject mo = assertManagedObject(test); assertManagedProperty(mo, "blackList", boolean.class, false); } public void testCapabilities() throws Exception { ClassLoadingMetaDataFactory factory = ClassLoadingMetaDataFactory.getInstance(); ClassLoadingMetaData test = new ClassLoadingMetaData(); test.getCapabilities().addCapability(factory.createModule("module")); test.getCapabilities().addCapability(factory.createPackage("package")); ManagedObject mo = assertManagedObject(test); assertManagedProperty(mo, "requirements", RequirementsMetaData.class, test.getRequirements()); } public void testRequirements() throws Exception { ClassLoadingMetaDataFactory factory = ClassLoadingMetaDataFactory.getInstance(); ClassLoadingMetaData test = new ClassLoadingMetaData(); test.getRequirements().addRequirement(factory.createRequireModule("module")); test.getRequirements().addRequirement(factory.createRequirePackage("package")); ManagedObject mo = assertManagedObject(test); assertManagedProperty(mo, "requirements", RequirementsMetaData.class, test.getRequirements()); } } ././@LongLink0000000000000000000000000000017700000000000011572 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloading/src/test/java/org/jboss/test/classloading/metadata/MetaDataTestSuite.javalibjboss-classloader-java-2.0.6.GA.orig/classloading/src/test/java/org/jboss/test/classloading/metad0000644000175000017500000000667210757515224033445 0ustar twernertwerner/* * JBoss, Home of Professional Open Source. * Copyright 2008, Red Hat Middleware LLC, and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.test.classloading.metadata; import junit.framework.Test; import junit.framework.TestSuite; import junit.textui.TestRunner; import org.jboss.test.classloading.metadata.test.CapabilitiesMetaDataUnitTestCase; import org.jboss.test.classloading.metadata.test.ClassLoadingMetaDataFactoryUnitTestCase; import org.jboss.test.classloading.metadata.test.ClassLoadingMetaDataUnitTestCase; import org.jboss.test.classloading.metadata.test.ManagedObjectClassLoadingMetaDataUnitTestCase; import org.jboss.test.classloading.metadata.test.ModuleCapabilityUnitTestCase; import org.jboss.test.classloading.metadata.test.ModuleRequirementUnitTestCase; import org.jboss.test.classloading.metadata.test.NameAndVersionRangeUnitTestCase; import org.jboss.test.classloading.metadata.test.NameAndVersionUnitTestCase; import org.jboss.test.classloading.metadata.test.PackageCapabilityUnitTestCase; import org.jboss.test.classloading.metadata.test.PackageRequirementUnitTestCase; import org.jboss.test.classloading.metadata.test.RequirementsMetaDataUnitTestCase; import org.jboss.test.classloading.metadata.xml.test.ClassLoadingMetaDataXmlUnitTestCase; /** * Version Test Suite. * * @author Adrian Brock * @version $Revision: 37459 $ */ public class MetaDataTestSuite extends TestSuite { /** * For running the testsuite from the command line * * @param args the command line args */ public static void main(String[] args) { TestRunner.run(suite()); } /** * Create the testsuite * * @return the testsuite */ public static Test suite() { TestSuite suite = new TestSuite("MetaData Tests"); suite.addTest(NameAndVersionUnitTestCase.suite()); suite.addTest(NameAndVersionRangeUnitTestCase.suite()); suite.addTest(ModuleCapabilityUnitTestCase.suite()); suite.addTest(PackageRequirementUnitTestCase.suite()); suite.addTest(ModuleRequirementUnitTestCase.suite()); suite.addTest(PackageCapabilityUnitTestCase.suite()); suite.addTest(CapabilitiesMetaDataUnitTestCase.suite()); suite.addTest(RequirementsMetaDataUnitTestCase.suite()); suite.addTest(ClassLoadingMetaDataFactoryUnitTestCase.suite()); suite.addTest(ClassLoadingMetaDataUnitTestCase.suite()); suite.addTest(ManagedObjectClassLoadingMetaDataUnitTestCase.suite()); suite.addTest(ClassLoadingMetaDataXmlUnitTestCase.suite()); return suite; } } ././@LongLink0000000000000000000000000000015500000000000011566 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloading/src/test/java/org/jboss/test/classloading/metadata/xml/libjboss-classloader-java-2.0.6.GA.orig/classloading/src/test/java/org/jboss/test/classloading/metad0000755000175000017500000000000011620043417033416 5ustar twernertwerner././@LongLink0000000000000000000000000000016200000000000011564 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloading/src/test/java/org/jboss/test/classloading/metadata/xml/test/libjboss-classloader-java-2.0.6.GA.orig/classloading/src/test/java/org/jboss/test/classloading/metad0000755000175000017500000000000011620043417033416 5ustar twernertwerner././@LongLink0000000000000000000000000000023200000000000011562 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloading/src/test/java/org/jboss/test/classloading/metadata/xml/test/ClassLoadingMetaDataXmlUnitTestCase.javalibjboss-classloader-java-2.0.6.GA.orig/classloading/src/test/java/org/jboss/test/classloading/metad0000644000175000017500000003453210761314167033437 0ustar twernertwerner/* * JBoss, Home of Professional Open Source. * Copyright 2008, Red Hat Middleware LLC, and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.test.classloading.metadata.xml.test; import java.util.ArrayList; import java.util.List; import junit.framework.Test; import org.jboss.classloading.spi.metadata.Capability; import org.jboss.classloading.spi.metadata.ClassLoadingMetaData; import org.jboss.classloading.spi.metadata.ClassLoadingMetaData10; import org.jboss.classloading.spi.metadata.ClassLoadingMetaDataFactory; import org.jboss.classloading.spi.metadata.ExportAll; import org.jboss.classloading.spi.metadata.Requirement; import org.jboss.classloading.spi.version.Version; import org.jboss.classloading.spi.version.VersionRange; import org.jboss.test.classloading.metadata.xml.AbstractJBossXBTest; import org.jboss.test.classloading.metadata.xml.support.TestCapability; import org.jboss.test.classloading.metadata.xml.support.TestRequirement; /** * ClassLoadingMetaDataXmlUnitTestCase. * * @author Adrian Brock * @version $Revision: 1.1 $ */ public class ClassLoadingMetaDataXmlUnitTestCase extends AbstractJBossXBTest { public static Test suite() { return suite(ClassLoadingMetaDataXmlUnitTestCase.class); } public ClassLoadingMetaDataXmlUnitTestCase(String name) { super(name); } public void testModuleName() throws Exception { ClassLoadingMetaData result = unmarshal(); assertEquals("test", result.getName()); assertEquals(Version.DEFAULT_VERSION, result.getVersion()); assertNull(result.getDomain()); assertNull(result.getParentDomain()); assertNull(result.getExportAll()); assertNull(result.getIncludedPackages()); assertNull(result.getExcludedPackages()); assertNull(result.getExcludedExportPackages()); assertFalse(result.isImportAll()); assertTrue(result.isJ2seClassLoadingCompliance()); assertTrue(result.isCacheable()); assertTrue(result.isBlackListable()); assertNull(result.getCapabilities().getCapabilities()); assertNull(result.getRequirements().getRequirements()); } public void testModuleVersion() throws Exception { ClassLoadingMetaData result = unmarshal(); assertEquals(Version.parseVersion("1.0.0"), result.getVersion()); } public void testModuleDomain() throws Exception { ClassLoadingMetaData result = unmarshal(); assertEquals("testDomain", result.getDomain()); } public void testModuleParentDomain() throws Exception { ClassLoadingMetaData result = unmarshal(); assertEquals("testParentDomain", result.getParentDomain()); } public void testModuleExportAll() throws Exception { ClassLoadingMetaData result = unmarshal(); assertEquals(ExportAll.ALL, result.getExportAll()); } public void testModuleIncluded() throws Exception { ClassLoadingMetaData result = unmarshal(); assertEquals("Included", result.getIncludedPackages()); } public void testModuleExcluded() throws Exception { ClassLoadingMetaData result = unmarshal(); assertEquals("Excluded", result.getExcludedPackages()); } public void testModuleExcludedExport() throws Exception { ClassLoadingMetaData result = unmarshal(); assertEquals("ExcludedExport", result.getExcludedExportPackages()); } public void testModuleImportAll() throws Exception { ClassLoadingMetaData result = unmarshal(); assertTrue(result.isImportAll()); } public void testModuleJ2seClassLoadingCompliance() throws Exception { ClassLoadingMetaData result = unmarshal(); assertFalse(result.isJ2seClassLoadingCompliance()); } public void testModuleCache() throws Exception { ClassLoadingMetaData result = unmarshal(); assertFalse(result.isCacheable()); } public void testModuleBlackList() throws Exception { ClassLoadingMetaData result = unmarshal(); assertFalse(result.isBlackListable()); } public void testExportOneModuleNoVersion() throws Exception { ClassLoadingMetaData result = unmarshal(); ClassLoadingMetaDataFactory factory = ClassLoadingMetaDataFactory.getInstance(); assertCapabilities(result, factory.createModule("export1")); } public void testExportOneModuleVersioned() throws Exception { ClassLoadingMetaData result = unmarshal(); ClassLoadingMetaDataFactory factory = ClassLoadingMetaDataFactory.getInstance(); assertCapabilities(result, factory.createModule("export1", "1.0.0")); } public void testExportThreeModules() throws Exception { ClassLoadingMetaData result = unmarshal(); ClassLoadingMetaDataFactory factory = ClassLoadingMetaDataFactory.getInstance(); assertCapabilities(result, factory.createModule("export1", "1.0.0"), factory.createModule("export2", "2.0.0"), factory.createModule("export3", "3.0.0")); } public void testExportOnePackageNoVersion() throws Exception { ClassLoadingMetaData result = unmarshal(); ClassLoadingMetaDataFactory factory = ClassLoadingMetaDataFactory.getInstance(); assertCapabilities(result, factory.createPackage("export1")); } public void testExportOnePackageVersioned() throws Exception { ClassLoadingMetaData result = unmarshal(); ClassLoadingMetaDataFactory factory = ClassLoadingMetaDataFactory.getInstance(); assertCapabilities(result, factory.createPackage("export1", "1.0.0")); } public void testExportThreePackages() throws Exception { ClassLoadingMetaData result = unmarshal(); ClassLoadingMetaDataFactory factory = ClassLoadingMetaDataFactory.getInstance(); assertCapabilities(result, factory.createPackage("export1", "1.0.0"), factory.createPackage("export2", "2.0.0"), factory.createPackage("export3", "3.0.0")); } public void testImportOneModuleNoVersion() throws Exception { ClassLoadingMetaData result = unmarshal(); ClassLoadingMetaDataFactory factory = ClassLoadingMetaDataFactory.getInstance(); assertRequirements(result, factory.createRequireModule("export1")); } public void testImportOneModuleVersioned() throws Exception { ClassLoadingMetaData result = unmarshal(); ClassLoadingMetaDataFactory factory = ClassLoadingMetaDataFactory.getInstance(); assertRequirements(result, factory.createRequireModule("export1", new VersionRange("1.0.0", "2.0.0"))); } public void testImportThreeModules() throws Exception { ClassLoadingMetaData result = unmarshal(); ClassLoadingMetaDataFactory factory = ClassLoadingMetaDataFactory.getInstance(); assertRequirements(result, factory.createRequireModule("export1", new VersionRange("1.0.0", "1.1.0")), factory.createRequireModule("export2", new VersionRange("2.0.0", "2.1.0")), factory.createRequireModule("export3", new VersionRange("3.0.0", "3.1.0"))); } public void testImportOnePackageNoVersion() throws Exception { ClassLoadingMetaData result = unmarshal(); ClassLoadingMetaDataFactory factory = ClassLoadingMetaDataFactory.getInstance(); assertRequirements(result, factory.createRequirePackage("export1")); } public void testImportOnePackageVersioned() throws Exception { ClassLoadingMetaData result = unmarshal(); ClassLoadingMetaDataFactory factory = ClassLoadingMetaDataFactory.getInstance(); assertRequirements(result, factory.createRequirePackage("export1", new VersionRange("1.0.0", "2.0.0"))); } public void testImportThreePackages() throws Exception { ClassLoadingMetaData result = unmarshal(); ClassLoadingMetaDataFactory factory = ClassLoadingMetaDataFactory.getInstance(); assertRequirements(result, factory.createRequirePackage("export1", new VersionRange("1.0.0", "1.1.0")), factory.createRequirePackage("export2", new VersionRange("2.0.0", "2.1.0")), factory.createRequirePackage("export3", new VersionRange("3.0.0", "3.1.0"))); } public void testImportVersionRange() throws Exception { ClassLoadingMetaData result = unmarshal(); ClassLoadingMetaDataFactory factory = ClassLoadingMetaDataFactory.getInstance(); assertRequirements(result, factory.createRequireModule("export1"), factory.createRequireModule("export2", new VersionRange("1.0.0")), factory.createRequireModule("export3", new VersionRange("0.0.0", "1.0.0")), factory.createRequireModule("export4", new VersionRange("1.0.0", "2.0.0")), factory.createRequireModule("export5", new VersionRange("1.0.0", false, "2.0.0", false)), factory.createRequireModule("export6", new VersionRange("1.0.0", false, "2.0.0", true)), factory.createRequireModule("export7", new VersionRange("1.0.0", true, "2.0.0", false)), factory.createRequireModule("export8", new VersionRange("1.0.0", true, "2.0.0", true))); } public void testExportImportMixed() throws Exception { ClassLoadingMetaData result = unmarshal(); ClassLoadingMetaDataFactory factory = ClassLoadingMetaDataFactory.getInstance(); assertCapabilities(result, factory.createModule("test2", "2.0.0"), factory.createPackage("test2", "2.0.0"), factory.createModule("test1", "1.0.0"), factory.createPackage("test1", "1.0.0")); assertRequirements(result, factory.createRequireModule("test2", new VersionRange("2.0.0")), factory.createRequirePackage("test2", new VersionRange("2.0.0")), factory.createRequireModule("test1", new VersionRange("1.0.0")), factory.createRequirePackage("test1", new VersionRange("1.0.0"))); } public void testWildcardCapability() throws Exception { ClassLoadingMetaData result = unmarshal(TestCapability.class); ClassLoadingMetaDataFactory factory = ClassLoadingMetaDataFactory.getInstance(); assertCapabilities(result, factory.createModule("test1", "1.0.0"), factory.createPackage("test1", "1.0.0"), new TestCapability("test", "1.0.0")); } public void testWildcardRequirement() throws Exception { ClassLoadingMetaData result = unmarshal(TestRequirement.class); ClassLoadingMetaDataFactory factory = ClassLoadingMetaDataFactory.getInstance(); assertRequirements(result, factory.createRequireModule("test1", new VersionRange("1.0.0")), factory.createRequirePackage("test1", new VersionRange("1.0.0")), new TestRequirement("test", new VersionRange("1.0.0"))); } public void testOptionalRequirement() throws Exception { ClassLoadingMetaData result = unmarshal(TestRequirement.class); ClassLoadingMetaDataFactory factory = ClassLoadingMetaDataFactory.getInstance(); assertRequirements(result, factory.createRequireModule("test1", new VersionRange("1.0.0"), true, false, false), factory.createRequirePackage("test1", new VersionRange("1.0.0"), true, false, false)); } public void testDynamicRequirement() throws Exception { ClassLoadingMetaData result = unmarshal(TestRequirement.class); ClassLoadingMetaDataFactory factory = ClassLoadingMetaDataFactory.getInstance(); assertRequirements(result, factory.createRequireModule("test1", new VersionRange("1.0.0"), false, false, true), factory.createRequirePackage("test1", new VersionRange("1.0.0"), false, false, true)); } public void testReExportRequirement() throws Exception { ClassLoadingMetaData result = unmarshal(TestRequirement.class); ClassLoadingMetaDataFactory factory = ClassLoadingMetaDataFactory.getInstance(); assertRequirements(result, factory.createReExportModule("test1", new VersionRange("1.0.0")), factory.createReExportPackage("test1", new VersionRange("1.0.0"))); } public void testUsesRequirement() throws Exception { ClassLoadingMetaData result = unmarshal(TestRequirement.class); ClassLoadingMetaDataFactory factory = ClassLoadingMetaDataFactory.getInstance(); assertRequirements(result, factory.createUsesPackage("test1", new VersionRange("1.0.0"))); } public void assertCapabilities(ClassLoadingMetaData metadata, Capability... expected) { List temp = new ArrayList(); for (Capability capability : expected) temp.add(capability); assertEquals(temp, metadata.getCapabilities().getCapabilities()); } public void assertRequirements(ClassLoadingMetaData metadata, Requirement... expected) { List temp = new ArrayList(); for (Requirement requirement : expected) temp.add(requirement); assertEquals(temp, metadata.getRequirements().getRequirements()); } protected ClassLoadingMetaData unmarshal(Class... extra) throws Exception { return unmarshalObject(ClassLoadingMetaData10.class, ClassLoadingMetaData10.class, extra); } } ././@LongLink0000000000000000000000000000020400000000000011561 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloading/src/test/java/org/jboss/test/classloading/metadata/xml/TestSchemaResolver.javalibjboss-classloader-java-2.0.6.GA.orig/classloading/src/test/java/org/jboss/test/classloading/metad0000644000175000017500000000535511063447574033445 0ustar twernertwerner/* * JBoss, Home of Professional Open Source * Copyright 2006, JBoss Inc., and individual contributors as indicated * by the @authors tag. See the copyright.txt in the distribution for a * full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.test.classloading.metadata.xml; import java.util.HashMap; import org.jboss.logging.Logger; import org.jboss.xb.binding.sunday.unmarshalling.SchemaBinding; import org.jboss.xb.binding.sunday.unmarshalling.SchemaBindingResolver; import org.w3c.dom.ls.LSInput; /** * TestSchemaResolver. * * @author Ales Justin * @author Adrian Brock * @version $Revision: 1.1 $ */ public class TestSchemaResolver implements SchemaBindingResolver { private static final Logger log = Logger.getLogger(TestSchemaResolver.class); private HashMap bindings = new HashMap(); public String getBaseURI() { return null; } public void addSchemaBinding(SchemaBinding schemaBinding) { schemaBinding.setSchemaResolver(this); String nsURI = schemaBinding.getNamespaces().iterator().next(); bindings.put(nsURI, schemaBinding); if (log.isTraceEnabled()) { String schema = SchemaPrinter.printSchema(schemaBinding); log.trace("Bound: " + nsURI + "\n" + schema); } } public SchemaBinding resolve(String nsUri, String baseURI, String schemaLocation) { SchemaBinding result = bindings.get(nsUri); if (result == null) throw new RuntimeException("Schema not bound: " + nsUri + " available: " + bindings.keySet()); return result; } public LSInput resolveAsLSInput(String nsUri, String baseUri, String schemaLocation) { throw new UnsupportedOperationException(); } public void setBaseURI(String baseURI) { throw new org.jboss.util.NotImplementedException("setBaseURI"); } } ././@LongLink0000000000000000000000000000020500000000000011562 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloading/src/test/java/org/jboss/test/classloading/metadata/xml/JBossXBTestDelegate.javalibjboss-classloader-java-2.0.6.GA.orig/classloading/src/test/java/org/jboss/test/classloading/metad0000644000175000017500000001252610770573237033443 0ustar twernertwerner/* * JBoss, Home of Professional Open Source * Copyright 2006, JBoss Inc., and individual contributors as indicated * by the @authors tag. See the copyright.txt in the distribution for a * full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.test.classloading.metadata.xml; import java.lang.reflect.Method; import java.net.URL; import org.jboss.net.protocol.URLStreamHandlerFactory; import org.jboss.test.AbstractTestDelegate; import org.jboss.xb.binding.Unmarshaller; import org.jboss.xb.binding.UnmarshallerFactory; import org.jboss.xb.binding.sunday.unmarshalling.DefaultSchemaResolver; import org.jboss.xb.binding.sunday.unmarshalling.SchemaBinding; import org.jboss.xb.binding.sunday.unmarshalling.SchemaBindingResolver; import org.jboss.xb.binding.sunday.unmarshalling.XsdBinder; /** * JBossXBTestDelegate. * * @author Ales Justin * @author Adrian Brock * @version $Revision: 40492 $ */ public class JBossXBTestDelegate extends AbstractTestDelegate { /** Whether initialization has been done */ private static boolean done = false; /** The unmarshaller factory */ protected UnmarshallerFactory unmarshallerFactory; /** The resolver */ protected SchemaBindingResolver defaultResolver; /** * Initialize */ public synchronized static void init() { if (done) return; done = true; URL.setURLStreamHandlerFactory(new URLStreamHandlerFactory()); URLStreamHandlerFactory.preload(); String handlerPkgs = System.getProperty("java.protocol.handler.pkgs"); if (handlerPkgs != null) handlerPkgs += "|org.jboss.net.protocol"; else handlerPkgs = "org.jboss.net.protocol"; System.setProperty("java.protocol.handler.pkgs", handlerPkgs); } /** * Create a new JBossXBTestDelegate. * * @param clazz the test class */ public JBossXBTestDelegate(Class clazz) { super(clazz); } @Override public void setUp() throws Exception { super.setUp(); init(); unmarshallerFactory = UnmarshallerFactory.newInstance(); initResolver(); } protected void initResolver() throws Exception { try { Method method = clazz.getMethod("initResolver", (Class[]) null); defaultResolver = (SchemaBindingResolver) method.invoke(null, (Object[]) null); } catch (NoSuchMethodException ignored) { defaultResolver = new DefaultSchemaResolver(); } } /** * Unmarshal an object * * @param url the url * @param resolver the resolver * @return the object * @throws Exception for any error */ public Object unmarshal(String url, SchemaBindingResolver resolver) throws Exception { if (resolver == null) resolver = defaultResolver; long start = System.currentTimeMillis(); Unmarshaller unmarshaller = unmarshallerFactory.newUnmarshaller(); log.debug("Initialized parsing in " + (System.currentTimeMillis() - start) + "ms"); try { Object result = unmarshaller.unmarshal(url, resolver); log.debug("Total parse for " + url + " took " + (System.currentTimeMillis() - start) + "ms"); return result; } catch (Exception e) { log.debug("Error during parsing: " + url, e); throw e; } } /** * Unmarshal an object * * @param url the url * @param schema the schema * @return the object * @throws Exception for any error */ public Object unmarshal(String url, SchemaBinding schema) throws Exception { long start = System.currentTimeMillis(); Unmarshaller unmarshaller = unmarshallerFactory.newUnmarshaller(); log.debug("Initialized parsing in " + (System.currentTimeMillis() - start) + "ms"); try { Object result = unmarshaller.unmarshal(url, schema); log.debug("Total parse for " + url + " took " + (System.currentTimeMillis() - start) + "ms"); return result; } catch (Exception e) { log.debug("Error during parsing: " + url, e); throw e; } } /** * Bind a schema * * @param url the url * @param resolver the resolver * @return the object * @throws Exception for any error */ public SchemaBinding bind(String url, SchemaBindingResolver resolver) throws Exception { return XsdBinder.bind(url, resolver); } } ././@LongLink0000000000000000000000000000016500000000000011567 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloading/src/test/java/org/jboss/test/classloading/metadata/xml/support/libjboss-classloader-java-2.0.6.GA.orig/classloading/src/test/java/org/jboss/test/classloading/metad0000755000175000017500000000000011620043417033416 5ustar twernertwerner././@LongLink0000000000000000000000000000021000000000000011556 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloading/src/test/java/org/jboss/test/classloading/metadata/xml/support/TestCapability.javalibjboss-classloader-java-2.0.6.GA.orig/classloading/src/test/java/org/jboss/test/classloading/metad0000644000175000017500000000351010756304141033422 0ustar twernertwerner/* * JBoss, Home of Professional Open Source * Copyright 2007, JBoss Inc., and individual contributors as indicated * by the @authors tag. See the copyright.txt in the distribution for a * full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.test.classloading.metadata.xml.support; import javax.xml.bind.annotation.XmlNsForm; import javax.xml.bind.annotation.XmlRootElement; import org.jboss.classloading.spi.dependency.Module; import org.jboss.classloading.spi.metadata.Requirement; import org.jboss.classloading.spi.metadata.helpers.AbstractCapability; import org.jboss.xb.annotations.JBossXmlSchema; @JBossXmlSchema(namespace="urn:jboss:test:classloading:capability:1.0", elementFormDefault=XmlNsForm.QUALIFIED) @XmlRootElement(name="test") public class TestCapability extends AbstractCapability { private static final long serialVersionUID = -1L; public TestCapability() { } public TestCapability(String name, Object version) { super(name, version); } public boolean resolves(Module module, Requirement requirement) { return false; } } ././@LongLink0000000000000000000000000000020600000000000011563 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloading/src/test/java/org/jboss/test/classloading/metadata/xml/support/package-info.javalibjboss-classloader-java-2.0.6.GA.orig/classloading/src/test/java/org/jboss/test/classloading/metad0000644000175000017500000000262010756304141033423 0ustar twernertwerner/* * JBoss, Home of Professional Open Source * Copyright 2008, JBoss Inc., and individual contributors as indicated * by the @authors tag. See the copyright.txt in the distribution for a * full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ @JBossXmlAdaptedTypes ({ @JBossXmlAdaptedType(type=Version.class, valueAdapter=VersionValueAdapter.class) }) package org.jboss.test.classloading.metadata.xml.support; import org.jboss.classloading.plugins.metadata.VersionValueAdapter; import org.jboss.classloading.spi.version.Version; import org.jboss.xb.annotations.JBossXmlAdaptedType; import org.jboss.xb.annotations.JBossXmlAdaptedTypes; ././@LongLink0000000000000000000000000000021100000000000011557 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloading/src/test/java/org/jboss/test/classloading/metadata/xml/support/TestRequirement.javalibjboss-classloader-java-2.0.6.GA.orig/classloading/src/test/java/org/jboss/test/classloading/metad0000644000175000017500000000326610756304141033432 0ustar twernertwerner/* * JBoss, Home of Professional Open Source * Copyright 2007, JBoss Inc., and individual contributors as indicated * by the @authors tag. See the copyright.txt in the distribution for a * full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.test.classloading.metadata.xml.support; import javax.xml.bind.annotation.XmlNsForm; import javax.xml.bind.annotation.XmlRootElement; import org.jboss.classloading.spi.metadata.helpers.AbstractRequirement; import org.jboss.classloading.spi.version.VersionRange; import org.jboss.xb.annotations.JBossXmlSchema; @JBossXmlSchema(namespace="urn:jboss:test:classloading:requirement:1.0", elementFormDefault=XmlNsForm.QUALIFIED) @XmlRootElement(name="test") public class TestRequirement extends AbstractRequirement { private static final long serialVersionUID = -1L; public TestRequirement() { } public TestRequirement(String name, VersionRange range) { super(name, range); } } ././@LongLink0000000000000000000000000000020500000000000011562 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloading/src/test/java/org/jboss/test/classloading/metadata/xml/AbstractJBossXBTest.javalibjboss-classloader-java-2.0.6.GA.orig/classloading/src/test/java/org/jboss/test/classloading/metad0000644000175000017500000001063410770573237033441 0ustar twernertwerner/* * JBoss, Home of Professional Open Source * Copyright 2006, JBoss Inc., and individual contributors as indicated * by the @authors tag. See the copyright.txt in the distribution for a * full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.test.classloading.metadata.xml; import java.net.URL; import org.jboss.test.AbstractTestCaseWithSetup; import org.jboss.test.AbstractTestDelegate; import org.jboss.util.UnreachableStatementException; import org.jboss.xb.binding.sunday.unmarshalling.SchemaBinding; import org.jboss.xb.builder.JBossXBBuilder; /** * AbstractBuilderTest. * * @author Ales Justin * @author Adrian Brock * @version $Revision: 1.1 $ */ public class AbstractJBossXBTest extends AbstractTestCaseWithSetup { public AbstractJBossXBTest(String name) { super(name); } /** * Setup the test delegate * * @param clazz the class * @return the delegate * @throws Exception for any error */ public static AbstractTestDelegate getDelegate(Class clazz) throws Exception { return new JBossXBTestDelegate(clazz); } protected JBossXBTestDelegate getJBossXBDelegate() { return (JBossXBTestDelegate) getDelegate(); } @Override protected void setUp() throws Exception { super.setUp(); configureLogging(); } protected void tearDown() throws Exception { super.tearDown(); } protected T unmarshalObject(Class expected, Class reference, Class... others) throws Exception { TestSchemaResolver resolver = new TestSchemaResolver(); SchemaBinding schemaBinding = JBossXBBuilder.build(reference); resolver.addSchemaBinding(schemaBinding); if (others != null) { for (Class other : others) { SchemaBinding otherBinding = JBossXBBuilder.build(other); resolver.addSchemaBinding(otherBinding); } } String testXml = findTestXml(); Object o = unmarshal(testXml, schemaBinding); assertNotNull(o); getLog().debug("Unmarshalled " + o + " of type " + o.getClass().getName()); try { return expected.cast(o); } catch (ClassCastException e) { fail("Expected " + expected.getName() + " got " + o.getClass().getName()); throw new UnreachableStatementException(); } } /** * Unmarshal some xml * * @param name the name * @param schema the schema * @return the unmarshalled object * @throws Exception for any error */ protected Object unmarshal(String name, SchemaBinding schema) throws Exception { String url = findXML(name); return getJBossXBDelegate().unmarshal(url, schema); } protected T unmarshalObject(Class expected, Class reference) throws Exception { return unmarshalObject(expected, reference, (Class[]) null); } protected T unmarshalObject(Class expected) throws Exception { return unmarshalObject(expected, expected, (Class[]) null); } protected String findTestXml() { return getName().substring(4) + ".xml"; } /** * Find the xml * * @param name the name * @return the url of the xml */ protected String findXML(String name) { URL url = getResource(name); if (url == null) fail(name + " not found"); return url.toString(); } @Override public void configureLogging() { //enableTrace("org.jboss.xb"); } } ././@LongLink0000000000000000000000000000017700000000000011572 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloading/src/test/java/org/jboss/test/classloading/metadata/xml/SchemaPrinter.javalibjboss-classloader-java-2.0.6.GA.orig/classloading/src/test/java/org/jboss/test/classloading/metad0000644000175000017500000002413411063447574033441 0ustar twernertwerner/* * JBoss, Home of Professional Open Source * Copyright 2006, JBoss Inc., and individual contributors as indicated * by the @authors tag. See the copyright.txt in the distribution for a * full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.test.classloading.metadata.xml; import java.util.Collection; import java.util.Iterator; import javax.xml.XMLConstants; import org.jboss.xb.binding.sunday.unmarshalling.AllBinding; import org.jboss.xb.binding.sunday.unmarshalling.AttributeBinding; import org.jboss.xb.binding.sunday.unmarshalling.ChoiceBinding; import org.jboss.xb.binding.sunday.unmarshalling.ElementBinding; import org.jboss.xb.binding.sunday.unmarshalling.ModelGroupBinding; import org.jboss.xb.binding.sunday.unmarshalling.ParticleBinding; import org.jboss.xb.binding.sunday.unmarshalling.SchemaBinding; import org.jboss.xb.binding.sunday.unmarshalling.SequenceBinding; import org.jboss.xb.binding.sunday.unmarshalling.TermBinding; import org.jboss.xb.binding.sunday.unmarshalling.TypeBinding; import org.jboss.xb.binding.sunday.unmarshalling.WildcardBinding; /** * SchemaPrinter. * * @author Ales Justin * @author Adrian Brock * @version $Revision: 1.1 $ */ public class SchemaPrinter { @SuppressWarnings("unchecked") public static String printSchema(SchemaBinding schemaBinding) { String nsURI = schemaBinding.getNamespaces().iterator().next(); StringBuilder builder = new StringBuilder(); builder.append("\n"); int pad=3; Iterator elements = schemaBinding.getElementParticles(); while (elements != null && elements.hasNext()) printElement(builder, pad, elements.next()); Iterator types = schemaBinding.getTypes(); while (types != null && types.hasNext()) printType(builder, pad, types.next()); builder.append(""); return builder.toString(); } public static void printElement(StringBuilder builder, int pad, ParticleBinding particle) { ElementBinding element = (ElementBinding) particle.getTerm(); pad(builder, pad); builder.append(""); if (type != null && type.getQName() == null) printAnonymousType(builder, pad + 3, type); pad(builder, pad); builder.append(""); } public static void printAnonymousType(StringBuilder builder, int pad, TypeBinding type) { pad(builder, pad); builder.append(""); TypeBinding baseTypeBinding = type.getBaseType(); String qName; if (baseTypeBinding != null) qName = baseTypeBinding.getQName().toString(); else qName = "xsd:anyType"; pad(builder, pad); builder.append(" "); printTypeInfo(builder, pad+6, type); pad(builder, pad); builder.append(" "); pad(builder, pad); builder.append(""); } public static void printType(StringBuilder builder, int pad, TypeBinding type) { if (type.isSimple()) printSimpleType(builder, pad, type); else printComplexType(builder, pad, type); } public static void printSimpleType(StringBuilder builder, int pad, TypeBinding type) { pad(builder, pad); builder.append(""); printTypeInfo(builder, pad+3, type); pad(builder, pad); builder.append(""); } public static void printComplexType(StringBuilder builder, int pad, TypeBinding type) { pad(builder, pad); builder.append(""); printTypeInfo(builder, pad+3, type); pad(builder, pad); builder.append(""); } @SuppressWarnings("unchecked") public static void printTypeInfo(StringBuilder builder, int pad, TypeBinding type) { ParticleBinding particle = type.getParticle(); if (particle != null) { printParticle(builder, pad, particle); } Collection attributes = type.getAttributes(); if (attributes != null) { for (AttributeBinding attribute : attributes) { printAttribute(builder, pad, attribute); } } } public static void printParticle(StringBuilder builder, int pad, ParticleBinding particle) { TermBinding term = particle.getTerm(); if (term instanceof ElementBinding) printElement(builder, pad, particle); else if (term instanceof WildcardBinding) printWildcard(builder, pad, particle); else if (term instanceof SequenceBinding) printModel(builder, pad, particle, "sequence"); else if (term instanceof AllBinding) printModel(builder, pad, particle, "all"); else if (term instanceof ChoiceBinding) printModel(builder, pad, particle, "choice"); } @SuppressWarnings("unchecked") public static void printModel(StringBuilder builder, int pad, ParticleBinding particle, String prefix) { pad(builder, pad); builder.append("<").append(prefix); int minOccurs = particle.getMinOccurs(); if (minOccurs != 1) builder.append(" minOccurs=\"").append(minOccurs).append("\""); int maxOccurs = particle.getMaxOccurs(); if (maxOccurs != 1) { builder.append(" maxOccurs=\""); if (maxOccurs == -1) builder.append("unbounded"); else builder.append(maxOccurs); builder.append("\""); } builder.append(">"); ModelGroupBinding model = (ModelGroupBinding) particle.getTerm(); Collection particles = model.getParticles(); boolean newLine = true; if (particles != null) { for (ParticleBinding component : particles) printParticle(builder, pad+3, component); } else { newLine = false; } pad(builder, pad, newLine); builder.append(""); } public static void printWildcard(StringBuilder builder, int pad, ParticleBinding particle) { pad(builder, pad); builder.append(""); } public static void printAttribute(StringBuilder builder, int pad, AttributeBinding attribute) { pad(builder, pad); TypeBinding typeBinding = attribute.getType(); String qName = null; if (typeBinding != null && typeBinding.getQName() != null) qName = typeBinding.getQName().toString(); else qName = "CDATA"; builder.append(""); } public static void pad(StringBuilder builder, int pad) { pad(builder, pad, true); } public static void pad(StringBuilder builder, int pad, boolean newLine) { if (newLine) builder.append("\n"); for (int i = 0; i < pad; ++ i) builder.append(' '); } } ././@LongLink0000000000000000000000000000017500000000000011570 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloading/src/test/java/org/jboss/test/classloading/ClassLoadingAllTestSuite.javalibjboss-classloader-java-2.0.6.GA.orig/classloading/src/test/java/org/jboss/test/classloading/Class0000644000175000017500000000406510756304141033403 0ustar twernertwerner/* * JBoss, Home of Professional Open Source. * Copyright 2008, Red Hat Middleware LLC, and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.test.classloading; import junit.framework.Test; import junit.framework.TestSuite; import junit.textui.TestRunner; import org.jboss.test.classloading.dependency.DependencyTestSuite; import org.jboss.test.classloading.metadata.MetaDataTestSuite; import org.jboss.test.classloading.version.VersionTestSuite; /** * ClassLoading All Test Suite. * * @author Adrian Brock * @version $Revision: 37459 $ */ public class ClassLoadingAllTestSuite extends TestSuite { /** * For running the testsuite from the command line * * @param args the command line args */ public static void main(String[] args) { TestRunner.run(suite()); } /** * Create the testsuite * * @return the testsuite */ public static Test suite() { TestSuite suite = new TestSuite("ClassLoading All Tests"); suite.addTest(VersionTestSuite.suite()); suite.addTest(MetaDataTestSuite.suite()); suite.addTest(DependencyTestSuite.suite()); return suite; } } ././@LongLink0000000000000000000000000000021100000000000011557 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloading/src/test/java/org/jboss/test/classloading/AbstractClassLoadingTestWithSecurity.javalibjboss-classloader-java-2.0.6.GA.orig/classloading/src/test/java/org/jboss/test/classloading/Abstr0000644000175000017500000000333610756304141033411 0ustar twernertwerner/* * JBoss, Home of Professional Open Source. * Copyright 2008, Red Hat Middleware LLC, and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.test.classloading; import org.jboss.test.AbstractTestDelegate; import org.jboss.test.security.NothingPolicyPlugin; /** * AbstractClassLoaderTest. * * @author Adrian Brock * @version $Revision: 1.1 $ */ public abstract class AbstractClassLoadingTestWithSecurity extends AbstractClassLoadingTest { public static AbstractTestDelegate getDelegate(Class clazz) { AbstractTestDelegate delegate = new AbstractTestDelegate(clazz); delegate.enableSecurity = true; delegate.securityPolicyName = NothingPolicyPlugin.class.getName(); return delegate; } public AbstractClassLoadingTestWithSecurity(String name) { super(name); } } ././@LongLink0000000000000000000000000000015000000000000011561 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloading/src/test/java/org/jboss/test/classloading/version/libjboss-classloader-java-2.0.6.GA.orig/classloading/src/test/java/org/jboss/test/classloading/versi0000755000175000017500000000000011620043417033454 5ustar twernertwerner././@LongLink0000000000000000000000000000015500000000000011566 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloading/src/test/java/org/jboss/test/classloading/version/test/libjboss-classloader-java-2.0.6.GA.orig/classloading/src/test/java/org/jboss/test/classloading/versi0000755000175000017500000000000011620043417033454 5ustar twernertwerner././@LongLink0000000000000000000000000000020500000000000011562 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloading/src/test/java/org/jboss/test/classloading/version/test/VersionUnitTestCase.javalibjboss-classloader-java-2.0.6.GA.orig/classloading/src/test/java/org/jboss/test/classloading/versi0000644000175000017500000005325510756304141033473 0ustar twernertwerner/* * JBoss, Home of Professional Open Source. * Copyright 2008, Red Hat Middleware LLC, and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.test.classloading.version.test; import junit.framework.Test; import org.jboss.classloading.spi.version.Version; import org.jboss.classloading.spi.version.VersionComparatorRegistry; import org.jboss.test.classloading.AbstractClassLoadingTestWithSecurity; /** * VersionUnitTestCase. * * @author Adrian Brock * @version $Revision: 1.1 $ */ public class VersionUnitTestCase extends AbstractClassLoadingTestWithSecurity { public static Test suite() { return suite(VersionUnitTestCase.class); } public VersionUnitTestCase(String name) { super(name); } public void testDefaultVersion() throws Exception { Version version = Version.DEFAULT_VERSION; assertVersion(version, 0, 0, 0, null); } public void testMajorMinorMicro() throws Exception { testVersion(0, 0, 0); testVersion(1, 2, 3); testVersion(3, 2, 1); assertBadVersion(-1, 0, 0); assertBadVersion(0, -1, 0); assertBadVersion(0, 0, -1); } public void testMajorMinorMicroQualifier() throws Exception { testVersion(0, 0, 0, "GA"); testVersion(1, 2, 3, "CR"); testVersion(3, 2, 1, "Beta1"); testVersion(0, 0, 0, "1234567890"); testVersion(0, 0, 0, "abcdefghijklmnopqrstuvwxyz"); testVersion(0, 0, 0, "ABCDEFGHIJKLMNOPQRSTUVWXYZ"); testVersion(0, 0, 0, "_"); testVersion(0, 0, 0, "-"); testVersion(0, 0, 0, null); assertBadVersion(-1, 0, 0, "GA"); assertBadVersion(0, -1, 0, "GA"); assertBadVersion(0, 0, -1, "GA"); assertBadVersion(0, 0, 0, "G A"); assertBadVersion(0, 0, 0, "!"); } public void testParseVersion() throws Exception { testVersion(null, 0, 0, 0, null); testVersion("", 0, 0, 0, null); testVersion("1", 1, 0, 0, null); testVersion("1.2", 1, 2, 0, null); testVersion("1.2.3", 1, 2, 3, null); testVersion("1.2.3.GA", 1, 2, 3, "GA"); testVersion("10.2.3.GA", 10, 2, 3, "GA"); testVersion("1.20.3.GA", 1, 20, 3, "GA"); testVersion("1.2.30.GA", 1, 2, 30, "GA"); testVersion("0.0.0.1234567890", 0, 0, 0, "1234567890"); testVersion("0.0.0.abcdefghijklmnopqrstuvwxyz", 0, 0, 0, "abcdefghijklmnopqrstuvwxyz"); testVersion("0.0.0.ABCDEFGHIJKLMNOPQRSTUVWXYZ", 0, 0, 0, "ABCDEFGHIJKLMNOPQRSTUVWXYZ"); testVersion("0.0.0._", 0, 0, 0, "_"); testVersion("0.0.0.-", 0, 0, 0, "-"); testVersion(" ", 0, 0, 0, null); testVersion(" 1.2.3.GA", 1, 2, 3, "GA"); testVersion("1 .2.3.GA", 1, 2, 3, "GA"); testVersion("1. 2.3.GA", 1, 2, 3, "GA"); testVersion("1.2 .3.GA", 1, 2, 3, "GA"); testVersion("1.2. 3.GA", 1, 2, 3, "GA"); testVersion("1.2.3 .GA", 1, 2, 3, "GA"); testVersion("1.2.3. GA", 1, 2, 3, "GA"); testVersion("1.2.3.GA ", 1, 2, 3, "GA"); assertBadVersion("x"); assertBadVersion("1.x"); assertBadVersion("1.2.x"); assertBadVersion("1.2.3.GA.x"); assertBadVersion("1.2.3.G A"); assertBadVersion("1.2.3.!"); assertBadVersion("1 0.2.3.GA"); assertBadVersion("1.2 0.3.GA"); assertBadVersion("1.2.3 0.GA"); assertBadVersion(".2.3.GA"); assertBadVersion("1..3.GA"); assertBadVersion("1.2..GA"); assertBadVersion("1.2.3."); } public void testEquals() throws Exception { testEquals(null, Version.DEFAULT_VERSION, true); testEquals("", Version.DEFAULT_VERSION, true); testEquals(" ", Version.DEFAULT_VERSION, true); testEquals(0, Version.DEFAULT_VERSION, true); testEquals(1, Version.DEFAULT_VERSION, false); testEquals(0, 1, Version.DEFAULT_VERSION, false); testEquals(0, 0, 1, Version.DEFAULT_VERSION, false); testEquals(0, 0, 0, "GA", Version.DEFAULT_VERSION, false); testEquals(null, (String) null, true); testEquals(null, "", true); testEquals(null, " ", true); testEquals("", " ", true); testEquals("", 0, true); testEquals("1", 1, true); testEquals("1.2", 1, 2, true); testEquals("1.2.3", 1, 2, 3, true); testEquals("1.2.3.GA", 1, 2, 3, "GA", true); testEquals("1", 1, 2, 3, "GA", false); testEquals("1.2", 1, 2, 3, "GA", false); testEquals("1.2.3", 1, 2, 3, "GA", false); testEquals("2.2.3.GA", 1, 2, 3, "GA", false); testEquals("1.2.2.GA", 1, 2, 3, "GA", false); testEquals("1.2.2.AG", 1, 2, 3, "GA", false); testEquals("10.2.3.GA", 1, 2, 3, "GA", false); testEquals("1.20.3.GA", 1, 2, 3, "GA", false); testEquals("1.2.30.GA", 1, 2, 3, "GA", false); } public void testComareTo() throws Exception { testCompare(null, Version.DEFAULT_VERSION, 0); testCompare("", Version.DEFAULT_VERSION, 0); testCompare("0", Version.DEFAULT_VERSION, 0); testCompare("0", "0", 0); testCompare("0", "0.0", 0); testCompare("0", "0.0.0", 0); testCompare("0.0", "0.0.0", 0); testCompare("1", "1", 0); testCompare("1", "1.0", 0); testCompare("1", "1.0.0", 0); testCompare("1.0", "1.0.0", 0); testCompare("1", "2", -1); testCompare("1", "2.0", -1); testCompare("1", "2.0.0", -1); testCompare("1.0", "1.1", -1); testCompare("1.0", "1.1.0", -1); testCompare("1.0", "1.2", -1); testCompare("1.0", "1.2.0", -1); testCompare("1.1", "1.2", -1); testCompare("1.1", "1.2.0", -1); testCompare("1.1", "1.3", -1); testCompare("1.1", "1.3.0", -1); testCompare("1.0.0", "1.0.1", -1); testCompare("1.0.0", "1.0.2", -1); testCompare("1.1.1", "1.1.2", -1); testCompare("1.1.1", "1.1.3", -1); testCompare("1.0.0", "1.0.0.A", -1); testCompare("1.0.0.A", "1.0.0.B", -1); testCompare("1.0.0.AA", "1.0.0.AB", -1); testCompare("1.0.0.Beta1", "1.0.0.Beta2", -1); testCompare("1.0.0.Beta10", "1.0.0.Beta2", -1); } public void testSerialization() throws Exception { Version version = new Version(1, 0, 0, "GA");; Version other = serializeDeserialize(version, Version.class); assertVersion(other, 1, 0, 0, "GA"); assertEquals(version, other); } protected void testVersion(int major, int minor, int micro) { Version version = new Version(major, minor, micro); assertVersion(version, major, minor, micro); testToString(version, major, minor, micro, null); } protected void testVersion(int major, int minor, int micro, String qualifier) { Version version = new Version(major, minor, micro, qualifier); assertVersion(version, major, minor, micro, qualifier); testToString(version, major, minor, micro, qualifier); } protected void testVersion(String test, int major, int minor, int micro, String qualifier) { Version version = Version.parseVersion(test); assertVersion(version, major, minor, micro, qualifier); testToString(version, major, minor, micro, qualifier); } protected void testToString(Version version, int major, int minor, int micro, String qualifier) { String expected = major + "." + minor + "." + micro; if (qualifier != null) { qualifier = qualifier.trim(); if (qualifier.length() > 0) expected += "." + qualifier; } assertEquals(expected, version.toString()); } protected void assertBadVersion(int major, int minor, int micro) { try { new Version(major, minor, micro); fail("Should not be here!"); } catch (Throwable t) { checkThrowable(IllegalArgumentException.class, t); } } protected void assertBadVersion(int major, int minor, int micro, String qualifier) { try { new Version(major, minor, micro, qualifier); fail("Should not be here!"); } catch (Throwable t) { checkThrowable(IllegalArgumentException.class, t); } } protected void assertBadVersion(String version) { try { Version.parseVersion(version); fail("Should not be here!"); } catch (Throwable t) { checkThrowable(IllegalArgumentException.class, t); } } protected void testEquals(String test1, String test2, boolean result) { Version version1 = Version.parseVersion(test1); Version version2 = Version.parseVersion(test2); testVersionEquals(version1, version2, result); } protected void testEquals(String test1, int major, boolean result) { Version version1 = Version.parseVersion(test1); Version version2 = Version.parseVersion("" + major); testVersionEquals(version1, version2, result); version2 = Version.parseVersion(" " + major); testVersionEquals(version1, version2, result); version2 = Version.parseVersion("" + major + " "); testVersionEquals(version1, version2, result); version2 = Version.parseVersion(" " + major + " "); testVersionEquals(version1, version2, result); version2 = Version.parseVersion(major + ".0"); testVersionEquals(version1, version2, result); version2 = Version.parseVersion(major + ".0.0"); testVersionEquals(version1, version2, result); } protected void testEquals(String test1, int major, int minor, boolean result) { Version version1 = Version.parseVersion(test1); Version version2 = Version.parseVersion(major + "." + minor); testVersionEquals(version1, version2, result); version2 = Version.parseVersion(major + ". " + minor); testVersionEquals(version1, version2, result); version2 = Version.parseVersion(major + "." + minor + " "); testVersionEquals(version1, version2, result); version2 = Version.parseVersion(major + ". " + minor + " "); testVersionEquals(version1, version2, result); version2 = Version.parseVersion(major + ". " + minor + ".0"); testVersionEquals(version1, version2, result); } protected void testEquals(String test1, int major, int minor, int micro, boolean result) { Version version1 = Version.parseVersion(test1); Version version2 = Version.parseVersion(major + "." + minor + "." + micro); testVersionEquals(version1, version2, result); version2 = Version.parseVersion(major + "." + minor + ". " + micro); testVersionEquals(version1, version2, result); version2 = Version.parseVersion(major + "." + minor + "." + micro + " "); testVersionEquals(version1, version2, result); version2 = Version.parseVersion(major + "." + minor + ". " + micro + " "); testVersionEquals(version1, version2, result); } protected void testEquals(String test1, int major, int minor, int micro, String qualifier, boolean result) { Version version1 = Version.parseVersion(test1); Version version2 = Version.parseVersion(major + "." + minor + "." + micro + "." + qualifier); testVersionEquals(version1, version2, result); version2 = Version.parseVersion(major + "." + minor + "." + micro + ". " + qualifier); testVersionEquals(version1, version2, result); version2 = Version.parseVersion(major + "." + minor + "." + micro + "." + qualifier + " "); testVersionEquals(version1, version2, result); version2 = Version.parseVersion(major + "." + minor + "." + micro + ". " + qualifier + " "); testVersionEquals(version1, version2, result); } protected void testEquals(String test1, Version version2, boolean result) { Version version1 = Version.parseVersion(test1); testVersionEquals(version1, version2, result); } protected void testEquals(int major, Version version2, boolean result) { Version version1 = Version.parseVersion("" + major); testVersionEquals(version1, version2, result); version1 = Version.parseVersion(" " + major); testVersionEquals(version1, version2, result); version1 = Version.parseVersion(major + " "); testVersionEquals(version1, version2, result); version1 = Version.parseVersion(" " + major + " "); testVersionEquals(version1, version2, result); version1 = Version.parseVersion(major + ".0"); testVersionEquals(version1, version2, result); version1 = Version.parseVersion(major + ".0.0"); testVersionEquals(version1, version2, result); } protected void testEquals(int major, int minor, Version version2, boolean result) { Version version1 = Version.parseVersion(major + "." + minor); testVersionEquals(version1, version2, result); version1 = Version.parseVersion(major + ". " + minor); testVersionEquals(version1, version2, result); version1 = Version.parseVersion(major + "." + minor + " "); testVersionEquals(version1, version2, result); version1 = Version.parseVersion(major + ". " + minor + " "); testVersionEquals(version1, version2, result); version1 = Version.parseVersion(major + "." + minor + ".0"); testVersionEquals(version1, version2, result); } protected void testEquals(int major, int minor, int micro, Version version2, boolean result) { Version version1 = Version.parseVersion(major + "." + minor + "." + micro); testVersionEquals(version1, version2, result); version1 = Version.parseVersion(major + "." + minor + ". " + micro); testVersionEquals(version1, version2, result); version1 = Version.parseVersion(major + "." + minor + "." + micro + " "); testVersionEquals(version1, version2, result); version1 = Version.parseVersion(major + "." + minor + ". " + micro + " "); testVersionEquals(version1, version2, result); } protected void testEquals(int major, int minor, int micro, String qualifier, Version version2, boolean result) { Version version1 = Version.parseVersion(major + "." + minor + "." + micro + "." + qualifier); testVersionEquals(version1, version2, result); version1 = Version.parseVersion(major + "." + minor + "." + micro + ". " + qualifier); testVersionEquals(version1, version2, result); version1 = Version.parseVersion(major + "." + minor + "." + micro + "." + qualifier + " "); testVersionEquals(version1, version2, result); version1 = Version.parseVersion(major + "." + minor + "." + micro + ". " + qualifier + " "); testVersionEquals(version1, version2, result); } protected void testVersionEquals(Version version1, Version version2, boolean result) { if (result) { assertTrue("Expected " + version1 + ".equals(" + version2 + ") to be true", version1.equals(version2)); assertTrue("Expected " + version2 + ".equals(" + version1 + ") to be true", version2.equals(version1)); } else { assertFalse("Expected " + version1 + ".equals(" + version2 + ") to be false", version1.equals(version2)); assertFalse("Expected " + version2 + ".equals(" + version1 + ") to be false", version2.equals(version1)); } } protected void testCompare(String test1, String test2, int result) { Version version1 = Version.parseVersion(test1); Version version2 = Version.parseVersion(test2); testVersionCompare(version1, version2, result); testVersionCompareViaRegistry(test1, test2, result); } protected void testCompare(String test1, Version version2, int result) { Version version1 = Version.parseVersion(test1); testVersionCompare(version1, version2, result); testVersionCompareViaRegistry(test1, version2, result); } protected void testVersionCompare(Version version1, Version version2, int result) { if (result < 0) { assertTrue("Expected " + version1 + ".compareTo(" + version2 + ") to be negative " + version1.compareTo(version2), version1.compareTo(version2) < 0); assertTrue("Expected " + version2 + ".compareTo(" + version1 + ") to be positive " + version2.compareTo(version1), version2.compareTo(version1) > 0); } else if (result > 0) { assertTrue("Expected " + version1 + ".compareTo(" + version2 + ") to be positive " + version1.compareTo(version2), version1.compareTo(version2) > 0); assertTrue("Expected " + version2 + ".compareTo(" + version1 + ") to be negative" + version2.compareTo(version1), version2.compareTo(version1) < 0); } else { assertTrue("Expected " + version1 + ".compareTo(" + version2 + ") to be zero " + version1.compareTo(version2), version1.compareTo(version2) == 0); assertTrue("Expected " + version2 + ".compareTo(" + version1 + ") to be zero" + version2.compareTo(version1), version2.compareTo(version1) == 0); } testVersionCompareViaRegistry(version1, version2, result); } protected void testVersionCompareViaRegistry(String version1, String version2, int result) { if (version1 == null) return; VersionComparatorRegistry registry = VersionComparatorRegistry.getInstance(); if (result < 0) { assertTrue("Expected " + version1 + ".compareTo(" + version2 + ") to be negative " + registry.compare(version1, version2), registry.compare(version1, version2) < 0); assertTrue("Expected " + version2 + ".compareTo(" + version1 + ") to be positive " + registry.compare(version2, version1), registry.compare(version2, version1) > 0); } else if (result > 0) { assertTrue("Expected " + version1 + ".compareTo(" + version2 + ") to be positive " + registry.compare(version1, version2), registry.compare(version1, version2) > 0); assertTrue("Expected " + version2 + ".compareTo(" + version1 + ") to be negative" + registry.compare(version2, version1), registry.compare(version2, version1) < 0); } else { assertTrue("Expected " + version1 + ".compareTo(" + version2 + ") to be zero " + registry.compare(version1, version2), registry.compare(version1, version2) == 0); assertTrue("Expected " + version2 + ".compareTo(" + version1 + ") to be zero" + registry.compare(version2, version1), registry.compare(version2, version1) == 0); } } protected void testVersionCompareViaRegistry(String version1, Version version2, int result) { if (version1 == null) return; VersionComparatorRegistry registry = VersionComparatorRegistry.getInstance(); if (result < 0) { assertTrue("Expected " + version1 + ".compareTo(" + version2 + ") to be negative " + registry.compare(version1, version2), registry.compare(version1, version2) < 0); assertTrue("Expected " + version2 + ".compareTo(" + version1 + ") to be positive " + registry.compare(version2, version1), registry.compare(version2, version1) > 0); } else if (result > 0) { assertTrue("Expected " + version1 + ".compareTo(" + version2 + ") to be positive " + registry.compare(version1, version2), registry.compare(version1, version2) > 0); assertTrue("Expected " + version2 + ".compareTo(" + version1 + ") to be negative" + registry.compare(version2, version1), registry.compare(version2, version1) < 0); } else { assertTrue("Expected " + version1 + ".compareTo(" + version2 + ") to be zero " + registry.compare(version1, version2), registry.compare(version1, version2) == 0); assertTrue("Expected " + version2 + ".compareTo(" + version1 + ") to be zero" + registry.compare(version2, version1), registry.compare(version2, version1) == 0); } } protected void testVersionCompareViaRegistry(Version version1, Version version2, int result) { if (version1 == null) return; VersionComparatorRegistry registry = VersionComparatorRegistry.getInstance(); if (result < 0) { assertTrue("Expected " + version1 + ".compareTo(" + version2 + ") to be negative " + registry.compare(version1, version2), registry.compare(version1, version2) < 0); assertTrue("Expected " + version2 + ".compareTo(" + version1 + ") to be positive " + registry.compare(version2, version1), registry.compare(version2, version1) > 0); } else if (result > 0) { assertTrue("Expected " + version1 + ".compareTo(" + version2 + ") to be positive " + registry.compare(version1, version2), registry.compare(version1, version2) > 0); assertTrue("Expected " + version2 + ".compareTo(" + version1 + ") to be negative" + registry.compare(version2, version1), registry.compare(version2, version1) < 0); } else { assertTrue("Expected " + version1 + ".compareTo(" + version2 + ") to be zero " + registry.compare(version1, version2), registry.compare(version1, version2) == 0); assertTrue("Expected " + version2 + ".compareTo(" + version1 + ") to be zero" + registry.compare(version2, version1), registry.compare(version2, version1) == 0); } } } ././@LongLink0000000000000000000000000000021200000000000011560 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloading/src/test/java/org/jboss/test/classloading/version/test/VersionRangeUnitTestCase.javalibjboss-classloader-java-2.0.6.GA.orig/classloading/src/test/java/org/jboss/test/classloading/versi0000644000175000017500000006271711035356200033470 0ustar twernertwerner/* * JBoss, Home of Professional Open Source. * Copyright 2008, Red Hat Middleware LLC, and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.test.classloading.version.test; import junit.framework.Test; import org.jboss.classloading.spi.version.Version; import org.jboss.classloading.spi.version.VersionRange; import org.jboss.test.classloading.AbstractClassLoadingTestWithSecurity; /** * VersionRangeUnitTestCase. * * @author Adrian Brock * @version $Revision: 1.1 $ */ public class VersionRangeUnitTestCase extends AbstractClassLoadingTestWithSecurity { public static Test suite() { return suite(VersionRangeUnitTestCase.class); } public VersionRangeUnitTestCase(String name) { super(name); } public void testAllVersions() throws Exception { VersionRange range = VersionRange.ALL_VERSIONS; assertVersionRange(range, Version.DEFAULT_VERSION, null); } public void testLow() throws Exception { testVersionRangeFromString("1.2.3"); testVersionRangeFromString(null); } public void testLowHigh() throws Exception { testVersionRangeFromString(null, null); testVersionRangeFromString("1.2.3", null); testVersionRangeFromString(null, "4.5.6"); testVersionRangeFromString("1.2.3", "4.5.6"); assertBadVersionRangeFromString("2", "1"); assertBadVersionRangeFromString("1.1", "1.0"); assertBadVersionRangeFromString("1.1.1", "1.1.0"); assertBadVersionRangeFromString("1", "1"); assertBadVersionRangeFromString("1.1", "1.1"); assertBadVersionRangeFromString("1.1.1", "1.1.1"); } public void testLowHighWithInclusive() throws Exception { testVersionRangeFromStringAllPerms(null, null); testVersionRangeFromStringAllPerms("1.2.3", null); testVersionRangeFromStringAllPerms(null, "4.5.6"); testVersionRangeFromStringAllPerms("1.2.3", "4.5.6"); testVersionRangeFromString(null, true, "0.0.0", true); testVersionRangeFromString("1.0.0", true, "1.0.0", true); assertBadVersionRangeFromStringAllPerms("2", "1"); assertBadVersionRangeFromStringAllPerms("1.1", "1.0"); assertBadVersionRangeFromStringAllPerms("1.1.1", "1.1.0"); assertBadVersionRangeFromStringNotBoth("1.1", "1.1"); assertBadVersionRangeFromStringNotBoth("1.1.1", "1.1.1"); assertBadVersionRangeFromStringNotBoth(null, "0.0.0"); } public void testEquals() throws Exception { testEqualsFromString(null, null, null, null, true); testEqualsFromString("0.0.0", null, null, null, true); testEqualsFromString("0.0.0", null, "0.0.0", null, true); testEquals(Version.DEFAULT_VERSION, null, null, null, true); testEquals(Version.DEFAULT_VERSION, null, Version.DEFAULT_VERSION, null, true); testEquals(Version.DEFAULT_VERSION, null, "0.0.0", null, true); testEqualsFromString("1.0.0", null, "1.0.0", null, true); testEqualsFromString(null, "1.0.0", null, "1.0.0", true); testEqualsFromString("1.2.3", "4.5.6", "1.2.3", "4.5.6", true); testEqualsFromString(null, false, null, false, null, false, null, false, true); testEqualsFromString(null, false, null, false, null, false, null, true, true); testEqualsFromString(null, false, null, false, null, true, null, false, false); testEqualsFromString(null, false, null, false, null, true, null, true, false); testEqualsFromString(null, false, null, true, null, false, null, false, true); testEqualsFromString(null, false, null, true, null, false, null, true, true); testEqualsFromString(null, false, null, true, null, true, null, false, false); testEqualsFromString(null, false, null, true, null, true, null, true, false); testEqualsFromString(null, true, null, false, null, false, null, false, false); testEqualsFromString(null, true, null, false, null, false, null, true, false); testEqualsFromString(null, true, null, false, null, true, null, false, true); testEqualsFromString(null, true, null, false, null, true, null, true, true); testEqualsFromString(null, true, null, true, null, false, null, false, false); testEqualsFromString(null, true, null, true, null, false, null, true, false); testEqualsFromString(null, true, null, true, null, true, null, false, true); testEqualsFromString(null, true, null, true, null, true, null, true, true); testEqualsFromString(null, false, null, false, "0.0.0", false, null, false, true); testEqualsFromString(null, false, null, false, "0.0.0", true, null, false, false); testEqualsFromString("1.0.0", true, "1.0.0", true, "0.0.0", false, null, false, false); testEqualsFromString("1.0.0", true, "1.0.0", true, "0.0.0", false, null, true, false); testEqualsFromString("1.0.0", true, "1.0.0", true, "0.0.0", true, null, false, false); testEqualsFromString("1.0.0", true, "1.0.0", true, "0.0.0", true, null, true, false); testEqualsFromString("1.2.3", false, "4.5.6", false, "1.2.3", false, "4.5.6", false, true); testEqualsFromString("1.2.3", false, "4.5.6", false, "1.2.3", false, "4.5.6", true, false); testEqualsFromString("1.2.3", false, "4.5.6", false, "1.2.3", true, "4.5.6", false, false); testEqualsFromString("1.2.3", false, "4.5.6", false, "1.2.3", true, "4.5.6", true, false); testEqualsFromString("1.2.3", false, "4.5.6", true, "1.2.3", false, "4.5.6", false, false); testEqualsFromString("1.2.3", false, "4.5.6", true, "1.2.3", false, "4.5.6", true, true); testEqualsFromString("1.2.3", false, "4.5.6", true, "1.2.3", true, "4.5.6", false, false); testEqualsFromString("1.2.3", false, "4.5.6", true, "1.2.3", true, "4.5.6", true, false); testEqualsFromString("1.2.3", true, "4.5.6", false, "1.2.3", false, "4.5.6", false, false); testEqualsFromString("1.2.3", true, "4.5.6", false, "1.2.3", false, "4.5.6", true, false); testEqualsFromString("1.2.3", true, "4.5.6", false, "1.2.3", true, "4.5.6", false, true); testEqualsFromString("1.2.3", true, "4.5.6", false, "1.2.3", true, "4.5.6", true, false); testEqualsFromString("1.2.3", true, "4.5.6", true, "1.2.3", false, "4.5.6", false, false); testEqualsFromString("1.2.3", true, "4.5.6", true, "1.2.3", false, "4.5.6", true, false); testEqualsFromString("1.2.3", true, "4.5.6", true, "1.2.3", true, "4.5.6", false, false); testEqualsFromString("1.2.3", true, "4.5.6", true, "1.2.3", true, "4.5.6", true, true); } public void testIsInRange() throws Exception { testIsInRangeFromString(null, null, "0.0.0", true); testIsInRangeFromString(null, null, "1.2.3", true); testIsInRangeFromString("0.0.0", null, "0.0.0", true); testIsInRangeFromString("0.0.0", null, "1.2.3", true); testIsInRangeFromString("1.2.3", "4.5.6", "1.2.3", true); testIsInRangeFromString("1.2.3", "4.5.6", "4.5.6", false); testIsInRangeFromStringAllPerms("1.2.3", "4.5.6", "1.2.4", true); testIsInRangeFromStringAllPerms("1.2.3", "4.5.6", "4.5.5", true); testIsInRangeFromStringAllPerms("1.2.3", "4.5.6", "1.3", true); testIsInRangeFromStringAllPerms("1.2.3", "4.5.6", "4.4", true); testIsInRangeFromStringAllPerms("1.2.3", "4.5.6", "2.3.4", true); testIsInRangeFromStringAllPerms("1.2.3", "4.5.6", "0.0.0", false); testIsInRangeFromStringAllPerms("1.2.3", "4.5.6", "1.1", false); testIsInRangeFromStringAllPerms("1.2.3", "4.5.6", "1.2.2", false); testIsInRangeFromStringAllPerms("1.2.3", "4.5.6", "1.0", false); testIsInRangeFromStringAllPerms("1.2.3", "4.5.6", "0.9", false); testIsInRangeFromStringAllPerms("1.2.3", "4.5.6", "4.6", false); testIsInRangeFromStringAllPerms("1.2.3", "4.5.6", "4.5.7", false); testIsInRangeFromStringAllPerms("1.2.3", "4.5.6", "5.0", false); testIsInRangeFromString(null, false, null, false, "0.0.0", false); testIsInRangeFromString(null, false, null, true, "0.0.0", false); testIsInRangeFromString(null, true, null, false, "0.0.0", true); testIsInRangeFromString(null, true, null, true, "0.0.0", true); testIsInRangeFromString("0.0.0", false, null, false, "0.0.0", false); testIsInRangeFromString("0.0.0", false, null, true, "0.0.0", false); testIsInRangeFromString("0.0.0", true, null, false, "0.0.0", true); testIsInRangeFromString("0.0.0", true, null, true, "0.0.0", true); testIsInRangeFromString("1.2.3", false, "4.5.6", false, "1.2.3", false); testIsInRangeFromString("1.2.3", false, "4.5.6", true, "1.2.3", false); testIsInRangeFromString("1.2.3", true, "4.5.6", false, "1.2.3", true); testIsInRangeFromString("1.2.3", true, "4.5.6", true, "1.2.3", true); testIsInRangeFromString("1.2.3", false, "4.5.6", false, "4.5.6", false); testIsInRangeFromString("1.2.3", false, "4.5.6", true, "4.5.6", true); testIsInRangeFromString("1.2.3", true, "4.5.6", false, "4.5.6", false); testIsInRangeFromString("1.2.3", true, "4.5.6", true, "4.5.6", true); } public void testIsConsistent() throws Exception { testIsConsistentFromString(null, null, null, null, true); testIsConsistentFromString(null, null, "0.0.0", null, true); testIsConsistentFromString("0.0.0", null, "0.0.0", null, true); testIsConsistentFromString(null, null, null, "1.2.3", true); testIsConsistentFromString(null, null, "0.0.0", "1.2.3", true); testIsConsistentFromString("0.0.0", null, "0.0.0", "1.2.3", true); testIsConsistentFromString(null, "1.2.3", "0.0.0", "1.2.3", true); testIsConsistentFromString("0.0.0", "1.2.3", "0.0.0", "1.2.3", true); testIsConsistentFromString("1.2.3", "4.5.6", "1.2.3", "4.5.6", true); testIsConsistentFromString("1.2.3", "4.5.6", "0.0.0", "1.2.3", false); testIsConsistentFromString("1.2.3", "4.5.6", "4.5.7", "5.0.0", false); testIsConsistentFromStringAllPerms("1.0.0", "2.0.0", "3.0.0", "4.0.0", false); testIsConsistentFromStringAllPerms("1.0.0", "2.0.0", "1.0.1", "1.9.0", true); testIsConsistentFromStringAllPerms("1.0.0", "2.0.0", "1.0.1", "2.0.1", true); testIsConsistentFromStringAllPerms("1.0.0", "2.0.0", "0.9.0", "1.9.0", true); testIsConsistent("1.0.0", true, "2.0.0", false, "1.0.0", true, "2.0.0", false, true); testIsConsistentOneWay("1.0.0", true, "2.0.0", false, "2.0.0", true, "2.0.0", true, false); testIsConsistentOneWay("1.0.0", true, "2.0.0", false, "1.0.0", true, "1.0.0", true, true); testIsConsistentOneWay("1.0.0", false, "2.0.0", false, "1.0.0", true, "1.0.0", true, false); testIsConsistentOneWay("1.0.0", true, "2.0.0", true, "2.0.0", true, "2.0.0", true, true); testIsConsistentOneWay("1.0.0", true, "2.0.0", false, "2.0.0", false, "3.0.0", true, false); } public void testSerialization() throws Exception { VersionRange range = new VersionRange("1.0.0", "2.0.0");; VersionRange other = serializeDeserialize(range, VersionRange.class); assertVersionRange(other, "1.0.0", "2.0.0"); assertEquals(range, other); } protected void testVersionRangeFromString(String low) { testVersionRange(low); Version lowVersion = null; if (low != null) lowVersion = Version.parseVersion(low); testVersionRange(lowVersion); } protected void testVersionRangeFromString(String low, String high) { testVersionRange(low, high); Version lowVersion = null; if (low != null) lowVersion = Version.parseVersion(low); Version highVersion = null; if (high != null) highVersion = Version.parseVersion(high); testVersionRange(lowVersion, highVersion); } protected void testVersionRangeFromStringAllPerms(String low, String high) { testVersionRangeFromString(low, false, high, false); testVersionRangeFromString(low, true, high, false); testVersionRangeFromString(low, false, high, true); testVersionRangeFromString(low, true, high, true); } protected void testVersionRangeFromString(String low, boolean lowInclusive, String high, boolean highInclusive) { testVersionRange(low, lowInclusive, high, highInclusive); Version lowVersion = null; if (low != null) lowVersion = Version.parseVersion(low); Version highVersion = null; if (high != null) highVersion = Version.parseVersion(high); testVersionRange(lowVersion, lowInclusive, highVersion, highInclusive); } protected void testVersionRange(Object low) { VersionRange range = new VersionRange(low); assertVersionRange(range, low, null); testToString(range, low, true, null, false); } protected void testVersionRange(Object low, Object high) { VersionRange range = new VersionRange(low, high); assertVersionRange(range, low, high); testToString(range, low, true, high, false); } protected void testVersionRange(Object low, boolean lowInclusive, Object high, boolean highInclusive) { VersionRange range = new VersionRange(low, lowInclusive, high, highInclusive); assertVersionRange(range, low, lowInclusive, high, highInclusive); testToString(range, low, lowInclusive, high, highInclusive); } protected void testToString(VersionRange range, Object low, boolean lowInclusive, Object high, boolean highInclusive) { StringBuilder expected = new StringBuilder(); if (low == null) low = Version.DEFAULT_VERSION; if (lowInclusive) expected.append("[").append(low); else expected.append("(").append(low); expected.append(","); if (high == null) expected.append("?").append(")"); else if (highInclusive) expected.append(high).append("]"); else expected.append(high).append(")"); assertEquals(expected.toString(), range.toString()); } protected void assertBadVersionRangeFromString(String low, String high) { assertBadVersionRange(low, high); Version lowVersion = null; if (low != null) lowVersion = Version.parseVersion(low); Version highVersion = null; if (high != null) highVersion = Version.parseVersion(high); assertBadVersionRange(lowVersion, highVersion); } protected void assertBadVersionRange(Object low, Object high) { try { fail("Should not be here! Got " + new VersionRange(low, high)); } catch (Throwable t) { checkThrowable(IllegalArgumentException.class, t); } } protected void assertBadVersionRangeFromStringAllPerms(String low, String high) { assertBadVersionRangeFromString(low, false, high, false); assertBadVersionRangeFromString(low, true, high, false); assertBadVersionRangeFromString(low, false, high, true); assertBadVersionRangeFromString(low, true, high, true); } protected void assertBadVersionRangeFromStringNotBoth(String low, String high) { assertBadVersionRangeFromString(low, false, high, false); assertBadVersionRangeFromString(low, true, high, false); assertBadVersionRangeFromString(low, false, high, true); } protected void assertBadVersionRangeFromString(String low, boolean lowInclusive, String high, boolean highInclusive) { assertBadVersionRange(low, lowInclusive, high, highInclusive); Version lowVersion = null; if (low != null) lowVersion = Version.parseVersion(low); Version highVersion = null; if (high != null) highVersion = Version.parseVersion(high); assertBadVersionRange(lowVersion, lowInclusive, highVersion, highInclusive); } protected void assertBadVersionRange(Object low, boolean lowInclusive, Object high, boolean highInclusive) { try { fail("Should not be here! Got: " + new VersionRange(low, lowInclusive, high, highInclusive)); } catch (Throwable t) { checkThrowable(IllegalArgumentException.class, t); } } protected void testEqualsFromString(String low1, String high1, String low2, String high2, boolean result) { testEqualsFromString(low1, true, high1, false, low2, true, high2, false, result); } protected void testEqualsFromString(String low1, boolean low1Inclusive, String high1, boolean high1Inclusive, String low2, boolean low2Inclusive, String high2, boolean high2Inclusive, boolean result) { testEquals(low1, low1Inclusive, high1, high1Inclusive, low2, low2Inclusive, high2, high2Inclusive, result); Version versionLow1 = null; if (low1 != null) versionLow1 = Version.parseVersion(low1); Version versionHigh1 = null; if (high1 != null) versionHigh1 = Version.parseVersion(high1); Version versionLow2 = null; if (low2 != null) versionLow2 = Version.parseVersion(low2); Version versionHigh2 = null; if (high2 != null) versionHigh2 = Version.parseVersion(high2); testEquals(versionLow1, low1Inclusive, versionHigh1, high1Inclusive, versionLow2, low2Inclusive, versionHigh2, high2Inclusive, result); } protected void testEquals(Object low1, Object high1, Object low2, Object high2, boolean result) { testEquals(low1, true, high1, false, low2, true, high2, false, result); } protected void testEquals(Object low1, boolean low1Inclusive, Object high1, boolean high1Inclusive, Object low2, boolean low2Inclusive, Object high2, boolean high2Inclusive, boolean result) { VersionRange range1 = new VersionRange(low1, low1Inclusive, high1, high1Inclusive); VersionRange range2 = new VersionRange(low2, low2Inclusive, high2, high2Inclusive); testEquals(range1, range2, result); } protected void testEquals(VersionRange range1, VersionRange range2, boolean result) { if (result) { assertTrue("Expected " + range1 + ".equals(" + range2 + ") to be true", range1.equals(range2)); assertTrue("Expected " + range2 + ".equals(" + range1 + ") to be true", range2.equals(range1)); } else { assertFalse("Expected " + range1 + ".equals(" + range2 + ") to be false", range1.equals(range2)); assertFalse("Expected " + range2 + ".equals(" + range1 + ") to be false", range2.equals(range1)); } } protected void testIsInRangeFromString(String low, String high, String test, boolean result) { testIsInRangeFromString(low, true, high, false, test, result); } protected void testIsInRangeFromStringAllPerms(String low, String high, String test, boolean result) { testIsInRangeFromString(low, false, high, false, test, result); testIsInRangeFromString(low, false, high, true, test, result); testIsInRangeFromString(low, true, high, false, test, result); testIsInRangeFromString(low, true, high, true, test, result); } protected void testIsInRangeFromString(String low, boolean lowInclusive, String high, boolean highInclusive, String test, boolean result) { testIsInRange(low, lowInclusive, high, highInclusive, test, result); Version lowVersion = null; if (low != null) lowVersion = Version.parseVersion(low); Version highVersion = null; if (high != null) highVersion = Version.parseVersion(high); Version version = Version.parseVersion(test); testIsInRange(lowVersion, lowInclusive, highVersion, highInclusive, version, result); } protected void testIsInRange(Object low, boolean lowInclusive, Object high, boolean highInclusive, Object version, boolean result) { VersionRange range = new VersionRange(low, lowInclusive, high, highInclusive); testIsInRange(range, version, result); } protected void testIsInRange(VersionRange range, Object version, boolean result) { if (result) assertTrue("Expected " + range + ".isInRange(" + version + ") to be true", range.isInRange(version)); else assertFalse("Expected " + range + ".isInRange(" + version + ") to be false", range.isInRange(version)); } protected void testIsConsistentFromString(String low1, String high1, String low2, String high2, boolean result) { testIsConsistentFromString(low1, false, high1, false, low2, false, high2, false, result); } protected void testIsConsistentFromStringAllPerms(String low1, String high1, String low2, String high2, boolean result) { testIsConsistentFromString(low1, false, high1, false, low2, false, high2, false, result); testIsConsistentFromString(low1, false, high1, false, low2, false, high2, true, result); testIsConsistentFromString(low1, false, high1, false, low2, true, high2, false, result); testIsConsistentFromString(low1, false, high1, false, low2, true, high2, true, result); testIsConsistentFromString(low1, false, high1, true, low2, false, high2, false, result); testIsConsistentFromString(low1, false, high1, true, low2, false, high2, true, result); testIsConsistentFromString(low1, false, high1, true, low2, true, high2, false, result); testIsConsistentFromString(low1, false, high1, true, low2, true, high2, true, result); testIsConsistentFromString(low1, true, high1, false, low2, false, high2, false, result); testIsConsistentFromString(low1, true, high1, false, low2, false, high2, true, result); testIsConsistentFromString(low1, true, high1, false, low2, true, high2, false, result); testIsConsistentFromString(low1, true, high1, false, low2, true, high2, true, result); testIsConsistentFromString(low1, true, high1, true, low2, false, high2, false, result); testIsConsistentFromString(low1, true, high1, true, low2, false, high2, true, result); testIsConsistentFromString(low1, true, high1, true, low2, true, high2, false, result); testIsConsistentFromString(low1, true, high1, true, low2, true, high2, true, result); } protected void testIsConsistentFromString(String low1, boolean lowInclusive1, String high1, boolean highInclusive1, String low2, boolean lowInclusive2, String high2, boolean highInclusive2, boolean result) { testIsConsistent(low1, lowInclusive1, high1, highInclusive1, low2, lowInclusive2, high2, highInclusive2, result); Version lowVersion1 = null; if (low1 != null) lowVersion1 = Version.parseVersion(low1); Version highVersion1 = null; if (high1 != null) highVersion1 = Version.parseVersion(high1); Version lowVersion2 = null; if (low2 != null) lowVersion2 = Version.parseVersion(low2); Version highVersion2 = null; if (high2 != null) highVersion2 = Version.parseVersion(high2); testIsConsistent(lowVersion1, lowInclusive1, highVersion1, highInclusive1, lowVersion2, lowInclusive2, highVersion2, highInclusive2, result); } protected void testIsConsistent(Object low1, boolean lowInclusive1, Object high1, boolean highInclusive1, Object low2, boolean lowInclusive2, Object high2, boolean highInclusive2, boolean result) { VersionRange range1 = new VersionRange(low1, lowInclusive1, high1, highInclusive1); VersionRange range2 = new VersionRange(low2, lowInclusive2, high2, highInclusive2); testIsConsistent(range1, range2, result); } protected void testIsConsistentOneWay(Object low1, boolean lowInclusive1, Object high1, boolean highInclusive1, Object low2, boolean lowInclusive2, Object high2, boolean highInclusive2, boolean result) { VersionRange range1 = new VersionRange(low1, lowInclusive1, high1, highInclusive1); VersionRange range2 = new VersionRange(low2, lowInclusive2, high2, highInclusive2); testIsConsistentOneWay(range1, range2, result); } protected void testIsConsistent(VersionRange range1, VersionRange range2, boolean result) { if (result) { assertTrue("Expected " + range1 + ".isConsistent(" + range2 + ") to be true", range1.isConsistent(range2)); assertTrue("Expected " + range2 + ".isConsistent(" + range1 + ") to be true", range2.isConsistent(range1)); } else { assertFalse("Expected " + range1 + ".isConsistent(" + range2 + ") to be false", range1.isConsistent(range2)); assertFalse("Expected " + range2 + ".isConsistent(" + range1 + ") to be false", range2.isConsistent(range1)); } } protected void testIsConsistentOneWay(VersionRange range1, VersionRange range2, boolean result) { if (result) assertTrue("Expected " + range1 + ".isConsistent(" + range2 + ") to be true", range1.isConsistent(range2)); else assertFalse("Expected " + range1 + ".isConsistent(" + range2 + ") to be false", range1.isConsistent(range2)); } } ././@LongLink0000000000000000000000000000022700000000000011566 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloading/src/test/java/org/jboss/test/classloading/version/test/VersionComparatorRegistryUnitTestCase.javalibjboss-classloader-java-2.0.6.GA.orig/classloading/src/test/java/org/jboss/test/classloading/versi0000644000175000017500000003732310756304141033471 0ustar twernertwerner/* * JBoss, Home of Professional Open Source. * Copyright 2008, Red Hat Middleware LLC, and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.test.classloading.version.test; import junit.framework.Test; import org.jboss.classloading.spi.version.Version; import org.jboss.classloading.spi.version.VersionComparator; import org.jboss.classloading.spi.version.VersionComparatorRegistry; import org.jboss.test.classloading.AbstractClassLoadingTestWithSecurity; import org.jboss.test.classloading.version.support.TestStringToMyVersionComparator; import org.jboss.test.classloading.version.support.TestStringToStringComparator; import org.jboss.test.classloading.version.support.TestStringToVersionComparator; import org.jboss.test.classloading.version.support.MyVersion; import org.jboss.test.classloading.version.support.MyVersionToMyVersionComparator; import org.jboss.test.classloading.version.support.TestVersionToStringComparator; import org.jboss.test.classloading.version.support.TestVersionToVersionComparator; /** * VersionComparatorRegistryUnitTestCase. * * @author Adrian Brock * @version $Revision: 1.1 $ */ public class VersionComparatorRegistryUnitTestCase extends AbstractClassLoadingTestWithSecurity { public static Test suite() { return suite(VersionComparatorRegistryUnitTestCase.class); } public VersionComparatorRegistryUnitTestCase(String name) { super(name); } public void testComparatorSameClass() { VersionComparatorRegistry registry = new VersionComparatorRegistry(); MyVersion version1 = MyVersion.parseMyVersion("1.0"); MyVersion version2 = MyVersion.parseMyVersion("2.0"); try { registry.compare(version1, version2); fail("Should not be here"); } catch (Throwable t) { checkThrowable(IllegalArgumentException.class, t); } MyVersionToMyVersionComparator comparator = new MyVersionToMyVersionComparator(); registry.registerVersionComparator(MyVersion.class, comparator); assertTrue(registry.compare(version1, version2) < 0); assertTrue(registry.compare(version2, version1) > 0); registry.removeVersionComparator(MyVersion.class); try { registry.compare(version1, version2); fail("Should not be here"); } catch (Throwable t) { checkThrowable(IllegalArgumentException.class, t); } registry.registerVersionComparator(MyVersion.class, MyVersion.class, comparator); assertTrue(registry.compare(version1, version2) < 0); assertTrue(registry.compare(version2, version1) > 0); registry.removeVersionComparator(MyVersion.class, MyVersion.class); try { registry.compare(version1, version2); fail("Should not be here"); } catch (Throwable t) { checkThrowable(IllegalArgumentException.class, t); } } public void testComparatorDifferentClass() { VersionComparatorRegistry registry = new VersionComparatorRegistry(); String version1 = "1.0"; MyVersion version2 = MyVersion.parseMyVersion("2.0"); try { registry.compare(version1, version2); fail("Should not be here"); } catch (Throwable t) { checkThrowable(IllegalArgumentException.class, t); } TestStringToMyVersionComparator comparator = new TestStringToMyVersionComparator(); registry.registerVersionComparator(String.class, MyVersion.class, comparator); assertTrue(registry.compare(version1, version2) < 0); assertTrue(registry.compare(version2, version1) > 0); registry.removeVersionComparator(MyVersion.class, String.class); try { registry.compare(version1, version2); fail("Should not be here"); } catch (Throwable t) { checkThrowable(IllegalArgumentException.class, t); } registry.registerVersionComparator(String.class, MyVersion.class, comparator); assertTrue(registry.compare(version1, version2) < 0); assertTrue(registry.compare(version2, version1) > 0); registry.removeVersionComparator(MyVersion.class, String.class); try { registry.compare(version1, version2); fail("Should not be here"); } catch (Throwable t) { checkThrowable(IllegalArgumentException.class, t); } } public void testReplaceBuiltInComparator() throws Exception { testReplaceBuiltInComparator(Version.class, new TestVersionToVersionComparator()); testReplaceBuiltInComparator(String.class, new TestStringToStringComparator()); testReplaceBuiltInComparator(Version.class, String.class, new TestVersionToStringComparator()); testReplaceBuiltInComparator(String.class, Version.class, new TestStringToVersionComparator()); } public void testVersionVersionCompare() throws Exception { testVersionVersionCompare(null, Version.DEFAULT_VERSION, 0); testVersionVersionCompare("", Version.DEFAULT_VERSION, 0); testVersionVersionCompare("0", Version.DEFAULT_VERSION, 0); testVersionVersionCompare("0", "0", 0); testVersionVersionCompare("0", "0.0", 0); testVersionVersionCompare("0", "0.0.0", 0); testVersionVersionCompare("0.0", "0.0.0", 0); testVersionVersionCompare("1", "1", 0); testVersionVersionCompare("1", "1.0", 0); testVersionVersionCompare("1", "1.0.0", 0); testVersionVersionCompare("1.0", "1.0.0", 0); testVersionVersionCompare("1", "2", -1); testVersionVersionCompare("1", "2.0", -1); testVersionVersionCompare("1", "2.0.0", -1); testVersionVersionCompare("1.0", "1.1", -1); testVersionVersionCompare("1.0", "1.1.0", -1); testVersionVersionCompare("1.0", "1.2", -1); testVersionVersionCompare("1.0", "1.2.0", -1); testVersionVersionCompare("1.1", "1.2", -1); testVersionVersionCompare("1.1", "1.2.0", -1); testVersionVersionCompare("1.1", "1.3", -1); testVersionVersionCompare("1.1", "1.3.0", -1); testVersionVersionCompare("1.0.0", "1.0.1", -1); testVersionVersionCompare("1.0.0", "1.0.2", -1); testVersionVersionCompare("1.1.1", "1.1.2", -1); testVersionVersionCompare("1.1.1", "1.1.3", -1); testVersionVersionCompare("1.0.0", "1.0.0.A", -1); testVersionVersionCompare("1.0.0.A", "1.0.0.B", -1); testVersionVersionCompare("1.0.0.AA", "1.0.0.AB", -1); testVersionVersionCompare("1.0.0.Beta1", "1.0.0.Beta2", -1); testVersionVersionCompare("1.0.0.Beta10", "1.0.0.Beta2", -1); } public void testVersionStringCompare() throws Exception { testVersionStringCompare("", Version.DEFAULT_VERSION, 0); testVersionStringCompare("0", Version.DEFAULT_VERSION, 0); testVersionStringCompare("0", "0", 0); testVersionStringCompare("0", "0.0", 0); testVersionStringCompare("0", "0.0.0", 0); testVersionStringCompare("0.0", "0.0.0", 0); testVersionStringCompare("1", "1", 0); testVersionStringCompare("1", "1.0", 0); testVersionStringCompare("1", "1.0.0", 0); testVersionStringCompare("1.0", "1.0.0", 0); testVersionStringCompare("1", "2", -1); testVersionStringCompare("1", "2.0", -1); testVersionStringCompare("1", "2.0.0", -1); testVersionStringCompare("1.0", "1.1", -1); testVersionStringCompare("1.0", "1.1.0", -1); testVersionStringCompare("1.0", "1.2", -1); testVersionStringCompare("1.0", "1.2.0", -1); testVersionStringCompare("1.1", "1.2", -1); testVersionStringCompare("1.1", "1.2.0", -1); testVersionStringCompare("1.1", "1.3", -1); testVersionStringCompare("1.1", "1.3.0", -1); testVersionStringCompare("1.0.0", "1.0.1", -1); testVersionStringCompare("1.0.0", "1.0.2", -1); testVersionStringCompare("1.1.1", "1.1.2", -1); testVersionStringCompare("1.1.1", "1.1.3", -1); testVersionStringCompare("1.0.0", "1.0.0.A", -1); testVersionStringCompare("1.0.0.A", "1.0.0.B", -1); testVersionStringCompare("1.0.0.AA", "1.0.0.AB", -1); testVersionStringCompare("1.0.0.Beta1", "1.0.0.Beta2", -1); testVersionStringCompare("1.0.0.Beta10", "1.0.0.Beta2", -1); } public void testStringStringCompare() throws Exception { testStringStringCompare("0", "0", 0); testStringStringCompare("0", "0.0", 0); testStringStringCompare("0", "0.0.0", 0); testStringStringCompare("0.0", "0.0.0", 0); testStringStringCompare("1", "1", 0); testStringStringCompare("1", "1.0", 0); testStringStringCompare("1", "1.0.0", 0); testStringStringCompare("1.0", "1.0.0", 0); testStringStringCompare("1", "2", -1); testStringStringCompare("1", "2.0", -1); testStringStringCompare("1", "2.0.0", -1); testStringStringCompare("1.0", "1.1", -1); testStringStringCompare("1.0", "1.1.0", -1); testStringStringCompare("1.0", "1.2", -1); testStringStringCompare("1.0", "1.2.0", -1); testStringStringCompare("1.1", "1.2", -1); testStringStringCompare("1.1", "1.2.0", -1); testStringStringCompare("1.1", "1.3", -1); testStringStringCompare("1.1", "1.3.0", -1); testStringStringCompare("1.0.0", "1.0.1", -1); testStringStringCompare("1.0.0", "1.0.2", -1); testStringStringCompare("1.1.1", "1.1.2", -1); testStringStringCompare("1.1.1", "1.1.3", -1); testStringStringCompare("1.0.0", "1.0.0.A", -1); testStringStringCompare("1.0.0.A", "1.0.0.B", -1); testStringStringCompare("1.0.0.AA", "1.0.0.AB", -1); testStringStringCompare("1.0.0.Beta1", "1.0.0.Beta2", -1); testStringStringCompare("1.0.0.Beta10", "1.0.0.Beta2", -1); } protected void testReplaceBuiltInComparator(Class classT, VersionComparator comparator) { VersionComparatorRegistry registry = new VersionComparatorRegistry(); try { registry.registerVersionComparator(classT, comparator); fail("Should not be here"); } catch (Throwable t) { checkThrowable(IllegalArgumentException.class, t); } try { registry.registerVersionComparator(classT, classT, comparator); fail("Should not be here"); } catch (Throwable t) { checkThrowable(IllegalArgumentException.class, t); } try { registry.removeVersionComparator(classT); fail("Should not be here"); } catch (Throwable t) { checkThrowable(IllegalArgumentException.class, t); } try { registry.removeVersionComparator(classT, classT); fail("Should not be here"); } catch (Throwable t) { checkThrowable(IllegalArgumentException.class, t); } try { registry.registerVersionComparator(classT, classT, null); fail("Should not be here"); } catch (Throwable t) { checkThrowable(IllegalArgumentException.class, t); } } protected void testReplaceBuiltInComparator(Class classT, Class classU, VersionComparator comparator) { VersionComparatorRegistry registry = new VersionComparatorRegistry(); try { registry.registerVersionComparator(classT, classU, comparator); fail("Should not be here"); } catch (Throwable t) { checkThrowable(IllegalArgumentException.class, t); } try { registry.removeVersionComparator(classT, classU); fail("Should not be here"); } catch (Throwable t) { checkThrowable(IllegalArgumentException.class, t); } try { registry.registerVersionComparator(classT, classU, null); fail("Should not be here"); } catch (Throwable t) { checkThrowable(IllegalArgumentException.class, t); } } protected void testVersionVersionCompare(String test1, String test2, int result) { Version version1 = Version.parseVersion(test1); Version version2 = Version.parseVersion(test2); testVersionVersionCompareViaRegistry(version1, version2, result); } protected void testVersionVersionCompare(String test1, Version version2, int result) { Version version1 = Version.parseVersion(test1); testVersionVersionCompareViaRegistry(version1, version2, result); } protected void testVersionStringCompare(String version1, String test2, int result) { Version version2 = Version.parseVersion(test2); testVersionVersionCompareViaRegistry(version1, version2, result); } protected void testVersionStringCompare(String version1, Version version2, int result) { testVersionVersionCompareViaRegistry(version1, version2, result); } protected void testStringStringCompare(String version1, String version2, int result) { testVersionVersionCompareViaRegistry(version1, version2, result); } protected void testVersionVersionCompareViaRegistry(Object version1, Object version2, int result) { VersionComparatorRegistry registry = VersionComparatorRegistry.getInstance(); if (result < 0) { assertTrue("Expected " + version1 + ".compareTo(" + version2 + ") to be negative " + registry.compare(version1, version2), registry.compare(version1, version2) < 0); assertTrue("Expected " + version2 + ".compareTo(" + version1 + ") to be positive " + registry.compare(version2, version1), registry.compare(version2, version1) > 0); } else if (result > 0) { assertTrue("Expected " + version1 + ".compareTo(" + version2 + ") to be positive " + registry.compare(version1, version2), registry.compare(version1, version2) > 0); assertTrue("Expected " + version2 + ".compareTo(" + version1 + ") to be negative" + registry.compare(version2, version1), registry.compare(version2, version1) < 0); } else { assertTrue("Expected " + version1 + ".compareTo(" + version2 + ") to be zero " + registry.compare(version1, version2), registry.compare(version1, version2) == 0); assertTrue("Expected " + version2 + ".compareTo(" + version1 + ") to be zero" + registry.compare(version2, version1), registry.compare(version2, version1) == 0); } if (result == 0) { assertTrue("Expected " + version1 + ".equals(" + version2 + ") to be true", registry.same(version1, version2)); assertTrue("Expected " + version2 + ".equals(" + version1 + ") to be true", registry.same(version2, version1)); } else { assertFalse("Expected " + version1 + ".equals(" + version2 + ") to be false", registry.same(version1, version2)); assertFalse("Expected " + version2 + ".equals(" + version1 + ") to be false", registry.same(version2, version1)); } } } ././@LongLink0000000000000000000000000000016000000000000011562 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloading/src/test/java/org/jboss/test/classloading/version/support/libjboss-classloader-java-2.0.6.GA.orig/classloading/src/test/java/org/jboss/test/classloading/versi0000755000175000017500000000000011620043417033454 5ustar twernertwerner././@LongLink0000000000000000000000000000022300000000000011562 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloading/src/test/java/org/jboss/test/classloading/version/support/MyVersionToMyVersionComparator.javalibjboss-classloader-java-2.0.6.GA.orig/classloading/src/test/java/org/jboss/test/classloading/versi0000644000175000017500000000313210756304141033460 0ustar twernertwerner/* * JBoss, Home of Professional Open Source * Copyright 2008, JBoss Inc., and individual contributors as indicated * by the @authors tag. See the copyright.txt in the distribution for a * full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.test.classloading.version.support; import org.jboss.classloading.spi.version.Version; import org.jboss.classloading.spi.version.VersionComparator; /** * MyVersionToMyVersionComparator. * * @author Adrian Brock * @version $Revision: 1.1 $ */ public class MyVersionToMyVersionComparator implements VersionComparator { public int compare(MyVersion one, MyVersion two) { Version version1 = Version.parseVersion(one.getVersion()); Version version2 = Version.parseVersion(two.getVersion()); return version1.compareTo(version2); } } ././@LongLink0000000000000000000000000000022200000000000011561 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloading/src/test/java/org/jboss/test/classloading/version/support/TestStringToVersionComparator.javalibjboss-classloader-java-2.0.6.GA.orig/classloading/src/test/java/org/jboss/test/classloading/versi0000644000175000017500000000274310756304141033467 0ustar twernertwerner/* * JBoss, Home of Professional Open Source * Copyright 2008, JBoss Inc., and individual contributors as indicated * by the @authors tag. See the copyright.txt in the distribution for a * full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.test.classloading.version.support; import org.jboss.classloading.spi.version.Version; import org.jboss.classloading.spi.version.VersionComparator; /** * TestStringToVersionComparator. * * @author Adrian Brock * @version $Revision: 1.1 $ */ public class TestStringToVersionComparator implements VersionComparator { public int compare(String one, Version two) { throw new UnsupportedOperationException("Not implemented"); } } ././@LongLink0000000000000000000000000000022400000000000011563 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloading/src/test/java/org/jboss/test/classloading/version/support/TestStringToMyVersionComparator.javalibjboss-classloader-java-2.0.6.GA.orig/classloading/src/test/java/org/jboss/test/classloading/versi0000644000175000017500000000311110756304141033455 0ustar twernertwerner/* * JBoss, Home of Professional Open Source * Copyright 2008, JBoss Inc., and individual contributors as indicated * by the @authors tag. See the copyright.txt in the distribution for a * full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.test.classloading.version.support; import org.jboss.classloading.spi.version.Version; import org.jboss.classloading.spi.version.VersionComparator; /** * TestStringToMyVersionComparator. * * @author Adrian Brock * @version $Revision: 1.1 $ */ public class TestStringToMyVersionComparator implements VersionComparator { public int compare(String one, MyVersion two) { Version version1 = Version.parseVersion(one); Version version2 = Version.parseVersion(two.getVersion()); return version1.compareTo(version2); } } ././@LongLink0000000000000000000000000000022300000000000011562 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloading/src/test/java/org/jboss/test/classloading/version/support/TestVersionToVersionComparator.javalibjboss-classloader-java-2.0.6.GA.orig/classloading/src/test/java/org/jboss/test/classloading/versi0000644000175000017500000000274710756304141033473 0ustar twernertwerner/* * JBoss, Home of Professional Open Source * Copyright 2008, JBoss Inc., and individual contributors as indicated * by the @authors tag. See the copyright.txt in the distribution for a * full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.test.classloading.version.support; import org.jboss.classloading.spi.version.Version; import org.jboss.classloading.spi.version.VersionComparator; /** * TestVersionToVersionComparator. * * @author Adrian Brock * @version $Revision: 1.1 $ */ public class TestVersionToVersionComparator implements VersionComparator { public int compare(Version one, Version two) { throw new UnsupportedOperationException("Not implemented"); } } ././@LongLink0000000000000000000000000000022200000000000011561 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloading/src/test/java/org/jboss/test/classloading/version/support/TestVersionToStringComparator.javalibjboss-classloader-java-2.0.6.GA.orig/classloading/src/test/java/org/jboss/test/classloading/versi0000644000175000017500000000274310756304141033467 0ustar twernertwerner/* * JBoss, Home of Professional Open Source * Copyright 2008, JBoss Inc., and individual contributors as indicated * by the @authors tag. See the copyright.txt in the distribution for a * full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.test.classloading.version.support; import org.jboss.classloading.spi.version.Version; import org.jboss.classloading.spi.version.VersionComparator; /** * TestVersionToStringComparator. * * @author Adrian Brock * @version $Revision: 1.1 $ */ public class TestVersionToStringComparator implements VersionComparator { public int compare(Version one, String two) { throw new UnsupportedOperationException("Not implemented"); } } ././@LongLink0000000000000000000000000000017600000000000011571 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloading/src/test/java/org/jboss/test/classloading/version/support/MyVersion.javalibjboss-classloader-java-2.0.6.GA.orig/classloading/src/test/java/org/jboss/test/classloading/versi0000644000175000017500000000267010756304141033466 0ustar twernertwerner/* * JBoss, Home of Professional Open Source * Copyright 2007, JBoss Inc., and individual contributors as indicated * by the @authors tag. See the copyright.txt in the distribution for a * full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.test.classloading.version.support; /** * MyVersion. * * @author Adrian Brock * @version $Revision: 1.1 $ */ public class MyVersion { private String version; public static MyVersion parseMyVersion(String version) { return new MyVersion(version); } public MyVersion(String version) { this.version = version; } public String getVersion() { return version; } } ././@LongLink0000000000000000000000000000022100000000000011560 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloading/src/test/java/org/jboss/test/classloading/version/support/TestStringToStringComparator.javalibjboss-classloader-java-2.0.6.GA.orig/classloading/src/test/java/org/jboss/test/classloading/versi0000644000175000017500000000265410756304141033470 0ustar twernertwerner/* * JBoss, Home of Professional Open Source * Copyright 2008, JBoss Inc., and individual contributors as indicated * by the @authors tag. See the copyright.txt in the distribution for a * full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.test.classloading.version.support; import org.jboss.classloading.spi.version.VersionComparator; /** * TestStringToStringComparator. * * @author Adrian Brock * @version $Revision: 1.1 $ */ public class TestStringToStringComparator implements VersionComparator { public int compare(String one, String two) { throw new UnsupportedOperationException("Not implemented"); } } ././@LongLink0000000000000000000000000000017500000000000011570 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloading/src/test/java/org/jboss/test/classloading/version/VersionTestSuite.javalibjboss-classloader-java-2.0.6.GA.orig/classloading/src/test/java/org/jboss/test/classloading/versi0000644000175000017500000000414610756304141033466 0ustar twernertwerner/* * JBoss, Home of Professional Open Source. * Copyright 2008, Red Hat Middleware LLC, and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.test.classloading.version; import junit.framework.Test; import junit.framework.TestSuite; import junit.textui.TestRunner; import org.jboss.test.classloading.version.test.VersionComparatorRegistryUnitTestCase; import org.jboss.test.classloading.version.test.VersionRangeUnitTestCase; import org.jboss.test.classloading.version.test.VersionUnitTestCase; /** * Version Test Suite. * * @author Adrian Brock * @version $Revision: 37459 $ */ public class VersionTestSuite extends TestSuite { /** * For running the testsuite from the command line * * @param args the command line args */ public static void main(String[] args) { TestRunner.run(suite()); } /** * Create the testsuite * * @return the testsuite */ public static Test suite() { TestSuite suite = new TestSuite("Version Tests"); suite.addTest(VersionUnitTestCase.suite()); suite.addTest(VersionRangeUnitTestCase.suite()); suite.addTest(VersionComparatorRegistryUnitTestCase.suite()); return suite; } } ././@LongLink0000000000000000000000000000015300000000000011564 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloading/src/test/java/org/jboss/test/classloading/dependency/libjboss-classloader-java-2.0.6.GA.orig/classloading/src/test/java/org/jboss/test/classloading/depen0000755000175000017500000000000011620043417033417 5ustar twernertwerner././@LongLink0000000000000000000000000000016000000000000011562 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloading/src/test/java/org/jboss/test/classloading/dependency/test/libjboss-classloader-java-2.0.6.GA.orig/classloading/src/test/java/org/jboss/test/classloading/depen0000755000175000017500000000000011620043417033417 5ustar twernertwerner././@LongLink0000000000000000000000000000022300000000000011562 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloading/src/test/java/org/jboss/test/classloading/dependency/test/ModuleClassLoadingUnitTestCase.javalibjboss-classloader-java-2.0.6.GA.orig/classloading/src/test/java/org/jboss/test/classloading/depen0000644000175000017500000005042411137575176033445 0ustar twernertwerner/* * JBoss, Home of Professional Open Source. * Copyright 2009, Red Hat Middleware LLC, and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.test.classloading.dependency.test; import java.net.URL; import java.util.Enumeration; import junit.framework.Test; import org.jboss.classloader.plugins.ClassLoaderUtils; import org.jboss.classloading.spi.dependency.ClassLoading; import org.jboss.classloading.spi.dependency.Module; import org.jboss.classloading.spi.dependency.policy.mock.MockClassLoadingMetaData; import org.jboss.classloading.spi.metadata.ClassLoadingMetaDataFactory; import org.jboss.classloading.spi.version.VersionRange; import org.jboss.kernel.spi.dependency.KernelControllerContext; import org.jboss.test.classloading.dependency.support.a.A; import org.jboss.test.classloading.dependency.support.b.B; import org.jboss.test.classloading.dependency.support.c.C; /** * ModuleClassLoadingUnitTestCase. * * @author Adrian Brock * @version $Revision: 1.1 $ */ public class ModuleClassLoadingUnitTestCase extends AbstractMockClassLoaderUnitTest { public static Test suite() { return suite(ModuleClassLoadingUnitTestCase.class); } public ModuleClassLoadingUnitTestCase(String name) { super(name); } public void testLoadClassFromThisModule() throws Exception { MockClassLoadingMetaData a = new MockClassLoadingMetaData("a"); ClassLoadingMetaDataFactory factory = ClassLoadingMetaDataFactory.getInstance(); a.getCapabilities().addCapability(factory.createModule("ModuleA")); a.getCapabilities().addCapability(factory.createPackage(A.class.getPackage().getName())); a.setPathsAndPackageNames(A.class); KernelControllerContext contextA = install(a); try { ClassLoader clA = assertClassLoader(contextA); Module moduleA = assertModule(contextA); Class result = moduleA.loadClass(A.class.getName()); assertEquals(clA, result.getClassLoader()); Module other = moduleA.getModuleForClass(A.class.getName()); assertEquals(moduleA, other); assertEquals(moduleA, ClassLoading.getModuleForClassLoader(clA)); assertEquals(clA, ClassLoading.getClassLoaderForModule(moduleA)); } finally { uninstall(contextA); } assertNoClassLoader(contextA); } public void testLoadClassFromOtherModule() throws Exception { MockClassLoadingMetaData a = new MockClassLoadingMetaData("a"); ClassLoadingMetaDataFactory factory = ClassLoadingMetaDataFactory.getInstance(); a.getCapabilities().addCapability(factory.createModule("ModuleA")); a.getCapabilities().addCapability(factory.createPackage(A.class.getPackage().getName())); a.setPathsAndPackageNames(A.class); KernelControllerContext contextA = install(a); try { ClassLoader clA = assertClassLoader(contextA); Module moduleA = assertModule(contextA); assertEquals(moduleA, ClassLoading.getModuleForClassLoader(clA)); MockClassLoadingMetaData b = new MockClassLoadingMetaData("b"); b.getRequirements().addRequirement(factory.createRequireModule("ModuleA")); b.setPathsAndPackageNames(B.class); KernelControllerContext contextB = install(b); try { ClassLoader clB = assertClassLoader(contextB); Module moduleB = assertModule(contextB); Class result = moduleB.loadClass(A.class.getName()); assertEquals(clA, result.getClassLoader()); Module other = moduleB.getModuleForClass(A.class.getName()); assertEquals(moduleA, other); assertEquals(moduleA, ClassLoading.getModuleForClassLoader(clA)); assertEquals(moduleB, ClassLoading.getModuleForClassLoader(clB)); assertEquals(clA, ClassLoading.getClassLoaderForModule(moduleA)); assertEquals(clB, ClassLoading.getClassLoaderForModule(moduleB)); } finally { uninstall(contextB); } } finally { uninstall(contextA); } assertNoClassLoader(contextA); } public void testLoadClassFromOtherModuleDuplicates() throws Exception { ClassLoadingMetaDataFactory factory = ClassLoadingMetaDataFactory.getInstance(); MockClassLoadingMetaData a1 = new MockClassLoadingMetaData("a", "1.0.0"); a1.getCapabilities().addCapability(factory.createModule("ModuleA", "1.0.0")); a1.getCapabilities().addCapability(factory.createPackage(A.class.getPackage().getName())); a1.setPathsAndPackageNames(A.class); KernelControllerContext contextA1 = install(a1); try { ClassLoader clA1 = assertClassLoader(contextA1); Module moduleA1 = assertModule(contextA1); assertEquals(moduleA1, ClassLoading.getModuleForClassLoader(clA1)); MockClassLoadingMetaData a2 = new MockClassLoadingMetaData("a", "2.0.0"); a2.getCapabilities().addCapability(factory.createModule("ModuleA", "2.0.0")); a2.getCapabilities().addCapability(factory.createPackage(A.class.getPackage().getName())); a2.setPathsAndPackageNames(A.class); KernelControllerContext contextA2 = install(a2); try { ClassLoader clA2 = assertClassLoader(contextA2); Module moduleA2 = assertModule(contextA2); assertEquals(moduleA1, ClassLoading.getModuleForClassLoader(clA1)); assertEquals(moduleA2, ClassLoading.getModuleForClassLoader(clA2)); MockClassLoadingMetaData b = new MockClassLoadingMetaData("b"); b.getRequirements().addRequirement(factory.createRequireModule("ModuleA", new VersionRange("2.0.0"))); b.setPathsAndPackageNames(B.class); KernelControllerContext contextB = install(b); try { ClassLoader clB = assertClassLoader(contextB); Module moduleB = assertModule(contextB); Class result = moduleB.loadClass(A.class.getName()); assertEquals(clA2, result.getClassLoader()); Module other = moduleB.getModuleForClass(A.class.getName()); assertEquals(moduleA2, other); assertEquals(moduleA1, ClassLoading.getModuleForClassLoader(clA1)); assertEquals(moduleA2, ClassLoading.getModuleForClassLoader(clA2)); assertEquals(moduleB, ClassLoading.getModuleForClassLoader(clB)); assertEquals(clA1, ClassLoading.getClassLoaderForModule(moduleA1)); assertEquals(clA2, ClassLoading.getClassLoaderForModule(moduleA2)); assertEquals(clB, ClassLoading.getClassLoaderForModule(moduleB)); } finally { uninstall(contextB); } } finally { uninstall(contextA2); } assertNoClassLoader(contextA2); } finally { uninstall(contextA1); } assertNoClassLoader(contextA1); } public void testLoadClassNotFound() throws Exception { MockClassLoadingMetaData a = new MockClassLoadingMetaData("a"); ClassLoadingMetaDataFactory factory = ClassLoadingMetaDataFactory.getInstance(); a.getCapabilities().addCapability(factory.createModule("ModuleA")); a.getCapabilities().addCapability(factory.createPackage(A.class.getPackage().getName())); a.setPathsAndPackageNames(A.class); KernelControllerContext contextA = install(a); try { assertClassLoader(contextA); Module moduleA = assertModule(contextA); MockClassLoadingMetaData b = new MockClassLoadingMetaData("b"); b.getRequirements().addRequirement(factory.createRequireModule("ModuleA")); b.setPathsAndPackageNames(B.class); KernelControllerContext contextB = install(b); try { assertClassLoader(contextB); try { moduleA.loadClass(C.class.getName()); fail("Should not be here!"); } catch (Exception e) { checkThrowable(ClassNotFoundException.class, e); } try { moduleA.getModuleForClass(C.class.getName()); fail("Should not be here!"); } catch (Exception e) { checkThrowable(ClassNotFoundException.class, e); } Module moduleB = assertModule(contextB); try { moduleB.loadClass(C.class.getName()); fail("Should not be here!"); } catch (Exception e) { checkThrowable(ClassNotFoundException.class, e); } try { moduleB.getModuleForClass(C.class.getName()); fail("Should not be here!"); } catch (Exception e) { checkThrowable(ClassNotFoundException.class, e); } } finally { uninstall(contextB); } } finally { uninstall(contextA); } assertNoClassLoader(contextA); } public void testLoadClassNotAModule() throws Exception { MockClassLoadingMetaData a = new MockClassLoadingMetaData("a"); ClassLoadingMetaDataFactory factory = ClassLoadingMetaDataFactory.getInstance(); a.getCapabilities().addCapability(factory.createModule("ModuleA")); a.getCapabilities().addCapability(factory.createPackage(A.class.getPackage().getName())); a.setPathsAndPackageNames(A.class); KernelControllerContext contextA = install(a); try { assertClassLoader(contextA); Module moduleA = assertModule(contextA); MockClassLoadingMetaData b = new MockClassLoadingMetaData("b"); b.getRequirements().addRequirement(factory.createRequireModule("ModuleA")); b.setPathsAndPackageNames(B.class); KernelControllerContext contextB = install(b); try { assertClassLoader(contextB); Module moduleB = assertModule(contextB); moduleA.loadClass(Object.class.getName()); assertNull(moduleA.getModuleForClass(Object.class.getName())); moduleB.loadClass(Object.class.getName()); assertNull(moduleB.getModuleForClass(Object.class.getName())); assertNull(ClassLoading.getModuleForClassLoader(Object.class.getClassLoader())); } finally { uninstall(contextB); } } finally { uninstall(contextA); } assertNoClassLoader(contextA); } public void testGetResourceFromThisModule() throws Exception { MockClassLoadingMetaData a = new MockClassLoadingMetaData("a"); ClassLoadingMetaDataFactory factory = ClassLoadingMetaDataFactory.getInstance(); a.getCapabilities().addCapability(factory.createModule("ModuleA")); a.getCapabilities().addCapability(factory.createPackage(A.class.getPackage().getName())); a.setPathsAndPackageNames(A.class); KernelControllerContext contextA = install(a); try { assertClassLoader(contextA); String path = ClassLoaderUtils.classNameToPath(A.class); URL expected = getResource("/" + path); Module moduleA = assertModule(contextA); URL actual = moduleA.getResource(path); assertEquals(expected, actual); Enumeration actuals = moduleA.getResources(path); assertTrue(actuals.hasMoreElements()); actual = actuals.nextElement(); assertEquals(expected, actual); assertFalse(actuals.hasMoreElements()); } finally { uninstall(contextA); } assertNoClassLoader(contextA); } public void testSeveralModulesWithSamePackages() throws Exception { ClassLoadingMetaDataFactory factory = ClassLoadingMetaDataFactory.getInstance(); MockClassLoadingMetaData x = new MockClassLoadingMetaData("x"); x.getCapabilities().addCapability(factory.createModule("ModuleX")); x.getCapabilities().addCapability(factory.createPackage(A.class.getPackage().getName())); x.setPathsAndPackageNames(A.class); KernelControllerContext contextX = install(x); MockClassLoadingMetaData a = new MockClassLoadingMetaData("a"); a.getCapabilities().addCapability(factory.createModule("ModuleA")); a.getCapabilities().addCapability(factory.createPackage(A.class.getPackage().getName())); a.setPathsAndPackageNames(A.class); KernelControllerContext contextA = install(a); MockClassLoadingMetaData y = new MockClassLoadingMetaData("y"); y.getCapabilities().addCapability(factory.createModule("ModuleY")); y.getCapabilities().addCapability(factory.createPackage(A.class.getPackage().getName())); y.setPathsAndPackageNames(A.class); KernelControllerContext contextY = install(y); try { ClassLoader clX = assertClassLoader(contextX); ClassLoader clA = assertClassLoader(contextA); ClassLoader clY = assertClassLoader(contextY); assertLoadClass(A.class, clX); assertLoadClass(A.class, clA); assertLoadClass(A.class, clY); MockClassLoadingMetaData b = new MockClassLoadingMetaData("b"); b.getRequirements().addRequirement(factory.createRequireModule("ModuleA")); b.getCapabilities().addCapability(factory.createPackage(B.class.getPackage().getName())); b.setPathsAndPackageNames(B.class); KernelControllerContext contextB = install(b); try { ClassLoader clB = assertClassLoader(contextB); assertLoadClass(B.class, clB); assertLoadClass(A.class, clB, clA); Module moduleA = assertModule(contextA); Module moduleB = assertModule(contextB); Module result = moduleB.getModuleForClass(A.class.getName()); assertSame(moduleA, result); } finally { uninstall(contextB); } } finally { uninstall(contextX); uninstall(contextA); uninstall(contextY); } } public void testSeveralModulesWithSameNamesDifferentVersions() throws Exception { ClassLoadingMetaDataFactory factory = ClassLoadingMetaDataFactory.getInstance(); MockClassLoadingMetaData a1 = new MockClassLoadingMetaData("a1"); a1.getCapabilities().addCapability(factory.createModule("ModuleA", "1.0.0")); a1.getCapabilities().addCapability(factory.createPackage(A.class.getPackage().getName())); a1.setPathsAndPackageNames(A.class); KernelControllerContext contextA1 = install(a1); MockClassLoadingMetaData a2 = new MockClassLoadingMetaData("a2"); a2.getCapabilities().addCapability(factory.createModule("ModuleA", "2.0.0")); a2.getCapabilities().addCapability(factory.createPackage(A.class.getPackage().getName())); a2.setPathsAndPackageNames(A.class); KernelControllerContext contextA2 = install(a2); MockClassLoadingMetaData a3 = new MockClassLoadingMetaData("a3"); a3.getCapabilities().addCapability(factory.createModule("ModuleA", "3.0.0")); a3.getCapabilities().addCapability(factory.createPackage(A.class.getPackage().getName())); a3.setPathsAndPackageNames(A.class); KernelControllerContext contextA3 = install(a3); try { ClassLoader clA1 = assertClassLoader(contextA1); ClassLoader clA2 = assertClassLoader(contextA2); ClassLoader clA3 = assertClassLoader(contextA3); assertLoadClass(A.class, clA1); assertLoadClass(A.class, clA2); assertLoadClass(A.class, clA3); MockClassLoadingMetaData b = new MockClassLoadingMetaData("b"); b.getRequirements().addRequirement(factory.createRequireModule("ModuleA", new VersionRange("2.0.0", true, "3.0.0", false))); b.getCapabilities().addCapability(factory.createPackage(B.class.getPackage().getName())); b.setPathsAndPackageNames(B.class); KernelControllerContext contextB = install(b); try { ClassLoader clB = assertClassLoader(contextB); assertLoadClass(B.class, clB); assertLoadClass(A.class, clB, clA2); Module moduleA2 = assertModule(contextA2); Module moduleB = assertModule(contextB); Module result = moduleB.getModuleForClass(A.class.getName()); assertSame(moduleA2, result); } finally { uninstall(contextB); } } finally { uninstall(contextA1); uninstall(contextA2); uninstall(contextA3); } } public void testSeveralModulesWithSamePackagesDifferentVersions() throws Exception { ClassLoadingMetaDataFactory factory = ClassLoadingMetaDataFactory.getInstance(); MockClassLoadingMetaData a1 = new MockClassLoadingMetaData("a1"); a1.getCapabilities().addCapability(factory.createModule("ModuleA")); a1.getCapabilities().addCapability(factory.createPackage(A.class.getPackage().getName(), "1.0.0")); a1.setPathsAndPackageNames(A.class); KernelControllerContext contextA1 = install(a1); MockClassLoadingMetaData a2 = new MockClassLoadingMetaData("a2"); a2.getCapabilities().addCapability(factory.createModule("ModuleA")); a2.getCapabilities().addCapability(factory.createPackage(A.class.getPackage().getName(), "2.0.0")); a2.setPathsAndPackageNames(A.class); KernelControllerContext contextA2 = install(a2); MockClassLoadingMetaData a3 = new MockClassLoadingMetaData("a3"); a3.getCapabilities().addCapability(factory.createModule("ModuleA")); a3.getCapabilities().addCapability(factory.createPackage(A.class.getPackage().getName(), "3.0.0")); a3.setPathsAndPackageNames(A.class); KernelControllerContext contextA3 = install(a3); try { ClassLoader clA1 = assertClassLoader(contextA1); ClassLoader clA2 = assertClassLoader(contextA2); ClassLoader clA3 = assertClassLoader(contextA3); assertLoadClass(A.class, clA1); assertLoadClass(A.class, clA2); assertLoadClass(A.class, clA3); MockClassLoadingMetaData b = new MockClassLoadingMetaData("b"); b.getRequirements().addRequirement(factory.createRequirePackage(A.class.getPackage().getName(), new VersionRange("2.0.0", true, "3.0.0", false))); b.getCapabilities().addCapability(factory.createPackage(B.class.getPackage().getName())); b.setPathsAndPackageNames(B.class); KernelControllerContext contextB = install(b); try { ClassLoader clB = assertClassLoader(contextB); assertLoadClass(B.class, clB); assertLoadClass(A.class, clB, clA2); Module moduleA2 = assertModule(contextA2); Module moduleB = assertModule(contextB); Module result = moduleB.getModuleForClass(A.class.getName()); assertSame(moduleA2, result); } finally { uninstall(contextB); } } finally { uninstall(contextA1); uninstall(contextA2); uninstall(contextA3); } } } ././@LongLink0000000000000000000000000000021700000000000011565 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloading/src/test/java/org/jboss/test/classloading/dependency/test/ReExportModuleUnitTestCase.javalibjboss-classloader-java-2.0.6.GA.orig/classloading/src/test/java/org/jboss/test/classloading/depen0000644000175000017500000001625310756304141033433 0ustar twernertwerner/* * JBoss, Home of Professional Open Source. * Copyright 2008, Red Hat Middleware LLC, and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.test.classloading.dependency.test; import junit.framework.Test; import org.jboss.classloading.spi.dependency.policy.mock.MockClassLoadingMetaData; import org.jboss.classloading.spi.metadata.ClassLoadingMetaDataFactory; import org.jboss.kernel.spi.dependency.KernelControllerContext; import org.jboss.test.classloading.dependency.support.a.A; import org.jboss.test.classloading.dependency.support.b.B; import org.jboss.test.classloading.dependency.support.c.C; /** * ReExportModuleUnitTestCase. * * @author Adrian Brock * @version $Revision: 1.1 $ */ public class ReExportModuleUnitTestCase extends AbstractMockClassLoaderUnitTest { public static Test suite() { return suite(ReExportModuleUnitTestCase.class); } public ReExportModuleUnitTestCase(String name) { super(name); } public void testReExport() throws Exception { ClassLoadingMetaDataFactory factory = ClassLoadingMetaDataFactory.getInstance(); MockClassLoadingMetaData a = new MockClassLoadingMetaData("a"); a.setPathsAndPackageNames(A.class); KernelControllerContext contextA = install(a); try { ClassLoader clA = assertClassLoader(contextA); assertLoadClass(A.class, clA); assertLoadClassFail(B.class, clA); assertLoadClassFail(C.class, clA); MockClassLoadingMetaData b = new MockClassLoadingMetaData("b"); b.getRequirements().addRequirement(factory.createReExportModule("a")); b.setPathsAndPackageNames(B.class); KernelControllerContext contextB = install(b); try { assertLoadClass(A.class, clA); assertLoadClassFail(B.class, clA); assertLoadClassFail(C.class, clA); ClassLoader clB = assertClassLoader(contextB); assertLoadClass(A.class, clB, clA); assertLoadClass(B.class, clB); assertLoadClassFail(C.class, clB); MockClassLoadingMetaData c = new MockClassLoadingMetaData("c"); c.getRequirements().addRequirement(factory.createRequireModule("b")); c.setPathsAndPackageNames(C.class); KernelControllerContext contextC = install(c); try { assertLoadClass(A.class, clA); assertLoadClassFail(B.class, clA); assertLoadClassFail(C.class, clA); assertLoadClass(A.class, clB, clA); assertLoadClass(B.class, clB); assertLoadClassFail(C.class, clB); ClassLoader clC = assertClassLoader(contextC); assertLoadClass(A.class, clC, clA); assertLoadClass(B.class, clC, clB); assertLoadClass(C.class, clC); } finally { uninstall(contextC); } assertNoClassLoader(contextC); assertLoadClass(A.class, clA); assertLoadClassFail(B.class, clA); assertLoadClassFail(C.class, clA); assertLoadClass(A.class, clB, clA); assertLoadClass(B.class, clB); assertLoadClassFail(C.class, clB); } finally { uninstall(contextB); } assertNoClassLoader(contextB); assertLoadClass(A.class, clA); assertLoadClassFail(B.class, clA); assertLoadClassFail(C.class, clA); } finally { uninstall(contextA); } assertNoClassLoader(contextA); } public void testNoReExport() throws Exception { ClassLoadingMetaDataFactory factory = ClassLoadingMetaDataFactory.getInstance(); MockClassLoadingMetaData a = new MockClassLoadingMetaData("a"); a.setPathsAndPackageNames(A.class); KernelControllerContext contextA = install(a); try { ClassLoader clA = assertClassLoader(contextA); assertLoadClass(A.class, clA); assertLoadClassFail(B.class, clA); assertLoadClassFail(C.class, clA); MockClassLoadingMetaData b = new MockClassLoadingMetaData("b"); b.getRequirements().addRequirement(factory.createReExportModule("a")); b.setPathsAndPackageNames(B.class); KernelControllerContext contextB = install(b); try { assertLoadClass(A.class, clA); assertLoadClassFail(B.class, clA); assertLoadClassFail(C.class, clA); ClassLoader clB = assertClassLoader(contextB); assertLoadClass(A.class, clB, clA); assertLoadClass(B.class, clB); assertLoadClassFail(C.class, clB); MockClassLoadingMetaData c = new MockClassLoadingMetaData("c"); c.getRequirements().addRequirement(factory.createRequirePackage(B.class.getPackage().getName())); c.setPathsAndPackageNames(C.class); KernelControllerContext contextC = install(c); try { assertLoadClass(A.class, clA); assertLoadClassFail(B.class, clA); assertLoadClassFail(C.class, clA); assertLoadClass(A.class, clB, clA); assertLoadClass(B.class, clB); assertLoadClassFail(C.class, clB); ClassLoader clC = assertClassLoader(contextC); assertLoadClassFail(A.class, clC); assertLoadClass(B.class, clC, clB); assertLoadClass(C.class, clC); } finally { uninstall(contextC); } assertNoClassLoader(contextC); assertLoadClass(A.class, clA); assertLoadClassFail(B.class, clA); assertLoadClassFail(C.class, clA); assertLoadClass(A.class, clB, clA); assertLoadClass(B.class, clB); assertLoadClassFail(C.class, clB); } finally { uninstall(contextB); } assertNoClassLoader(contextB); assertLoadClass(A.class, clA); assertLoadClassFail(B.class, clA); assertLoadClassFail(C.class, clA); } finally { uninstall(contextA); } assertNoClassLoader(contextA); } } ././@LongLink0000000000000000000000000000022400000000000011563 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloading/src/test/java/org/jboss/test/classloading/dependency/test/MockResourceVisitorUnitTestCase.javalibjboss-classloader-java-2.0.6.GA.orig/classloading/src/test/java/org/jboss/test/classloading/depen0000644000175000017500000002240711071406374033433 0ustar twernertwerner/* * JBoss, Home of Professional Open Source. * Copyright 2008, Red Hat Middleware LLC, and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.test.classloading.dependency.test; import java.util.Arrays; import java.util.HashSet; import java.util.Set; import junit.framework.Test; import org.jboss.classloader.plugins.ClassLoaderUtils; import org.jboss.classloader.spi.filter.PackageClassFilter; import org.jboss.classloading.spi.dependency.policy.mock.MockClassLoaderPolicyModule; import org.jboss.classloading.spi.dependency.policy.mock.MockClassLoadingMetaData; import org.jboss.classloading.spi.visitor.ResourceFilter; import org.jboss.classloading.spi.visitor.ResourceVisitor; import org.jboss.classloading.spi.visitor.ResourceContext; import org.jboss.kernel.spi.dependency.KernelControllerContext; import org.jboss.test.classloading.dependency.support.MockFederatedResourceVisitor; import org.jboss.test.classloading.dependency.support.MockFilteredResourceVisitor; import org.jboss.test.classloading.dependency.support.MockResourceVisitor; import org.jboss.test.classloading.dependency.support.ResourcesAdapter; import org.jboss.test.classloading.dependency.support.a.A; import org.jboss.test.classloading.dependency.support.b.B; import org.jboss.test.classloading.dependency.support.c.C; /** * MockResourceVisitorUnitTestCase. * * @author Ales Justin */ public class MockResourceVisitorUnitTestCase extends AbstractMockClassLoaderUnitTest { private static String[] paths = new String[] { ClassLoaderUtils.packageNameToPath(A.class.getName()), ClassLoaderUtils.packageNameToPath(B.class.getName()), ClassLoaderUtils.packageNameToPath(C.class.getName()), }; private static String[] classes = new String[] { ClassLoaderUtils.classNameToPath(A.class), ClassLoaderUtils.classNameToPath(B.class), ClassLoaderUtils.classNameToPath(C.class), }; public static Test suite() { return suite(MockResourceVisitorUnitTestCase.class); } public MockResourceVisitorUnitTestCase(String name) { super(name); } protected MockClassLoadingMetaData createClassLoadingMetaData(String name) { MockClassLoadingMetaData clmd = new MockClassLoadingMetaData(name); clmd.setPaths(paths); return clmd; } public void testIncluded() throws Exception { MockClassLoadingMetaData a = createClassLoadingMetaData("a"); a.setIncluded(new PackageClassFilter(new String[]{A.class.getPackage().getName(), B.class.getPackage().getName()})); testMockClassLoadingMetaData(a); } public void testExcluded() throws Exception { MockClassLoadingMetaData a = createClassLoadingMetaData("a"); a.setExcluded(new PackageClassFilter(new String[]{C.class.getPackage().getName()})); testMockClassLoadingMetaData(a); } public void testFiltered() throws Exception { MockClassLoadingMetaData a = createClassLoadingMetaData("a"); testMockClassLoadingMetaData(a, new MockFilteredResourceVisitor("C.class")); } public void testRecurseFilter() throws Exception { Set resources = new HashSet(Arrays.asList(classes)); resources.remove(ClassLoaderUtils.classNameToPath(C.class)); MockClassLoadingMetaData a = new MockClassLoadingMetaData("a"); a.setExcluded(new PackageClassFilter(new String[]{ResourcesAdapter.class.getPackage().getName()})); a.setPaths(ResourcesAdapter.class); ResourceFilter recurseFilter = new ResourceFilter() { public boolean accepts(ResourceContext resource) { String name = resource.getResourceName(); boolean result = name.contains("support/c") || name.contains("support\\c"); return result == false; } }; testMockClassLoadingMetaData(a, new MockResourceVisitor(), null, recurseFilter, resources); } public void testFederated() throws Exception { MockClassLoadingMetaData a = createClassLoadingMetaData("a"); MockFilteredResourceVisitor fa = new MockFilteredResourceVisitor("B\\.class|C\\.class"); MockFilteredResourceVisitor fb = new MockFilteredResourceVisitor("A\\.class|C\\.class"); testMockClassLoadingMetaData(a, new MockFederatedResourceVisitor(new ResourceVisitor[]{fa, fb}, null, null)); } public void testFederatedWithRecurse() throws Exception { MockClassLoadingMetaData a = new MockClassLoadingMetaData("a"); a.setExcluded(new PackageClassFilter(new String[]{ResourcesAdapter.class.getPackage().getName()})); a.setPaths(ResourcesAdapter.class); MockFilteredResourceVisitor fa = new MockFilteredResourceVisitor("A\\.class"); MockFilteredResourceVisitor fb = new MockFilteredResourceVisitor("B\\.class"); ResourceFilter recurseFilter = new ResourceFilter() { public boolean accepts(ResourceContext resource) { String name = resource.getResourceName(); boolean result = name.contains("support/c") || name.contains("support\\c"); return result == false; } }; MockFederatedResourceVisitor federatedRV = new MockFederatedResourceVisitor(new ResourceVisitor[]{fa, fb}, null, new ResourceFilter[]{recurseFilter, recurseFilter}); Set resources = new HashSet(Arrays.asList(classes)); resources.remove(ClassLoaderUtils.classNameToPath(C.class)); testMockClassLoadingMetaData(a, federatedRV, federatedRV.getFilter(), federatedRV.getRecurseFilter(), resources); } public void testFederatedWithRecurseMixed() throws Exception { MockClassLoadingMetaData a = new MockClassLoadingMetaData("a"); a.setExcluded(new PackageClassFilter(new String[]{ResourcesAdapter.class.getPackage().getName()})); a.setPaths(ResourcesAdapter.class); MockFilteredResourceVisitor fa = new MockFilteredResourceVisitor("A\\.class|C\\.class"); MockFilteredResourceVisitor fb = new MockFilteredResourceVisitor("B\\.class"); ResourceFilter recurseFilter = new ResourceFilter() { public boolean accepts(ResourceContext resource) { String name = resource.getResourceName(); boolean result = name.contains("support/c") || name.contains("support\\c"); return result == false; } }; MockFederatedResourceVisitor federatedRV = new MockFederatedResourceVisitor(new ResourceVisitor[]{fa, fb}, null, new ResourceFilter[]{null, recurseFilter}); Set resources = new HashSet(Arrays.asList(classes)); resources.remove(ClassLoaderUtils.classNameToPath(C.class)); testMockClassLoadingMetaData(a, federatedRV, federatedRV.getFilter(), federatedRV.getRecurseFilter(), resources); } protected void testMockClassLoadingMetaData(MockClassLoadingMetaData a) throws Exception { testMockClassLoadingMetaData(a, new MockResourceVisitor()); } protected void testMockClassLoadingMetaData(MockClassLoadingMetaData a, ResourcesAdapter visitor) throws Exception { Set resources = new HashSet(Arrays.asList(classes)); resources.remove(ClassLoaderUtils.classNameToPath(C.class)); testMockClassLoadingMetaData(a, visitor, resources); } protected void testMockClassLoadingMetaData(MockClassLoadingMetaData a, ResourcesAdapter visitor, Set expectedResources) throws Exception { testMockClassLoadingMetaData(a, visitor, visitor.getFilter(), null, expectedResources); } protected void testMockClassLoadingMetaData(MockClassLoadingMetaData a, ResourcesAdapter visitor, ResourceFilter filter, ResourceFilter recurseFilter, Set expectedResources) throws Exception { KernelControllerContext contextA = install(a); try { MockClassLoaderPolicyModule module = assertModule(contextA); module.registerClassLoaderPolicy(system); if (recurseFilter != null) { if (filter != null) module.visit(visitor, filter, recurseFilter); else module.visit(visitor, visitor.getFilter(), recurseFilter); } else if (filter != null) { module.visit(visitor, filter); } else { module.visit(visitor); } assertEquals(expectedResources, visitor.getResources()); } finally { uninstall(contextA); } assertNoModule(contextA); } }././@LongLink0000000000000000000000000000021700000000000011565 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloading/src/test/java/org/jboss/test/classloading/dependency/test/DynamicPackageUnitTestCase.javalibjboss-classloader-java-2.0.6.GA.orig/classloading/src/test/java/org/jboss/test/classloading/depen0000644000175000017500000000562210761314167033436 0ustar twernertwerner/* * JBoss, Home of Professional Open Source. * Copyright 2008, Red Hat Middleware LLC, and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.test.classloading.dependency.test; import junit.framework.Test; import org.jboss.classloading.spi.dependency.policy.mock.MockClassLoadingMetaData; import org.jboss.classloading.spi.metadata.ClassLoadingMetaDataFactory; import org.jboss.kernel.spi.dependency.KernelControllerContext; import org.jboss.test.classloading.dependency.support.a.A; /** * ReExportPackageUnitTestCase. * * @author Adrian Brock * @version $Revision: 1.1 $ */ public class DynamicPackageUnitTestCase extends AbstractMockClassLoaderUnitTest { public static Test suite() { return suite(DynamicPackageUnitTestCase.class); } public DynamicPackageUnitTestCase(String name) { super(name); } public void testDynamicPackage() throws Exception { ClassLoadingMetaDataFactory factory = ClassLoadingMetaDataFactory.getInstance(); MockClassLoadingMetaData a1 = new MockClassLoadingMetaData("a1"); a1.getRequirements().addRequirement(factory.createRequirePackage(A.class.getPackage().getName(), null, false, false, true)); KernelControllerContext contextA1 = install(a1); try { ClassLoader clA1 = assertClassLoader(contextA1); assertLoadClassFail(A.class, clA1); MockClassLoadingMetaData a2 = new MockClassLoadingMetaData("a2"); a2.setPathsAndPackageNames(A.class); KernelControllerContext contextA2 = install(a2); try { ClassLoader clA2 = assertClassLoader(contextA2); assertLoadClass(A.class, clA2); enableTrace("org.jboss.classloader"); assertLoadClass(A.class, clA1, clA2); } finally { uninstall(contextA2); } assertNoClassLoader(contextA2); } finally { uninstall(contextA1); } assertNoClassLoader(contextA1); } } ././@LongLink0000000000000000000000000000022300000000000011562 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloading/src/test/java/org/jboss/test/classloading/dependency/test/HierarchicalDomainUnitTestCase.javalibjboss-classloader-java-2.0.6.GA.orig/classloading/src/test/java/org/jboss/test/classloading/depen0000644000175000017500000004043311035356200033422 0ustar twernertwerner/* * JBoss, Home of Professional Open Source. * Copyright 2008, Red Hat Middleware LLC, and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.test.classloading.dependency.test; import junit.framework.Test; import org.jboss.classloading.spi.dependency.policy.mock.MockClassLoadingMetaData; import org.jboss.classloading.spi.metadata.ClassLoadingMetaDataFactory; import org.jboss.kernel.spi.dependency.KernelControllerContext; import org.jboss.test.classloading.dependency.support.a.A; import org.jboss.test.classloading.dependency.support.b.B; /** * HierarchicalDomainUnitTestCase. * * @author Adrian Brock * @version $Revision: 1.1 $ */ public class HierarchicalDomainUnitTestCase extends AbstractMockClassLoaderUnitTest { public static Test suite() { return suite(HierarchicalDomainUnitTestCase.class); } public HierarchicalDomainUnitTestCase(String name) { super(name); } public void testParentFirst() throws Exception { ClassLoadingMetaDataFactory factory = ClassLoadingMetaDataFactory.getInstance(); MockClassLoadingMetaData aParent = new MockClassLoadingMetaData("aParent"); aParent.setPathsAndPackageNames(A.class); KernelControllerContext contextParentA = install(aParent); try { ClassLoader clParentA = assertClassLoader(contextParentA); assertLoadClass(A.class, clParentA); assertLoadClassFail(B.class, clParentA); MockClassLoadingMetaData aChild = new MockClassLoadingMetaData("aChild"); aChild.setDomain("ChildDomain"); aChild.setJ2seClassLoadingCompliance(true); aChild.setPathsAndPackageNames(A.class); KernelControllerContext contextChildA = install(aChild); try { ClassLoader clChildA = assertClassLoader(contextChildA); assertLoadClass(A.class, clParentA); assertLoadClassFail(B.class, clChildA); MockClassLoadingMetaData b = new MockClassLoadingMetaData("b"); b.setDomain("ChildDomain"); b.setJ2seClassLoadingCompliance(true); b.setPathsAndPackageNames(B.class); b.getRequirements().addRequirement(factory.createRequirePackage(A.class.getPackage().getName())); KernelControllerContext contextB = install(b); try { ClassLoader clB = assertClassLoader(contextB); assertLoadClass(A.class, clParentA); assertLoadClass(B.class, clB); } finally { uninstall(contextB); } assertNoClassLoader(contextB); } finally { uninstall(contextChildA); } assertNoClassLoader(contextChildA); } finally { uninstall(contextParentA); } assertNoClassLoader(contextParentA); } public void testParentLast() throws Exception { ClassLoadingMetaDataFactory factory = ClassLoadingMetaDataFactory.getInstance(); MockClassLoadingMetaData aParent = new MockClassLoadingMetaData("aParent"); aParent.setPathsAndPackageNames(A.class); KernelControllerContext contextParentA = install(aParent); try { ClassLoader clParentA = assertClassLoader(contextParentA); assertLoadClass(A.class, clParentA); assertLoadClassFail(B.class, clParentA); MockClassLoadingMetaData aChild = new MockClassLoadingMetaData("aChild"); aChild.setDomain("ChildDomain"); aChild.setJ2seClassLoadingCompliance(false); aChild.setPathsAndPackageNames(A.class); KernelControllerContext contextChildA = install(aChild); try { ClassLoader clChildA = assertClassLoader(contextChildA); assertLoadClass(A.class, clChildA); assertLoadClassFail(B.class, clChildA); MockClassLoadingMetaData b = new MockClassLoadingMetaData("b"); b.setDomain("ChildDomain"); b.setJ2seClassLoadingCompliance(false); b.setPathsAndPackageNames(B.class); b.getRequirements().addRequirement(factory.createRequirePackage(A.class.getPackage().getName())); KernelControllerContext contextB = install(b); try { ClassLoader clB = assertClassLoader(contextB); assertLoadClass(A.class, clChildA); assertLoadClass(B.class, clB); } finally { uninstall(contextB); } assertNoClassLoader(contextB); } finally { uninstall(contextChildA); } assertNoClassLoader(contextChildA); } finally { uninstall(contextParentA); } assertNoClassLoader(contextParentA); } public void testParentLastNotInChild() throws Exception { ClassLoadingMetaDataFactory factory = ClassLoadingMetaDataFactory.getInstance(); MockClassLoadingMetaData aParent = new MockClassLoadingMetaData("aParent"); aParent.setPathsAndPackageNames(A.class); KernelControllerContext contextParentA = install(aParent); try { ClassLoader clParentA = assertClassLoader(contextParentA); assertLoadClass(A.class, clParentA); assertLoadClassFail(B.class, clParentA); MockClassLoadingMetaData b = new MockClassLoadingMetaData("b"); b.setDomain("ChildDomain"); b.setJ2seClassLoadingCompliance(false); b.setPathsAndPackageNames(B.class); b.getRequirements().addRequirement(factory.createRequirePackage(A.class.getPackage().getName())); KernelControllerContext contextB = install(b); try { ClassLoader clB = assertClassLoader(contextB); assertLoadClass(A.class, clParentA); assertLoadClass(B.class, clB); } finally { uninstall(contextB); } assertNoClassLoader(contextB); } finally { uninstall(contextParentA); } assertNoClassLoader(contextParentA); } public void testParentFirstWrongWayAround() throws Exception { ClassLoadingMetaDataFactory factory = ClassLoadingMetaDataFactory.getInstance(); MockClassLoadingMetaData b = new MockClassLoadingMetaData("b"); b.setDomain("ChildDomain"); b.setJ2seClassLoadingCompliance(true); b.setPathsAndPackageNames(B.class); b.getRequirements().addRequirement(factory.createRequirePackage(A.class.getPackage().getName())); KernelControllerContext contextB = install(b); try { assertNoClassLoader(contextB); MockClassLoadingMetaData aParent = new MockClassLoadingMetaData("aParent"); aParent.setPathsAndPackageNames(A.class); KernelControllerContext contextParentA = install(aParent); try { ClassLoader clParentA = assertClassLoader(contextParentA); assertLoadClass(A.class, clParentA); assertLoadClassFail(B.class, clParentA); ClassLoader clB = assertClassLoader(contextB); assertLoadClass(A.class, clParentA); assertLoadClass(B.class, clB); } finally { uninstall(contextParentA); } assertNoClassLoader(contextParentA); } finally { uninstall(contextB); } assertNoClassLoader(contextB); } public void testParentLastWrongWayAround() throws Exception { ClassLoadingMetaDataFactory factory = ClassLoadingMetaDataFactory.getInstance(); MockClassLoadingMetaData b = new MockClassLoadingMetaData("b"); b.setDomain("ChildDomain"); b.setJ2seClassLoadingCompliance(false); b.setPathsAndPackageNames(B.class); b.getRequirements().addRequirement(factory.createRequirePackage(A.class.getPackage().getName())); KernelControllerContext contextB = install(b); try { assertNoClassLoader(contextB); MockClassLoadingMetaData aParent = new MockClassLoadingMetaData("aParent"); aParent.setPathsAndPackageNames(A.class); KernelControllerContext contextParentA = install(aParent); try { ClassLoader clParentA = assertClassLoader(contextParentA); assertLoadClass(A.class, clParentA); assertLoadClassFail(B.class, clParentA); ClassLoader clB = assertClassLoader(contextB); assertLoadClass(A.class, clParentA); assertLoadClass(B.class, clB); } finally { uninstall(contextParentA); } assertNoClassLoader(contextParentA); } finally { uninstall(contextB); } assertNoClassLoader(contextB); } public void testParentRedeploy() throws Exception { ClassLoadingMetaDataFactory factory = ClassLoadingMetaDataFactory.getInstance(); MockClassLoadingMetaData b = new MockClassLoadingMetaData("b"); b.setDomain("ChildDomain"); b.setJ2seClassLoadingCompliance(true); b.setPathsAndPackageNames(B.class); b.getRequirements().addRequirement(factory.createRequirePackage(A.class.getPackage().getName())); KernelControllerContext contextB = install(b); try { assertNoClassLoader(contextB); MockClassLoadingMetaData aParent = new MockClassLoadingMetaData("aParent"); aParent.setPathsAndPackageNames(A.class); KernelControllerContext contextParentA = install(aParent); try { ClassLoader clParentA = assertClassLoader(contextParentA); assertLoadClass(A.class, clParentA); assertLoadClassFail(B.class, clParentA); ClassLoader clB = assertClassLoader(contextB); assertLoadClass(A.class, clParentA); assertLoadClass(B.class, clB); } finally { uninstall(contextParentA); } assertNoClassLoader(contextParentA); assertNoClassLoader(contextB); contextParentA = install(aParent); try { ClassLoader clParentA = assertClassLoader(contextParentA); assertLoadClass(A.class, clParentA); assertLoadClassFail(B.class, clParentA); ClassLoader clB = assertClassLoader(contextB); assertLoadClass(A.class, clParentA); assertLoadClass(B.class, clB); } finally { uninstall(contextParentA); } assertNoClassLoader(contextParentA); } finally { uninstall(contextB); } assertNoClassLoader(contextB); } public void testParentOtherDomain() throws Exception { ClassLoadingMetaDataFactory factory = ClassLoadingMetaDataFactory.getInstance(); MockClassLoadingMetaData aParent = new MockClassLoadingMetaData("aParent"); aParent.setPathsAndPackageNames(A.class); aParent.setDomain("ParentDomain"); KernelControllerContext contextParentA = install(aParent); try { ClassLoader clParentA = assertClassLoader(contextParentA); assertLoadClass(A.class, clParentA); assertLoadClassFail(B.class, clParentA); MockClassLoadingMetaData b = new MockClassLoadingMetaData("b"); b.setDomain("ChildDomain"); b.setParentDomain("ParentDomain"); b.setJ2seClassLoadingCompliance(true); b.setPathsAndPackageNames(B.class); b.getRequirements().addRequirement(factory.createRequirePackage(A.class.getPackage().getName())); KernelControllerContext contextB = install(b); try { ClassLoader clB = assertClassLoader(contextB); assertLoadClass(A.class, clParentA); assertLoadClass(B.class, clB); } finally { uninstall(contextB); } assertNoClassLoader(contextB); } finally { uninstall(contextParentA); } assertNoClassLoader(contextParentA); } public void testParentOtherDomainLazy() throws Exception { ClassLoadingMetaDataFactory factory = ClassLoadingMetaDataFactory.getInstance(); MockClassLoadingMetaData b = new MockClassLoadingMetaData("b"); b.setDomain("ChildDomain"); b.setParentDomain("ParentDomain"); b.setJ2seClassLoadingCompliance(true); b.setPathsAndPackageNames(B.class); b.getRequirements().addRequirement(factory.createRequirePackage(A.class.getPackage().getName())); KernelControllerContext contextB = install(b); try { assertNoClassLoader(contextB); MockClassLoadingMetaData aParent = new MockClassLoadingMetaData("aParent"); aParent.setPathsAndPackageNames(A.class); aParent.setDomain("ParentDomain"); KernelControllerContext contextParentA = install(aParent); try { ClassLoader clParentA = assertClassLoader(contextParentA); assertLoadClass(A.class, clParentA); assertLoadClassFail(B.class, clParentA); ClassLoader clB = assertClassLoader(contextB); assertLoadClass(A.class, clParentA); assertLoadClass(B.class, clB); } finally { uninstall(contextParentA); } assertNoClassLoader(contextParentA); } finally { uninstall(contextB); } assertNoClassLoader(contextB); } public void testParentRedeployOtherDomain() throws Exception { ClassLoadingMetaDataFactory factory = ClassLoadingMetaDataFactory.getInstance(); MockClassLoadingMetaData b = new MockClassLoadingMetaData("b"); b.setDomain("ChildDomain"); b.setParentDomain("ParentDomain"); b.setJ2seClassLoadingCompliance(true); b.setPathsAndPackageNames(B.class); b.getRequirements().addRequirement(factory.createRequirePackage(A.class.getPackage().getName())); KernelControllerContext contextB = install(b); try { assertNoClassLoader(contextB); MockClassLoadingMetaData aParent = new MockClassLoadingMetaData("aParent"); aParent.setPathsAndPackageNames(A.class); aParent.setDomain("ParentDomain"); KernelControllerContext contextParentA = install(aParent); try { ClassLoader clParentA = assertClassLoader(contextParentA); assertLoadClass(A.class, clParentA); assertLoadClassFail(B.class, clParentA); ClassLoader clB = assertClassLoader(contextB); assertLoadClass(A.class, clParentA); assertLoadClass(B.class, clB); } finally { uninstall(contextParentA); } assertNoClassLoader(contextParentA); assertNoClassLoader(contextB); contextParentA = install(aParent); try { ClassLoader clParentA = assertClassLoader(contextParentA); assertLoadClass(A.class, clParentA); assertLoadClassFail(B.class, clParentA); ClassLoader clB = assertClassLoader(contextB); assertLoadClass(A.class, clParentA); assertLoadClass(B.class, clB); } finally { uninstall(contextParentA); } assertNoClassLoader(contextParentA); } finally { uninstall(contextB); } assertNoClassLoader(contextB); } } ././@LongLink0000000000000000000000000000023100000000000011561 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloading/src/test/java/org/jboss/test/classloading/dependency/test/MockClassLoadingMetaDataUnitTestCase.javalibjboss-classloader-java-2.0.6.GA.orig/classloading/src/test/java/org/jboss/test/classloading/depen0000644000175000017500000002466710756304141033443 0ustar twernertwerner/* * JBoss, Home of Professional Open Source. * Copyright 2008, Red Hat Middleware LLC, and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.test.classloading.dependency.test; import java.util.ArrayList; import java.util.Collections; import java.util.List; import junit.framework.Test; import org.jboss.classloader.spi.ClassLoaderSystem; import org.jboss.classloader.spi.filter.ClassFilter; import org.jboss.classloading.spi.dependency.policy.mock.MockClassLoaderPolicyModule; import org.jboss.classloading.spi.dependency.policy.mock.MockClassLoadingMetaData; import org.jboss.classloading.spi.metadata.Capability; import org.jboss.classloading.spi.metadata.ClassLoadingMetaDataFactory; import org.jboss.classloading.spi.metadata.ExportAll; import org.jboss.classloading.spi.metadata.Requirement; import org.jboss.classloading.spi.version.Version; import org.jboss.kernel.spi.dependency.KernelControllerContext; import org.jboss.test.classloading.dependency.support.a.A; import org.jboss.test.classloading.dependency.support.b.B; /** * MockClassLoadingMetaDataUnitTestCase. * * @author Adrian Brock * @version $Revision: 1.1 $ */ public class MockClassLoadingMetaDataUnitTestCase extends AbstractMockClassLoaderUnitTest { public static Test suite() { return suite(MockClassLoadingMetaDataUnitTestCase.class); } public MockClassLoadingMetaDataUnitTestCase(String name) { super(name); } public void testName() throws Exception { MockClassLoadingMetaData a = new MockClassLoadingMetaData("a"); KernelControllerContext contextA = install(a); try { MockClassLoaderPolicyModule module = assertModule(contextA); assertEquals("a", module.getName()); assertEquals(Version.DEFAULT_VERSION, module.getVersion()); assertNull(module.getDomainName()); assertNull(module.getParentDomainName()); assertNull(module.getExportAll()); assertNull(module.getIncluded()); assertNull(module.getExcluded()); assertNull(module.getExcludedExport()); assertFalse(module.isImportAll()); assertTrue(module.isJ2seClassLoadingCompliance()); ClassLoadingMetaDataFactory factory = ClassLoadingMetaDataFactory.getInstance(); Capability capability = factory.createModule("a"); assertEquals(Collections.singletonList(capability), module.getCapabilities()); assertNull(module.getRequirements()); } finally { uninstall(contextA); } assertNoModule(contextA); } public void testVersion() throws Exception { Version version = Version.parseVersion("1.0.0"); MockClassLoadingMetaData a = new MockClassLoadingMetaData("a", version); KernelControllerContext contextA = install(a); try { MockClassLoaderPolicyModule module = assertModule(contextA); assertEquals(version, module.getVersion()); } finally { uninstall(contextA); } assertNoModule(contextA); } public void testDomainName() throws Exception { MockClassLoadingMetaData a = new MockClassLoadingMetaData("a"); a.setDomain("DomainName"); KernelControllerContext contextA = install(a); try { MockClassLoaderPolicyModule module = assertModule(contextA); assertEquals("DomainName", module.getDomainName()); } finally { uninstall(contextA); } assertNoModule(contextA); } public void testParentDomainName() throws Exception { MockClassLoadingMetaData a = new MockClassLoadingMetaData("a"); a.setDomain("DomainName"); a.setParentDomain(ClassLoaderSystem.DEFAULT_DOMAIN_NAME); KernelControllerContext contextA = install(a); try { MockClassLoaderPolicyModule module = assertModule(contextA); assertEquals(ClassLoaderSystem.DEFAULT_DOMAIN_NAME, module.getParentDomainName()); } finally { uninstall(contextA); } assertNoModule(contextA); } public void testExportAll() throws Exception { MockClassLoadingMetaData a = new MockClassLoadingMetaData("a"); a.setExportAll(ExportAll.ALL); KernelControllerContext contextA = install(a); try { MockClassLoaderPolicyModule module = assertModule(contextA); assertEquals(ExportAll.ALL, module.getExportAll()); } finally { uninstall(contextA); } assertNoModule(contextA); } public void testIncluded() throws Exception { MockClassLoadingMetaData a = new MockClassLoadingMetaData("a"); a.setIncluded(ClassFilter.JAVA_ONLY); KernelControllerContext contextA = install(a); try { MockClassLoaderPolicyModule module = assertModule(contextA); assertEquals(ClassFilter.JAVA_ONLY, module.getIncluded()); } finally { uninstall(contextA); } assertNoModule(contextA); } public void testExcluded() throws Exception { MockClassLoadingMetaData a = new MockClassLoadingMetaData("a"); a.setExcluded(ClassFilter.JAVA_ONLY); KernelControllerContext contextA = install(a); try { MockClassLoaderPolicyModule module = assertModule(contextA); assertEquals(ClassFilter.JAVA_ONLY, module.getExcluded()); } finally { uninstall(contextA); } assertNoModule(contextA); } public void testExcludedExport() throws Exception { MockClassLoadingMetaData a = new MockClassLoadingMetaData("a"); a.setExcludedExport(ClassFilter.JAVA_ONLY); KernelControllerContext contextA = install(a); try { MockClassLoaderPolicyModule module = assertModule(contextA); assertEquals(ClassFilter.JAVA_ONLY, module.getExcludedExport()); } finally { uninstall(contextA); } assertNoModule(contextA); } public void testImportAll() throws Exception { MockClassLoadingMetaData a = new MockClassLoadingMetaData("a"); a.setImportAll(true); KernelControllerContext contextA = install(a); try { MockClassLoaderPolicyModule module = assertModule(contextA); assertTrue(module.isImportAll()); } finally { uninstall(contextA); } assertNoModule(contextA); } public void testJ2seClassLoading() throws Exception { MockClassLoadingMetaData a = new MockClassLoadingMetaData("a"); a.setJ2seClassLoadingCompliance(false); KernelControllerContext contextA = install(a); try { MockClassLoaderPolicyModule module = assertModule(contextA); assertFalse(module.isJ2seClassLoadingCompliance()); } finally { uninstall(contextA); } assertNoModule(contextA); } public void testManualCapabilities() throws Exception { MockClassLoadingMetaData a = new MockClassLoadingMetaData("a"); ClassLoadingMetaDataFactory factory = ClassLoadingMetaDataFactory.getInstance(); List capabilities = new ArrayList(); capabilities.add(factory.createModule("b")); capabilities.add(factory.createPackage("p1")); capabilities.add(factory.createPackage("p2")); a.setCapabilities(capabilities); KernelControllerContext contextA = install(a); try { MockClassLoaderPolicyModule module = assertModule(contextA); assertEquals(capabilities, module.getCapabilities()); } finally { uninstall(contextA); } assertNoModule(contextA); } public void testAutoCapabilities() throws Exception { MockClassLoadingMetaData a = new MockClassLoadingMetaData("a"); a.setPathsAndPackageNames(A.class, B.class); KernelControllerContext contextA = install(a); try { MockClassLoaderPolicyModule module = assertModule(contextA); ClassLoadingMetaDataFactory factory = ClassLoadingMetaDataFactory.getInstance(); List capabilities = new ArrayList(); capabilities.add(factory.createModule("a")); capabilities.add(factory.createPackage(A.class.getPackage().getName())); capabilities.add(factory.createPackage(B.class.getPackage().getName())); assertEquals(capabilities, module.getCapabilities()); } finally { uninstall(contextA); } assertNoModule(contextA); } public void testRequirements() throws Exception { MockClassLoadingMetaData a = new MockClassLoadingMetaData("a"); ClassLoadingMetaDataFactory factory = ClassLoadingMetaDataFactory.getInstance(); List requirements = new ArrayList(); requirements.add(factory.createRequireModule("b")); requirements.add(factory.createRequirePackage(B.class.getPackage().getName())); a.setRequirements(requirements); KernelControllerContext contextA = install(a); try { MockClassLoadingMetaData b = new MockClassLoadingMetaData("b"); b.setPathsAndPackageNames(B.class); KernelControllerContext contextB = install(b); try { MockClassLoaderPolicyModule module = assertModule(contextA); assertEquals(requirements, module.getRequirements()); } finally { uninstall(contextB); } assertNoModule(contextB); } finally { uninstall(contextA); } assertNoModule(contextA); } } ././@LongLink0000000000000000000000000000021400000000000011562 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloading/src/test/java/org/jboss/test/classloading/dependency/test/UsesPackageUnitTestCase.javalibjboss-classloader-java-2.0.6.GA.orig/classloading/src/test/java/org/jboss/test/classloading/depen0000644000175000017500000000701110756304141033423 0ustar twernertwerner/* * JBoss, Home of Professional Open Source. * Copyright 2008, Red Hat Middleware LLC, and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.test.classloading.dependency.test; import junit.framework.Test; import org.jboss.classloading.spi.dependency.policy.mock.MockClassLoadingMetaData; import org.jboss.classloading.spi.metadata.ClassLoadingMetaDataFactory; import org.jboss.kernel.spi.dependency.KernelControllerContext; import org.jboss.test.classloading.dependency.support.a.A; /** * ReExportPackageUnitTestCase. * * @author Adrian Brock * @version $Revision: 1.1 $ */ public class UsesPackageUnitTestCase extends AbstractMockClassLoaderUnitTest { public static Test suite() { return suite(UsesPackageUnitTestCase.class); } public UsesPackageUnitTestCase(String name) { super(name); } public void testUsesImport() throws Exception { ClassLoadingMetaDataFactory factory = ClassLoadingMetaDataFactory.getInstance(); MockClassLoadingMetaData a1 = new MockClassLoadingMetaData("a1"); a1.setPathsAndPackageNames(A.class); KernelControllerContext contextA1 = install(a1); try { ClassLoader clA1 = assertClassLoader(contextA1); assertLoadClass(A.class, clA1); MockClassLoadingMetaData a2 = new MockClassLoadingMetaData("a2"); a2.getRequirements().addRequirement(factory.createUsesPackage(A.class.getPackage().getName())); a2.setPathsAndPackageNames(A.class); KernelControllerContext contextA2 = install(a2); try { assertLoadClass(A.class, clA1); ClassLoader clA2 = assertClassLoader(contextA2); assertLoadClass(A.class, clA2, clA1); } finally { uninstall(contextA2); } assertNoClassLoader(contextA2); assertLoadClass(A.class, clA1); } finally { uninstall(contextA1); } assertNoClassLoader(contextA1); } public void testUsesNoImport() throws Exception { ClassLoadingMetaDataFactory factory = ClassLoadingMetaDataFactory.getInstance(); MockClassLoadingMetaData a1 = new MockClassLoadingMetaData("a1"); a1.getRequirements().addRequirement(factory.createUsesPackage(A.class.getPackage().getName())); a1.setPaths(A.class); KernelControllerContext contextA1 = install(a1); try { ClassLoader clA1 = assertClassLoader(contextA1); assertLoadClass(A.class, clA1); } finally { uninstall(contextA1); } assertNoClassLoader(contextA1); } } ././@LongLink0000000000000000000000000000021200000000000011560 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloading/src/test/java/org/jboss/test/classloading/dependency/test/ImportAllUnitTestCase.javalibjboss-classloader-java-2.0.6.GA.orig/classloading/src/test/java/org/jboss/test/classloading/depen0000644000175000017500000000554210756304141033432 0ustar twernertwerner/* * JBoss, Home of Professional Open Source. * Copyright 2008, Red Hat Middleware LLC, and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.test.classloading.dependency.test; import junit.framework.Test; import org.jboss.classloading.spi.dependency.policy.mock.MockClassLoadingMetaData; import org.jboss.kernel.spi.dependency.KernelControllerContext; import org.jboss.test.classloading.dependency.support.a.A; import org.jboss.test.classloading.dependency.support.b.B; /** * ImportAllUnitTestCase. * * @author Adrian Brock * @version $Revision: 1.1 $ */ public class ImportAllUnitTestCase extends AbstractMockClassLoaderUnitTest { public static Test suite() { return suite(ImportAllUnitTestCase.class); } public ImportAllUnitTestCase(String name) { super(name); } public void testImportAll() throws Exception { MockClassLoadingMetaData a = new MockClassLoadingMetaData("a"); a.setPathsAndPackageNames(A.class); KernelControllerContext contextA = install(a); try { ClassLoader clA = assertClassLoader(contextA); assertLoadClass(A.class, clA); assertLoadClassFail(B.class, clA); MockClassLoadingMetaData b = new MockClassLoadingMetaData("b"); b.setImportAll(true); b.setPathsAndPackageNames(B.class); KernelControllerContext contextB = install(b); try { assertLoadClass(A.class, clA); assertLoadClassFail(B.class, clA); ClassLoader clB = assertClassLoader(contextB); assertLoadClass(B.class, clB); assertLoadClass(A.class, clB, clA); } finally { uninstall(contextB); } assertLoadClass(A.class, clA); assertLoadClassFail(B.class, clA); assertNoClassLoader(contextB); } finally { uninstall(contextA); } assertNoClassLoader(contextA); } } ././@LongLink0000000000000000000000000000022200000000000011561 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloading/src/test/java/org/jboss/test/classloading/dependency/test/PackageDependencyUnitTestCase.javalibjboss-classloader-java-2.0.6.GA.orig/classloading/src/test/java/org/jboss/test/classloading/depen0000644000175000017500000001445610756304141033436 0ustar twernertwerner/* * JBoss, Home of Professional Open Source. * Copyright 2008, Red Hat Middleware LLC, and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.test.classloading.dependency.test; import junit.framework.Test; import org.jboss.classloading.spi.dependency.policy.mock.MockClassLoadingMetaData; import org.jboss.classloading.spi.metadata.ClassLoadingMetaDataFactory; import org.jboss.classloading.spi.version.VersionRange; import org.jboss.kernel.spi.dependency.KernelControllerContext; import org.jboss.test.classloading.dependency.support.a.A; import org.jboss.test.classloading.dependency.support.b.B; /** * PackageDependencyUnitTestCase. * * @author Adrian Brock * @version $Revision: 1.1 $ */ public class PackageDependencyUnitTestCase extends AbstractMockClassLoaderUnitTest { public static Test suite() { return suite(PackageDependencyUnitTestCase.class); } public PackageDependencyUnitTestCase(String name) { super(name); } public void testImportPackageNoVersionCheck() throws Exception { MockClassLoadingMetaData a = new MockClassLoadingMetaData("a"); ClassLoadingMetaDataFactory factory = ClassLoadingMetaDataFactory.getInstance(); a.getCapabilities().addCapability(factory.createModule("ModuleA")); a.getCapabilities().addCapability(factory.createPackage(A.class.getPackage().getName())); a.setPathsAndPackageNames(A.class); KernelControllerContext contextA = install(a); try { ClassLoader clA = assertClassLoader(contextA); assertLoadClass(A.class, clA); assertLoadClassFail(B.class, clA); MockClassLoadingMetaData b = new MockClassLoadingMetaData("b"); b.getRequirements().addRequirement(factory.createRequirePackage(A.class.getPackage().getName())); b.setPathsAndPackageNames(B.class); KernelControllerContext contextB = install(b); try { assertLoadClass(A.class, clA); assertLoadClassFail(B.class, clA); ClassLoader clB = assertClassLoader(contextB); assertLoadClass(B.class, clB); assertLoadClass(A.class, clB, clA); } finally { uninstall(contextB); } assertLoadClass(A.class, clA); assertLoadClassFail(B.class, clA); assertNoClassLoader(contextB); } finally { uninstall(contextA); } assertNoClassLoader(contextA); } public void testImportPackageVersionCheck() throws Exception { MockClassLoadingMetaData a = new MockClassLoadingMetaData("a"); ClassLoadingMetaDataFactory factory = ClassLoadingMetaDataFactory.getInstance(); a.getCapabilities().addCapability(factory.createModule("ModuleA")); a.getCapabilities().addCapability(factory.createPackage(A.class.getPackage().getName(), "1.0.0")); a.setPathsAndPackageNames(A.class); KernelControllerContext contextA = install(a); try { ClassLoader clA = assertClassLoader(contextA); assertLoadClass(A.class, clA); assertLoadClassFail(B.class, clA); MockClassLoadingMetaData b = new MockClassLoadingMetaData("b"); b.getRequirements().addRequirement(factory.createRequirePackage(A.class.getPackage().getName(), new VersionRange("1.0.0", "2.0.0"))); b.setPathsAndPackageNames(B.class); KernelControllerContext contextB = install(b); try { assertLoadClass(A.class, clA); assertLoadClassFail(B.class, clA); ClassLoader clB = assertClassLoader(contextB); assertLoadClass(B.class, clB); assertLoadClass(A.class, clB, clA); } finally { uninstall(contextB); } assertLoadClass(A.class, clA); assertLoadClassFail(B.class, clA); assertNoClassLoader(contextB); } finally { uninstall(contextA); } assertNoClassLoader(contextA); } public void testImportPackageVersionCheckFailed() throws Exception { MockClassLoadingMetaData a = new MockClassLoadingMetaData("a"); ClassLoadingMetaDataFactory factory = ClassLoadingMetaDataFactory.getInstance(); a.getCapabilities().addCapability(factory.createModule("ModuleA")); a.getCapabilities().addCapability(factory.createPackage(A.class.getPackage().getName(), "3.0.0")); a.setPathsAndPackageNames(A.class); KernelControllerContext contextA = install(a); try { ClassLoader clA = assertClassLoader(contextA); assertLoadClass(A.class, clA); assertLoadClassFail(B.class, clA); MockClassLoadingMetaData b = new MockClassLoadingMetaData("b"); b.getRequirements().addRequirement(factory.createRequirePackage(A.class.getPackage().getName(), new VersionRange("1.0.0", "2.0.0"))); b.setPathsAndPackageNames(B.class); KernelControllerContext contextB = install(b); try { assertLoadClass(A.class, clA); assertLoadClassFail(B.class, clA); assertNoClassLoader(contextB); } finally { uninstall(contextB); } assertLoadClass(A.class, clA); assertLoadClassFail(B.class, clA); assertNoClassLoader(contextB); } finally { uninstall(contextA); } assertNoClassLoader(contextA); } } ././@LongLink0000000000000000000000000000022000000000000011557 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloading/src/test/java/org/jboss/test/classloading/dependency/test/ReExportPackageUnitTestCase.javalibjboss-classloader-java-2.0.6.GA.orig/classloading/src/test/java/org/jboss/test/classloading/depen0000644000175000017500000001634710756304141033437 0ustar twernertwerner/* * JBoss, Home of Professional Open Source. * Copyright 2008, Red Hat Middleware LLC, and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.test.classloading.dependency.test; import junit.framework.Test; import org.jboss.classloading.spi.dependency.policy.mock.MockClassLoadingMetaData; import org.jboss.classloading.spi.metadata.ClassLoadingMetaDataFactory; import org.jboss.kernel.spi.dependency.KernelControllerContext; import org.jboss.test.classloading.dependency.support.a.A; import org.jboss.test.classloading.dependency.support.b.B; import org.jboss.test.classloading.dependency.support.c.C; /** * ReExportPackageUnitTestCase. * * @author Adrian Brock * @version $Revision: 1.1 $ */ public class ReExportPackageUnitTestCase extends AbstractMockClassLoaderUnitTest { public static Test suite() { return suite(ReExportPackageUnitTestCase.class); } public ReExportPackageUnitTestCase(String name) { super(name); } public void testReExport() throws Exception { ClassLoadingMetaDataFactory factory = ClassLoadingMetaDataFactory.getInstance(); MockClassLoadingMetaData a = new MockClassLoadingMetaData("a"); a.setPathsAndPackageNames(A.class); KernelControllerContext contextA = install(a); try { ClassLoader clA = assertClassLoader(contextA); assertLoadClass(A.class, clA); assertLoadClassFail(B.class, clA); assertLoadClassFail(C.class, clA); MockClassLoadingMetaData b = new MockClassLoadingMetaData("b"); b.getRequirements().addRequirement(factory.createReExportPackage(A.class.getPackage().getName())); b.setPathsAndPackageNames(B.class); KernelControllerContext contextB = install(b); try { assertLoadClass(A.class, clA); assertLoadClassFail(B.class, clA); assertLoadClassFail(C.class, clA); ClassLoader clB = assertClassLoader(contextB); assertLoadClass(A.class, clB, clA); assertLoadClass(B.class, clB); assertLoadClassFail(C.class, clB); MockClassLoadingMetaData c = new MockClassLoadingMetaData("c"); c.getRequirements().addRequirement(factory.createRequireModule("b")); c.setPathsAndPackageNames(C.class); KernelControllerContext contextC = install(c); try { assertLoadClass(A.class, clA); assertLoadClassFail(B.class, clA); assertLoadClassFail(C.class, clA); assertLoadClass(A.class, clB, clA); assertLoadClass(B.class, clB); assertLoadClassFail(C.class, clB); ClassLoader clC = assertClassLoader(contextC); assertLoadClass(A.class, clC, clA); assertLoadClass(B.class, clC, clB); assertLoadClass(C.class, clC); } finally { uninstall(contextC); } assertNoClassLoader(contextC); assertLoadClass(A.class, clA); assertLoadClassFail(B.class, clA); assertLoadClassFail(C.class, clA); assertLoadClass(A.class, clB, clA); assertLoadClass(B.class, clB); assertLoadClassFail(C.class, clB); } finally { uninstall(contextB); } assertNoClassLoader(contextB); assertLoadClass(A.class, clA); assertLoadClassFail(B.class, clA); assertLoadClassFail(C.class, clA); } finally { uninstall(contextA); } assertNoClassLoader(contextA); } public void testNoReExport() throws Exception { ClassLoadingMetaDataFactory factory = ClassLoadingMetaDataFactory.getInstance(); MockClassLoadingMetaData a = new MockClassLoadingMetaData("a"); a.setPathsAndPackageNames(A.class); KernelControllerContext contextA = install(a); try { ClassLoader clA = assertClassLoader(contextA); assertLoadClass(A.class, clA); assertLoadClassFail(B.class, clA); assertLoadClassFail(C.class, clA); MockClassLoadingMetaData b = new MockClassLoadingMetaData("b"); b.getRequirements().addRequirement(factory.createReExportPackage(A.class.getPackage().getName())); b.setPathsAndPackageNames(B.class); KernelControllerContext contextB = install(b); try { assertLoadClass(A.class, clA); assertLoadClassFail(B.class, clA); assertLoadClassFail(C.class, clA); ClassLoader clB = assertClassLoader(contextB); assertLoadClass(A.class, clB, clA); assertLoadClass(B.class, clB); assertLoadClassFail(C.class, clB); MockClassLoadingMetaData c = new MockClassLoadingMetaData("c"); c.getRequirements().addRequirement(factory.createRequirePackage(B.class.getPackage().getName())); c.setPathsAndPackageNames(C.class); KernelControllerContext contextC = install(c); try { assertLoadClass(A.class, clA); assertLoadClassFail(B.class, clA); assertLoadClassFail(C.class, clA); assertLoadClass(A.class, clB, clA); assertLoadClass(B.class, clB); assertLoadClassFail(C.class, clB); ClassLoader clC = assertClassLoader(contextC); assertLoadClassFail(A.class, clC); assertLoadClass(B.class, clC, clB); assertLoadClass(C.class, clC); } finally { uninstall(contextC); } assertNoClassLoader(contextC); assertLoadClass(A.class, clA); assertLoadClassFail(B.class, clA); assertLoadClassFail(C.class, clA); assertLoadClass(A.class, clB, clA); assertLoadClass(B.class, clB); assertLoadClassFail(C.class, clB); } finally { uninstall(contextB); } assertNoClassLoader(contextB); assertLoadClass(A.class, clA); assertLoadClassFail(B.class, clA); assertLoadClassFail(C.class, clA); } finally { uninstall(contextA); } assertNoClassLoader(contextA); } } ././@LongLink0000000000000000000000000000022400000000000011563 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloading/src/test/java/org/jboss/test/classloading/dependency/test/AbstractMockClassLoaderUnitTest.javalibjboss-classloader-java-2.0.6.GA.orig/classloading/src/test/java/org/jboss/test/classloading/depen0000644000175000017500000001460511035356200033424 0ustar twernertwerner/* * JBoss, Home of Professional Open Source. * Copyright 2008, Red Hat Middleware LLC, and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.test.classloading.dependency.test; import junit.framework.Test; import org.jboss.beans.metadata.spi.BeanMetaData; import org.jboss.beans.metadata.spi.builder.BeanMetaDataBuilder; import org.jboss.classloader.plugins.system.DefaultClassLoaderSystem; import org.jboss.classloader.spi.ClassLoaderDomain; import org.jboss.classloader.spi.ClassLoaderSystem; import org.jboss.classloader.spi.ParentPolicy; import org.jboss.classloading.spi.dependency.ClassLoading; import org.jboss.classloading.spi.dependency.policy.mock.MockClassLoaderPolicyModule; import org.jboss.classloading.spi.dependency.policy.mock.MockClassLoadingMetaData; import org.jboss.dependency.spi.ControllerState; import org.jboss.dependency.spi.ControllerStateModel; import org.jboss.kernel.Kernel; import org.jboss.kernel.plugins.bootstrap.AbstractBootstrap; import org.jboss.kernel.plugins.bootstrap.basic.BasicBootstrap; import org.jboss.kernel.spi.dependency.KernelController; import org.jboss.kernel.spi.dependency.KernelControllerContext; import org.jboss.test.classloading.AbstractClassLoadingTest; /** * AbstractMockClassLoaderUnitTest. * * @author Adrian Brock * @version $Revision: 1.1 $ */ public abstract class AbstractMockClassLoaderUnitTest extends AbstractClassLoadingTest { private KernelController controller; protected ClassLoaderSystem system; public static Test suite() { return suite(AbstractMockClassLoaderUnitTest.class); } public AbstractMockClassLoaderUnitTest(String name) { super(name); } protected ClassLoader assertClassLoader(KernelControllerContext context) throws Exception { MockClassLoaderPolicyModule module = assertModule(context); return module.registerClassLoaderPolicy(system); } protected MockClassLoaderPolicyModule assertModule(KernelControllerContext context) throws Exception { ControllerStateModel states = context.getController().getStates(); ControllerState state = context.getState(); ControllerState next = states.getNextState(state); assertEquals(context.getName() + " should be installed: " + state + " unresolved=" + context.getDependencyInfo().getUnresolvedDependencies(next), ControllerState.INSTALLED, context.getState()); Object target = context.getTarget(); assertNotNull(target); return assertInstanceOf(target, MockClassLoaderPolicyModule.class); } protected void assertNoClassLoader(KernelControllerContext context) throws Exception { assertNoModule(context); } protected void assertNoModule(KernelControllerContext context) throws Exception { boolean test = ControllerState.INSTALLED.equals(context.getState()); if (test) { MockClassLoaderPolicyModule module = assertModule(context); Object target = context.getTarget(); assertNotNull(target); try { fail("Should not be able to create classloader: " + module.registerClassLoaderPolicy(system)); } catch (IllegalStateException expected) { } } } protected KernelControllerContext install(MockClassLoadingMetaData metaData) throws Exception { return install(metaData, MockClassLoaderPolicyModule.class); } protected KernelControllerContext install(MockClassLoadingMetaData metaData, Class clazz) throws Exception { // Determine some properties String contextName = metaData.getName() + ":" + metaData.getVersion().toString(); // Create the module BeanMetaDataBuilder builder = BeanMetaDataBuilder.createBuilder(contextName, clazz.getName()); builder.addConstructorParameter(MockClassLoadingMetaData.class.getName(), metaData); builder.addConstructorParameter(String.class.getName(), contextName); builder.setNoClassLoader(); builder.addUninstall("removeClassLoader"); BeanMetaData module = builder.getBeanMetaData(); return install(module); } protected KernelControllerContext install(BeanMetaData beanMetaData) throws Exception { try { return controller.install(beanMetaData); } catch (Exception e) { throw e; } catch (Throwable t) { throw new RuntimeException("Error during install: " + beanMetaData, t); } } protected void uninstall(KernelControllerContext context) { controller.uninstall(context.getName()); } protected void setUp() throws Exception { super.setUp(); // Bootstrap the kernel AbstractBootstrap bootstrap = new BasicBootstrap(); bootstrap.run(); Kernel kernel = bootstrap.getKernel(); controller = kernel.getController(); system = new DefaultClassLoaderSystem(); ClassLoaderDomain defaultDomain = system.getDefaultDomain(); defaultDomain.setParentPolicy(ParentPolicy.BEFORE_BUT_JAVA_ONLY); BeanMetaDataBuilder builder = BeanMetaDataBuilder.createBuilder("ClassLoading", ClassLoading.class.getName()); builder.addMethodInstallCallback("addModule", null, null, ControllerState.CONFIGURED, null); builder.addMethodUninstallCallback("removeModule", null, null, ControllerState.CONFIGURED, null); install(builder.getBeanMetaData()); } protected void tearDown() throws Exception { controller.shutdown(); super.tearDown(); } } ././@LongLink0000000000000000000000000000022100000000000011560 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloading/src/test/java/org/jboss/test/classloading/dependency/test/ModuleDependencyUnitTestCase.javalibjboss-classloader-java-2.0.6.GA.orig/classloading/src/test/java/org/jboss/test/classloading/depen0000644000175000017500000001434510756304141033433 0ustar twernertwerner/* * JBoss, Home of Professional Open Source. * Copyright 2008, Red Hat Middleware LLC, and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.test.classloading.dependency.test; import junit.framework.Test; import org.jboss.classloading.spi.dependency.policy.mock.MockClassLoadingMetaData; import org.jboss.classloading.spi.metadata.ClassLoadingMetaDataFactory; import org.jboss.classloading.spi.version.VersionRange; import org.jboss.kernel.spi.dependency.KernelControllerContext; import org.jboss.test.classloading.dependency.support.a.A; import org.jboss.test.classloading.dependency.support.b.B; /** * ModuleDependencyUnitTestCase. * * @author Adrian Brock * @version $Revision: 1.1 $ */ public class ModuleDependencyUnitTestCase extends AbstractMockClassLoaderUnitTest { public static Test suite() { return suite(ModuleDependencyUnitTestCase.class); } public ModuleDependencyUnitTestCase(String name) { super(name); } public void testImportModuleNoVersionCheck() throws Exception { MockClassLoadingMetaData a = new MockClassLoadingMetaData("a"); ClassLoadingMetaDataFactory factory = ClassLoadingMetaDataFactory.getInstance(); a.getCapabilities().addCapability(factory.createModule("ModuleA")); a.getCapabilities().addCapability(factory.createPackage(A.class.getPackage().getName())); a.setPathsAndPackageNames(A.class); KernelControllerContext contextA = install(a); try { ClassLoader clA = assertClassLoader(contextA); assertLoadClass(A.class, clA); assertLoadClassFail(B.class, clA); MockClassLoadingMetaData b = new MockClassLoadingMetaData("b"); b.getRequirements().addRequirement(factory.createRequireModule("ModuleA")); b.setPathsAndPackageNames(B.class); KernelControllerContext contextB = install(b); try { assertLoadClass(A.class, clA); assertLoadClassFail(B.class, clA); ClassLoader clB = assertClassLoader(contextB); assertLoadClass(B.class, clB); assertLoadClass(A.class, clB, clA); } finally { uninstall(contextB); } assertLoadClass(A.class, clA); assertLoadClassFail(B.class, clA); assertNoClassLoader(contextB); } finally { uninstall(contextA); } assertNoClassLoader(contextA); } public void testImportModuleVersionCheck() throws Exception { MockClassLoadingMetaData a = new MockClassLoadingMetaData("a"); ClassLoadingMetaDataFactory factory = ClassLoadingMetaDataFactory.getInstance(); a.getCapabilities().addCapability(factory.createModule("ModuleA", "1.0.0")); a.getCapabilities().addCapability(factory.createPackage(A.class.getPackage().getName())); a.setPathsAndPackageNames(A.class); KernelControllerContext contextA = install(a); try { ClassLoader clA = assertClassLoader(contextA); assertLoadClass(A.class, clA); assertLoadClassFail(B.class, clA); MockClassLoadingMetaData b = new MockClassLoadingMetaData("b"); b.getRequirements().addRequirement(factory.createRequireModule("ModuleA", new VersionRange("1.0.0", "2.0.0"))); b.setPathsAndPackageNames(B.class); KernelControllerContext contextB = install(b); try { assertLoadClass(A.class, clA); assertLoadClassFail(B.class, clA); ClassLoader clB = assertClassLoader(contextB); assertLoadClass(B.class, clB); assertLoadClass(A.class, clB, clA); } finally { uninstall(contextB); } assertLoadClass(A.class, clA); assertLoadClassFail(B.class, clA); assertNoClassLoader(contextB); } finally { uninstall(contextA); } assertNoClassLoader(contextA); } public void testImportModuleVersionCheckFailed() throws Exception { MockClassLoadingMetaData a = new MockClassLoadingMetaData("a"); ClassLoadingMetaDataFactory factory = ClassLoadingMetaDataFactory.getInstance(); a.getCapabilities().addCapability(factory.createModule("ModuleA", "3.0.0")); a.getCapabilities().addCapability(factory.createPackage(A.class.getPackage().getName())); a.setPathsAndPackageNames(A.class); KernelControllerContext contextA = install(a); try { ClassLoader clA = assertClassLoader(contextA); assertLoadClass(A.class, clA); assertLoadClassFail(B.class, clA); MockClassLoadingMetaData b = new MockClassLoadingMetaData("b"); b.getRequirements().addRequirement(factory.createRequireModule("ModuleA", new VersionRange("1.0.0", "2.0.0"))); b.setPathsAndPackageNames(B.class); KernelControllerContext contextB = install(b); try { assertLoadClass(A.class, clA); assertLoadClassFail(B.class, clA); assertNoClassLoader(contextB); } finally { uninstall(contextB); } assertLoadClass(A.class, clA); assertLoadClassFail(B.class, clA); assertNoClassLoader(contextB); } finally { uninstall(contextA); } assertNoClassLoader(contextA); } } ././@LongLink0000000000000000000000000000022300000000000011562 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloading/src/test/java/org/jboss/test/classloading/dependency/test/ConflictingPackageUnitTestCase.javalibjboss-classloader-java-2.0.6.GA.orig/classloading/src/test/java/org/jboss/test/classloading/depen0000644000175000017500000001723311035356200033424 0ustar twernertwerner/* * JBoss, Home of Professional Open Source. * Copyright 2008, Red Hat Middleware LLC, and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.test.classloading.dependency.test; import junit.framework.Test; import org.jboss.classloading.spi.dependency.policy.mock.MockClassLoadingMetaData; import org.jboss.classloading.spi.metadata.ClassLoadingMetaDataFactory; import org.jboss.kernel.spi.dependency.KernelControllerContext; import org.jboss.test.classloading.dependency.support.a.A; import org.jboss.test.classloading.dependency.support.b.B; /** * ConflictingPackageUnitTestCase. * * @author Adrian Brock * @version $Revision: 1.1 $ */ public class ConflictingPackageUnitTestCase extends AbstractMockClassLoaderUnitTest { public static Test suite() { return suite(ConflictingPackageUnitTestCase.class); } public ConflictingPackageUnitTestCase(String name) { super(name); } public void testConflictingPackage() throws Exception { ClassLoadingMetaDataFactory factory = ClassLoadingMetaDataFactory.getInstance(); MockClassLoadingMetaData a1 = new MockClassLoadingMetaData("a1", "1.0.0"); a1.setPathsAndPackageNames(A.class); KernelControllerContext contextA1 = install(a1); try { ClassLoader clA1 = assertClassLoader(contextA1); assertLoadClass(A.class, clA1); assertLoadClassFail(B.class, clA1); MockClassLoadingMetaData a2 = new MockClassLoadingMetaData("a2", "2.0.0"); a2.getRequirements().addRequirement(factory.createRequireModule("a1")); a2.setPathsAndPackageNames(A.class); KernelControllerContext contextA2 = install(a2); try { assertNoClassLoader(contextA2); } finally { uninstall(contextA2); } assertNoClassLoader(contextA2); } finally { uninstall(contextA1); } assertNoClassLoader(contextA1); } public void testConflictingPackageNoImport() throws Exception { MockClassLoadingMetaData a1 = new MockClassLoadingMetaData("a1", "1.0.0"); a1.setPathsAndPackageNames(A.class); KernelControllerContext contextA1 = install(a1); try { ClassLoader clA1 = assertClassLoader(contextA1); assertLoadClass(A.class, clA1); assertLoadClassFail(B.class, clA1); MockClassLoadingMetaData a2 = new MockClassLoadingMetaData("a2", "2.0.0"); a2.setPathsAndPackageNames(A.class); KernelControllerContext contextA2 = install(a2); try { ClassLoader clA2 = assertClassLoader(contextA2); assertLoadClass(A.class, clA2); assertLoadClassFail(B.class, clA2); } finally { uninstall(contextA2); } assertNoClassLoader(contextA2); } finally { uninstall(contextA1); } assertNoClassLoader(contextA1); } public void testConflictingPackageNoExport() throws Exception { ClassLoadingMetaDataFactory factory = ClassLoadingMetaDataFactory.getInstance(); MockClassLoadingMetaData a1 = new MockClassLoadingMetaData("a1", "1.0.0"); a1.setPaths(A.class); KernelControllerContext contextA1 = install(a1); try { ClassLoader clA1 = assertClassLoader(contextA1); assertLoadClass(A.class, clA1); assertLoadClassFail(B.class, clA1); MockClassLoadingMetaData a2 = new MockClassLoadingMetaData("a2", "2.0.0"); a2.getRequirements().addRequirement(factory.createRequireModule("a1")); a2.setPathsAndPackageNames(A.class); KernelControllerContext contextA2 = install(a2); try { ClassLoader clA2 = assertClassLoader(contextA2); assertLoadClass(A.class, clA2); assertLoadClassFail(B.class, clA2); } finally { uninstall(contextA2); } assertNoClassLoader(contextA2); } finally { uninstall(contextA1); } assertNoClassLoader(contextA1); } public void testConflictingPackageUses() throws Exception { ClassLoadingMetaDataFactory factory = ClassLoadingMetaDataFactory.getInstance(); MockClassLoadingMetaData a1 = new MockClassLoadingMetaData("a1", "1.0.0"); a1.setPathsAndPackageNames(A.class); KernelControllerContext contextA1 = install(a1); try { ClassLoader clA1 = assertClassLoader(contextA1); assertLoadClass(A.class, clA1); assertLoadClassFail(B.class, clA1); MockClassLoadingMetaData a2 = new MockClassLoadingMetaData("a2", "2.0.0"); a2.getRequirements().addRequirement(factory.createUsesPackage(A.class.getPackage().getName())); a2.setPathsAndPackageNames(A.class); KernelControllerContext contextA2 = install(a2); try { ClassLoader clA2 = assertClassLoader(contextA2); assertLoadClass(A.class, clA2, clA1); assertLoadClassFail(B.class, clA2); } finally { uninstall(contextA2); } assertNoClassLoader(contextA2); } finally { uninstall(contextA1); } assertNoClassLoader(contextA1); } public void testConflictingPackageRedeploy() throws Exception { ClassLoadingMetaDataFactory factory = ClassLoadingMetaDataFactory.getInstance(); MockClassLoadingMetaData a1 = new MockClassLoadingMetaData("a1", "1.0.0"); a1.getRequirements().addRequirement(factory.createRequireModule("a2")); a1.setPathsAndPackageNames(A.class); KernelControllerContext contextA1 = install(a1); try { assertNoClassLoader(contextA1); MockClassLoadingMetaData a2 = new MockClassLoadingMetaData("a2", "2.0.0"); a2.setPathsAndPackageNames(A.class); KernelControllerContext contextA2 = install(a2); try { ClassLoader clA2 = assertClassLoader(contextA2); assertLoadClass(A.class, clA2); assertLoadClassFail(B.class, clA2); uninstall(contextA1); a1 = new MockClassLoadingMetaData("a1", "1.0.0"); a1.getRequirements().addRequirement(factory.createRequireModule("a2")); a1.setPathsAndPackageNames(B.class); contextA1 = install(a1); ClassLoader clA1 = assertClassLoader(contextA1); assertLoadClass(A.class, clA2); assertLoadClass(B.class, clA1); } finally { uninstall(contextA2); } assertNoClassLoader(contextA2); } finally { uninstall(contextA1); } assertNoClassLoader(contextA1); } } ././@LongLink0000000000000000000000000000021300000000000011561 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloading/src/test/java/org/jboss/test/classloading/dependency/test/DependencyUnitTestCase.javalibjboss-classloader-java-2.0.6.GA.orig/classloading/src/test/java/org/jboss/test/classloading/depen0000644000175000017500000002136710756304141033435 0ustar twernertwerner/* * JBoss, Home of Professional Open Source. * Copyright 2008, Red Hat Middleware LLC, and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.test.classloading.dependency.test; import java.util.Collections; import junit.framework.Test; import org.jboss.classloading.spi.dependency.policy.mock.MockClassLoadingMetaData; import org.jboss.classloading.spi.metadata.ClassLoadingMetaDataFactory; import org.jboss.classloading.spi.metadata.Requirement; import org.jboss.kernel.spi.dependency.KernelControllerContext; import org.jboss.test.classloading.dependency.support.a.A; import org.jboss.test.classloading.dependency.support.b.B; /** * DependencyUnitTestCase. * * @author Adrian Brock * @version $Revision: 1.1 $ */ public class DependencyUnitTestCase extends AbstractMockClassLoaderUnitTest { public static Test suite() { return suite(DependencyUnitTestCase.class); } public DependencyUnitTestCase(String name) { super(name); } public void testSmoke() throws Exception { MockClassLoadingMetaData a = new MockClassLoadingMetaData("a"); a.setPathsAndPackageNames(A.class); KernelControllerContext contextA = install(a); try { ClassLoader clA = assertClassLoader(contextA); assertLoadClass(A.class, clA); assertLoadClassFail(B.class, clA); } finally { uninstall(contextA); } assertNoClassLoader(contextA); } public void testBDependsACorrectWay() throws Exception { MockClassLoadingMetaData a = new MockClassLoadingMetaData("a"); a.setPathsAndPackageNames(A.class); KernelControllerContext contextA = install(a); try { ClassLoader clA = assertClassLoader(contextA); assertLoadClass(A.class, clA); assertLoadClassFail(B.class, clA); MockClassLoadingMetaData b = new MockClassLoadingMetaData("b"); b.setPathsAndPackageNames(B.class); ClassLoadingMetaDataFactory factory = ClassLoadingMetaDataFactory.getInstance(); Requirement requirement = factory.createRequirePackage(A.class.getPackage().getName()); b.setRequirements(Collections.singletonList(requirement)); KernelControllerContext contextB = install(b); try { assertLoadClass(A.class, clA); assertLoadClassFail(B.class, clA); ClassLoader clB = assertClassLoader(contextB); assertLoadClass(B.class, clB); assertLoadClass(A.class, clB, clA); } finally { uninstall(contextB); } assertLoadClass(A.class, clA); assertLoadClassFail(B.class, clA); assertNoClassLoader(contextB); } finally { uninstall(contextA); } assertNoClassLoader(contextA); } public void testBDependsAWrongWay() throws Exception { MockClassLoadingMetaData b = new MockClassLoadingMetaData("b"); b.setPathsAndPackageNames(B.class); ClassLoadingMetaDataFactory factory = ClassLoadingMetaDataFactory.getInstance(); Requirement requirement = factory.createRequirePackage(A.class.getPackage().getName()); b.setRequirements(Collections.singletonList(requirement)); KernelControllerContext contextB = install(b); try { assertNoClassLoader(contextB); MockClassLoadingMetaData a = new MockClassLoadingMetaData("a"); a.setPathsAndPackageNames(A.class); KernelControllerContext contextA = install(a); try { ClassLoader clA = assertClassLoader(contextA); assertLoadClass(A.class, clA); assertLoadClassFail(B.class, clA); ClassLoader clB = assertClassLoader(contextB); assertLoadClass(B.class, clB); assertLoadClass(A.class, clB, clA); } finally { uninstall(contextA); } assertNoClassLoader(contextA); } finally { uninstall(contextB); } assertNoClassLoader(contextB); } public void testBDependsARedeployA() throws Exception { MockClassLoadingMetaData a = new MockClassLoadingMetaData("a"); a.setPathsAndPackageNames(A.class); KernelControllerContext contextA = install(a); try { ClassLoader clA = assertClassLoader(contextA); assertLoadClass(A.class, clA); assertLoadClassFail(B.class, clA); MockClassLoadingMetaData b = new MockClassLoadingMetaData("b"); b.setPathsAndPackageNames(B.class); ClassLoadingMetaDataFactory factory = ClassLoadingMetaDataFactory.getInstance(); Requirement requirement = factory.createRequirePackage(A.class.getPackage().getName()); b.setRequirements(Collections.singletonList(requirement)); KernelControllerContext contextB = install(b); try { assertLoadClass(A.class, clA); assertLoadClassFail(B.class, clA); ClassLoader clB = assertClassLoader(contextB); assertLoadClass(B.class, clB); assertLoadClass(A.class, clB, clA); uninstall(contextA); try { assertNoClassLoader(contextA); assertNoClassLoader(contextB); } finally { contextA = install(a); } clA = assertClassLoader(contextA); assertLoadClass(A.class, clA); assertLoadClassFail(B.class, clA); clB = assertClassLoader(contextB); assertLoadClass(B.class, clB); assertLoadClass(A.class, clB, clA); } finally { uninstall(contextB); } assertLoadClass(A.class, clA); assertLoadClassFail(B.class, clA); assertNoClassLoader(contextB); } finally { uninstall(contextA); } assertNoClassLoader(contextA); } public void testBDependsARedeployB() throws Exception { MockClassLoadingMetaData a = new MockClassLoadingMetaData("a"); a.setPathsAndPackageNames(A.class); KernelControllerContext contextA = install(a); try { ClassLoader clA = assertClassLoader(contextA); assertLoadClass(A.class, clA); assertLoadClassFail(B.class, clA); MockClassLoadingMetaData b = new MockClassLoadingMetaData("b"); b.setPathsAndPackageNames(B.class); ClassLoadingMetaDataFactory factory = ClassLoadingMetaDataFactory.getInstance(); Requirement requirement = factory.createRequirePackage(A.class.getPackage().getName()); b.setRequirements(Collections.singletonList(requirement)); KernelControllerContext contextB = install(b); try { assertLoadClass(A.class, clA); assertLoadClassFail(B.class, clA); ClassLoader clB = assertClassLoader(contextB); assertLoadClass(B.class, clB); assertLoadClass(A.class, clB, clA); uninstall(contextB); try { assertLoadClass(A.class, clA); assertLoadClassFail(B.class, clA); assertNoClassLoader(contextB); } finally { contextB = install(b); } assertLoadClass(A.class, clA); assertLoadClassFail(B.class, clA); clB = assertClassLoader(contextB); assertLoadClass(B.class, clB); assertLoadClass(A.class, clB, clA); } finally { uninstall(contextB); } assertLoadClass(A.class, clA); assertLoadClassFail(B.class, clA); assertNoClassLoader(contextB); } finally { uninstall(contextA); } assertNoClassLoader(contextA); } } ././@LongLink0000000000000000000000000000020700000000000011564 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloading/src/test/java/org/jboss/test/classloading/dependency/test/DomainUnitTestCase.javalibjboss-classloader-java-2.0.6.GA.orig/classloading/src/test/java/org/jboss/test/classloading/depen0000644000175000017500000001417110756304141033430 0ustar twernertwerner/* * JBoss, Home of Professional Open Source. * Copyright 2008, Red Hat Middleware LLC, and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.test.classloading.dependency.test; import junit.framework.Test; import org.jboss.classloader.spi.ClassLoaderDomain; import org.jboss.classloader.spi.ParentPolicy; import org.jboss.classloading.spi.dependency.policy.mock.MockClassLoadingMetaData; import org.jboss.kernel.spi.dependency.KernelControllerContext; import org.jboss.test.classloading.dependency.support.a.A; import org.jboss.test.classloading.dependency.support.b.B; /** * DomainUnitTestCase. * * @author Adrian Brock * @version $Revision: 1.1 $ */ public class DomainUnitTestCase extends AbstractMockClassLoaderUnitTest { public static Test suite() { return suite(DomainUnitTestCase.class); } public DomainUnitTestCase(String name) { super(name); } public void testDefaultDomain() throws Exception { MockClassLoadingMetaData a = new MockClassLoadingMetaData("a"); a.setPathsAndPackageNames(A.class); KernelControllerContext contextA = install(a); try { ClassLoader clA = assertClassLoader(contextA); assertLoadClass(A.class, clA); assertLoadClassFail(B.class, clA); } finally { uninstall(contextA); } assertNoClassLoader(contextA); } public void testSubDomainParentBefore() throws Exception { MockClassLoadingMetaData a = new MockClassLoadingMetaData("a"); a.setPathsAndPackageNames(A.class); KernelControllerContext contextA = install(a); try { ClassLoader clA = assertClassLoader(contextA); assertLoadClass(A.class, clA); assertLoadClassFail(B.class, clA); MockClassLoadingMetaData b = new MockClassLoadingMetaData("b"); b.setDomain("SubDomain"); b.setPathsAndPackageNames(A.class, B.class); KernelControllerContext contextB = install(b); try { assertLoadClass(A.class, clA); assertLoadClassFail(B.class, clA); ClassLoader clB = assertClassLoader(contextB); assertLoadClass(B.class, clB); assertLoadClass(A.class, clB, clA); } finally { uninstall(contextB); } assertLoadClass(A.class, clA); assertLoadClassFail(B.class, clA); assertNoClassLoader(contextB); } finally { uninstall(contextA); } assertNoClassLoader(contextA); } public void testSubDomainParentAfter() throws Exception { MockClassLoadingMetaData a = new MockClassLoadingMetaData("a"); a.setPathsAndPackageNames(A.class); KernelControllerContext contextA = install(a); try { ClassLoader clA = assertClassLoader(contextA); assertLoadClass(A.class, clA); assertLoadClassFail(B.class, clA); MockClassLoadingMetaData b = new MockClassLoadingMetaData("b"); b.setDomain("SubDomain"); b.setJ2seClassLoadingCompliance(false); b.setPathsAndPackageNames(A.class, B.class); KernelControllerContext contextB = install(b); try { assertLoadClass(A.class, clA); assertLoadClassFail(B.class, clA); ClassLoader clB = assertClassLoader(contextB); assertLoadClass(B.class, clB); assertLoadClass(A.class, clB); } finally { uninstall(contextB); } assertLoadClass(A.class, clA); assertLoadClassFail(B.class, clA); assertNoClassLoader(contextB); } finally { uninstall(contextA); } assertNoClassLoader(contextA); } public void testParentDoesNotExist() throws Exception { MockClassLoadingMetaData a = new MockClassLoadingMetaData("a"); a.setDomain("SubDomain"); a.setParentDomain("DOESNOTEXIST"); a.setPathsAndPackageNames(A.class); KernelControllerContext contextA = install(a); try { assertNoClassLoader(contextA); } catch (Throwable t) { checkThrowable(IllegalStateException.class, t); } finally { uninstall(contextA); } assertNoClassLoader(contextA); } public void testParentDoesExists() throws Exception { ClassLoaderDomain domain = system.createAndRegisterDomain("TestDomain", ParentPolicy.BEFORE_BUT_JAVA_ONLY); try { MockClassLoadingMetaData a = new MockClassLoadingMetaData("a"); a.setDomain("SubDomain"); a.setParentDomain("TestDomain"); a.setPathsAndPackageNames(A.class); KernelControllerContext contextA = install(a); try { ClassLoader clA = assertClassLoader(contextA); assertLoadClass(A.class, clA); assertLoadClassFail(B.class, clA); } catch (Throwable t) { checkThrowable(IllegalStateException.class, t); } finally { uninstall(contextA); } assertNoClassLoader(contextA); } finally { system.unregisterDomain(domain); } } } ././@LongLink0000000000000000000000000000022700000000000011566 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloading/src/test/java/org/jboss/test/classloading/dependency/test/ConflictingRequirementUnitTestCase.javalibjboss-classloader-java-2.0.6.GA.orig/classloading/src/test/java/org/jboss/test/classloading/depen0000644000175000017500000003443611116232600033425 0ustar twernertwerner/* * JBoss, Home of Professional Open Source. * Copyright 2008, Red Hat Middleware LLC, and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.test.classloading.dependency.test; import junit.framework.Test; import org.jboss.classloading.spi.dependency.policy.mock.MockClassLoadingMetaData; import org.jboss.classloading.spi.metadata.ClassLoadingMetaDataFactory; import org.jboss.classloading.spi.version.VersionRange; import org.jboss.kernel.spi.dependency.KernelControllerContext; import org.jboss.test.classloading.dependency.support.a.A; import org.jboss.test.classloading.dependency.support.b.B; import org.jboss.test.classloading.dependency.support.c.C; /** * ConflictingPackageUnitTestCase. * * @author Adrian Brock * @version $Revision: 1.1 $ */ public class ConflictingRequirementUnitTestCase extends AbstractMockClassLoaderUnitTest { public static Test suite() { return suite(ConflictingRequirementUnitTestCase.class); } public ConflictingRequirementUnitTestCase(String name) { super(name); } public void testConflictingRequirement() throws Exception { ClassLoadingMetaDataFactory factory = ClassLoadingMetaDataFactory.getInstance(); MockClassLoadingMetaData a1 = new MockClassLoadingMetaData("a", "1.0.0"); a1.setPathsAndPackageNames(A.class); KernelControllerContext contextA1 = install(a1); try { ClassLoader clA1 = assertClassLoader(contextA1); assertLoadClass(A.class, clA1); assertLoadClassFail(B.class, clA1); assertLoadClassFail(C.class, clA1); MockClassLoadingMetaData a2 = new MockClassLoadingMetaData("a", "2.0.0"); a2.setPathsAndPackageNames(A.class); KernelControllerContext contextA2 = install(a2); try { ClassLoader clA2 = assertClassLoader(contextA2); assertLoadClass(A.class, clA2); assertLoadClassFail(B.class, clA2); assertLoadClassFail(C.class, clA2); MockClassLoadingMetaData b1 = new MockClassLoadingMetaData("b", "1.0.0"); b1.getRequirements().addRequirement(factory.createRequireModule("a", new VersionRange("2.0.0", "3.0.0"))); b1.setPathsAndPackageNames(B.class); KernelControllerContext contextB1 = install(b1); try { ClassLoader clB1 = assertClassLoader(contextB1); assertLoadClass(B.class, clB1); assertLoadClass(A.class, clB1, clA2); assertLoadClassFail(C.class, clB1); MockClassLoadingMetaData c1 = new MockClassLoadingMetaData("c", "1.0.0"); c1.getRequirements().addRequirement(factory.createRequireModule("b")); c1.getRequirements().addRequirement(factory.createRequireModule("a", new VersionRange("1.0.0", "2.0.0"))); c1.setPathsAndPackageNames(C.class); KernelControllerContext contextC1 = install(c1); try { assertNoClassLoader(contextC1); } finally { uninstall(contextC1); } assertNoClassLoader(contextC1); } finally { uninstall(contextB1); } assertNoClassLoader(contextB1); } finally { uninstall(contextA2); } assertNoClassLoader(contextA2); } finally { uninstall(contextA1); } assertNoClassLoader(contextA1); } public void testConflictingRequirementNoJoin() throws Exception { ClassLoadingMetaDataFactory factory = ClassLoadingMetaDataFactory.getInstance(); MockClassLoadingMetaData a1 = new MockClassLoadingMetaData("a", "1.0.0"); a1.setPathsAndPackageNames(A.class); KernelControllerContext contextA1 = install(a1); try { ClassLoader clA1 = assertClassLoader(contextA1); assertLoadClass(A.class, clA1); assertLoadClassFail(B.class, clA1); assertLoadClassFail(C.class, clA1); MockClassLoadingMetaData a2 = new MockClassLoadingMetaData("a", "2.0.0"); a2.setPathsAndPackageNames(A.class); KernelControllerContext contextA2 = install(a2); try { ClassLoader clA2 = assertClassLoader(contextA2); assertLoadClass(A.class, clA2); assertLoadClassFail(B.class, clA2); assertLoadClassFail(C.class, clA2); MockClassLoadingMetaData b1 = new MockClassLoadingMetaData("b", "1.0.0"); b1.getRequirements().addRequirement(factory.createRequireModule("a", new VersionRange("2.0.0", "3.0.0"))); b1.setPathsAndPackageNames(B.class); KernelControllerContext contextB1 = install(b1); try { ClassLoader clB1 = assertClassLoader(contextB1); assertLoadClass(B.class, clB1); assertLoadClass(A.class, clB1, clA2); assertLoadClassFail(C.class, clB1); MockClassLoadingMetaData c1 = new MockClassLoadingMetaData("c", "1.0.0"); c1.getRequirements().addRequirement(factory.createRequireModule("a", new VersionRange("1.0.0", "2.0.0"))); c1.setPathsAndPackageNames(C.class); KernelControllerContext contextC1 = install(c1); try { ClassLoader clC1 = assertClassLoader(contextC1); assertLoadClass(C.class, clC1); assertLoadClass(A.class, clC1, clA1); assertLoadClassFail(B.class, clC1); } finally { uninstall(contextC1); } assertNoClassLoader(contextC1); } finally { uninstall(contextB1); } assertNoClassLoader(contextB1); } finally { uninstall(contextA2); } assertNoClassLoader(contextA2); } finally { uninstall(contextA1); } assertNoClassLoader(contextA1); } public void testRequirementIsConsistent() throws Exception { ClassLoadingMetaDataFactory factory = ClassLoadingMetaDataFactory.getInstance(); MockClassLoadingMetaData a1 = new MockClassLoadingMetaData("a", "1.0.0"); a1.setPathsAndPackageNames(A.class); KernelControllerContext contextA1 = install(a1); try { ClassLoader clA1 = assertClassLoader(contextA1); assertLoadClass(A.class, clA1); assertLoadClassFail(B.class, clA1); assertLoadClassFail(C.class, clA1); MockClassLoadingMetaData a2 = new MockClassLoadingMetaData("a", "2.0.0"); a2.setPathsAndPackageNames(A.class); KernelControllerContext contextA2 = install(a2); try { ClassLoader clA2 = assertClassLoader(contextA2); assertLoadClass(A.class, clA2); assertLoadClassFail(B.class, clA2); assertLoadClassFail(C.class, clA2); MockClassLoadingMetaData b1 = new MockClassLoadingMetaData("b", "1.0.0"); b1.getRequirements().addRequirement(factory.createRequireModule("a", new VersionRange("1.0.0", "2.0.0"))); b1.setPathsAndPackageNames(B.class); KernelControllerContext contextB1 = install(b1); try { ClassLoader clB1 = assertClassLoader(contextB1); assertLoadClass(B.class, clB1); assertLoadClass(A.class, clB1, clA1); assertLoadClassFail(C.class, clB1); MockClassLoadingMetaData c1 = new MockClassLoadingMetaData("c", "1.0.0"); c1.getRequirements().addRequirement(factory.createRequireModule("b")); c1.getRequirements().addRequirement(factory.createRequireModule("a", new VersionRange("1.0.0", "2.0.0"))); c1.setPathsAndPackageNames(C.class); KernelControllerContext contextC1 = install(c1); try { ClassLoader clC1 = assertClassLoader(contextC1); assertLoadClass(C.class, clC1); assertLoadClass(A.class, clC1, clA1); assertLoadClass(B.class, clC1, clB1); } finally { uninstall(contextC1); } assertNoClassLoader(contextC1); } finally { uninstall(contextB1); } assertNoClassLoader(contextB1); } finally { uninstall(contextA2); } assertNoClassLoader(contextA2); } finally { uninstall(contextA1); } assertNoClassLoader(contextA1); } public void testRequirementRedeploy() throws Exception { ClassLoadingMetaDataFactory factory = ClassLoadingMetaDataFactory.getInstance(); MockClassLoadingMetaData a1 = new MockClassLoadingMetaData("a", "1.0.0"); a1.setPathsAndPackageNames(A.class); KernelControllerContext contextA1 = install(a1); try { ClassLoader clA1 = assertClassLoader(contextA1); assertLoadClass(A.class, clA1); assertLoadClassFail(B.class, clA1); assertLoadClassFail(C.class, clA1); MockClassLoadingMetaData a2 = new MockClassLoadingMetaData("a", "2.0.0"); a2.setPathsAndPackageNames(A.class); KernelControllerContext contextA2 = install(a2); try { ClassLoader clA2 = assertClassLoader(contextA2); assertLoadClass(A.class, clA2); assertLoadClassFail(B.class, clA2); assertLoadClassFail(C.class, clA2); MockClassLoadingMetaData b1 = new MockClassLoadingMetaData("b", "1.0.0"); b1.getRequirements().addRequirement(factory.createRequireModule("a", new VersionRange("1.0.0", "2.0.0"))); b1.setPathsAndPackageNames(B.class); KernelControllerContext contextB1 = install(b1); try { ClassLoader clB1 = assertClassLoader(contextB1); assertLoadClass(B.class, clB1); assertLoadClass(A.class, clB1, clA1); assertLoadClassFail(C.class, clB1); MockClassLoadingMetaData c1 = new MockClassLoadingMetaData("c", "1.0.0"); c1.getRequirements().addRequirement(factory.createRequireModule("b")); c1.getRequirements().addRequirement(factory.createRequireModule("a", new VersionRange("2.0.0", "3.0.0"))); c1.setPathsAndPackageNames(C.class); KernelControllerContext contextC1 = install(c1); try { assertNoClassLoader(contextC1); } finally { uninstall(contextC1); } assertNoClassLoader(contextC1); c1 = new MockClassLoadingMetaData("c", "1.0.0"); c1.getRequirements().addRequirement(factory.createRequireModule("b")); c1.getRequirements().addRequirement(factory.createRequireModule("a", new VersionRange("1.0.0", "2.0.0"))); c1.setPathsAndPackageNames(C.class); contextC1 = install(c1); try { ClassLoader clC1 = assertClassLoader(contextC1); assertLoadClass(C.class, clC1); assertLoadClass(A.class, clC1, clA1); assertLoadClass(B.class, clC1, clB1); } finally { uninstall(contextC1); } assertNoClassLoader(contextC1); } finally { uninstall(contextB1); } assertNoClassLoader(contextB1); } finally { uninstall(contextA2); } assertNoClassLoader(contextA2); } finally { uninstall(contextA1); } assertNoClassLoader(contextA1); } public void testRequirementReferencesImportAll() throws Exception { ClassLoadingMetaDataFactory factory = ClassLoadingMetaDataFactory.getInstance(); MockClassLoadingMetaData a1 = new MockClassLoadingMetaData("a", "1.0.0"); a1.setPathsAndPackageNames(A.class); a1.setImportAll(true); KernelControllerContext contextA1 = install(a1); try { ClassLoader clA1 = assertClassLoader(contextA1); assertLoadClass(A.class, clA1); assertLoadClassFail(B.class, clA1); assertLoadClassFail(C.class, clA1); MockClassLoadingMetaData b1 = new MockClassLoadingMetaData("b", "1.0.0"); b1.getRequirements().addRequirement(factory.createRequireModule("a", new VersionRange("1.0.0", "2.0.0"))); b1.setPathsAndPackageNames(B.class); KernelControllerContext contextB1 = install(b1); try { ClassLoader clB1 = assertClassLoader(contextB1); assertLoadClass(B.class, clB1); assertLoadClass(A.class, clB1, clA1); assertLoadClassFail(C.class, clB1); } finally { uninstall(contextB1); } assertNoClassLoader(contextB1); } finally { uninstall(contextA1); } assertNoClassLoader(contextA1); } } ././@LongLink0000000000000000000000000000016300000000000011565 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloading/src/test/java/org/jboss/test/classloading/dependency/support/libjboss-classloader-java-2.0.6.GA.orig/classloading/src/test/java/org/jboss/test/classloading/depen0000755000175000017500000000000011620043417033417 5ustar twernertwerner././@LongLink0000000000000000000000000000021300000000000011561 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloading/src/test/java/org/jboss/test/classloading/dependency/support/MockResourceVisitor.javalibjboss-classloader-java-2.0.6.GA.orig/classloading/src/test/java/org/jboss/test/classloading/depen0000644000175000017500000000337011071406374033431 0ustar twernertwerner/* * JBoss, Home of Professional Open Source * Copyright 2006, JBoss Inc., and individual contributors as indicated * by the @authors tag. See the copyright.txt in the distribution for a * full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.test.classloading.dependency.support; import java.util.HashSet; import java.util.Set; import org.jboss.classloading.spi.visitor.ClassFilter; import org.jboss.classloading.spi.visitor.ResourceContext; import org.jboss.classloading.spi.visitor.ResourceFilter; /** * @author Ales Justin */ public class MockResourceVisitor implements ResourcesAdapter { private Set resources = new HashSet(); public ResourceFilter getFilter() { return ClassFilter.INSTANCE; } public void visit(ResourceContext resource) { resources.add(resource.getResourceName()); } public Set getResources() { return resources; } } ././@LongLink0000000000000000000000000000022400000000000011563 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloading/src/test/java/org/jboss/test/classloading/dependency/support/MockFederatedResourceVisitor.javalibjboss-classloader-java-2.0.6.GA.orig/classloading/src/test/java/org/jboss/test/classloading/depen0000644000175000017500000000411211071406374033424 0ustar twernertwerner/* * JBoss, Home of Professional Open Source * Copyright 2006, JBoss Inc., and individual contributors as indicated * by the @authors tag. See the copyright.txt in the distribution for a * full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.test.classloading.dependency.support; import java.util.HashSet; import java.util.Set; import org.jboss.classloading.plugins.visitor.FederatedResourceVisitor; import org.jboss.classloading.spi.visitor.ResourceFilter; import org.jboss.classloading.spi.visitor.ResourceVisitor; /** * @author Ales Justin */ public class MockFederatedResourceVisitor extends FederatedResourceVisitor implements ResourcesAdapter { private ResourceVisitor[] tmp; private Set resources = new HashSet(); public MockFederatedResourceVisitor(ResourceVisitor[] visitors, ResourceFilter[] filters, ResourceFilter[] recurseFilters) { super(visitors, filters, recurseFilters); tmp = visitors; } public Set getResources() { for (ResourceVisitor rv : tmp) { if (rv instanceof ResourcesAdapter) { ResourcesAdapter ra = (ResourcesAdapter)rv; resources.addAll(ra.getResources()); } } return resources; } }././@LongLink0000000000000000000000000000016500000000000011567 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloading/src/test/java/org/jboss/test/classloading/dependency/support/a/libjboss-classloader-java-2.0.6.GA.orig/classloading/src/test/java/org/jboss/test/classloading/depen0000755000175000017500000000000011620043417033417 5ustar twernertwerner././@LongLink0000000000000000000000000000017300000000000011566 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloading/src/test/java/org/jboss/test/classloading/dependency/support/a/A.javalibjboss-classloader-java-2.0.6.GA.orig/classloading/src/test/java/org/jboss/test/classloading/depen0000644000175000017500000000222610756304141033426 0ustar twernertwerner/* * JBoss, Home of Professional Open Source * Copyright 2008, JBoss Inc., and individual contributors as indicated * by the @authors tag. See the copyright.txt in the distribution for a * full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.test.classloading.dependency.support.a; /** * A. * * @author Adrian Brock * @version $Revision: 1.1 $ */ public class A { } ././@LongLink0000000000000000000000000000016500000000000011567 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloading/src/test/java/org/jboss/test/classloading/dependency/support/b/libjboss-classloader-java-2.0.6.GA.orig/classloading/src/test/java/org/jboss/test/classloading/depen0000755000175000017500000000000011620043417033417 5ustar twernertwerner././@LongLink0000000000000000000000000000017300000000000011566 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloading/src/test/java/org/jboss/test/classloading/dependency/support/b/B.javalibjboss-classloader-java-2.0.6.GA.orig/classloading/src/test/java/org/jboss/test/classloading/depen0000644000175000017500000000222610756304141033426 0ustar twernertwerner/* * JBoss, Home of Professional Open Source * Copyright 2008, JBoss Inc., and individual contributors as indicated * by the @authors tag. See the copyright.txt in the distribution for a * full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.test.classloading.dependency.support.b; /** * B. * * @author Adrian Brock * @version $Revision: 1.1 $ */ public class B { } ././@LongLink0000000000000000000000000000022300000000000011562 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloading/src/test/java/org/jboss/test/classloading/dependency/support/MockFilteredResourceVisitor.javalibjboss-classloader-java-2.0.6.GA.orig/classloading/src/test/java/org/jboss/test/classloading/depen0000644000175000017500000000351211071406374033427 0ustar twernertwerner/* * JBoss, Home of Professional Open Source * Copyright 2006, JBoss Inc., and individual contributors as indicated * by the @authors tag. See the copyright.txt in the distribution for a * full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.test.classloading.dependency.support; import java.util.regex.Pattern; import org.jboss.classloading.spi.visitor.ResourceContext; import org.jboss.classloading.spi.visitor.ResourceFilter; /** * @author Ales Justin */ public class MockFilteredResourceVisitor extends MockResourceVisitor { private Pattern excludePattern; public MockFilteredResourceVisitor(String excludeString) { this.excludePattern = Pattern.compile(excludeString); } @Override public ResourceFilter getFilter() { return new ResourceFilter() { public boolean accepts(ResourceContext resource) { return resource.isClass() && excludePattern.matcher(resource.getResourceName()).find() == false; } }; } }././@LongLink0000000000000000000000000000016500000000000011567 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloading/src/test/java/org/jboss/test/classloading/dependency/support/c/libjboss-classloader-java-2.0.6.GA.orig/classloading/src/test/java/org/jboss/test/classloading/depen0000755000175000017500000000000011620043417033417 5ustar twernertwerner././@LongLink0000000000000000000000000000017300000000000011566 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloading/src/test/java/org/jboss/test/classloading/dependency/support/c/C.javalibjboss-classloader-java-2.0.6.GA.orig/classloading/src/test/java/org/jboss/test/classloading/depen0000644000175000017500000000222610756304141033426 0ustar twernertwerner/* * JBoss, Home of Professional Open Source * Copyright 2008, JBoss Inc., and individual contributors as indicated * by the @authors tag. See the copyright.txt in the distribution for a * full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.test.classloading.dependency.support.c; /** * C. * * @author Adrian Brock * @version $Revision: 1.1 $ */ public class C { } ././@LongLink0000000000000000000000000000021000000000000011556 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloading/src/test/java/org/jboss/test/classloading/dependency/support/ResourcesAdapter.javalibjboss-classloader-java-2.0.6.GA.orig/classloading/src/test/java/org/jboss/test/classloading/depen0000644000175000017500000000246711071406374033437 0ustar twernertwerner/* * JBoss, Home of Professional Open Source * Copyright 2006, JBoss Inc., and individual contributors as indicated * by the @authors tag. See the copyright.txt in the distribution for a * full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.test.classloading.dependency.support; import java.util.Set; import org.jboss.classloading.spi.visitor.ResourceVisitor; /** * @author Ales Justin */ public interface ResourcesAdapter extends ResourceVisitor { Set getResources(); } ././@LongLink0000000000000000000000000000020300000000000011560 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloading/src/test/java/org/jboss/test/classloading/dependency/DependencyTestSuite.javalibjboss-classloader-java-2.0.6.GA.orig/classloading/src/test/java/org/jboss/test/classloading/depen0000644000175000017500000000674011035356200033425 0ustar twernertwerner/* * JBoss, Home of Professional Open Source. * Copyright 2008, Red Hat Middleware LLC, and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.test.classloading.dependency; import junit.framework.Test; import junit.framework.TestSuite; import junit.textui.TestRunner; import org.jboss.test.classloading.dependency.test.ConflictingPackageUnitTestCase; import org.jboss.test.classloading.dependency.test.ConflictingRequirementUnitTestCase; import org.jboss.test.classloading.dependency.test.DependencyUnitTestCase; import org.jboss.test.classloading.dependency.test.DomainUnitTestCase; import org.jboss.test.classloading.dependency.test.HierarchicalDomainUnitTestCase; import org.jboss.test.classloading.dependency.test.ImportAllUnitTestCase; import org.jboss.test.classloading.dependency.test.MockClassLoadingMetaDataUnitTestCase; import org.jboss.test.classloading.dependency.test.ModuleDependencyUnitTestCase; import org.jboss.test.classloading.dependency.test.PackageDependencyUnitTestCase; import org.jboss.test.classloading.dependency.test.ReExportModuleUnitTestCase; import org.jboss.test.classloading.dependency.test.ReExportPackageUnitTestCase; import org.jboss.test.classloading.dependency.test.UsesPackageUnitTestCase; import org.jboss.test.classloading.dependency.test.MockResourceVisitorUnitTestCase; /** * Version Test Suite. * * @author Adrian Brock * @version $Revision: 37459 $ */ public class DependencyTestSuite extends TestSuite { /** * For running the testsuite from the command line * * @param args the command line args */ public static void main(String[] args) { TestRunner.run(suite()); } /** * Create the testsuite * * @return the testsuite */ public static Test suite() { TestSuite suite = new TestSuite("Dependency Tests"); suite.addTest(MockClassLoadingMetaDataUnitTestCase.suite()); suite.addTest(DomainUnitTestCase.suite()); suite.addTest(ImportAllUnitTestCase.suite()); suite.addTest(ModuleDependencyUnitTestCase.suite()); suite.addTest(PackageDependencyUnitTestCase.suite()); suite.addTest(DependencyUnitTestCase.suite()); suite.addTest(ReExportModuleUnitTestCase.suite()); suite.addTest(ReExportPackageUnitTestCase.suite()); suite.addTest(UsesPackageUnitTestCase.suite()); suite.addTest(MockResourceVisitorUnitTestCase.suite()); suite.addTest(HierarchicalDomainUnitTestCase.suite()); suite.addTest(ConflictingPackageUnitTestCase.suite()); suite.addTest(ConflictingRequirementUnitTestCase.suite()); return suite; } } libjboss-classloader-java-2.0.6.GA.orig/classloading/src/main/0000755000175000017500000000000011620043420024070 5ustar twernertwernerlibjboss-classloader-java-2.0.6.GA.orig/classloading/src/main/java/0000755000175000017500000000000011620043420025011 5ustar twernertwernerlibjboss-classloader-java-2.0.6.GA.orig/classloading/src/main/java/org/0000755000175000017500000000000011620043420025600 5ustar twernertwernerlibjboss-classloader-java-2.0.6.GA.orig/classloading/src/main/java/org/jboss/0000755000175000017500000000000011620043420026720 5ustar twernertwernerlibjboss-classloader-java-2.0.6.GA.orig/classloading/src/main/java/org/jboss/classloading/0000755000175000017500000000000011620043420031363 5ustar twernertwernerlibjboss-classloader-java-2.0.6.GA.orig/classloading/src/main/java/org/jboss/classloading/plugins/0000755000175000017500000000000011620043420033044 5ustar twernertwerner././@LongLink0000000000000000000000000000015400000000000011565 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloading/src/main/java/org/jboss/classloading/plugins/metadata/libjboss-classloader-java-2.0.6.GA.orig/classloading/src/main/java/org/jboss/classloading/plugins/me0000755000175000017500000000000011620043420033366 5ustar twernertwerner././@LongLink0000000000000000000000000000020700000000000011564 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloading/src/main/java/org/jboss/classloading/plugins/metadata/UsesPackageRequirement.javalibjboss-classloader-java-2.0.6.GA.orig/classloading/src/main/java/org/jboss/classloading/plugins/me0000644000175000017500000000427710756304141033413 0ustar twernertwerner/* * JBoss, Home of Professional Open Source * Copyright 2006, JBoss Inc., and individual contributors as indicated * by the @authors tag. See the copyright.txt in the distribution for a * full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.classloading.plugins.metadata; import org.jboss.classloading.spi.version.VersionRange; /** * UsesPackageRequirement. * * @author Adrian Brock * @version $Revision: 1.1 $ */ public class UsesPackageRequirement extends PackageRequirement { /** The serialVersionUID */ private static final long serialVersionUID = -7552921085464308835L; /** * Create a new UsesPackageRequirement. */ public UsesPackageRequirement() { init(); } /** * Create a new UsesPackageRequirement with no version constraint * * @param name the name * @throws IllegalArgumentException for a null name */ public UsesPackageRequirement(String name) { super(name); init(); } /** * Create a new UsesPackageRequirement. * * @param name the name * @param versionRange the version range - pass null for all versions * @throws IllegalArgumentException for a null name */ public UsesPackageRequirement(String name, VersionRange versionRange) { super(name, versionRange); init(); } /** * Initialise the requirement */ protected void init() { setOptional(true); } } ././@LongLink0000000000000000000000000000020300000000000011560 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloading/src/main/java/org/jboss/classloading/plugins/metadata/PackageRequirement.javalibjboss-classloader-java-2.0.6.GA.orig/classloading/src/main/java/org/jboss/classloading/plugins/me0000644000175000017500000000554711035356200033406 0ustar twernertwerner/* * JBoss, Home of Professional Open Source * Copyright 2006, JBoss Inc., and individual contributors as indicated * by the @authors tag. See the copyright.txt in the distribution for a * full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.classloading.plugins.metadata; import java.util.Collections; import java.util.Set; import org.jboss.classloading.spi.dependency.Module; import org.jboss.classloading.spi.metadata.OptionalPackages; import org.jboss.classloading.spi.metadata.Requirement; import org.jboss.classloading.spi.metadata.helpers.AbstractRequirement; import org.jboss.classloading.spi.version.VersionRange; /** * PackageRequirement. * * @author Adrian Brock * @version $Revision: 1.1 $ */ public class PackageRequirement extends AbstractRequirement implements OptionalPackages { /** The serialVersionUID */ private static final long serialVersionUID = -7552921085464308835L; /** * Create a new PackageRequirement. */ public PackageRequirement() { } /** * Create a new PackageRequirement with no version constraint * * @param name the name * @throws IllegalArgumentException for a null name */ public PackageRequirement(String name) { super(name); } /** * Create a new PackageRequirement. * * @param name the name * @param versionRange the version range - pass null for all versions * @throws IllegalArgumentException for a null name */ public PackageRequirement(String name, VersionRange versionRange) { super(name, versionRange); } public Set getOptionalPackageNames(Module module) { if (isOptional() == false) return null; return Collections.singleton(getName()); } @Override public boolean isConsistent(Requirement other) { return isConsistent(other, PackageRequirement.class); } @Override public boolean equals(Object obj) { if (obj == this) return true; if (obj == null || obj instanceof PackageRequirement == false) return false; return super.equals(obj); } } ././@LongLink0000000000000000000000000000020100000000000011556 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloading/src/main/java/org/jboss/classloading/plugins/metadata/ModuleCapability.javalibjboss-classloader-java-2.0.6.GA.orig/classloading/src/main/java/org/jboss/classloading/plugins/me0000644000175000017500000000532111035356200033374 0ustar twernertwerner/* * JBoss, Home of Professional Open Source * Copyright 2006, JBoss Inc., and individual contributors as indicated * by the @authors tag. See the copyright.txt in the distribution for a * full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.classloading.plugins.metadata; import org.jboss.classloading.spi.dependency.Module; import org.jboss.classloading.spi.metadata.Requirement; import org.jboss.classloading.spi.metadata.helpers.AbstractCapability; /** * ModuleCapability. * * @author Adrian Brock * @version $Revision: 1.1 $ */ public class ModuleCapability extends AbstractCapability { /** The serialVersionUID */ private static final long serialVersionUID = -5444212755644141118L; /** * Create a new ModuleCapability. */ public ModuleCapability() { } /** * Create a new ModuleCapability with the default version * * @param name the name * @throws IllegalArgumentException for a null name */ public ModuleCapability(String name) { super(name); } /** * Create a new ModuleCapability. * * @param name the name * @param version the version - pass null for default version * @throws IllegalArgumentException for a null name */ public ModuleCapability(String name, Object version) { super(name, version); } public boolean resolves(Module module, Requirement requirement) { if (requirement instanceof ModuleRequirement == false) return false; ModuleRequirement moduleRequirement = (ModuleRequirement) requirement; if (getName().equals(moduleRequirement.getName()) == false) return false; return moduleRequirement.getVersionRange().isInRange(getVersion()); } @Override public boolean equals(Object obj) { if (obj == this) return true; if (obj == null || obj instanceof ModuleCapability == false) return false; return super.equals(obj); } } ././@LongLink0000000000000000000000000000020200000000000011557 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloading/src/main/java/org/jboss/classloading/plugins/metadata/VersionMetaMapper.javalibjboss-classloader-java-2.0.6.GA.orig/classloading/src/main/java/org/jboss/classloading/plugins/me0000644000175000017500000000420310761511660033402 0ustar twernertwerner/* * JBoss, Home of Professional Open Source * Copyright 2007, JBoss Inc., and individual contributors as indicated * by the @authors tag. See the copyright.txt in the distribution for a * full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.classloading.plugins.metadata; import java.lang.reflect.Type; import org.jboss.classloading.spi.version.Version; import org.jboss.metatype.api.types.MetaType; import org.jboss.metatype.api.types.SimpleMetaType; import org.jboss.metatype.api.values.MetaValue; import org.jboss.metatype.api.values.SimpleValue; import org.jboss.metatype.api.values.SimpleValueSupport; import org.jboss.metatype.spi.values.MetaMapper; /** * VersionMetaMapper. * * @author Adrian Brock * @version $Revision: 1.1 $ */ public class VersionMetaMapper extends MetaMapper { public Type mapToType() { return String.class; } public MetaValue createMetaValue(MetaType metaType, Version object) { return SimpleValueSupport.wrap(object.toString()); } public Version unwrapMetaValue(MetaValue metaValue) { if (SimpleMetaType.STRING.equals(metaValue.getMetaType()) == false) throw new IllegalArgumentException("Not a string: " + metaValue); SimpleValue simple = (SimpleValue) metaValue; String value = (String) simple.getValue(); return Version.parseVersion(value); } } ././@LongLink0000000000000000000000000000020200000000000011557 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloading/src/main/java/org/jboss/classloading/plugins/metadata/PackageCapability.javalibjboss-classloader-java-2.0.6.GA.orig/classloading/src/main/java/org/jboss/classloading/plugins/me0000644000175000017500000000571510756304141033411 0ustar twernertwerner/* * JBoss, Home of Professional Open Source * Copyright 2006, JBoss Inc., and individual contributors as indicated * by the @authors tag. See the copyright.txt in the distribution for a * full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.classloading.plugins.metadata; import java.util.Collections; import java.util.Set; import org.jboss.classloading.spi.dependency.Module; import org.jboss.classloading.spi.metadata.ExportPackages; import org.jboss.classloading.spi.metadata.Requirement; import org.jboss.classloading.spi.metadata.helpers.AbstractCapability; /** * PackageCapability. * * @author Adrian Brock * @version $Revision: 1.1 $ */ public class PackageCapability extends AbstractCapability implements ExportPackages { /** The serialVersionUID */ private static final long serialVersionUID = -1586959469453286396L; /** * Create a new PackageCapability. */ public PackageCapability() { } /** * Create a new PackageCapability with the default version * * @param name the name * @throws IllegalArgumentException for a null name */ public PackageCapability(String name) { super(name); } /** * Create a new PackageCapability. * * @param name the name * @param version the version - pass null for default version * @throws IllegalArgumentException for a null name */ public PackageCapability(String name, Object version) { super(name, version); } public boolean resolves(Module module, Requirement requirement) { if (requirement instanceof PackageRequirement == false) return false; PackageRequirement requirePackage = (PackageRequirement) requirement; if (getName().equals(requirePackage.getName()) == false) return false; return requirePackage.getVersionRange().isInRange(getVersion()); } public Set getPackageNames(Module module) { return Collections.singleton(getName()); } @Override public boolean equals(Object obj) { if (obj == this) return true; if (obj == null || obj instanceof PackageCapability == false) return false; return super.equals(obj); } } ././@LongLink0000000000000000000000000000022300000000000011562 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloading/src/main/java/org/jboss/classloading/plugins/metadata/DefaultClassLoadingMetaDataFactory.javalibjboss-classloader-java-2.0.6.GA.orig/classloading/src/main/java/org/jboss/classloading/plugins/me0000644000175000017500000000522510761314167033412 0ustar twernertwerner/* * JBoss, Home of Professional Open Source * Copyright 2007, JBoss Inc., and individual contributors as indicated * by the @authors tag. See the copyright.txt in the distribution for a * full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.classloading.plugins.metadata; import org.jboss.classloading.spi.metadata.Capability; import org.jboss.classloading.spi.metadata.ClassLoadingMetaDataFactory; import org.jboss.classloading.spi.metadata.Requirement; import org.jboss.classloading.spi.version.VersionRange; /** * DefaultClassLoadingMetaDataFactory. * * @author Adrian Brock * @version $Revision: 1.1 $ */ public class DefaultClassLoadingMetaDataFactory extends ClassLoadingMetaDataFactory { public Capability createModule(String name, Object version) { return new ModuleCapability(name, version); } public Requirement createRequireModule(String name, VersionRange versionRange, boolean optional, boolean reExport, boolean dynamic) { ModuleRequirement result = new ModuleRequirement(name, versionRange); result.setOptional(optional); result.setReExport(reExport); result.setDynamic(dynamic); return result; } public Capability createPackage(String name, Object version) { return new PackageCapability(name, version); } public Requirement createRequirePackage(String name, VersionRange versionRange, boolean optional, boolean reExport, boolean dynamic) { PackageRequirement result = new PackageRequirement(name, versionRange); result.setOptional(optional); result.setReExport(reExport); result.setDynamic(dynamic); return result; } public Requirement createUsesPackage(String name, VersionRange versionRange, boolean reExport) { UsesPackageRequirement result = new UsesPackageRequirement(name, versionRange); result.setReExport(reExport); return result; } } ././@LongLink0000000000000000000000000000020400000000000011561 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloading/src/main/java/org/jboss/classloading/plugins/metadata/VersionValueAdapter.javalibjboss-classloader-java-2.0.6.GA.orig/classloading/src/main/java/org/jboss/classloading/plugins/me0000644000175000017500000000270610756304141033406 0ustar twernertwerner/* * JBoss, Home of Professional Open Source * Copyright 2007, JBoss Inc., and individual contributors as indicated * by the @authors tag. See the copyright.txt in the distribution for a * full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.classloading.plugins.metadata; import org.jboss.classloading.spi.version.Version; import org.jboss.xb.binding.sunday.unmarshalling.ValueAdapter; /** * VersionXmlJavaTypeAdapter. * * @author Adrian Brock * @version $Revision: 1.1 $ */ public class VersionValueAdapter implements ValueAdapter { @SuppressWarnings("unchecked") public Object cast(Object o, Class c) { return Version.parseVersion((String) o); } } ././@LongLink0000000000000000000000000000020200000000000011557 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloading/src/main/java/org/jboss/classloading/plugins/metadata/ModuleRequirement.javalibjboss-classloader-java-2.0.6.GA.orig/classloading/src/main/java/org/jboss/classloading/plugins/me0000644000175000017500000000467010756304141033410 0ustar twernertwerner/* * JBoss, Home of Professional Open Source * Copyright 2006, JBoss Inc., and individual contributors as indicated * by the @authors tag. See the copyright.txt in the distribution for a * full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.classloading.plugins.metadata; import org.jboss.classloading.spi.metadata.helpers.AbstractRequirement; import org.jboss.classloading.spi.version.VersionRange; /** * ModuleRequirement. * * @author Adrian Brock * @version $Revision: 1.1 $ */ public class ModuleRequirement extends AbstractRequirement { /** The serialVersionUID */ private static final long serialVersionUID = -7108063877472769918L; /** * Create a new ModuleRequirement. */ public ModuleRequirement() { } /** * Create a new ModuleRequirement with no version constraint * * @param name the name * @throws IllegalArgumentException for a null name */ public ModuleRequirement(String name) { super(name); } /** * Create a new ModuleRequirement. * * @param name the name * @param versionRange the version range - pass null for all versions * @throws IllegalArgumentException for a null name */ public ModuleRequirement(String name, VersionRange versionRange) { super(name, versionRange); } /** * For module requirements we want re-exports */ @Override public boolean wantReExports() { return true; } @Override public boolean equals(Object obj) { if (obj == this) return true; if (obj == null || obj instanceof ModuleRequirement == false) return false; return super.equals(obj); } } ././@LongLink0000000000000000000000000000015600000000000011567 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloading/src/main/java/org/jboss/classloading/plugins/dependency/libjboss-classloader-java-2.0.6.GA.orig/classloading/src/main/java/org/jboss/classloading/plugins/de0000755000175000017500000000000011620043420033355 5ustar twernertwerner././@LongLink0000000000000000000000000000022400000000000011563 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloading/src/main/java/org/jboss/classloading/plugins/dependency/DefaultGlobalCapabilitiesProvider.javalibjboss-classloader-java-2.0.6.GA.orig/classloading/src/main/java/org/jboss/classloading/plugins/de0000644000175000017500000000332511173151646033377 0ustar twernertwerner/* * JBoss, Home of Professional Open Source. * Copyright 2006, Red Hat Middleware LLC, and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.classloading.plugins.dependency; import java.util.List; import org.jboss.classloading.spi.dependency.GlobalCapabilitiesProvider; import org.jboss.classloading.spi.metadata.CapabilitiesMetaData; import org.jboss.classloading.spi.metadata.Capability; /** * * @author Kabir Khan * @version $Revision: 1.1 $ */ public class DefaultGlobalCapabilitiesProvider implements GlobalCapabilitiesProvider { List capabilities; public void setGlobalCapabilities(CapabilitiesMetaData capabilitiesMetaData) { capabilities = capabilitiesMetaData.getCapabilities(); } public List getCapabilities() { return capabilities; } } ././@LongLink0000000000000000000000000000015300000000000011564 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloading/src/main/java/org/jboss/classloading/plugins/visitor/libjboss-classloader-java-2.0.6.GA.orig/classloading/src/main/java/org/jboss/classloading/plugins/vi0000755000175000017500000000000011620043420033403 5ustar twernertwerner././@LongLink0000000000000000000000000000020700000000000011564 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloading/src/main/java/org/jboss/classloading/plugins/visitor/AbstractResourceContext.javalibjboss-classloader-java-2.0.6.GA.orig/classloading/src/main/java/org/jboss/classloading/plugins/vi0000644000175000017500000001017711044556237033432 0ustar twernertwerner/* * JBoss, Home of Professional Open Source * Copyright 2006, JBoss Inc., and individual contributors as indicated * by the @authors tag. See the copyright.txt in the distribution for a * full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.classloading.plugins.visitor; import java.io.IOException; import java.io.InputStream; import java.net.URL; import org.jboss.classloader.plugins.ClassLoaderUtils; import org.jboss.classloading.spi.visitor.ResourceContext; /** * Abstract resource context. * Doesn't take url - super class should impl getURL. * * @author Adrian Brock * @author Ales Justin */ public abstract class AbstractResourceContext implements ResourceContext { /** The classloader */ private ClassLoader classLoader; /** The resource name */ private String resourceName; /** * Create a new ResourceContext. * * @param resourceName the resource name * @param classLoader the classloader */ public AbstractResourceContext(String resourceName, ClassLoader classLoader) { if (resourceName == null) throw new IllegalArgumentException("Null resourceName"); if (classLoader == null) throw new IllegalArgumentException("Null classloader"); this.resourceName = resourceName; this.classLoader = classLoader; } /** * Get the classLoader. * * @return the classLoader. */ public ClassLoader getClassLoader() { return classLoader; } /** * Get the resourceName. * * @return the resourceName. */ public String getResourceName() { return resourceName; } /** * Get the class name * * @return the class name or null if it is not a class */ public String getClassName() { return ClassLoaderUtils.resourceNameToClassName(getResourceName()); } /** * Whether the resource is a class * * @return true when the resource name ends with .class */ public boolean isClass() { return resourceName.endsWith(".class"); } /** * Load a class * * Do isClass check before, * unless you want to handle exception * when resource is not actually a class. * * @return the class from resource * @throws RuntimeException for any errors during class loading */ public Class loadClass() { String className = getClassName(); try { return classLoader.loadClass(className); } catch (ClassNotFoundException e) { throw new RuntimeException("Unexpected error loading class: " + className, e); } } /** * Get the input stream for the resource * * @return the input stream * @throws java.io.IOException for any error */ public InputStream getInputStream() throws IOException { URL url = getUrl(); if (url == null) throw new IllegalArgumentException("Null url: " + resourceName); return url.openStream(); } /** * Get the bytes for the resource * * @return the byte array * @throws java.io.IOException for any error */ public byte[] getBytes() throws IOException { return ClassLoaderUtils.loadBytes(getInputStream()); } }././@LongLink0000000000000000000000000000021000000000000011556 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloading/src/main/java/org/jboss/classloading/plugins/visitor/FederatedResourceVisitor.javalibjboss-classloader-java-2.0.6.GA.orig/classloading/src/main/java/org/jboss/classloading/plugins/vi0000644000175000017500000001061711071406374033425 0ustar twernertwerner/* * JBoss, Home of Professional Open Source * Copyright 2006, JBoss Inc., and individual contributors as indicated * by the @authors tag. See the copyright.txt in the distribution for a * full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.classloading.plugins.visitor; import java.util.Arrays; import org.jboss.classloading.spi.visitor.ResourceContext; import org.jboss.classloading.spi.visitor.ResourceFilter; import org.jboss.classloading.spi.visitor.ResourceVisitor; /** * Federated resource visitor. * * @author Ales Justin */ public class FederatedResourceVisitor implements ResourceVisitor { private ResourceVisitor[] visitors; private ResourceFilter[] filters; private ResourceFilter[] recurseFilters; private ResourceFilter filter; private ResourceFilter recurseFilter; private boolean[] recurseFlags; private boolean[] filterFlags; public FederatedResourceVisitor(ResourceVisitor[] visitors) { if (visitors == null || visitors.length == 0) throw new IllegalArgumentException("Null or empty visitors: " + Arrays.toString(visitors)); this.visitors = visitors; } public FederatedResourceVisitor(ResourceVisitor[] visitors, ResourceFilter[] filters, ResourceFilter[] recurseFilters) { this(visitors); this.filters = filters; this.recurseFilters = recurseFilters; } public ResourceFilter getRecurseFilter() { if (recurseFilters == null || recurseFilters.length == 0) return null; if (recurseFilter == null) { recurseFlags = new boolean[recurseFilters.length]; recurseFilter = new FederatedRecurseFilter(); } return recurseFilter; } public ResourceFilter getFilter() { if (filters != null && filters.length == 0) return null; if (filter == null) { if (filters == null) { filters = new ResourceFilter[visitors.length]; for (int i =0; i < visitors.length; i++) filters[i] = visitors[i].getFilter(); } filterFlags = new boolean[filters == null ? 0 : filters.length]; filter = new FederatedResourceFilter(); } return filter; } public void visit(ResourceContext resource) { for (int i = 0; i < visitors.length; i++) { if (filterFlags == null || filterFlags.length <= i || filterFlags[i]) { visitors[i].visit(resource); } } } private class FederatedRecurseFilter implements ResourceFilter { public boolean accepts(ResourceContext resource) { boolean accept = false; for (int i = 0; i < recurseFilters.length; i++) { recurseFlags[i] = recurseFilters[i] == null || recurseFilters[i].accepts(resource); if (recurseFlags[i]) accept = true; } return accept; } } private class FederatedResourceFilter implements ResourceFilter { public boolean accepts(ResourceContext resource) { boolean accept = false; for (int i = 0; i < filters.length; i++) { if (recurseFlags == null || recurseFlags.length <= i || recurseFlags[i]) { filterFlags[i] = filters[i] == null || filters[i].accepts(resource); if (filterFlags[i]) accept = true; } else filterFlags[i] = false; } return accept; } } } ././@LongLink0000000000000000000000000000020600000000000011563 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloading/src/main/java/org/jboss/classloading/plugins/visitor/DefaultResourceContext.javalibjboss-classloader-java-2.0.6.GA.orig/classloading/src/main/java/org/jboss/classloading/plugins/vi0000644000175000017500000000362011044556237033425 0ustar twernertwerner/* * JBoss, Home of Professional Open Source * Copyright 2006, JBoss Inc., and individual contributors as indicated * by the @authors tag. See the copyright.txt in the distribution for a * full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.classloading.plugins.visitor; import java.net.URL; /** * Default resource context. * * @author Adrian Brock * @author Ales Justin */ public class DefaultResourceContext extends AbstractResourceContext { /** The url of the resource */ private URL url; /** * Create a new ResourceContext. * * @param url the url * @param resourceName the resource name * @param classLoader the classloader */ public DefaultResourceContext(URL url, String resourceName, ClassLoader classLoader) { super(resourceName, classLoader); if (url == null) throw new IllegalArgumentException("Null url"); this.url = url; } /** * Get the url. * * @return the url. */ public URL getUrl() { return url; } } libjboss-classloader-java-2.0.6.GA.orig/classloading/src/main/java/org/jboss/classloading/spi/0000755000175000017500000000000011620043420032156 5ustar twernertwerner././@LongLink0000000000000000000000000000015000000000000011561 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloading/src/main/java/org/jboss/classloading/spi/metadata/libjboss-classloader-java-2.0.6.GA.orig/classloading/src/main/java/org/jboss/classloading/spi/metada0000755000175000017500000000000011620043420033332 5ustar twernertwerner././@LongLink0000000000000000000000000000017100000000000011564 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloading/src/main/java/org/jboss/classloading/spi/metadata/package-info.javalibjboss-classloader-java-2.0.6.GA.orig/classloading/src/main/java/org/jboss/classloading/spi/metada0000644000175000017500000000260110756304141033344 0ustar twernertwerner/* * JBoss, Home of Professional Open Source * Copyright 2008, JBoss Inc., and individual contributors as indicated * by the @authors tag. See the copyright.txt in the distribution for a * full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ @JBossXmlAdaptedTypes ({ @JBossXmlAdaptedType(type=Version.class, valueAdapter=VersionValueAdapter.class) }) package org.jboss.classloading.spi.metadata; import org.jboss.classloading.plugins.metadata.VersionValueAdapter; import org.jboss.classloading.spi.version.Version; import org.jboss.xb.annotations.JBossXmlAdaptedType; import org.jboss.xb.annotations.JBossXmlAdaptedTypes; ././@LongLink0000000000000000000000000000016700000000000011571 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloading/src/main/java/org/jboss/classloading/spi/metadata/Capability.javalibjboss-classloader-java-2.0.6.GA.orig/classloading/src/main/java/org/jboss/classloading/spi/metada0000644000175000017500000000316410756304141033351 0ustar twernertwerner/* * JBoss, Home of Professional Open Source. * Copyright 2007, Red Hat Middleware LLC, and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.classloading.spi.metadata; import java.io.Serializable; import org.jboss.classloading.spi.dependency.Module; /** * Capability. * * @author Adrian Brock * @version $Revision: 1.1 $ */ public interface Capability extends Serializable { /** * Whether this capability resolves the requirement * * @param module the module * @param requirement the requirement * @throws IllegalArgumentException for a null requirement * @return true when it is resolves the requirement */ boolean resolves(Module module, Requirement requirement); } ././@LongLink0000000000000000000000000000017000000000000011563 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloading/src/main/java/org/jboss/classloading/spi/metadata/Requirement.javalibjboss-classloader-java-2.0.6.GA.orig/classloading/src/main/java/org/jboss/classloading/spi/metada0000644000175000017500000000420211035356200033335 0ustar twernertwerner/* * JBoss, Home of Professional Open Source. * Copyright 2007, Red Hat Middleware LLC, and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.classloading.spi.metadata; import java.io.Serializable; /** * Requirement. * * @author Adrian Brock * @version $Revision: 1.1 $ */ public interface Requirement extends Serializable { /** * Whether to re-export the requirement * * @return true to re-export */ boolean isReExport(); /** * Whether we want re-exports * * @return true to process re-exports */ boolean wantReExports(); /** * Whether the requirement is optional * * @return true if the requirement is optional */ boolean isOptional(); /** * Whether the requirement is dynamic * * @return true if the requirement is dynamic */ boolean isDynamic(); /** * Check whether this requirement is consistent with another requirement.

* * Typically they will be inconsistent if they are the same type, * have the same name but a different version * * @param other the other requirement * @return true when consistent, false when inconsistent */ boolean isConsistent(Requirement other); } ././@LongLink0000000000000000000000000000021000000000000011556 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloading/src/main/java/org/jboss/classloading/spi/metadata/ClassLoadingMetaDataFactory.javalibjboss-classloader-java-2.0.6.GA.orig/classloading/src/main/java/org/jboss/classloading/spi/metada0000644000175000017500000002067110761314167033360 0ustar twernertwerner/* * JBoss, Home of Professional Open Source * Copyright 2008, JBoss Inc., and individual contributors as indicated * by the @authors tag. See the copyright.txt in the distribution for a * full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.classloading.spi.metadata; import org.jboss.classloading.spi.version.VersionRange; /** * ClassLoadingMetaDataFactory. * * @author Adrian Brock * @version $Revision: 1.1 $ */ public abstract class ClassLoadingMetaDataFactory { /** * Get an instance of the factory * * @return the factory */ public static ClassLoadingMetaDataFactory getInstance() { return ClassLoadingMetaDataFactoryBuilder.getInstance(); } /** * Create a new module with the default version * * @param name the name * @return the module capability * @throws IllegalArgumentException for a null name */ public Capability createModule(String name) { return createModule(name, null); } /** * Create a new module * * @param name the name * @param version the version * @return the module capability * @throws IllegalArgumentException for a null name */ public abstract Capability createModule(String name, Object version); /** * Create a new module requirement with no version constraint * * @param name the name * @return the module requirement * @throws IllegalArgumentException for a null name */ public Requirement createRequireModule(String name) { return createRequireModule(name, null); } /** * Create a new module requirement * * @param name the name * @param versionRange the version range * @return the module requirement * @throws IllegalArgumentException for a null name */ public Requirement createRequireModule(String name, VersionRange versionRange) { return createRequireModule(name, versionRange, false, false, false); } /** * Create a new module requirement * * @param name the name * @param versionRange the version range * @param optional whether the requirement is optional * @param reExport whether the requirement is a re-export * @param dynamic whether the requirement is dynamic * @return the module requirement * @throws IllegalArgumentException for a null name */ public abstract Requirement createRequireModule(String name, VersionRange versionRange, boolean optional, boolean reExport, boolean dynamic); /** * Create a new re-export module requirement with no version constraint * * @param name the name * @return the module requirement * @throws IllegalArgumentException for a null name */ public Requirement createReExportModule(String name) { return createReExportModule(name, null); } /** * Create a new re-export module requirement * * @param name the name * @param versionRange the version range * @return the module requirement * @throws IllegalArgumentException for a null name */ public Requirement createReExportModule(String name, VersionRange versionRange) { return createReExportModule(name, versionRange, false); } /** * Create a new re-export module requirement * * @param name the name * @param versionRange the version range * @param optional whether the requirement is optional * @return the module requirement * @throws IllegalArgumentException for a null name */ public Requirement createReExportModule(String name, VersionRange versionRange, boolean optional) { return createRequireModule(name, versionRange, optional, true, false); } /** * Create a new package with the default version * * @param name the name * @return the package capability * @throws IllegalArgumentException for a null name */ public Capability createPackage(String name) { return createPackage(name, null); } /** * Create a new package * * @param name the name * @param version the version * @return the package capability * @throws IllegalArgumentException for a null name */ public abstract Capability createPackage(String name, Object version); /** * Create a new packagerequirement with no version constraint * * @param name the name * @return the package requirement * @throws IllegalArgumentException for a null name */ public Requirement createRequirePackage(String name) { return createRequirePackage(name, null); } /** * Create a new package requirement * * @param name the name * @param versionRange the version range * @return the package requirement * @throws IllegalArgumentException for a null name */ public Requirement createRequirePackage(String name, VersionRange versionRange) { return createRequirePackage(name, versionRange, false, false, false); } /** * Create a new package requirement * * @param name the name * @param versionRange the version range * @param optional whether the requirement is optional * @param reExport whether the requirement is a re-export * @param dynamic whether the requirement is dynamic * @return the package requirement * @throws IllegalArgumentException for a null name */ public abstract Requirement createRequirePackage(String name, VersionRange versionRange, boolean optional, boolean reExport, boolean dynamic); /** * Create a new re-export package requirement with no version constraint * * @param name the name * @return the module requirement * @throws IllegalArgumentException for a null name */ public Requirement createReExportPackage(String name) { return createReExportPackage(name, null, false); } /** * Create a new re-export package requirement * * @param name the name * @param versionRange the version range * @return the module requirement * @throws IllegalArgumentException for a null name */ public Requirement createReExportPackage(String name, VersionRange versionRange) { return createReExportPackage(name, versionRange, false); } /** * Create a new re-export module requirement * * @param name the name * @param versionRange the version range * @param optional whether the requirement is optional * @return the module requirement * @throws IllegalArgumentException for a null name */ public Requirement createReExportPackage(String name, VersionRange versionRange, boolean optional) { return createRequirePackage(name, versionRange, optional, true, false); } /** * Create a new usespackagerequirement with no version constraint * * @param name the name * @return the package requirement * @throws IllegalArgumentException for a null name */ public Requirement createUsesPackage(String name) { return createUsesPackage(name, null); } /** * Create a new uses package requirement * * @param name the name * @param versionRange the version range * @return the package requirement * @throws IllegalArgumentException for a null name */ public Requirement createUsesPackage(String name, VersionRange versionRange) { return createUsesPackage(name, versionRange, false); } /** * Create a new uses package requirement * * @param name the name * @param versionRange the version range * @param reExport whether the requirement is a re-export * @return the package requirement * @throws IllegalArgumentException for a null name */ public abstract Requirement createUsesPackage(String name, VersionRange versionRange, boolean reExport); } ././@LongLink0000000000000000000000000000017300000000000011566 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloading/src/main/java/org/jboss/classloading/spi/metadata/ExportPackages.javalibjboss-classloader-java-2.0.6.GA.orig/classloading/src/main/java/org/jboss/classloading/spi/metada0000644000175000017500000000267010756304141033352 0ustar twernertwerner/* * JBoss, Home of Professional Open Source. * Copyright 2007, Red Hat Middleware LLC, and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.classloading.spi.metadata; import java.util.Set; import org.jboss.classloading.spi.dependency.Module; /** * ExportPackages. * * @author Adrian Brock * @version $Revision: 1.1 $ */ public interface ExportPackages { /** * Get the package names * * @param module the module * @return the package names */ Set getPackageNames(Module module); } ././@LongLink0000000000000000000000000000021700000000000011565 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloading/src/main/java/org/jboss/classloading/spi/metadata/ClassLoadingMetaDataFactoryBuilder.javalibjboss-classloader-java-2.0.6.GA.orig/classloading/src/main/java/org/jboss/classloading/spi/metada0000644000175000017500000000377510756304141033361 0ustar twernertwerner/* * JBoss, Home of Professional Open Source * Copyright 2008, JBoss Inc., and individual contributors as indicated * by the @authors tag. See the copyright.txt in the distribution for a * full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.classloading.spi.metadata; import java.security.AccessController; import org.jboss.classloading.plugins.metadata.DefaultClassLoadingMetaDataFactory; import org.jboss.util.builder.AbstractBuilder; /** * ClassLoadingMetaDataFactoryBuilder. * * @author Adrian Brock * @version $Revision: 1.1 $ */ class ClassLoadingMetaDataFactoryBuilder { /** The default factory */ private static String DEFAULT_FACTORY = DefaultClassLoadingMetaDataFactory.class.getName(); /** The singleton */ private static ClassLoadingMetaDataFactory singleton; /** * Get the instance * * @return the instance */ static synchronized ClassLoadingMetaDataFactory getInstance() { if (singleton == null) { AbstractBuilder builder = new AbstractBuilder(ClassLoadingMetaDataFactory.class, DEFAULT_FACTORY); singleton = AccessController.doPrivileged(builder); } return singleton; } } ././@LongLink0000000000000000000000000000020100000000000011556 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloading/src/main/java/org/jboss/classloading/spi/metadata/RequirementsMetaData.javalibjboss-classloader-java-2.0.6.GA.orig/classloading/src/main/java/org/jboss/classloading/spi/metada0000644000175000017500000000754110757312216033357 0ustar twernertwerner/* * JBoss, Home of Professional Open Source * Copyright 2008, JBoss Inc., and individual contributors as indicated * by the @authors tag. See the copyright.txt in the distribution for a * full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.classloading.spi.metadata; import java.io.Serializable; import java.util.List; import java.util.concurrent.CopyOnWriteArrayList; import javax.xml.bind.annotation.XmlAnyElement; import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlElements; import javax.xml.bind.annotation.XmlType; import org.jboss.classloading.plugins.metadata.ModuleRequirement; import org.jboss.classloading.plugins.metadata.PackageRequirement; import org.jboss.classloading.plugins.metadata.UsesPackageRequirement; /** * RequirementsMetaData. * * @author Adrian Brock * @version $Revision: 1.1 $ */ @XmlType(name="requirements", propOrder={"requirements"}) public class RequirementsMetaData implements Serializable, Cloneable { /** The serialVersionUID */ private static final long serialVersionUID = 3282035888494128833L; /** The requirements */ private List requirements; /** * Get the requirements. * * @return the requirements. */ public List getRequirements() { return requirements; } /** * Set the requirements. * * @param requirements the requirements. */ @XmlElements ({ @XmlElement(name="module", type=ModuleRequirement.class), @XmlElement(name="package", type=PackageRequirement.class), @XmlElement(name="uses", type=UsesPackageRequirement.class) }) @XmlAnyElement public void setRequirements(List requirements) { this.requirements = requirements; } /** * Add a requirement * * @param requirement the requirement * @throws IllegalArgumentException for a null requirement */ public void addRequirement(Requirement requirement) { if (requirement == null) throw new IllegalArgumentException("Null requirement"); if (requirements == null) requirements = new CopyOnWriteArrayList(); requirements.add(requirement); } /** * Remove a requirement * * @param requirement the requirement * @throws IllegalArgumentException for a null requirement */ public void removeRequirement(Requirement requirement) { if (requirement == null) throw new IllegalArgumentException("Null requirement"); if (requirements == null) return; requirements.remove(requirement); } @Override public RequirementsMetaData clone() { try { RequirementsMetaData clone = (RequirementsMetaData) super.clone(); if (requirements != null) { List clonedRequirements = new CopyOnWriteArrayList(requirements); clone.setRequirements(clonedRequirements); } return clone; } catch (CloneNotSupportedException e) { throw new RuntimeException("Unexpected", e); } } } ././@LongLink0000000000000000000000000000020100000000000011556 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloading/src/main/java/org/jboss/classloading/spi/metadata/CapabilitiesMetaData.javalibjboss-classloader-java-2.0.6.GA.orig/classloading/src/main/java/org/jboss/classloading/spi/metada0000644000175000017500000000747111173151646033362 0ustar twernertwerner/* * JBoss, Home of Professional Open Source * Copyright 2008, JBoss Inc., and individual contributors as indicated * by the @authors tag. See the copyright.txt in the distribution for a * full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.classloading.spi.metadata; import java.io.Serializable; import java.util.List; import java.util.concurrent.CopyOnWriteArrayList; import javax.xml.bind.annotation.XmlAnyElement; import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlElements; import javax.xml.bind.annotation.XmlRootElement; import javax.xml.bind.annotation.XmlType; import org.jboss.classloading.plugins.metadata.ModuleCapability; import org.jboss.classloading.plugins.metadata.PackageCapability; /** * CapabilitiesMetaData. * * @author Adrian Brock * @version $Revision: 1.1 $ */ @XmlType(name="capabilities", propOrder= {"capabilities"}) @XmlRootElement(name="capabilities", namespace="urn:jboss:classloading:1.0") public class CapabilitiesMetaData implements Serializable, Cloneable { /** The serialVersionUID */ private static final long serialVersionUID = -7910704924025591308L; /** The capabilities */ private List capabilities; /** * Get the capabilities. * * @return the capabilities. */ public List getCapabilities() { return capabilities; } /** * Set the capabilities. * * @param capabilities the capabilities. */ @XmlElements ({ @XmlElement(name="module", type=ModuleCapability.class), @XmlElement(name="package", type=PackageCapability.class) }) @XmlAnyElement public void setCapabilities(List capabilities) { this.capabilities = capabilities; } /** * Add a capability * * @param capability the capability * @throws IllegalArgumentException for a null capability */ public void addCapability(Capability capability) { if (capability == null) throw new IllegalArgumentException("Null capability"); if (capabilities == null) capabilities = new CopyOnWriteArrayList(); capabilities.add(capability); } /** * Remove a capability * * @param capability the capability * @throws IllegalArgumentException for a null capability */ public void removeCapability(Capability capability) { if (capability == null) throw new IllegalArgumentException("Null capability"); if (capabilities == null) return; capabilities.remove(capability); } @Override public CapabilitiesMetaData clone() { try { CapabilitiesMetaData clone = (CapabilitiesMetaData) super.clone(); if (capabilities != null) { List clonedCapabilities = new CopyOnWriteArrayList(capabilities); clone.setCapabilities(clonedCapabilities); } return clone; } catch (CloneNotSupportedException e) { throw new RuntimeException("Unexpected", e); } } } ././@LongLink0000000000000000000000000000020100000000000011556 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloading/src/main/java/org/jboss/classloading/spi/metadata/ClassLoadingMetaData.javalibjboss-classloader-java-2.0.6.GA.orig/classloading/src/main/java/org/jboss/classloading/spi/metada0000644000175000017500000003513510760762040033355 0ustar twernertwerner/* * JBoss, Home of Professional Open Source. * Copyright 2007, Red Hat Middleware LLC, and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.classloading.spi.metadata; import java.util.List; import javax.xml.bind.annotation.XmlAttribute; import javax.xml.bind.annotation.XmlTransient; import org.jboss.classloader.plugins.filter.CombiningClassFilter; import org.jboss.classloader.spi.filter.ClassFilter; import org.jboss.classloader.spi.filter.PackageClassFilter; import org.jboss.classloading.spi.helpers.NameAndVersionSupport; import org.jboss.managed.api.annotation.ManagementObject; import org.jboss.managed.api.annotation.ManagementProperties; import org.jboss.managed.api.annotation.ManagementProperty; /** * ClassLoadingMetaData. * * @author Adrian Brock * @version $Revision: 1.1 $ */ @ManagementObject(properties=ManagementProperties.EXPLICIT, name="org.jboss.classloading.spi.metadata.ClassLoadingMetaData") public class ClassLoadingMetaData extends NameAndVersionSupport { /** The serialVersionUID */ private static final long serialVersionUID = -2782951093046585620L; /** The classloading domain */ private String domain; /** The parent domain */ private String parentDomain; /** Whether to enforce j2se classloading compliance */ private boolean j2seClassLoadingCompliance = true; /** Whether we are cacheable */ private boolean cacheable = true; /** Whether we are blacklistable */ private boolean blackListable = true; /** Whether to export all */ private ExportAll exportAll; /** Whether to import all */ private boolean importAll; /** The included packages */ private String includedPackages; /** The excluded packages */ private String excludedPackages; /** The excluded for export */ private String excludedExportPackages; /** The included packages */ private ClassFilter included; /** The excluded packages */ private ClassFilter excluded; /** The excluded for export */ private ClassFilter excludedExport; /** The requirements */ private RequirementsMetaData requirements = new RequirementsMetaData(); /** The capabilities */ private CapabilitiesMetaData capabilities = new CapabilitiesMetaData(); /** * Get the domain. * * @return the domain. */ public String getDomain() { return domain; } /** * Set the domain. * * @param domain the domain. */ @ManagementProperty @XmlAttribute public void setDomain(String domain) { this.domain = domain; } /** * Get the parentDomain. * * @return the parentDomain. */ public String getParentDomain() { return parentDomain; } /** * Set the parentDomain. * * @param parentDomain the parentDomain. */ @ManagementProperty @XmlAttribute public void setParentDomain(String parentDomain) { this.parentDomain = parentDomain; } /** * Get the exportAll. * * @return the exportAll. */ public ExportAll getExportAll() { return exportAll; } /** * Set the exportAll. * * @param exportAll the exportAll. */ @ManagementProperty @XmlAttribute(name="export-all") public void setExportAll(ExportAll exportAll) { this.exportAll = exportAll; } /** * Get the includedPackages. * * @return the includedPackages. */ public String getIncludedPackages() { return includedPackages; } /** * Set the includedPackages. * * @param includedPackages the includedPackages. */ @ManagementProperty(name="included") @XmlAttribute(name="included") public void setIncludedPackages(String includedPackages) { this.includedPackages = includedPackages; } /** * Get a filter for the included packages * * @return the included packages */ public ClassFilter getIncluded() { ClassFilter packageFilter = null; if (includedPackages != null) packageFilter = PackageClassFilter.createPackageClassFilterFromString(includedPackages); if (packageFilter == null) return included; if (included == null) return packageFilter; return CombiningClassFilter.create(true, packageFilter, included); } /** * Set the included. * * @param included the included. */ @XmlTransient public void setIncluded(ClassFilter included) { this.included = included; } /** * Get the excludedPackages. * * @return the excludedPackages. */ public String getExcludedPackages() { return excludedPackages; } /** * Set the excludedPackages. * * @param excludedPackages the excludedPackages. */ @ManagementProperty(name="excluded") @XmlAttribute(name="excluded") public void setExcludedPackages(String excludedPackages) { this.excludedPackages = excludedPackages; } /** * Get a filter for the excluded packages * * @return the excluded packages */ public ClassFilter getExcluded() { ClassFilter packageFilter = null; if (excludedPackages != null) packageFilter = PackageClassFilter.createPackageClassFilterFromString(excludedPackages); if (packageFilter == null) return excluded; if (excluded == null) return packageFilter; return CombiningClassFilter.create(true, packageFilter, excluded); } /** * Set the excluded. * * @param excluded the excluded. */ @XmlTransient public void setExcluded(ClassFilter excluded) { this.excluded = excluded; } /** * Get the excludedExportPackages. * * @return the excludedExportPackages. */ public String getExcludedExportPackages() { return excludedExportPackages; } /** * Set the excludedExportPackages. * * @param excludedExportPackages the excludedExportPackages. */ @ManagementProperty(name="excludedExport") @XmlAttribute(name="excludedExport") public void setExcludedExportPackages(String excludedExportPackages) { this.excludedExportPackages = excludedExportPackages; } /** * Get a filter for the excluded export packages * * @return the excluded export packages */ public ClassFilter getExcludedExport() { ClassFilter packageFilter = null; if (excludedExportPackages != null) packageFilter = PackageClassFilter.createPackageClassFilterFromString(excludedExportPackages); if (packageFilter == null) return excludedExport; if (excludedExport == null) return packageFilter; return CombiningClassFilter.create(true, packageFilter, excludedExport); } /** * Set the excludedExport. * * @param excludedExport the excludedExport. */ @XmlTransient public void setExcludedExport(ClassFilter excludedExport) { this.excludedExport = excludedExport; } /** * Whether to import all * * @return true when there are no requirements */ public boolean isImportAll() { return importAll; } /** * Set the importAll. * * @param importAll the importAll. */ @ManagementProperty @XmlAttribute(name="import-all") public void setImportAll(boolean importAll) { this.importAll = importAll; } /** * Get the j2seClassLoadingCompliance. * * @return the j2seClassLoadingCompliance. */ public boolean isJ2seClassLoadingCompliance() { return j2seClassLoadingCompliance; } /** * Set the j2seClassLoadingCompliance. * * @param classLoadingCompliance the j2seClassLoadingCompliance. */ @ManagementProperty(name="parentFirst") @XmlAttribute(name="parent-first") public void setJ2seClassLoadingCompliance(boolean classLoadingCompliance) { j2seClassLoadingCompliance = classLoadingCompliance; } /** * Get the cacheable. * * @return the cacheable. */ public boolean isCacheable() { return cacheable; } /** * Set the cacheable. * * @param cacheable the cacheable. */ @ManagementProperty(name="cache") @XmlAttribute(name="cache") public void setCacheable(boolean cacheable) { this.cacheable = cacheable; } /** * Get the blackListable. * * @return the blackListable. */ public boolean isBlackListable() { return blackListable; } /** * Set the blackListable. * * @param blackListable the blackListable. */ @ManagementProperty(name="blackList") @XmlAttribute(name="blackList") public void setBlackListable(boolean blackListable) { this.blackListable = blackListable; } /** * Get the capabilities. * * @return the capabilities. */ public CapabilitiesMetaData getCapabilities() { return capabilities; } /** * Set the capabilities. * * @param capabilities the capabilities. * @throws IllegalArgumentException for null capabilities */ @ManagementProperty public void setCapabilities(CapabilitiesMetaData capabilities) { if (capabilities == null) throw new IllegalArgumentException("Null capabilities"); this.capabilities = capabilities; } /** * Set the capabilities. * * @param capabilities the capabilities. */ public void setCapabilities(List capabilities) { if (this.capabilities == null) this.capabilities = new CapabilitiesMetaData(); this.capabilities.setCapabilities(capabilities); } /** * Get the requirements. * * @return the requirements. */ public RequirementsMetaData getRequirements() { return requirements; } /** * Set the requirements. * * @param requirements the requirements. * @throws IllegalArgumentException for null requirements */ @ManagementProperty public void setRequirements(RequirementsMetaData requirements) { if (requirements == null) throw new IllegalArgumentException("Null requirements"); this.requirements = requirements; } /** * Set the requirements. * * @param requirements the requirements. */ public void setRequirements(List requirements) { if (this.requirements == null) this.requirements = new RequirementsMetaData(); this.requirements.setRequirements(requirements); } @Override public String toString() { StringBuilder builder = new StringBuilder(); builder.append(getClass().getSimpleName()); builder.append("@"); builder.append(Integer.toHexString(System.identityHashCode(this))); builder.append("{"); toString(builder); builder.append("}"); return builder.toString(); } /** * For subclasses to override the toString contents * * @param builder the builder */ protected void toString(StringBuilder builder) { builder.append("name=").append(getName()); builder.append(" version=").append(getVersion()); String domain = getDomain(); if (domain != null) builder.append(" domain=").append(domain); String parentDomain = getParentDomain(); if (parentDomain != null) builder.append(" parentDomain=").append(parentDomain); ExportAll exportAll = getExportAll(); if (exportAll != null) builder.append(" ").append(exportAll); if (isImportAll()) builder.append(" IMPORT-ALL"); builder.append(" parent-first=").append(isJ2seClassLoadingCompliance()); if (isCacheable() == false) builder.append(" NO-CACHE"); if (isBlackListable() == false) builder.append(" NO-BLACK-LIST"); List capabilities = getCapabilities().getCapabilities(); if (capabilities != null) builder.append(" capabilities=").append(capabilities); List requirements = getRequirements().getRequirements(); if (requirements != null) builder.append(" requirements=").append(requirements); } @Override public boolean equals(Object obj) { if (obj == this) return true; if (obj == null || obj instanceof ClassLoadingMetaData == false) return false; if (super.equals(obj) == false) return false; ClassLoadingMetaData other = (ClassLoadingMetaData) obj; if (equals(this.getDomain(), other.getDomain()) == false) return false; if (equals(this.getParentDomain(), other.getParentDomain()) == false) return false; if (equals(this.getExportAll(), other.getExportAll()) == false) return false; if (this.isImportAll() != other.isImportAll()) return false; if (this.isJ2seClassLoadingCompliance() != other.isJ2seClassLoadingCompliance()) return false; if (this.isCacheable() != other.isCacheable()) return false; if (this.isBlackListable() != other.isBlackListable()) return false; if (equals(this.getCapabilities().getCapabilities(), other.getCapabilities().getCapabilities()) == false) return false; if (equals(this.getRequirements().getRequirements(), other.getRequirements().getRequirements()) == false) return false; return true; } private static boolean equals(Object one, Object two) { if (one == null && two == null) return true; if (one == null && two != null) return false; return one.equals(two); } @Override public ClassLoadingMetaData clone() { ClassLoadingMetaData clone = (ClassLoadingMetaData) super.clone(); requirements = clone.requirements.clone(); capabilities = clone.capabilities.clone(); return clone; } } ././@LongLink0000000000000000000000000000016600000000000011570 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloading/src/main/java/org/jboss/classloading/spi/metadata/ExportAll.javalibjboss-classloader-java-2.0.6.GA.orig/classloading/src/main/java/org/jboss/classloading/spi/metada0000644000175000017500000000241710756304141033351 0ustar twernertwerner/* * JBoss, Home of Professional Open Source. * Copyright 2007, Red Hat Middleware LLC, and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.classloading.spi.metadata; /** * ExportAll. * * @author Adrian Brock * @version $Revision: 1.1 $ */ public enum ExportAll { /** All packages */ ALL, /** All non empty packages */ NON_EMPTY } ././@LongLink0000000000000000000000000000016000000000000011562 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloading/src/main/java/org/jboss/classloading/spi/metadata/helpers/libjboss-classloader-java-2.0.6.GA.orig/classloading/src/main/java/org/jboss/classloading/spi/metada0000755000175000017500000000000011620043420033332 5ustar twernertwerner././@LongLink0000000000000000000000000000020700000000000011564 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloading/src/main/java/org/jboss/classloading/spi/metadata/helpers/AbstractCapability.javalibjboss-classloader-java-2.0.6.GA.orig/classloading/src/main/java/org/jboss/classloading/spi/metada0000644000175000017500000000542210756304141033350 0ustar twernertwerner/* * JBoss, Home of Professional Open Source * Copyright 2007, JBoss Inc., and individual contributors as indicated * by the @authors tag. See the copyright.txt in the distribution for a * full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.classloading.spi.metadata.helpers; import org.jboss.classloading.spi.helpers.NameAndVersionSupport; import org.jboss.classloading.spi.metadata.Capability; /** * AbstractCapability. * * @author Adrian Brock * @version $Revision: 1.1 $ */ public abstract class AbstractCapability extends NameAndVersionSupport implements Capability { /** The serialVersionUID */ private static final long serialVersionUID = 1099174558119868306L; /** * Create a new AbstractCapability */ public AbstractCapability() { } /** * Create a new AbstractCapability * * @param name the name * @throws IllegalArgumentException for a null name */ public AbstractCapability(String name) { super(name); } /** * Create a new AbstractCapability. * * @param name the name * @param version the version - pass null for the default version * @throws IllegalArgumentException for a null name */ public AbstractCapability(String name, Object version) { super(name, version); } @Override public boolean equals(Object obj) { if (obj == this) return true; if (obj == null || obj instanceof AbstractCapability == false) return false; return super.equals(obj); } @Override public String toString() { StringBuffer buffer = new StringBuffer(); buffer.append(getClass().getSimpleName()); buffer.append("{"); toString(buffer); buffer.append("}"); return buffer.toString(); } /** * For subclasses to override toString() * * @param buffer the buffer */ protected void toString(StringBuffer buffer) { buffer.append(getName()); buffer.append(" ").append(getVersion()); } } ././@LongLink0000000000000000000000000000021000000000000011556 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloading/src/main/java/org/jboss/classloading/spi/metadata/helpers/AbstractRequirement.javalibjboss-classloader-java-2.0.6.GA.orig/classloading/src/main/java/org/jboss/classloading/spi/metada0000644000175000017500000001306511035356200033344 0ustar twernertwerner/* * JBoss, Home of Professional Open Source * Copyright 2007, JBoss Inc., and individual contributors as indicated * by the @authors tag. See the copyright.txt in the distribution for a * full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.classloading.spi.metadata.helpers; import javax.xml.bind.annotation.XmlAttribute; import org.jboss.classloading.spi.helpers.NameAndVersionRangeSupport; import org.jboss.classloading.spi.metadata.Requirement; import org.jboss.classloading.spi.version.VersionRange; /** * AbstractRequirement. * * @author Adrian Brock * @version $Revision: 1.1 $ */ public class AbstractRequirement extends NameAndVersionRangeSupport implements Requirement { /** The serialVersionUID */ private static final long serialVersionUID = -7898148730704557596L; /** Whether the requirement is optional */ private boolean optional = false; /** Whether the requirement is dynamic */ private boolean dynamic = false; /** Whether to re-export */ private boolean reExport = false; /** * Create a new AbstractRequirement */ public AbstractRequirement() { } /** * Create a new AbstractRequirement * * @param name the name * @throws IllegalArgumentException for a null name */ public AbstractRequirement(String name) { super(name); } /** * Create a new AbstractRequirement. * * @param name the name * @param versionRange the version range - pass null for all versions * @throws IllegalArgumentException for a null name */ public AbstractRequirement(String name, VersionRange versionRange) { super(name, versionRange); } public boolean isOptional() { return optional; } /** * Set the optional. * * @param optional the optional. */ @XmlAttribute(name="optional") public void setOptional(boolean optional) { this.optional = optional; } public boolean isDynamic() { return dynamic; } /** * Set the dynamic. * * @param dynamic the dynamic. */ @XmlAttribute(name="dynamic") public void setDynamic(boolean dynamic) { this.dynamic = dynamic; } public boolean wantReExports() { return false; } public boolean isReExport() { return reExport; } /** * Set the reExport. * * @param reExport the reExport. */ @XmlAttribute(name="reExport") public void setReExport(boolean reExport) { this.reExport = reExport; } public boolean isConsistent(Requirement other) { return isConsistent(other, null); } /** * Check whether the requirements are consistent * * @param other the other requirement * @param requirementType the class to check when looking for inconsistencies (uses getClass() when null) * @return true when consistent, false otherwise */ protected boolean isConsistent(Requirement other, Class requirementType) { if (other == null) throw new IllegalArgumentException("Null requirement"); if (requirementType == null) requirementType = getClass(); // Not our type if (requirementType.isInstance(other) == false) return true; AbstractRequirement otherRequirement = (AbstractRequirement) other; // Not the same name String name = getName(); String otherName = otherRequirement.getName(); if (name.equals(otherName) == false) return true; // Check the version ranges are consistent VersionRange range = getVersionRange(); VersionRange otherRange = otherRequirement.getVersionRange(); return range.isConsistent(otherRange); } @Override public boolean equals(Object obj) { if (obj == this) return true; if (obj == null || obj instanceof AbstractRequirement == false) return false; if (super.equals(obj) == false) return false; AbstractRequirement other = (AbstractRequirement) obj; if (this.isOptional() != other.isOptional()) return false; if (this.isReExport() != other.isReExport()) return false; return true; } @Override public String toString() { StringBuffer buffer = new StringBuffer(); buffer.append(getClass().getSimpleName()); buffer.append("{"); toString(buffer); buffer.append("}"); return buffer.toString(); } /** * For subclasses to override toString() * * @param buffer the buffer */ protected void toString(StringBuffer buffer) { buffer.append(getName()); buffer.append(" ").append(getVersionRange()); if (isOptional()) buffer.append(" OPTIONAL"); if (isReExport()) buffer.append(" RE-EXPORT"); } } ././@LongLink0000000000000000000000000000020300000000000011560 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloading/src/main/java/org/jboss/classloading/spi/metadata/ClassLoadingMetaData10.javalibjboss-classloader-java-2.0.6.GA.orig/classloading/src/main/java/org/jboss/classloading/spi/metada0000644000175000017500000000333311173151646033353 0ustar twernertwerner/* * JBoss, Home of Professional Open Source. * Copyright 2007, Red Hat Middleware LLC, and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.classloading.spi.metadata; import javax.xml.bind.annotation.XmlNsForm; import javax.xml.bind.annotation.XmlRootElement; import javax.xml.bind.annotation.XmlType; import org.jboss.xb.annotations.JBossXmlSchema; /** * ClassLoadingMetaData version 1.0. * * @author Adrian Brock * @version $Revision: 1.1 $ */ @JBossXmlSchema(namespace="urn:jboss:classloading:1.0", elementFormDefault=XmlNsForm.QUALIFIED) @XmlRootElement(name="classloading") @XmlType(propOrder = {"requirements", "capabilities"}) public class ClassLoadingMetaData10 extends ClassLoadingMetaData { /** The serialVersionUID */ private static final long serialVersionUID = -2782951093046585620L; } ././@LongLink0000000000000000000000000000017500000000000011570 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloading/src/main/java/org/jboss/classloading/spi/metadata/OptionalPackages.javalibjboss-classloader-java-2.0.6.GA.orig/classloading/src/main/java/org/jboss/classloading/spi/metada0000644000175000017500000000263511035356200033345 0ustar twernertwerner/* * JBoss, Home of Professional Open Source * Copyright 2007, JBoss Inc., and individual contributors as indicated * by the @authors tag. See the copyright.txt in the distribution for a * full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.classloading.spi.metadata; import java.util.Set; import org.jboss.classloading.spi.dependency.Module; /** * OptionalPackage. * * @author Adrian Brock * @version $Revision: 1.1 $ */ public interface OptionalPackages { /** * Get the package names * * @param module the module * @return the package names */ Set getOptionalPackageNames(Module module); } ././@LongLink0000000000000000000000000000014700000000000011567 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloading/src/main/java/org/jboss/classloading/spi/version/libjboss-classloader-java-2.0.6.GA.orig/classloading/src/main/java/org/jboss/classloading/spi/versio0000755000175000017500000000000011620043420033406 5ustar twernertwerner././@LongLink0000000000000000000000000000020500000000000011562 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloading/src/main/java/org/jboss/classloading/spi/version/VersionComparatorRegistry.javalibjboss-classloader-java-2.0.6.GA.orig/classloading/src/main/java/org/jboss/classloading/spi/versio0000644000175000017500000002431310756417772033443 0ustar twernertwerner/* * JBoss, Home of Professional Open Source * Copyright 2006, JBoss Inc., and individual contributors as indicated * by the @authors tag. See the copyright.txt in the distribution for a * full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.classloading.spi.version; import java.util.Map; import java.util.concurrent.ConcurrentHashMap; /** * Version comparator registry. * * @author Ales Justin * @author Adrian Brock */ public class VersionComparatorRegistry { /** The singleton */ private static VersionComparatorRegistry registry = new VersionComparatorRegistry(); /** The comparators */ private Map, Map, VersionComparator>> comparatorMap = new ConcurrentHashMap, Map, VersionComparator>>(); /** * Create a new VersionComparatorRegistry. */ public VersionComparatorRegistry() { // register all our known impls internalRegisterVersionComparator(Version.class, Version.class, new VersionToVersionComparator(), true); internalRegisterVersionComparator(Version.class, String.class, new VersionToStringComparator(), true); internalRegisterVersionComparator(String.class, String.class, new StringToStringComparator(), true); } /** * Get the singleton * * @return the singleton */ public static VersionComparatorRegistry getInstance() { return registry; } /** * Remove the version comparator. * * @param the first version type * @param the second version type * @param t first version impl * @param u second version impl */ public void removeVersionComparator(Class t, Class u) { registerVersionComparator(t, u, null); } /** * Remove the version comparator. * * @param the version type * @param t version impl */ public void removeVersionComparator(Class t) { registerVersionComparator(t, null); } /** * Register version comparator. * If comparator parameter is null, it's actually a removal. * * @param the version type * @param t version impl * @param comparator the version comparator */ public void registerVersionComparator(Class t, VersionComparator comparator) { registerVersionComparator(t, t, comparator); } /** * Register version comparator. * If comparator parameter is null, it's actually a removal. * * @param the first version type * @param the second version type * @param t first version impl * @param u second version impl * @param comparator the version comparator */ public void registerVersionComparator(Class t, Class u, VersionComparator comparator) { internalRegisterVersionComparator(t, u, comparator, false); } /** * Register version comparator. * If comparator parameter is null, it's actually a removal. * * @param the first version type * @param the second version type * @param t first version impl * @param u second version impl * @param comparator the version comparator * @param setup whether this is during setup */ private void internalRegisterVersionComparator(Class t, Class u, VersionComparator comparator, boolean setup) { if (t == null || u == null) throw new IllegalArgumentException("Null version class"); // Don't allow removal of the standard comparators if (setup == false) { if (t == Version.class && u == Version.class) throw new IllegalArgumentException("You can't remove or replace the built in Version->Version comparator"); if (t == Version.class && u == String.class) throw new IllegalArgumentException("You can't remove or replace the built in Version->String comparator"); if (t == String.class && u == Version.class) throw new IllegalArgumentException("You can't remove or replace the built in Version->String comparator"); if (t == String.class && u == String.class) throw new IllegalArgumentException("You can't remove or replace the built in Version->String comparator"); } if (comparator == null) { Map, VersionComparator> tKeyMap = comparatorMap.get(t); if (tKeyMap != null) tKeyMap.remove(u); // different impls if (t.equals(u) == false) { Map, VersionComparator> uKeyMap = comparatorMap.get(u); if (uKeyMap != null) uKeyMap.remove(t); } } else { Map, VersionComparator> tKeyMap = comparatorMap.get(t); if (tKeyMap == null) { tKeyMap = new ConcurrentHashMap, VersionComparator>(); comparatorMap.put(t, tKeyMap); } tKeyMap.put(u, comparator); // different impls if (t.equals(u) == false) { Map, VersionComparator> uKeyMap = comparatorMap.get(u); if (uKeyMap == null) { uKeyMap = new ConcurrentHashMap, VersionComparator>(); comparatorMap.put(u, uKeyMap); } uKeyMap.put(t, new SwitchVersionComparator(comparator)); } } } /** * Get the comparator. * * @param the first version type * @param the second version type * @param t first version impl * @param u second version impl * @return the matching comparator */ @SuppressWarnings("unchecked") protected VersionComparator getComparator(T t, U u) { if (t == null || u == null) return null; Class classT = (Class) t.getClass(); Class classU = (Class) u.getClass(); return getComparator(classT, classU); } /** * Get the comparator. * * @param the first version type * @param the second version type * @param t first version impl class * @param u second version impl class * @return the matching comparator */ @SuppressWarnings("unchecked") public VersionComparator getComparator(Class t, Class u) { Map, VersionComparator> map = comparatorMap.get(t); if (map == null) return null; else return (VersionComparator) map.get(u); } /** * Compare two version impls. * * @param the first version type * @param the second version type * @param t the first version * @param u the second version * @return the compare result */ public int compare(T t, U u) { VersionComparator comparator = getComparator(t, u); if (comparator == null) { String classT = null; if (t != null) classT = t.getClass().getName(); String classU = null; if (u != null) classU = u.getClass().getName(); throw new IllegalArgumentException("Missing version comparator for Version pair: (" + classT + "," + classU + ")"); } return comparator.compare(t, u); } /** * Test whether two version impls are request. * * @param the first version type * @param the second version type * @param t T version impl * @param u U version impl * @return the compare result */ public boolean same(T t, U u) { VersionComparator comparator = getComparator(t, u); if (comparator == null) return false; return comparator.compare(t, u) == 0; } /** * Switch the compare value. * * @param the first version type * @param the second version type */ private class SwitchVersionComparator implements VersionComparator { /** The delegate */ private VersionComparator delegate; /** * Create a new SwitchVersionComparator. * * @param delegate the delegate comparator */ public SwitchVersionComparator(VersionComparator delegate) { if (delegate == null) throw new IllegalArgumentException("Null delegate"); this.delegate = delegate; } public int compare(T t, U u) { return (-1) * delegate.compare(u, t); } } /** * VersionToVersionComparator. */ private class VersionToVersionComparator implements VersionComparator { public int compare(Version t, Version u) { return t.compareTo(u); } } /** * VersionToStringComparator. */ private class VersionToStringComparator implements VersionComparator { public int compare(Version t, String u) { return t.compareTo(Version.parseVersion(u)); } } /** * StringToStringComparator. */ private class StringToStringComparator implements VersionComparator { public int compare(String t, String u) { return Version.parseVersion(t).compareTo(Version.parseVersion(u)); } } } ././@LongLink0000000000000000000000000000017500000000000011570 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloading/src/main/java/org/jboss/classloading/spi/version/VersionComparator.javalibjboss-classloader-java-2.0.6.GA.orig/classloading/src/main/java/org/jboss/classloading/spi/versio0000644000175000017500000000304210756304141033420 0ustar twernertwerner/* * JBoss, Home of Professional Open Source * Copyright 2006, JBoss Inc., and individual contributors as indicated * by the @authors tag. See the copyright.txt in the distribution for a * full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.classloading.spi.version; /** * The Version impl comparator. * * @param the first version type * @param the second version type * @author Ales Justin * @author Adrian Brock */ public interface VersionComparator { /** * Compare the two version impls. * * @param one the first version * @param two the second versionl * @return compare the two versions */ int compare(T one, U two); } ././@LongLink0000000000000000000000000000017000000000000011563 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloading/src/main/java/org/jboss/classloading/spi/version/VersionRange.javalibjboss-classloader-java-2.0.6.GA.orig/classloading/src/main/java/org/jboss/classloading/spi/versio0000644000175000017500000002044711035356200033422 0ustar twernertwerner/* * JBoss, Home of Professional Open Source. * Copyright 2007, Red Hat Middleware LLC, and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.classloading.spi.version; import java.io.Serializable; /** * VersionRange. * * @author Adrian Brock * @version $Revision: 1.1 $ */ public class VersionRange implements Serializable { /** The serialVersionUID */ private static final long serialVersionUID = 8494384641173842116L; /** The low range */ private Object low; /** Whether low is inclusive */ private boolean lowInclusive; /** The high range */ private Object high; /** Whether high is inclusive */ private boolean highInclusive; /** All versions */ public static final VersionRange ALL_VERSIONS = new VersionRange(Version.DEFAULT_VERSION); /** * Create a new VersionRange with just a low inclusive check * * @param low the low range (null for no lower bound) */ public VersionRange(Object low) { this(low, null); } /** * Create a new VersionRange with low inclusive and high non-inclusive * * @param low the low range (null for no lower bound) * @param high the high range (null for no higher bound) */ public VersionRange(Object low, Object high) { this(low, true, high, false); } /** * Create a new VersionRange. * * @param low the low range (null for no lower bound) * @param lowInclusive whether the low bound is inclusive * @param high the high range (null for no higher bound) * @param highInclusive whether the high bound is inclusive * @throws IllegalArgumentException if the low or is inclusive but not in the range or the high is less than the low */ public VersionRange(Object low, boolean lowInclusive, Object high, boolean highInclusive) { if (low == null) low = Version.DEFAULT_VERSION; this.low = low; this.lowInclusive = lowInclusive; this.high = high; this.highInclusive = highInclusive; validate(); } /** * Validate the range * * @throws IllegalArgumentException for any error */ protected void validate() { if (lowInclusive && isInRange(low) == false) throw new IllegalArgumentException("Inclusive low is not in the range: " + toString()); if (high != null && highInclusive && isInRange(high) == false) throw new IllegalArgumentException("Inclusive high is not in the range: " + toString()); if (high != null) { VersionComparatorRegistry registry = VersionComparatorRegistry.getInstance(); int comparison = registry.compare(low, high); if (comparison > 0) throw new IllegalArgumentException("High is less than the low: " + toString()); if (comparison == 0) { if (lowInclusive == false || highInclusive == false) throw new IllegalArgumentException("High and low don't include each other: " + toString()); } } } /** * Get the low. * * @return the low. */ public Object getLow() { return low; } /** * Get the lowInclusive. * * @return the lowInclusive. */ public boolean isLowInclusive() { return lowInclusive; } /** * Get the high. * * @return the high. */ public Object getHigh() { return high; } /** * Get the highInclusive. * * @return the highInclusive. */ public boolean isHighInclusive() { return highInclusive; } /** * Test whether a version is in range * * @param version the version to test * @return true when the version is in range * @throws IllegalArgumentException for a null version */ public boolean isInRange(Object version) { if (version == null) throw new IllegalArgumentException("Null version"); VersionComparatorRegistry comparator = VersionComparatorRegistry.getInstance(); int comparison = comparator.compare(low, version); if (comparison > 0) return false; if (lowInclusive == false && comparison == 0) return false; if (high != null) { comparison = comparator.compare(high, version); if (comparison < 0) return false; if (highInclusive == false && comparison == 0) return false; } return true; } /** * Check whether two version ranges are consistent * * @param other the other version * @return true when the version ranges "overlap" */ public boolean isConsistent(VersionRange other) { // No version range is consistent with ours if (other == null) return true; Object otherLow = other.getLow(); Object otherHigh = other.getHigh(); VersionComparatorRegistry comparator = VersionComparatorRegistry.getInstance(); // Other low is "lower" int comparison = comparator.compare(low, otherLow); if (comparison > 0 || (lowInclusive == false && comparison == 0)) { // Just need to check that the other high is not lower if (otherHigh == null) return true; comparison = comparator.compare(low, otherHigh); return (comparison > 0 || (lowInclusive == false && comparison == 0)) == false; } // So the other low is "bigger" than our low // We have no high so we are done if (high == null) return true; // Check the other low is not "bigger" than our higher comparison = comparator.compare(high, otherLow); if (comparison < 0 || (highInclusive == false && comparison == 0)) return false; // The low is in our range so we are done return true; } @Override public boolean equals(Object obj) { if (obj == this) return true; if (obj == null || obj instanceof VersionRange == false) return false; VersionRange other = (VersionRange) obj; VersionComparatorRegistry comparator = VersionComparatorRegistry.getInstance(); Object thisLow = other.getLow(); Object otherLow = other.getLow(); if (comparator.same(thisLow, otherLow) == false) return false; if (isLowInclusive() != other.isLowInclusive()) return false; Object thisHigh = this.getHigh(); Object otherHigh = other.getHigh(); if (thisHigh == null) { if (otherHigh != null) return false; } else if (comparator.same(thisHigh, otherHigh) == false) return false; if (thisHigh != null && isHighInclusive() != other.isHighInclusive()) return false; return true; } @Override public int hashCode() { if (high != null) return high.hashCode(); return low.hashCode(); } @Override public String toString() { StringBuilder builder = new StringBuilder(); if (isLowInclusive()) builder.append("["); else builder.append("("); builder.append(low); builder.append(","); if (high != null) { builder.append(high); if (isHighInclusive()) builder.append("]"); else builder.append(")"); } else { builder.append("?)"); } return builder.toString(); } } ././@LongLink0000000000000000000000000000016300000000000011565 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloading/src/main/java/org/jboss/classloading/spi/version/Version.javalibjboss-classloader-java-2.0.6.GA.orig/classloading/src/main/java/org/jboss/classloading/spi/versio0000644000175000017500000001766710757515224033451 0ustar twernertwerner/* * JBoss, Home of Professional Open Source. * Copyright 2007, Red Hat Middleware LLC, and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.classloading.spi.version; import java.io.Serializable; import java.util.NoSuchElementException; import java.util.StringTokenizer; import java.util.regex.Pattern; import org.jboss.classloading.plugins.metadata.VersionMetaMapper; import org.jboss.metatype.api.annotations.MetaMapping; /** * Version. * * @author Ales Justin * @author Adrian Brock * @version $Revision: 1.1 $ */ @MetaMapping(VersionMetaMapper.class) public class Version implements Serializable, Comparable { /** The serialVersionUID */ private static final long serialVersionUID = 1L; /** The sperator */ private static final String SEPARATOR = "."; /** The raw pattern */ private static final String PATTERN = "[a-zA-Z0-9_-]*"; /** The qualifier pattern */ private static final Pattern QUALIFIER_PATTERN = Pattern.compile(PATTERN); /** The default version */ public static final Version DEFAULT_VERSION = new Version(0, 0, 0); /** The major part of the version */ private int major; /** The minor part of the version */ private int minor; /** The micro part of the version */ private int micro; /** The qualifier part of the version */ private String qualifier; /** * Create a new Version. * * @param major the major part * @param minor the minor part * @param micro the micro part */ public Version(int major, int minor, int micro) { this(major, minor, micro, null); } /** * Create a new VersionImpl. * * @param major the major part * @param minor the minor part * @param micro the micro part * @param qualifier the qualifier */ public Version(int major, int minor, int micro, String qualifier) { this.major = major; this.minor = minor; this.micro = micro; if (qualifier == null) qualifier = ""; this.qualifier = qualifier; validate(); } /** * Create a new VersionImpl. * * @param version the version as a string * @throws IllegalArgumentException for a null version or invalid format */ private Version(String version) { if (version == null) throw new IllegalArgumentException("Null version"); int major = 0; int minor = 0; int micro = 0; String qualifier = ""; try { StringTokenizer st = new StringTokenizer(version, SEPARATOR, true); major = Integer.parseInt(st.nextToken().trim()); if (st.hasMoreTokens()) { st.nextToken(); minor = Integer.parseInt(st.nextToken().trim()); if (st.hasMoreTokens()) { st.nextToken(); micro = Integer.parseInt(st.nextToken().trim()); if (st.hasMoreTokens()) { st.nextToken(); qualifier = st.nextToken().trim(); if (st.hasMoreTokens()) { throw new IllegalArgumentException("Invalid version format, too many seperators: " + version); } } } } } catch (NoSuchElementException e) { throw new IllegalArgumentException("Invalid version format: " + version); } catch (NumberFormatException e) { throw new IllegalArgumentException("Invalid version format: " + version); } this.major = major; this.minor = minor; this.micro = micro; this.qualifier = qualifier; validate(); } /** * Validate arguments. */ protected void validate() { if (major < 0) throw new IllegalArgumentException("negative major: " + major); if (minor < 0) throw new IllegalArgumentException("negative minor: " + minor); if (micro < 0) throw new IllegalArgumentException("negative micro: " + micro); if (QUALIFIER_PATTERN.matcher(qualifier).matches() == false) throw new IllegalArgumentException("Invalid qualifier, it must be " + PATTERN + ": " + qualifier); } /** * Parses a version identifier from the specified string. * See Version(String) for the format of the version string. * * @param version String representation of the version identifier. Leading * and trailing whitespace will be ignored. * @return A Version object representing the version * identifier. If version is null or * the empty string then emptyVersion will be * returned. * @throws IllegalArgumentException If version is improperly * formatted. */ public static Version parseVersion(String version) { if (version == null) return DEFAULT_VERSION; version = version.trim(); if (version.length() == 0) return DEFAULT_VERSION; return new Version(version); } /** * Returns the major component of this version identifier. * * @return The major component. */ public int getMajor() { return major; } /** * Returns the minor component of this version identifier. * * @return The minor component. */ public int getMinor() { return minor; } /** * Returns the micro component of this version identifier. * * @return The micro component. */ public int getMicro() { return micro; } /** * Returns the qualifier component of this version identifier. * * @return The qualifier component. */ public String getQualifier() { return qualifier; } @Override public String toString() { StringBuilder builder = new StringBuilder(); builder.append(major).append(SEPARATOR).append(minor).append(SEPARATOR).append(micro); if (qualifier.length() > 0) builder.append(SEPARATOR).append(qualifier); return builder.toString(); } @Override public int hashCode() { return (major << 24) + (minor << 16) + (micro << 8) + qualifier.hashCode(); } @Override @SuppressWarnings("unchecked") public boolean equals(Object object) { if (object == this) return true; if (object == null) return false; return VersionComparatorRegistry.getInstance().same(this, object); } /** * Compare two Versions. * * @param version the other version * @return compare result */ public int compareTo(Version version) { if (version == this) return 0; int result = major - version.major; if (result != 0) return result; result = minor - version.minor; if (result != 0) return result; result = micro - version.micro; if (result != 0) return result; return qualifier.compareTo(version.qualifier); } } ././@LongLink0000000000000000000000000000015200000000000011563 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloading/src/main/java/org/jboss/classloading/spi/dependency/libjboss-classloader-java-2.0.6.GA.orig/classloading/src/main/java/org/jboss/classloading/spi/depend0000755000175000017500000000000011620043421033337 5ustar twernertwerner././@LongLink0000000000000000000000000000016100000000000011563 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloading/src/main/java/org/jboss/classloading/spi/dependency/policy/libjboss-classloader-java-2.0.6.GA.orig/classloading/src/main/java/org/jboss/classloading/spi/depend0000755000175000017500000000000011620043420033336 5ustar twernertwerner././@LongLink0000000000000000000000000000016600000000000011570 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloading/src/main/java/org/jboss/classloading/spi/dependency/policy/mock/libjboss-classloader-java-2.0.6.GA.orig/classloading/src/main/java/org/jboss/classloading/spi/depend0000755000175000017500000000000011620043421033337 5ustar twernertwerner././@LongLink0000000000000000000000000000022600000000000011565 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloading/src/main/java/org/jboss/classloading/spi/dependency/policy/mock/MockClassLoaderPolicyModule.javalibjboss-classloader-java-2.0.6.GA.orig/classloading/src/main/java/org/jboss/classloading/spi/depend0000644000175000017500000002271211071406374033357 0ustar twernertwerner/* * JBoss, Home of Professional Open Source * Copyright 2008, JBoss Inc., and individual contributors as indicated * by the @authors tag. See the copyright.txt in the distribution for a * full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.classloading.spi.dependency.policy.mock; import java.io.File; import java.net.URL; import java.net.URISyntaxException; import java.util.Arrays; import java.util.Collection; import java.util.Collections; import java.util.List; import java.util.concurrent.CopyOnWriteArrayList; import org.jboss.classloader.spi.filter.ClassFilter; import org.jboss.classloader.test.support.MockClassLoaderHelper; import org.jboss.classloader.test.support.MockClassLoaderPolicy; import org.jboss.classloading.plugins.visitor.DefaultResourceContext; import org.jboss.classloading.spi.dependency.policy.ClassLoaderPolicyModule; import org.jboss.classloading.spi.metadata.Capability; import org.jboss.classloading.spi.metadata.ClassLoadingMetaDataFactory; import org.jboss.classloading.spi.visitor.ResourceContext; import org.jboss.classloading.spi.visitor.ResourceFilter; import org.jboss.classloading.spi.visitor.ResourceVisitor; import org.jboss.kernel.spi.dependency.KernelControllerContext; import org.jboss.kernel.spi.dependency.KernelControllerContextAware; /** * VFSClassLoaderPolicyModule. * * @author Adrian Brock * @version $Revision: 1.1 $ */ public class MockClassLoaderPolicyModule extends ClassLoaderPolicyModule implements KernelControllerContextAware { /** The serialVersionUID */ private static final long serialVersionUID = 1L; /** * Create a new VFSClassLoaderPolicyModule. * * @param classLoadingMetaData the classloading metadata * @param contextName the context name */ public MockClassLoaderPolicyModule(MockClassLoadingMetaData classLoadingMetaData, String contextName) { super(classLoadingMetaData, contextName); } /** * Get collection from string array. * * @param strings the strings * @return string collection */ private static Collection toCollection(String[] strings) { if (strings == null || strings.length == 0) return Collections.emptySet(); else return Arrays.asList(strings); } /** * Get URL for path param. * * @param path the path * @return path's URL */ protected URL getURL(String path) { ClassLoader classLoader = getClassLoader(); if (classLoader == null) throw new IllegalStateException("ClassLoader has not been constructed for " + getContextName()); return classLoader.getResource(path); } /** * Get file from path's url. * * @param url the path's url * @return path's file */ protected File getFile(URL url) { try { return new File(url.toURI()); } catch (URISyntaxException e) { throw new RuntimeException(e); } } public void visit(ResourceVisitor visitor, ResourceFilter filter, ResourceFilter recurseFilter, URL... urls) { MockClassLoadingMetaData mclmd = getClassLoadingMetaData(); String[] paths = mclmd.getPaths(); if (paths != null && paths.length > 0) { ClassLoader classLoader = getClassLoader(); if (classLoader == null) throw new IllegalStateException("ClassLoader has not been constructed for " + getContextName()); Collection included = toCollection(mclmd.getIncludedClasses()); ClassFilter includedFilter = getIncluded(); Collection excluded = toCollection(mclmd.getExcludedClasses()); ClassFilter excludedFilter = getExcluded(); for (String path : paths) { visitPath(null, path, visitor, filter, recurseFilter, classLoader, included, includedFilter, excluded, excludedFilter, null); } } } /** * Visit path. * * @param file the current path file * @param path the path * @param visitor the visitor * @param filter the filter * @param recurseFilter the recurse filter * @param classLoader the classloader * @param included the included * @param includedFilter the included filter * @param excluded the excluded * @param excludedFilter the excluded filter * @param context the current context */ protected void visitPath(File file, String path, ResourceVisitor visitor, ResourceFilter filter, ResourceFilter recurseFilter, ClassLoader classLoader, Collection included, ClassFilter includedFilter, Collection excluded, ClassFilter excludedFilter, ResourceContext context) { boolean visit = includePath(path, included, includedFilter, excluded, excludedFilter); URL url = getURL(path); if (visit) { if (context == null) context = new DefaultResourceContext(url, path, classLoader); if (filter == null || filter.accepts(context)) visitor.visit(context); } if (file == null) file = getFile(url); if (file.isFile()) return; File[] files = file.listFiles(); if (files != null && files.length > 0) { if (path.endsWith("/") == false) path += "/"; for (File child : files) { String childPath = path + child.getName(); ResourceContext childContext = new DefaultResourceContext(getURL(childPath), childPath, classLoader); if (recurseFilter == null || recurseFilter.accepts(childContext)) { visitPath(child, childPath, visitor, filter, recurseFilter, classLoader, included, includedFilter, excluded, excludedFilter, childContext); } } } } /** * Should we include path in visit. * * @param path the path * @param included the included * @param includedFilter the included filter * @param excluded the excluded * @param excludedFilter the excluded filter * @return true if path should be included in visit */ protected boolean includePath(String path, Collection included, ClassFilter includedFilter, Collection excluded, ClassFilter excludedFilter) { if (included.isEmpty() == false && included.contains(path) == false) return false; if (includedFilter != null && includedFilter.matchesResourcePath(path) == false) return false; if (excluded.isEmpty() == false && excluded.contains(path)) return false; if (excludedFilter != null && excludedFilter.matchesResourcePath(path)) return false; return true; } @Override protected List determineCapabilities() { List capabilities = super.determineCapabilities(); if (capabilities != null) return capabilities; // We need to work it out ClassLoadingMetaDataFactory factory = ClassLoadingMetaDataFactory.getInstance(); capabilities = new CopyOnWriteArrayList(); // We have a module capability Object version = getVersion(); Capability capability = factory.createModule(getName(), version); capabilities.add(capability); MockClassLoadingMetaData metadata = getClassLoadingMetaData(); String[] exported = metadata.getExportedPackages(); // Do we determine package capabilities? if (exported != null) { for (String packageName : exported) { capability = factory.createPackage(packageName, version); capabilities.add(capability); } } return capabilities; } public void setKernelControllerContext(KernelControllerContext context) throws Exception { setControllerContext(context); } public void unsetKernelControllerContext(KernelControllerContext context) throws Exception { setControllerContext(null); } @Override protected MockClassLoadingMetaData getClassLoadingMetaData() { return (MockClassLoadingMetaData) super.getClassLoadingMetaData(); } @Override public MockClassLoaderPolicy getPolicy() { return (MockClassLoaderPolicy) super.getPolicy(); } @Override protected MockClassLoaderPolicy determinePolicy() { MockClassLoadingMetaData metaData = getClassLoadingMetaData(); MockClassLoaderPolicy policy = MockClassLoaderHelper.createMockClassLoaderPolicy(getContextName()); policy.setPrefix(metaData.getPrefix()); policy.setPackageNames(getPackageNames()); policy.setPaths(metaData.getPaths()); policy.setIncluded(metaData.getIncludedClasses()); policy.setExcluded(metaData.getExcludedClasses()); policy.setImportAll(isImportAll()); policy.setDelegates(getDelegates()); return policy; } } ././@LongLink0000000000000000000000000000022300000000000011562 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloading/src/main/java/org/jboss/classloading/spi/dependency/policy/mock/MockClassLoadingMetaData.javalibjboss-classloader-java-2.0.6.GA.orig/classloading/src/main/java/org/jboss/classloading/spi/depend0000644000175000017500000001572710756304141033365 0ustar twernertwerner/* * JBoss, Home of Professional Open Source * Copyright 2007, JBoss Inc., and individual contributors as indicated * by the @authors tag. See the copyright.txt in the distribution for a * full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.classloading.spi.dependency.policy.mock; import org.jboss.classloader.plugins.ClassLoaderUtils; import org.jboss.classloading.spi.metadata.ClassLoadingMetaData; import org.jboss.classloading.spi.version.Version; /** * MockClassLoadingMetaData. * * @author Adrian Brock * @version $Revision: 1.1 $ */ public class MockClassLoadingMetaData extends ClassLoadingMetaData { /** The serialVersionUID */ private static final long serialVersionUID = 1L; /** The prefix */ private String prefix = ""; /** The paths */ private String[] paths; /** The included resources */ private String[] included; /** The excluded resources */ private String[] excluded; /** The exported package names */ private String[] exported; /** * Create a new MockClassLoadingMetaData. * * @param name the name */ public MockClassLoadingMetaData(String name) { this(name, Version.DEFAULT_VERSION); } /** * Create a new MockClassLoadingMetaData. * * @param name the name * @param version the version */ public MockClassLoadingMetaData(String name, String version) { setName(name); setVersion(Version.parseVersion(version)); } /** * Create a new MockClassLoadingMetaData. * * @param name the name * @param version the version */ public MockClassLoadingMetaData(String name, Version version) { setName(name); setVersion(version); } /** * Get the prefix. * * @return the prefix. */ public String getPrefix() { return prefix; } /** * Set the prefix. * * @param prefix the prefix. */ public void setPrefix(String prefix) { this.prefix = prefix; } /** * Get the paths to expose * * @return the paths */ public String[] getPaths() { return paths; } /** * Set the path to expose * * @param path the path */ public void setPath(String path) { setPaths(path); } /** * Set the paths to expose * * @param paths the paths to expose */ public void setPaths(String... paths) { this.paths = paths; } /** * Set the paths to expose * * @param classes the classes to reference to determine the package paths */ public void setPaths(Class... classes) { if (classes == null) { paths = null; return; } paths = new String[classes.length]; for (int i = 0; i < classes.length; ++i) paths[i] = ClassLoaderUtils.packageNameToPath(classes[i].getName()); } public String[] getExportedPackages() { return exported; } /** * Set the exported package names * * @param packageNames the exported packages */ public void setExportedPackages(String... packageNames) { this.exported = packageNames; } /** * Set the exported package names * * @param classes the classes to reference to determine the package names */ public void setExportedPackages(Class... classes) { if (classes == null) { exported = null; return; } exported = new String[classes.length]; for (int i = 0; i < classes.length; ++i) exported[i] = ClassLoaderUtils.getClassPackageName(classes[i].getName()); } /** * Get the included. * * @return the included. */ public String[] getIncludedClasses() { return included; } /** * Set the included. * * @param included the included. */ public void setIncluded(String[] included) { this.included = included; } /** * Get the excluded. * * @return the excluded. */ public String[] getExcludedClasses() { return excluded; } /** * Set the excluded. * * @param excluded the excluded. */ public void setExcluded(String[] excluded) { this.excluded = excluded; } /** * Set the included classes * * @param classes the classes to include from the paths */ public void setIncludedClasses(Class... classes) { if (classes == null) { included = null; return; } included = new String[classes.length]; for (int i = 0; i < classes.length; ++i) included[i] = ClassLoaderUtils.classNameToPath(classes[i].getName()); } /** * Set the included classes * * @param included the classes to include from the paths */ public void setIncludedClasses(String... included) { this.included = included; } /** * Set the excluded classes * * @param classes the classes to exclude from the paths */ public void setExcludedClasses(Class... classes) { if (classes == null) { excluded = null; return; } excluded = new String[classes.length]; for (int i = 0; i < classes.length; ++i) excluded[i] = ClassLoaderUtils.classNameToPath(classes[i].getName()); } /** * Set the excluded classes * * @param excluded the classes to include from the paths */ public void setExcludedClasses(String... excluded) { this.excluded = excluded; } /** * Set the paths and the exported package names * * @param classes the classes to reference */ public void setPathsAndPackageNames(Class... classes) { setPaths(classes); setExportedPackages(classes); } /** * Set the paths and the exported package names * * @param packages the packages */ public void setPathsAndPackageNames(String... packages) { if (packages == null) { paths = null; exported = null; return; } paths = new String[packages.length]; for (int i = 0; i < packages.length; ++i) paths[i] = packages[i].replace('.', '/'); setExportedPackages(packages); } } ././@LongLink0000000000000000000000000000021500000000000011563 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloading/src/main/java/org/jboss/classloading/spi/dependency/policy/ClassLoaderPolicyModule.javalibjboss-classloader-java-2.0.6.GA.orig/classloading/src/main/java/org/jboss/classloading/spi/depend0000644000175000017500000002047611133124140033347 0ustar twernertwerner/* * JBoss, Home of Professional Open Source * Copyright 2007, JBoss Inc., and individual contributors as indicated * by the @authors tag. See the copyright.txt in the distribution for a * full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.classloading.spi.dependency.policy; import java.security.AccessController; import java.security.PrivilegedActionException; import java.security.PrivilegedExceptionAction; import org.jboss.classloader.plugins.loader.ClassLoaderToLoaderAdapter; import org.jboss.classloader.spi.ClassLoaderPolicy; import org.jboss.classloader.spi.ClassLoaderSystem; import org.jboss.classloader.spi.DelegateLoader; import org.jboss.classloader.spi.Loader; import org.jboss.classloader.spi.ParentPolicy; import org.jboss.classloader.spi.base.BaseClassLoader; import org.jboss.classloader.spi.filter.LazyFilteredDelegateLoader; import org.jboss.classloading.spi.dependency.Domain; import org.jboss.classloading.spi.dependency.Module; import org.jboss.classloading.spi.dependency.RequirementDependencyItem; import org.jboss.classloading.spi.dependency.helpers.ClassLoadingMetaDataModule; import org.jboss.classloading.spi.metadata.ClassLoadingMetaData; import org.jboss.classloading.spi.metadata.Requirement; import org.jboss.dependency.spi.Controller; import org.jboss.dependency.spi.ControllerContext; /** * ClassLoaderPolicyModule. * * @author Adrian Brock * @version $Revision: 1.1 $ */ public abstract class ClassLoaderPolicyModule extends ClassLoadingMetaDataModule { /** The serialVersionUID */ private static final long serialVersionUID = -3357427104777457717L; /** Our cached policy */ private ClassLoaderPolicy policy; /** The classloader system we are registered with */ private ClassLoaderSystem system; /** The classloader */ private ClassLoader classLoader; /** * Create a new ClassLoaderPolicyModule. * * @param classLoadingMetaData the classloading metadata * @param contextName the context name */ public ClassLoaderPolicyModule(ClassLoadingMetaData classLoadingMetaData, String contextName) { super(classLoadingMetaData, contextName); } @Override protected ClassLoader getClassLoaderForClass(final String className) throws ClassNotFoundException { if (classLoader == null) throw new IllegalStateException("No classloader for module " + this); if (classLoader instanceof BaseClassLoader == false) return super.getClassLoaderForClass(className); final BaseClassLoader bcl = (BaseClassLoader) classLoader; SecurityManager sm = System.getSecurityManager(); if (sm != null) { try { return AccessController.doPrivileged(new PrivilegedExceptionAction() { public ClassLoader run() throws Exception { return bcl.findClassLoader(className); } }); } catch (PrivilegedActionException e) { Throwable t = e.getCause(); if (t instanceof ClassNotFoundException) throw (ClassNotFoundException) t; if (t instanceof Error) throw (Error) t; if (t instanceof RuntimeException) throw (RuntimeException) t; throw new RuntimeException("Error during findClassLoader for " + className, e); } } return bcl.findClassLoader(className); } /** * Register the classloader policy with a classloader system * * @param system the classloader system * @return the classloader */ public ClassLoader registerClassLoaderPolicy(ClassLoaderSystem system) { if (system == null) throw new IllegalArgumentException("Null classloader system"); if (isValid() == false) throw new IllegalStateException("Module " + this + " is not registered, see previous error messages"); String domainName = getDeterminedDomainName(); ParentPolicy parentPolicy = getDeterminedParentPolicy(); String parentName = getDeterminedParentDomainName(); ClassLoader result = system.registerClassLoaderPolicy(domainName, parentPolicy, parentName, getPolicy()); this.system = system; this.classLoader = result; registerModuleClassLoader(this, result); return result; } /** * Register the classloader policy with a classloader system * * @param system the classloader system * @param parent the parent classloader * @return the classloader */ public ClassLoader registerClassLoaderPolicy(ClassLoaderSystem system, ClassLoader parent) { if (system == null) throw new IllegalArgumentException("Null classloader system"); if (parent == null) throw new IllegalArgumentException("Null parent"); if (isValid() == false) throw new IllegalStateException("Module " + this + " is not registered, see previous error messages"); Loader loader = new ClassLoaderToLoaderAdapter(parent); ClassLoader result = registerClassLoaderPolicy(system, loader); this.classLoader = result; registerModuleClassLoader(this, result); return result; } /** * Register the classloader policy with a classloader system * * @param system the classloader system * @param loader the parent loader * @return the classloader */ public ClassLoader registerClassLoaderPolicy(ClassLoaderSystem system, Loader loader) { if (system == null) throw new IllegalArgumentException("Null classloader system"); if (isValid() == false) throw new IllegalStateException("Module " + this + " is not registered, see previous error messages"); String domainName = getDeterminedDomainName(); ParentPolicy parentPolicy = getDeterminedParentPolicy(); ClassLoader result = system.registerClassLoaderPolicy(domainName, parentPolicy, loader, getPolicy()); this.system = system; this.classLoader = result; registerModuleClassLoader(this, result); return result; } /** * Get the policy * * @return the policy */ public ClassLoaderPolicy getPolicy() { if (policy != null) return policy; policy = determinePolicy(); return policy; } public void removeClassLoader() { if (system != null && policy != null) system.unregisterClassLoaderPolicy(policy); if (classLoader != null) unregisterModuleClassLoader(this, classLoader); classLoader = null; system = null; policy = null; } /** * Determine the classloader policy * * @return the policy */ protected abstract ClassLoaderPolicy determinePolicy(); @Override protected ClassLoader getClassLoader() { return classLoader; } @Override public DelegateLoader createLazyDelegateLoader(Domain domain, RequirementDependencyItem item) { ControllerContext context = getControllerContext(); if (context == null) throw new IllegalStateException("No controller context"); Controller controller = context.getController(); DynamicClassLoaderPolicyFactory factory = new DynamicClassLoaderPolicyFactory(controller, domain, item); return new LazyFilteredDelegateLoader(factory); } @Override public DelegateLoader getDelegateLoader(Module requiringModule, Requirement requirement) { return getPolicy().getExported(); } @Override public void reset() { super.reset(); system = null; policy = null; } } ././@LongLink0000000000000000000000000000022500000000000011564 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloading/src/main/java/org/jboss/classloading/spi/dependency/policy/DynamicClassLoaderPolicyFactory.javalibjboss-classloader-java-2.0.6.GA.orig/classloading/src/main/java/org/jboss/classloading/spi/depend0000644000175000017500000000640110761314167033357 0ustar twernertwerner/* * JBoss, Home of Professional Open Source * Copyright 2007, JBoss Inc., and individual contributors as indicated * by the @authors tag. See the copyright.txt in the distribution for a * full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.classloading.spi.dependency.policy; import org.jboss.classloader.spi.ClassLoaderPolicy; import org.jboss.classloader.spi.ClassLoaderPolicyFactory; import org.jboss.classloading.spi.dependency.Domain; import org.jboss.classloading.spi.dependency.Module; import org.jboss.classloading.spi.dependency.RequirementDependencyItem; import org.jboss.dependency.spi.Controller; /** * DynamicClassLoaderPolicyFactory. * * @author Adrian Brock * @version $Revision: 1.1 $ */ public class DynamicClassLoaderPolicyFactory implements ClassLoaderPolicyFactory { /** The controller */ private Controller controller; /** The domain */ private Domain domain; /** The requirement dependency item */ private RequirementDependencyItem item; /** * Create a new DynamicClassLoaderPolicyFactory. * * @param controller the controller * @param domain the domain * @param item the item */ public DynamicClassLoaderPolicyFactory(Controller controller, Domain domain, RequirementDependencyItem item) { if (controller == null) throw new IllegalArgumentException("Null controller"); if (domain == null) throw new IllegalArgumentException("Null domain"); if (item == null) throw new IllegalArgumentException("Null item"); this.controller = controller; this.domain = domain; this.item = item; } public ClassLoaderPolicy createClassLoaderPolicy() { // Still undetermined String name = (String) item.getIDependOn(); if (name == null) { // Try to resolve item.resolve(controller); name = (String) item.getIDependOn(); if (name == null) return null; } Module iDependOnModule = domain.getModule(name); if (iDependOnModule == null) throw new IllegalStateException("Module not found with name: " + name); // Get the policy for the module if (iDependOnModule instanceof ClassLoaderPolicyModule == false) throw new IllegalStateException("Unable to determine ClassLoaderPolicy from module: " + iDependOnModule); ClassLoaderPolicyModule classLoaderPolicyModule = (ClassLoaderPolicyModule) iDependOnModule; return classLoaderPolicyModule.getPolicy(); } } ././@LongLink0000000000000000000000000000016500000000000011567 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloading/src/main/java/org/jboss/classloading/spi/dependency/Domain.javalibjboss-classloader-java-2.0.6.GA.orig/classloading/src/main/java/org/jboss/classloading/spi/depend0000644000175000017500000002006011173151646033353 0ustar twernertwerner/* * JBoss, Home of Professional Open Source. * Copyright 2007, Red Hat Middleware LLC, and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.classloading.spi.dependency; import java.util.List; import java.util.Map; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.CopyOnWriteArrayList; import org.jboss.classloading.spi.metadata.Capability; import org.jboss.classloading.spi.metadata.Requirement; import org.jboss.logging.Logger; /** * Domain. * * @author Adrian Brock * @author Ales Justin * @version $Revision: 1.1 $ */ public class Domain { /** The log */ private static final Logger log = Logger.getLogger(Domain.class); /** The domain name */ private String name; /** The classloading */ private ClassLoading classLoading; /** The parent domain name */ private String parentDomainName; /** Whether we are parent first */ private boolean parentFirst; /** The registered modules in registration order */ private List modules = new CopyOnWriteArrayList(); /** The registered modules by name */ private Map modulesByName = new ConcurrentHashMap(); /** * Create a new Domain. * * @param classLoading the classloading * @param name the name * @param parentDomainName the parent domain name * @param parentFirst whether to check the parent first * @throws IllegalArgumentException for a null domain or classloading */ public Domain(ClassLoading classLoading, String name, String parentDomainName, boolean parentFirst) { if (name == null) throw new IllegalArgumentException("Null name"); if (classLoading == null) throw new IllegalArgumentException("Null classLoading"); this.classLoading = classLoading; this.name = name; this.parentDomainName = parentDomainName; this.parentFirst = parentFirst; } /** * Get the name. * * @return the name. */ public String getName() { return name; } /** * Get the parentDomainName. * * @return the parentDomainName. */ public String getParentDomainName() { return parentDomainName; } public Domain getParentDomain() { if (parentDomainName != null) return classLoading.getDomain(parentDomainName); return null; } /** * Get the parentFirst. * * @return the parentFirst. */ public boolean isParentFirst() { return parentFirst; } /** * Add a module * * @param module the module * @throws IllegalStateException if the module is already registered * @throws IllegalArgumentException for a null parameter */ public synchronized void addModule(Module module) { if (module == null) throw new IllegalArgumentException("Null module"); Domain domain = module.getDomain(); if (domain != null) throw new IllegalArgumentException("The module is already registered with the domain " + domain.getName()); String contextName = module.getContextName(); if (modulesByName.containsKey(contextName)) throw new IllegalArgumentException("The context " + contextName + " is already registered in domain " + getName()); log.debug(this + " add module " + module); module.setDomain(this); modulesByName.put(contextName, module); modules.add(module); try { module.createDependencies(); // Skip the classloader space checking when it is import all if (module.isImportAll() == false) { ClassLoadingSpace space = new ClassLoadingSpace(); space.join(module); } } catch (Throwable t) { removeModule(module); if (t instanceof RuntimeException) throw (RuntimeException) t; else if (t instanceof Error) throw (Error) t; else throw new RuntimeException("Error adding module " + module, t); } } /** * Remove a deployment * * @param module the module * @throws IllegalArgumentException for a null parameter */ protected synchronized void removeModule(Module module) { if (module == null) throw new IllegalArgumentException("Null module"); log.debug(this + " remove module " + module); ClassLoadingSpace space = module.getClassLoadingSpace(); if (space != null) space.split(module); module.removeDependencies(); modules.remove(module); modulesByName.remove(module.getContextName()); module.setDomain(null); } /** * Get a module for a context name * * @param name the context name * @return the module */ public Module getModule(String name) { if (name == null) throw new IllegalArgumentException("Null module name"); Module module = modulesByName.get(name); if (module != null) return module; Domain parent = getParentDomain(); if (parent != null) return parent.getModule(name); return null; } /** * Merges the capabilities provided by our global capabilities provider with the passed in capabilities. * * @param capabilities the capabilities list into which we want to add the global capabilities * @return the passed in capabilities with the global capabilities merged in */ List mergeGlobalCapabilities(List capabilities) { return classLoading.mergeGlobalCapabilities(capabilities); } /** * Resolve a requirement to a module * * @param module the module * @param requirement the requirement * @return the resolved name or null if not resolved */ protected Module resolveModule(Module module, Requirement requirement) { // First check the parent domain has been setup Domain parentDomain = null; if (parentDomainName != null) { parentDomain = getParentDomain(); if (parentDomain == null) return null; } // Check the parent first when required if (parentDomain != null && parentFirst == true) { Module result = parentDomain.resolveModule(module, requirement); if (result != null) return result; } // TODO JBCL-24 check for self-dependency/circularity for (Module other : modules) { List capabilities = other.getCapabilities(); if (capabilities != null) { for (Capability capability : capabilities) { if (capability.resolves(module, requirement)) return other; } } } // Check the parent afterwards when required if (parentDomain != null && parentFirst == false) return parentDomain.resolveModule(module, requirement); return null; } @Override public String toString() { StringBuilder builder = new StringBuilder(); builder.append(super.toString()); builder.append('{').append(getName()).append('}'); return builder.toString(); } } ././@LongLink0000000000000000000000000000017500000000000011570 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloading/src/main/java/org/jboss/classloading/spi/dependency/ModuleRegistry.javalibjboss-classloader-java-2.0.6.GA.orig/classloading/src/main/java/org/jboss/classloading/spi/depend0000644000175000017500000000271111173151646033356 0ustar twernertwerner/* * JBoss, Home of Professional Open Source. * Copyright 2008, Red Hat Middleware LLC, and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.classloading.spi.dependency; /** * Track Module instances. * * @author Ales Justin */ public interface ModuleRegistry { /** * Add the module. * * @param module the module */ void addModule(Module module); /** * Remove module. * * @param module the module */ void removeModule(Module module); } ././@LongLink0000000000000000000000000000017300000000000011566 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloading/src/main/java/org/jboss/classloading/spi/dependency/ClassLoading.javalibjboss-classloader-java-2.0.6.GA.orig/classloading/src/main/java/org/jboss/classloading/spi/depend0000644000175000017500000002170311173151646033360 0ustar twernertwerner/* * JBoss, Home of Professional Open Source. * Copyright 2007, Red Hat Middleware LLC, and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.classloading.spi.dependency; import java.util.HashSet; import java.util.List; import java.util.Map; import java.util.Set; import java.util.concurrent.ConcurrentHashMap; import org.jboss.classloader.spi.ClassLoaderSystem; import org.jboss.classloading.spi.metadata.Capability; import org.jboss.logging.Logger; import org.jboss.util.collection.ConcurrentSet; /** * ClassLoading. * * @author Adrian Brock * @author Ales Justin * @version $Revision: 1.1 $ */ public class ClassLoading { /** The log */ private static final Logger log = Logger.getLogger(ClassLoading.class); /** An empty default domain */ private Domain EMPTY_DOMAIN = new Domain(this, ClassLoaderSystem.DEFAULT_DOMAIN_NAME, null, true); /** The classloading domains by name */ private final Map domains = new ConcurrentHashMap(); /** The global capabilities provider */ private final Set globalCapabilitiesProviders = new ConcurrentSet(); /** The module registries */ private final Set moduleRegistries = new ConcurrentSet(); /** * Add a module * * @param module the module * @throws IllegalArgumentException for a null module */ public void addModule(Module module) { if (module == null) throw new IllegalArgumentException("Null module"); String domainName = module.getDeterminedDomainName(); boolean parentFirst = module.isJ2seClassLoadingCompliance(); String parentDomainName = module.getDeterminedParentDomainName(); Domain domain = getDomain(domainName, parentDomainName, parentFirst); domain.addModule(module); Set added = new HashSet(); try { for (ModuleRegistry mr : moduleRegistries) { mr.addModule(module); added.add(mr); } } catch (Exception e) { for (ModuleRegistry mr : added) { try { mr.removeModule(module); } catch (Exception ignored) { } } module.release(); throw new IllegalArgumentException("Exception while registering Module.", e); } } /** * Remove a module * * @param module the module * @throws IllegalArgumentException for a null module */ public void removeModule(Module module) { if (module == null) throw new IllegalArgumentException("Null module"); for (ModuleRegistry mr : moduleRegistries) { try { mr.removeModule(module); } catch (Exception e) { log.warn("Exception unregistering module, registry: " + mr + ", cause: " + e); } } module.release(); } /** * Add a global capabilities provider * @param provider the provider * @throws IllegalArgumentException for a null provider */ public void addGlobalCapabilitiesProvider(GlobalCapabilitiesProvider provider) { if (provider == null) throw new IllegalArgumentException("Null global capabilities provider"); globalCapabilitiesProviders.add(provider); } /** * Remove a global capabilities provider * @param provider the provider * @throws IllegalArgumentException for a null provider */ public void removeGlobalCapabilitiesProvider(GlobalCapabilitiesProvider provider) { if (provider == null) throw new IllegalArgumentException("Null global capabilities provider"); globalCapabilitiesProviders.remove(provider); } /** * Get or create the domain * * @param domainName the domain name * @param parentDomainName the parent domain name * @param parentFirst whether to look in the parent first * @return the domain * @throws IllegalArgumentException for a null domain */ protected Domain getDomain(String domainName, String parentDomainName, boolean parentFirst) { Domain domain; synchronized (domains) { domain = getDomain(domainName); if (domain == null) { domain = createDomain(domainName, parentDomainName, parentFirst); domains.put(domainName, domain); } } return domain; } /** * Get a domain * * @param domainName the domain name * @return the domain or null if it doesn't exist */ protected Domain getDomain(String domainName) { if (domainName == null) throw new IllegalArgumentException("Null domain name"); Domain domain = domains.get(domainName); // This is hack, but it is a situation that probably only occurs in the tests // i.e. there are no classloaders in the default domain so it doesn't exist if (domain == null && ClassLoaderSystem.DEFAULT_DOMAIN_NAME.equals(domainName)) domain = EMPTY_DOMAIN; return domain; } /** * Create a domain * * @param domainName the domain name * @param parentDomainName the parent domain name * @param parentFirst whether to look in the parent first * @return the domain * @throws IllegalArgumentException for a null domain name */ protected Domain createDomain(String domainName, String parentDomainName, boolean parentFirst) { if (domainName == null) throw new IllegalArgumentException("Null domain name"); return new Domain(this, domainName, parentDomainName, parentFirst); } /** * Find the module for a classloader * * @param loader the classloader * @return the module or null if the classloader does not correspond to a registered module classloader * @throws SecurityException if the caller doesn't have new RuntimePermision("getClassLoader") */ public static Module getModuleForClassLoader(ClassLoader loader) { return Module.getModuleForClassLoader(loader); } /** * Find the classloader for a module * * @param module the module * @return the classloader or null if the module does not correspond to a registered classloader module * @throws SecurityException if the caller doesn't have new RuntimePermision("getClassLoader") */ public static ClassLoader getClassLoaderForModule(Module module) { SecurityManager sm = System.getSecurityManager(); if (sm != null) sm.checkPermission(new RuntimePermission("getClassLoader")); if (module == null) return null; return module.getClassLoader(); } /** * Merges the capabilities provided by our global capabilities provider with the passed in capabilities. * * @param capabilities the capabilities list into which we want to add the global capabilities * @return the passed in capabilities with the global capabilities merged in */ List mergeGlobalCapabilities(List capabilities) { if (capabilities == null) throw new IllegalArgumentException("Null capabilities"); if (globalCapabilitiesProviders != null && globalCapabilitiesProviders.size() > 0) { for (GlobalCapabilitiesProvider provider : globalCapabilitiesProviders) { capabilities.addAll(provider.getCapabilities()); } } return capabilities; } /** * Add module registry. * * @param moduleRegistry the module registry * @return see Set#add */ public boolean addModuleRegistry(ModuleRegistry moduleRegistry) { return moduleRegistries.add(moduleRegistry); } /** * Remove module registry. * * @param moduleRegistry the module registry * @return see Set#remove */ public boolean removeModuleRegistry(ModuleRegistry moduleRegistry) { return moduleRegistries.remove(moduleRegistry); } } ././@LongLink0000000000000000000000000000020000000000000011555 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloading/src/main/java/org/jboss/classloading/spi/dependency/ClassLoadingSpace.javalibjboss-classloader-java-2.0.6.GA.orig/classloading/src/main/java/org/jboss/classloading/spi/depend0000644000175000017500000002632111137575176033371 0ustar twernertwerner/* * JBoss, Home of Professional Open Source * Copyright 2007, JBoss Inc., and individual contributors as indicated * by the @authors tag. See the copyright.txt in the distribution for a * full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.classloading.spi.dependency; import java.util.Collections; import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.Set; import java.util.Map.Entry; import java.util.concurrent.ConcurrentHashMap; import org.jboss.classloading.spi.metadata.Requirement; import org.jboss.logging.Logger; /** * ClassLoadingSpace. This class does two stage join/resolve

* * join - work out a module's capabilities/requirements and validate they are not inconsistent with what is already there * resolve - resolve new requirements and potentially join with other spaces * unjoin - remove a module from the space * unresolve - work out the new state after a module splits * * TODO JBCL-25 handle split packages * @author Adrian Brock * @version $Revision: 1.1 $ */ public class ClassLoadingSpace { /** The log */ private static final Logger log = Logger.getLogger(ClassLoadingSpace.class); /** Whether trace is enabled */ private static boolean trace = log.isTraceEnabled(); /** The modules */ private Map modules = new ConcurrentHashMap(); /** The modules by package */ private Map modulesByPackage = new ConcurrentHashMap(); /** The requirements for all modules */ private Map> requirements = new ConcurrentHashMap>(); /** * Get an unmodifiable set of the collections * * @return the modules */ public Set getModules() { return Collections.unmodifiableSet(modules.keySet()); } /** * Join and resolve a module * * @param module the module to add * @throws IllegalArgumentException for a null module */ synchronized void joinAndResolve(Module module) { if (module == null) throw new IllegalArgumentException("Null module"); trace = log.isTraceEnabled(); join(module); try { resolve(module); } catch (Throwable t) { split(module); if (t instanceof RuntimeException) throw (RuntimeException) t; if (t instanceof Error) throw (Error) t; throw new RuntimeException(modules + " could not join " + this, t); } } /** * Join with a set of modules * * @param modules the modules * @throws IllegalArgumentException for null modules */ synchronized void joinAndResolve(Set modules) { if (modules == null) throw new IllegalArgumentException("Null modules"); Map previous = new HashMap(); try { for (Module module : modules) { ClassLoadingSpace space = module.getClassLoadingSpace(); join(module); previous.put(module, space); resolve(module); } } catch (Throwable t) { // Revert the previous joins for (Entry entry : previous.entrySet()) { Module module = entry.getKey(); ClassLoadingSpace space = entry.getValue(); split(module); try { space.join(module); } catch (Throwable t2) { log.error(module + " could not join " + space, t); throw new RuntimeException("BUG: " + module + " could not rejoin " + space + " after failing to join " + this, t2); } } if (t instanceof RuntimeException) throw (RuntimeException) t; if (t instanceof Error) throw (Error) t; throw new RuntimeException(modules + " could not join " + this, t); } } /** * Join with a classloading space * * @param space the classloading space * @throws IllegalArgumentException for null space */ void joinAndResolve(ClassLoadingSpace space) { if (space == null) throw new IllegalArgumentException("Null space"); if (space == this) return; int ourSize = getModules().size(); int otherSize = space.getModules().size(); if (ourSize >= otherSize) joinAndResolve(space.getModules()); else space.joinAndResolve(getModules()); } /** * Split with a module * * @param module the module to remove * @throws IllegalArgumentException for a null module * @throws IllegalStateException if the module is not associated with this classloading space */ synchronized void split(Module module) { if (module == null) throw new IllegalArgumentException("Null module"); ClassLoadingSpace other = module.getClassLoadingSpace(); if (other != this) throw new IllegalStateException(module + " has the wrong classloading space: expected=" + this + " was " + other); unjoin(module); unresolve(module); } /** * Join with a module * * @param module the module to add * @throws IllegalArgumentException for a null module */ synchronized void join(Module module) { if (module == null) throw new IllegalArgumentException("Null module"); // Nothing to do ClassLoadingSpace other = module.getClassLoadingSpace(); if (other == this) return; if (trace) log.trace(module + " joining " + this); // The packages exported by this module (excluding optional packages) List exportedPackages = module.determinePackageNames(false); // Check there are no conflicting packages if (exportedPackages != null && exportedPackages.isEmpty() == false) { for (String exportedPackage : exportedPackages) { Module otherModule = modulesByPackage.get(exportedPackage); // TODO JBCL-22 ERRORS if (otherModule != null) throw new IllegalStateException(module + " cannot be added because it is exports package " + exportedPackage + " which conflicts with " + otherModule); } } // Check our requirements are consistent with the other requirements List moduleDependencies = module.getDependencies(); if (requirements.isEmpty() == false) { if (moduleDependencies != null && moduleDependencies.isEmpty() == false) { for (RequirementDependencyItem dependency : moduleDependencies) { Requirement requirement = dependency.getRequirement(); for (Entry> entry : requirements.entrySet()) { Module otherModule = entry.getKey(); List dependencies = entry.getValue(); for (RequirementDependencyItem otherDependency : dependencies) { Requirement otherRequirement = otherDependency.getRequirement(); // TODO JBCL-22 ERRORS if (requirement.isConsistent(otherRequirement) == false) throw new IllegalStateException(module + " has a requirement " + requirement + " which is inconsistent with " + otherRequirement + " from " + otherModule); } } } } } // Update the exported packages if (exportedPackages != null && exportedPackages.isEmpty() == false) { for (String exportedPackage : exportedPackages) modulesByPackage.put(exportedPackage, module); } // Remember the module requirements if (moduleDependencies != null && moduleDependencies.isEmpty() == false) requirements.put(module, moduleDependencies); // Remove from any previous space if (other != null) other.split(module); // This module is now part of our space modules.put(module, module); module.setClassLoadingSpace(this); } /** * Unjoin a module * * @param module the module to remove */ private void unjoin(Module module) { if (trace) log.trace(module + " unjoining " + this); // Remove the exported packages for this module List packageNames = module.determinePackageNames(false); if (packageNames != null) { for (String packageName : packageNames) { Module removed = modulesByPackage.remove(packageName); if (removed != module) throw new IllegalStateException("BUG: Removed module " + removed + " for package " + packageName + " is not the expected module: " + module); } } // Remove the module requirements from the classloading space requirements.remove(module); // No longer part of this classloading space modules.remove(module); module.setClassLoadingSpace(null); } /** * Resolve a module * * @param module the module to resolve */ synchronized void resolve(Module module) { if (trace) log.trace(module + " resolving " + this); List moduleDependencies = requirements.get(module); if (moduleDependencies != null) { for (RequirementDependencyItem dependency : moduleDependencies) { if (dependency.isResolved() == false) { Module otherModule = module.resolveModule(dependency, false); if (otherModule != null) { // Do we need to join with another classloading space? ClassLoadingSpace space = otherModule.getClassLoadingSpace(); if (space != null && space != this) { space.joinAndResolve(this); } } } } } } /** * Unresolve a module * * @param module the module to resolve */ private void unresolve(Module module) { if (trace) log.trace(module + " unresolving " + this); // Nothing yet. Could try to split classloading spaces if they now have disjoint subsets? } } ././@LongLink0000000000000000000000000000021000000000000011556 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloading/src/main/java/org/jboss/classloading/spi/dependency/RequirementDependencyItem.javalibjboss-classloader-java-2.0.6.GA.orig/classloading/src/main/java/org/jboss/classloading/spi/depend0000644000175000017500000001042411116241707033351 0ustar twernertwerner/* * JBoss, Home of Professional Open Source * Copyright 2006, JBoss Inc., and individual contributors as indicated * by the @authors tag. See the copyright.txt in the distribution for a * full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.classloading.spi.dependency; import org.jboss.classloading.spi.metadata.Requirement; import org.jboss.dependency.plugins.AbstractDependencyItem; import org.jboss.dependency.spi.Controller; import org.jboss.dependency.spi.ControllerContext; import org.jboss.dependency.spi.ControllerState; import org.jboss.logging.Logger; import org.jboss.util.JBossStringBuilder; /** * RequirementDependencyItem. * * @author Adrian Brock * @version $Revision: 1.1 $ */ public class RequirementDependencyItem extends AbstractDependencyItem { /** The log */ private static final Logger log = Logger.getLogger(RequirementDependencyItem.class); /** The module */ private Module module; /** The requirement */ private Requirement requirement; /** * Create a new RequirementDependencyItem. * * @param module the module * @param requirement the requirement * @param state when the dependency is required and the state of the required dependency * @throws IllegalArgumentException for a null parameter */ public RequirementDependencyItem(Module module, Requirement requirement, ControllerState state) { super(module != null ? module.getContextName() : null, null, state, ControllerState.INSTALLED); if (module == null) throw new IllegalArgumentException("Null module"); if (requirement == null) throw new IllegalArgumentException("Null requirement"); this.module = module; this.requirement = requirement; } /** * Get the module. * * @return the module. */ public Module getModule() { return module; } /** * Get the requirement. * * @return the requirement. */ public Requirement getRequirement() { return requirement; } public boolean resolve(Controller controller) { Requirement requirement = getRequirement(); Module module = getModule().resolveModule(this, true); if (module != null) { Object iDependOn = module.getContextName(); ControllerContext context = controller.getContext(iDependOn, getDependentState()); if (context != null) { setIDependOn(context.getName()); addDependsOnMe(controller, context); setResolved(true); if (module.getClassLoadingSpace() == null) log.warn(getModule() + " resolved " + getRequirement() + " to " + module + " which has import-all=true. Cannot check its consistency."); } else { setResolved(false); } } else { // Optional requirement if (requirement.isOptional() || requirement.isDynamic()) setResolved(true); } return isResolved(); } @Override public boolean unresolved(Controller controller) { setIDependOn(null); setResolved(false); return true; } public void toString(JBossStringBuilder buffer) { super.toString(buffer); buffer.append(" requirement=").append(getRequirement()); } public void toShortString(JBossStringBuilder buffer) { buffer.append(getName()).append(" ").append(getRequirement()); } public String toHumanReadableString() { return getRequirement().toString(); } } ././@LongLink0000000000000000000000000000016200000000000011564 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloading/src/main/java/org/jboss/classloading/spi/dependency/helpers/libjboss-classloader-java-2.0.6.GA.orig/classloading/src/main/java/org/jboss/classloading/spi/depend0000755000175000017500000000000011620043421033337 5ustar twernertwerner././@LongLink0000000000000000000000000000022100000000000011560 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloading/src/main/java/org/jboss/classloading/spi/dependency/helpers/ClassLoadingMetaDataModule.javalibjboss-classloader-java-2.0.6.GA.orig/classloading/src/main/java/org/jboss/classloading/spi/depend0000644000175000017500000001124411035356200033345 0ustar twernertwerner/* * JBoss, Home of Professional Open Source * Copyright 2007, JBoss Inc., and individual contributors as indicated * by the @authors tag. See the copyright.txt in the distribution for a * full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.classloading.spi.dependency.helpers; import java.util.List; import org.jboss.classloader.spi.filter.ClassFilter; import org.jboss.classloading.spi.dependency.Module; import org.jboss.classloading.spi.metadata.Capability; import org.jboss.classloading.spi.metadata.ClassLoadingMetaData; import org.jboss.classloading.spi.metadata.ExportAll; import org.jboss.classloading.spi.metadata.Requirement; /** * ClassLoadingMetaDataModule. * * @author Adrian Brock * @version $Revision: 1.1 $ */ public abstract class ClassLoadingMetaDataModule extends Module { /** The serialVersionUID */ private static final long serialVersionUID = -1834649865956381804L; /** The classloading metadata */ private ClassLoadingMetaData classLoadingMetaData; /** * Determine the name from the classloading metadta * * @param classLoadingMetaData the classloading metadata * @return the name */ private static String determineName(ClassLoadingMetaData classLoadingMetaData) { if (classLoadingMetaData == null) throw new IllegalArgumentException("Null classLoading metadata"); return classLoadingMetaData.getName(); } /** * Determine the version from the classloading metadta * * @param classLoadingMetaData the classloading metadata * @return the version */ private static Object determineVersion(ClassLoadingMetaData classLoadingMetaData) { if (classLoadingMetaData == null) throw new IllegalArgumentException("Null classLoading metadata"); return classLoadingMetaData.getVersion(); } /** * Create a new ClassLoadingMetaDataModule. * * @param classLoadingMetaData the classLoading metadata * @param contextName the context name * @throws IllegalArgumentException for null classloading metadata */ public ClassLoadingMetaDataModule(ClassLoadingMetaData classLoadingMetaData, String contextName) { super(determineName(classLoadingMetaData), contextName, determineVersion(classLoadingMetaData)); this.classLoadingMetaData = classLoadingMetaData; } /** * Get the classloading metadata * * @return the metadata */ protected ClassLoadingMetaData getClassLoadingMetaData() { return classLoadingMetaData; } @Override public String getDomainName() { return classLoadingMetaData.getDomain(); } @Override public String getParentDomainName() { return classLoadingMetaData.getParentDomain(); } @Override public ExportAll getExportAll() { return classLoadingMetaData.getExportAll(); } @Override public ClassFilter getIncluded() { return classLoadingMetaData.getIncluded(); } @Override public ClassFilter getExcluded() { return classLoadingMetaData.getExcluded(); } @Override public ClassFilter getExcludedExport() { return classLoadingMetaData.getExcludedExport(); } @Override public boolean isImportAll() { return classLoadingMetaData.isImportAll(); } @Override public boolean isJ2seClassLoadingCompliance() { return classLoadingMetaData.isJ2seClassLoadingCompliance(); } @Override public boolean isCacheable() { return classLoadingMetaData.isCacheable(); } @Override public boolean isBlackListable() { return classLoadingMetaData.isBlackListable(); } @Override protected List determineCapabilities() { return classLoadingMetaData.getCapabilities().getCapabilities(); } @Override public List determineRequirements() { return classLoadingMetaData.getRequirements().getRequirements(); } } ././@LongLink0000000000000000000000000000021100000000000011557 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloading/src/main/java/org/jboss/classloading/spi/dependency/GlobalCapabilitiesProvider.javalibjboss-classloader-java-2.0.6.GA.orig/classloading/src/main/java/org/jboss/classloading/spi/depend0000644000175000017500000000276511173151646033367 0ustar twernertwerner/* * JBoss, Home of Professional Open Source. * Copyright 2006, Red Hat Middleware LLC, and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.classloading.spi.dependency; import java.util.List; import org.jboss.classloading.spi.metadata.Capability; /** * Used in ClassLoadings in/uncallback to obtain capabilities that should be * used for all loaders. * * @author Kabir Khan * @version $Revision: 1.1 $ */ public interface GlobalCapabilitiesProvider { /** * Gets the global capabilites * @return A list of the global capabilities */ List getCapabilities(); } ././@LongLink0000000000000000000000000000016500000000000011567 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloading/src/main/java/org/jboss/classloading/spi/dependency/Module.javalibjboss-classloader-java-2.0.6.GA.orig/classloading/src/main/java/org/jboss/classloading/spi/depend0000644000175000017500000006404211173151646033363 0ustar twernertwerner/* * JBoss, Home of Professional Open Source. * Copyright 2007, Red Hat Middleware LLC, and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.classloading.spi.dependency; import java.io.IOException; import java.net.URL; import java.security.AccessController; import java.security.PrivilegedAction; import java.util.ArrayList; import java.util.Collections; import java.util.Enumeration; import java.util.HashSet; import java.util.List; import java.util.Map; import java.util.Set; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.CopyOnWriteArrayList; import org.jboss.classloader.spi.ClassLoaderSystem; import org.jboss.classloader.spi.DelegateLoader; import org.jboss.classloader.spi.ParentPolicy; import org.jboss.classloader.spi.filter.ClassFilter; import org.jboss.classloading.spi.helpers.NameAndVersionSupport; import org.jboss.classloading.spi.metadata.Capability; import org.jboss.classloading.spi.metadata.ClassLoadingMetaDataFactory; import org.jboss.classloading.spi.metadata.ExportAll; import org.jboss.classloading.spi.metadata.ExportPackages; import org.jboss.classloading.spi.metadata.OptionalPackages; import org.jboss.classloading.spi.metadata.Requirement; import org.jboss.classloading.spi.visitor.ResourceFilter; import org.jboss.classloading.spi.visitor.ResourceVisitor; import org.jboss.dependency.spi.ControllerContext; import org.jboss.dependency.spi.ControllerState; /** * Module. * * @author Adrian Brock * @version $Revision: 1.1 $ */ public abstract class Module extends NameAndVersionSupport { /** The modules by classloader */ private static Map modulesByClassLoader = new ConcurrentHashMap(); /** The context name */ private String contextName; /** Our cached capabilities */ private List capabilities; /** Our cached requirements */ private List requirements; /** The controller context */ private ControllerContext context; /** The domain */ private Domain domain; /** The classloading space */ private ClassLoadingSpace space; /** The requirements */ private List requirementDependencies; /** * Register a classloader for a module * * @param module the module * @param classLoader the classloader * @throws IllegalArgumentException for a null parameter */ protected static void registerModuleClassLoader(Module module, ClassLoader classLoader) { if (module == null) throw new IllegalArgumentException("Null module"); if (classLoader == null) throw new IllegalArgumentException("Null classloader"); modulesByClassLoader.put(classLoader, module); } /** * Register a classloader for a module * * @param module the module * @param classLoader the classloader * @throws IllegalArgumentException for a null parameter */ protected static void unregisterModuleClassLoader(Module module, ClassLoader classLoader) { if (module == null) throw new IllegalArgumentException("Null module"); if (classLoader == null) throw new IllegalArgumentException("Null classloader"); modulesByClassLoader.remove(classLoader); } /** * Create a new Module with the default version * * @param name the name * @throws IllegalArgumentException for a null parameter */ public Module(String name) { this(name, name, null); } /** * Create a new Module with the given version * * @param name the name * @param version pass null for the default version * @throws IllegalArgumentException for a null parameter */ public Module(String name, Object version) { this(name, name, version); } /** * Create a new Module with the given version * * @param name the name * @param contextName the real name of the module in the controller * @param version pass null for the default version * @throws IllegalArgumentException for a null parameter */ public Module(String name, String contextName, Object version) { super(name, version); if (contextName == null) contextName = name + version.toString(); this.contextName = contextName; } /** * Get the context name * * @return the context name */ public String getContextName() { return contextName; } /** * Get the domain. * * @return the domain. */ Domain getDomain() { return domain; } void setDomain(Domain domain) { this.domain = domain; } Domain checkDomain() { Domain result = domain; if (result == null) throw new IllegalStateException("Domain is not set for " + this); return result; } /** * Whether this is a valid module * * @return true when valid */ public boolean isValid() { return domain != null; } /** * Get the domain name. * * @return the domain name. */ public String getDomainName() { return null; } /** * Get the determined domain name. * * @return the determined domain. */ public String getDeterminedDomainName() { String domainName = getDomainName(); if (domainName == null) domainName = ClassLoaderSystem.DEFAULT_DOMAIN_NAME; return domainName; } /** * Get the parent domain name. * * @return the parent domain name. */ public String getParentDomainName() { return null; } /** * Get the determined parentDomain name. * * @return the parentDomain. */ public String getDeterminedParentDomainName() { String parentDomain = getParentDomainName(); if (parentDomain == null) { if (ClassLoaderSystem.DEFAULT_DOMAIN_NAME.equals(getDeterminedDomainName()) == false) return ClassLoaderSystem.DEFAULT_DOMAIN_NAME; } return parentDomain; } /** * Get the classloading space. * * @return the space. */ ClassLoadingSpace getClassLoadingSpace() { return space; } /** * Set the classloading space. * * @param space the space. */ void setClassLoadingSpace(ClassLoadingSpace space) { this.space = space; } /** * Get the export all for the module * * @return the export all */ public ExportAll getExportAll() { return null; } /** * Get a filter for the included packages * * @return the excluded packages */ public ClassFilter getIncluded() { return null; } /** * Get a filter for the excluded packages * * @return the excluded packages */ public ClassFilter getExcluded() { return null; } /** * Get a filter for the excluded export packages * * @return the excluded packages */ public ClassFilter getExcludedExport() { return null; } /** * Get the import all for the module * * @return the import all */ public boolean isImportAll() { return false; } /** * Get delegate policy * * @return the delegation policy */ public boolean isJ2seClassLoadingCompliance() { return true; } public ParentPolicy getDeterminedParentPolicy() { if (isJ2seClassLoadingCompliance()) return ParentPolicy.BEFORE; else return ParentPolicy.AFTER_BUT_ONLY_JAVA_BEFORE; } /** * Whether to cache

* * @return true to cache */ protected boolean isCacheable() { return true; } /** * Whether to cache misses

* * @return true to cache misses */ protected boolean isBlackListable() { return true; } /** * Find the module for a classloader * * @param cl the classloader * @return the module or null if the classloader does not correspond to a registered module classloader * @throws SecurityException if the caller doesn't have new RuntimePermision("getClassLoader") */ static Module getModuleForClassLoader(ClassLoader cl) { SecurityManager sm = System.getSecurityManager(); if (sm != null) sm.checkPermission(new RuntimePermission("getClassLoader")); // Determine the module (if any) for the classloader if (cl != null) return modulesByClassLoader.get(cl); // Unknown return null; } /** * Find the module that loads a class * * @param className the class name * @return the module or null if the class is not loaded by a registered module classloader * @throws ClassNotFoundException when the class is not found * @throws IllegalStateException when the module is not associated with a classloader */ public Module getModuleForClass(String className) throws ClassNotFoundException { SecurityManager sm = System.getSecurityManager(); if (sm != null) sm.checkPermission(new RuntimePermission("getClassLoader")); ClassLoader cl = getClassLoaderForClass(className); // Determine the module (if any) for the classloader if (cl != null) return modulesByClassLoader.get(cl); // Unknown return null; } /** * Get the classloader for a class name * * @param className the class name * @return the class * @throws ClassNotFoundException when the class is not found * @throws IllegalStateException when the module is not associated with a classloader */ protected ClassLoader getClassLoaderForClass(String className) throws ClassNotFoundException { // Determine the classloader for this class final Class clazz = loadClass(className); SecurityManager sm = System.getSecurityManager(); if (sm != null) { return AccessController.doPrivileged(new PrivilegedAction() { public ClassLoader run() { return clazz.getClassLoader(); } }); } return clazz.getClassLoader(); } /** * Load a class for this module * * @param className the class name * @return the class * @throws ClassNotFoundException when the class is not found * @throws IllegalStateException when the module is not associated with a classloader */ public Class loadClass(String className) throws ClassNotFoundException { ClassLoader classLoader = getClassLoader(); if (classLoader == null) throw new IllegalStateException("No classloader for this module " + this); return classLoader.loadClass(className); } /** * Get a resource for this module * * @param resourceName the resource name * @return the class * @throws IllegalStateException when the module is not associated with a classloader */ public URL getResource(String resourceName) { ClassLoader classLoader = getClassLoader(); if (classLoader == null) throw new IllegalStateException("No classloader for this module " + this); return classLoader.getResource(resourceName); } /** * Get resources for this module * * @param resourceName the resource name * @return the class * @throws IOException for an error * @throws IllegalStateException when the module is not associated with a classloader */ public Enumeration getResources(String resourceName) throws IOException { ClassLoader classLoader = getClassLoader(); if (classLoader == null) throw new IllegalStateException("No classloader for this module " + this); return classLoader.getResources(resourceName); } /** * Get the classloader for this module * * @return the classloader */ protected ClassLoader getClassLoader() { return null; } /** * Visit the resources in this module * using the filter defined on the visitor * * @param visitor the visitor */ public void visit(ResourceVisitor visitor) { if (visitor == null) throw new IllegalArgumentException("Null visitor"); visit(visitor, visitor.getFilter()); } /** * Visit the resources in this module * using the given filter * * @param visitor the visitor * @param filter the filter */ public void visit(ResourceVisitor visitor, ResourceFilter filter) { visit(visitor, filter, null); } /** * Visit the resources in this module using the given filter(s) *

* Typically the filter is used to determine which types of files to visit, e.g. .class files. * While the recurseFilter determines which jars/directories to recurse into. * * @param visitor the visitor * @param filter the filter * @param recurseFilter the recursion filter (null means recurse into everything) * @param urls the urls we should visit */ public void visit(ResourceVisitor visitor, ResourceFilter filter, ResourceFilter recurseFilter, URL... urls) { throw new UnsupportedOperationException("The module " + getContextName() + " does not support filtering: " + getClass().getName()); } /** * Get the delegate loaders for this module * * @return the delegates */ public List getDelegates() { if (requirementDependencies == null || requirementDependencies.isEmpty()) return null; List result = new CopyOnWriteArrayList(); List dynamic = new CopyOnWriteArrayList(); Set visited = new HashSet(); addDelegates(this, result, dynamic, visited, false); // Make sure the dynamic delegates are last result.addAll(dynamic); return result; } /** * Get the dependency items * * @return the depenency items */ protected List getRequirementDependencyItems() { return requirementDependencies; } /** * Add delegates * * @param module the module to add delegates from * @param delegates the current list of delegates * @param dynamic the dynamic delegates * @param visited the visited modules * @param reExport whether to only add re-exports */ protected void addDelegates(Module module, List delegates, List dynamic, Set visited, boolean reExport) { // Check whether we already did this module if (visited.contains(module)) return; visited.add(module); List dependencies = module.getRequirementDependencyItems(); if (dependencies == null || dependencies.isEmpty()) return; for (RequirementDependencyItem item : dependencies) { Requirement requirement = item.getRequirement(); // If we are looking at everything or this is a re-export if (reExport == false || requirement.isReExport()) { // Sanity checks if (item.isResolved() == false) throw new IllegalStateException("Item not resolved: " + item); // Dynamic requirement, create it lazily if (requirement.isDynamic()) { DelegateLoader delegate = createLazyDelegateLoader(checkDomain(), item); dynamic.add(delegate); continue; } String name = (String) item.getIDependOn(); if (name == null) { // Optional requirement, just ignore if (requirement.isOptional()) continue; // Something has gone wrong throw new IllegalStateException("No iDependOn for item: " + item); } Module iDependOnModule = checkDomain().getModule(name); if (iDependOnModule == null) throw new IllegalStateException("Module not found with name: " + name); // Determine the delegate loader for the module Module other = item.getModule(); DelegateLoader delegate = iDependOnModule.getDelegateLoader(other, requirement); // Check for re-export by the module if (requirement.wantReExports()) addDelegates(iDependOnModule, delegates, dynamic, visited, true); // We want a module's re-exports (i.e. part of its imports) before the module itself if (delegate != null) delegates.add(delegate); } } } /** * Create a lazy delegate loader * * @param domain the domain * @param item the dependency item * @return the delegate loader */ public abstract DelegateLoader createLazyDelegateLoader(Domain domain, RequirementDependencyItem item); /** * Get the delegate loader * * @param requiringModule the requiring module * @param requirement the requirement * @return the delegate loader */ public abstract DelegateLoader getDelegateLoader(Module requiringModule, Requirement requirement); /** * Get the capabilities. * * @return the capabilities. */ public List getCapabilities() { // Have we already worked this out? if (capabilities != null) return capabilities; // Are there any configured ones? List capabilities = determineCapabilities(); // Use the defaults if (capabilities == null) capabilities = defaultCapabilities(); //Add global capabilities capabilities = checkDomain().mergeGlobalCapabilities(capabilities); // Cache it this.capabilities = capabilities; return capabilities; } /** * Determine the capabilities * * @return the capabilities */ protected List determineCapabilities() { return null; } /** * Determine the default capabilities.

* * By default it is just the module capability * * @return the capabilities */ protected List defaultCapabilities() { List capabilities = new CopyOnWriteArrayList(); ClassLoadingMetaDataFactory factory = ClassLoadingMetaDataFactory.getInstance(); Capability capability = factory.createModule(getName(), getVersion()); capabilities.add(capability); return capabilities; } /** * Get the package names * * @return the package names */ public String[] getPackageNames() { List packageNames = determinePackageNames(true); return packageNames.toArray(new String[packageNames.size()]); } /** * Determine the package names * * TODO JBCL-23 Better handling of conflicts for optional packages * @param optional whether to include optional packages * @return the package names */ public List determinePackageNames(boolean optional) { List packageNames = Collections.emptyList(); List capabilities = getCapabilities(); if (capabilities != null && capabilities.isEmpty() == false) { for (Capability capability : capabilities) { if (capability instanceof ExportPackages) { ExportPackages exported = (ExportPackages) capability; Set exportPackages = exported.getPackageNames(this); if (exportPackages != null) { if (packageNames.isEmpty()) packageNames = new ArrayList(); packageNames.addAll(exportPackages); } } } } List requirements = getRequirements(); if (requirements != null && requirements.isEmpty() == false) { for (Requirement requirement : getRequirements()) { if (requirement instanceof ExportPackages) { ExportPackages exported = (ExportPackages) requirement; Set exportPackages = exported.getPackageNames(this); if (optional || requirement.isOptional() == false) { if (exportPackages != null && exportPackages.isEmpty() == false) { if (packageNames.isEmpty()) packageNames = new ArrayList(); packageNames.addAll(exportPackages); } } } else if (optional == false && requirement instanceof OptionalPackages) { OptionalPackages exported = (OptionalPackages) requirement; Set optionalPackages = exported.getOptionalPackageNames(this); if (optionalPackages != null && packageNames.isEmpty() == false) packageNames.removeAll(optionalPackages); } } } return packageNames; } /** * Get the state for the classloader * * @return the state */ public ControllerState getClassLoaderState() { return ControllerState.INSTALLED; } /** * Get the requirements. * * @return the requirements. */ public List getRequirements() { // Have we already worked this out? if (requirements != null) return requirements; // Are there any configured ones? List requirements = determineRequirements(); // Cache it this.requirements = requirements; return requirements; } /** * Determine the requirements. * * @return the requirements. */ public List determineRequirements() { return Collections.emptyList(); } /** * Return a URL where dynamic classes can be stored * * @return the url or null if there isn't one */ public URL getDynamicClassRoot() { return null; } List getDependencies() { return requirementDependencies; } /** * Create the dependencies for the module */ protected void createDependencies() { ControllerState classLoaderState = getClassLoaderState(); List requirements = getRequirements(); if (requirements != null) { requirementDependencies = new ArrayList(); for (Requirement requirement : requirements) { RequirementDependencyItem item = new RequirementDependencyItem(this, requirement, classLoaderState); addIDependOn(item); requirementDependencies.add(item); } } } /** * Remove dependencies */ protected void removeDependencies() { if (requirementDependencies != null && requirementDependencies.isEmpty() == false) { for (RequirementDependencyItem item : requirementDependencies) removeIDependOn(item); } requirementDependencies = null; } /** * Get the controller context. * * @return the controller context. */ protected ControllerContext getControllerContext() { return context; } /** * Set the controller context * * @param context the context */ protected void setControllerContext(ControllerContext context) { this.context = context; } /** * Add a dependency * * @param item the dependency item */ protected void addIDependOn(RequirementDependencyItem item) { if (context == null) throw new IllegalStateException("No controller context"); context.getDependencyInfo().addIDependOn(item); } /** * Remove a dependency * * @param item the dependency item */ protected void removeIDependOn(RequirementDependencyItem item) { if (context == null) throw new IllegalStateException("No controller context"); context.getDependencyInfo().removeIDependOn(item); } /** * Resolve a requirement * * @param dependency the dependency the dependency * @param resolveSpace whether to resolve the module in the classloading space * @return the resolved name or null if not resolved */ protected Module resolveModule(RequirementDependencyItem dependency, boolean resolveSpace) { ClassLoadingSpace space = getClassLoadingSpace(); if (resolveSpace && space != null) space.resolve(this); Requirement requirement = dependency.getRequirement(); return checkDomain().resolveModule(this, requirement); } /** * Release the module */ public void release() { Domain domain = this.domain; if (domain != null) domain.removeModule(this); reset(); } /** * Reset the module */ public void reset() { ClassLoader classLoader = getClassLoader(); if (classLoader != null) unregisterModuleClassLoader(this, classLoader); this.capabilities = null; this.requirements = null; } @Override public boolean equals(Object obj) { if (obj == this) return true; if (obj == null || obj instanceof Module == false) return false; return super.equals(obj); } } ././@LongLink0000000000000000000000000000014700000000000011567 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloading/src/main/java/org/jboss/classloading/spi/visitor/libjboss-classloader-java-2.0.6.GA.orig/classloading/src/main/java/org/jboss/classloading/spi/visito0000755000175000017500000000000011620043420033414 5ustar twernertwerner././@LongLink0000000000000000000000000000017300000000000011566 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloading/src/main/java/org/jboss/classloading/spi/visitor/ResourceContext.javalibjboss-classloader-java-2.0.6.GA.orig/classloading/src/main/java/org/jboss/classloading/spi/visito0000644000175000017500000000475111044556237033444 0ustar twernertwerner/* * JBoss, Home of Professional Open Source * Copyright 2007, JBoss Inc., and individual contributors as indicated * by the @authors tag. See the copyright.txt in the distribution for a * full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.classloading.spi.visitor; import java.io.IOException; import java.io.InputStream; import java.net.URL; /** * ResourceContext. * * @author Adrian Brock * @author Ales Justin */ public interface ResourceContext { /** * Get the url. * * @return the url. */ URL getUrl(); /** * Get the classLoader. * * @return the classLoader. */ ClassLoader getClassLoader(); /** * Get the resourceName. * * @return the resourceName. */ String getResourceName(); /** * Get the class name * * @return the class name or null if it is not a class */ String getClassName(); /** * Whether the resource is a class * * @return true when the resource name ends with .class */ boolean isClass(); /** * Load a class * * Do isClass check before, * unless you want to handle exception * when resource is not actually a class. * * @return the class from resource * @throws RuntimeException for any errors during class loading */ Class loadClass(); /** * Get the input stream for the resource * * @return the input stream * @throws IOException for any error */ InputStream getInputStream() throws IOException; /** * Get the bytes for the resource * * @return the byte array * @throws IOException for any error */ byte[] getBytes() throws IOException; } ././@LongLink0000000000000000000000000000017000000000000011563 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloading/src/main/java/org/jboss/classloading/spi/visitor/ClassVisitor.javalibjboss-classloader-java-2.0.6.GA.orig/classloading/src/main/java/org/jboss/classloading/spi/visito0000644000175000017500000000242411003641020033413 0ustar twernertwerner/* * JBoss, Home of Professional Open Source * Copyright 2007, JBoss Inc., and individual contributors as indicated * by the @authors tag. See the copyright.txt in the distribution for a * full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.classloading.spi.visitor; /** * ClassVisitor. * * @author Adrian Brock * @version $Revision: 1.1 $ */ public abstract class ClassVisitor implements ResourceVisitor { public ResourceFilter getFilter() { return ClassFilter.INSTANCE; } } ././@LongLink0000000000000000000000000000016700000000000011571 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloading/src/main/java/org/jboss/classloading/spi/visitor/ClassFilter.javalibjboss-classloader-java-2.0.6.GA.orig/classloading/src/main/java/org/jboss/classloading/spi/visito0000644000175000017500000000257711003641020033424 0ustar twernertwerner/* * JBoss, Home of Professional Open Source * Copyright 2007, JBoss Inc., and individual contributors as indicated * by the @authors tag. See the copyright.txt in the distribution for a * full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.classloading.spi.visitor; /** * ClassFilter. * * @author Adrian Brock * @version $Revision: 1.1 $ */ public class ClassFilter implements ResourceFilter { /** The class filter instance */ public static final ClassFilter INSTANCE = new ClassFilter(); public boolean accepts(ResourceContext resource) { return resource.isClass(); } } ././@LongLink0000000000000000000000000000017200000000000011565 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloading/src/main/java/org/jboss/classloading/spi/visitor/ResourceFilter.javalibjboss-classloader-java-2.0.6.GA.orig/classloading/src/main/java/org/jboss/classloading/spi/visito0000644000175000017500000000256311003641020033417 0ustar twernertwerner/* * JBoss, Home of Professional Open Source * Copyright 2007, JBoss Inc., and individual contributors as indicated * by the @authors tag. See the copyright.txt in the distribution for a * full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.classloading.spi.visitor; /** * ResourceFilter. * * @author Adrian Brock * @version $Revision: 1.1 $ */ public interface ResourceFilter { /** * Controls whether to visit a particular resource * * @param resource the resource context * @return true to visit the resource */ boolean accepts(ResourceContext resource); } ././@LongLink0000000000000000000000000000017300000000000011566 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloading/src/main/java/org/jboss/classloading/spi/visitor/ResourceVisitor.javalibjboss-classloader-java-2.0.6.GA.orig/classloading/src/main/java/org/jboss/classloading/spi/visito0000644000175000017500000000267511003641020033423 0ustar twernertwerner/* * JBoss, Home of Professional Open Source * Copyright 2007, JBoss Inc., and individual contributors as indicated * by the @authors tag. See the copyright.txt in the distribution for a * full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.classloading.spi.visitor; /** * ResourceVisitor. * * @author Adrian Brock * @version $Revision: 1.1 $ */ public interface ResourceVisitor { /** * Get the filter for this visitor * * @return the filter or null if no filtering */ ResourceFilter getFilter(); /** * Visit a resource * * @param resource the resource being visited */ void visit(ResourceContext resource); } ././@LongLink0000000000000000000000000000014700000000000011567 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloading/src/main/java/org/jboss/classloading/spi/helpers/libjboss-classloader-java-2.0.6.GA.orig/classloading/src/main/java/org/jboss/classloading/spi/helper0000755000175000017500000000000011620043420033356 5ustar twernertwerner././@LongLink0000000000000000000000000000020600000000000011563 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloading/src/main/java/org/jboss/classloading/spi/helpers/NameAndVersionRangeSupport.javalibjboss-classloader-java-2.0.6.GA.orig/classloading/src/main/java/org/jboss/classloading/spi/helper0000644000175000017500000001756110757515224033412 0ustar twernertwerner/* * JBoss, Home of Professional Open Source * Copyright 2008, JBoss Inc., and individual contributors as indicated * by the @authors tag. See the copyright.txt in the distribution for a * full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.classloading.spi.helpers; import java.io.Serializable; import javax.xml.bind.annotation.XmlAttribute; import javax.xml.bind.annotation.XmlTransient; import org.jboss.classloading.spi.version.Version; import org.jboss.classloading.spi.version.VersionRange; import org.jboss.metatype.api.annotations.CompositeKey; import org.jboss.metatype.api.annotations.CompositeValue; /** * NameAndVersionRangeSupport. * * @author Adrian Brock * @version $Revision: 1.1 $ */ public class NameAndVersionRangeSupport implements Serializable { /** The serialVersionUID */ private static final long serialVersionUID = 3318997559330427708L; /** The name */ private String name = ""; /** The version range */ private VersionRange versionRange = VersionRange.ALL_VERSIONS; /** * Create a new NameAndVersionRangeSupport */ public NameAndVersionRangeSupport() { } /** * Create a new NameAndVersionRangeSupport with no version constraint * * @param name the name * @throws IllegalArgumentException for a null name */ public NameAndVersionRangeSupport(String name) { this(name, null); } /** * Create a new NameAndVersionRangeSupport. * * @param name the name * @param versionRange the version range - pass null for all versions * @throws IllegalArgumentException for a null name */ public NameAndVersionRangeSupport(String name, VersionRange versionRange) { if (name == null) throw new IllegalArgumentException("Null name"); if (versionRange == null) versionRange = VersionRange.ALL_VERSIONS; this.name = name; this.versionRange = versionRange; } /** * Get the name. * * @return the name. */ public String getName() { return name; } /** * Set the name. * * @param name the name. */ @CompositeKey @XmlAttribute public void setName(String name) { if (name == null) throw new IllegalArgumentException("Null name"); this.name = name; } /** * Get the versionRange. * * @return the versionRange. */ public VersionRange getVersionRange() { return versionRange; } /** * Set the versionRange. * * @param versionRange the versionRange. */ @CompositeValue(ignore=true) @XmlTransient public void setVersionRange(VersionRange versionRange) { if (versionRange == null) versionRange = VersionRange.ALL_VERSIONS; this.versionRange = versionRange; } /** * Get the fromVersion. * * @return the fromVersion. */ public Object getFrom() { return versionRange.getLow(); } /** * Set the fromVersion. * * @param fromVersion the fromVersion. */ @CompositeValue(ignore=true) @XmlTransient public void setFrom(Object fromVersion) { versionRange = new VersionRange(fromVersion, versionRange.isLowInclusive(), versionRange.getHigh(), versionRange.isHighInclusive()); } /** * Get the fromVersion. * * @return the fromVersion. */ public Version getFromVersion() { Object from = getFrom(); if (from == null) return null; if (from instanceof Version) return (Version) from; if (from instanceof String) return Version.parseVersion((String) from); throw new IllegalStateException(from + " is not an instance of version"); } /** * Set the fromVersion. * * @param fromVersion the fromVersion. */ @CompositeKey @CompositeValue(name="from") @XmlAttribute(name="from") public void setFromVersion(Version fromVersion) { setFrom(fromVersion); } /** * Get the fromVersionInclusive. * * @return the fromVersionInclusive. */ public boolean isFromVersionInclusive() { return versionRange.isLowInclusive(); } /** * Set the fromVersionInclusive. * * @param fromVersionInclusive the fromVersionInclusive. */ @CompositeKey @XmlAttribute(name="from-inclusive") public void setFromVersionInclusive(boolean fromVersionInclusive) { versionRange = new VersionRange(versionRange.getLow(), fromVersionInclusive, versionRange.getHigh(), versionRange.isHighInclusive()); } /** * Get the toVersion. * * @return the toVersion. */ public Object getTo() { return versionRange.getHigh(); } /** * Set the toVersion. * * @param toVersion the toVersion. */ @CompositeValue(ignore=true) @XmlTransient public void setTo(Object toVersion) { versionRange = new VersionRange(versionRange.getLow(), versionRange.isLowInclusive(), toVersion, versionRange.isHighInclusive()); } /** * Get the toVersion. * * @return the toVersion. */ public Version getToVersion() { Object to = getTo(); if (to == null) return null; if (to instanceof Version) return (Version) to; if (to instanceof String) return Version.parseVersion((String) to); throw new IllegalStateException(to + " is not an instance of version"); } /** * Set the toVersion. * * @param toVersion the toVersion. */ @CompositeKey @CompositeValue(name="to") @XmlAttribute(name="to") public void setToVersion(Version toVersion) { setTo(toVersion); } /** * Get the toVersionInclusive. * * @return the toVersionInclusive. */ public boolean isToVersionInclusive() { return versionRange.isHighInclusive(); } /** * Set the toVersionInclusive. * * @param toVersionInclusive the toVersionInclusive. */ @CompositeKey @XmlAttribute(name="to-inclusive") public void setToVersionInclusive(boolean toVersionInclusive) { versionRange = new VersionRange(versionRange.getLow(), versionRange.isLowInclusive(), versionRange.getHigh(), toVersionInclusive); } /** * Set a single version as the version range * * @param version the version */ @CompositeValue(ignore=true) @XmlAttribute(name="version") public void setVersion(Version version) { versionRange = new VersionRange(version, true, version, true); } @Override public boolean equals(Object obj) { if (obj == this) return true; if (obj == null || obj instanceof NameAndVersionRangeSupport == false) return false; NameAndVersionRangeSupport other = (NameAndVersionRangeSupport) obj; if (getName().equals(other.getName()) == false) return false; return getVersionRange().equals(other.getVersionRange()); } @Override public int hashCode() { return getName().hashCode(); } @Override public String toString() { return getClass().getSimpleName() + " " + getName() + ":" + getVersionRange(); } } ././@LongLink0000000000000000000000000000020100000000000011556 Lustar rootrootlibjboss-classloader-java-2.0.6.GA.orig/classloading/src/main/java/org/jboss/classloading/spi/helpers/NameAndVersionSupport.javalibjboss-classloader-java-2.0.6.GA.orig/classloading/src/main/java/org/jboss/classloading/spi/helper0000644000175000017500000001215410757515224033403 0ustar twernertwerner/* * JBoss, Home of Professional Open Source * Copyright 2008, JBoss Inc., and individual contributors as indicated * by the @authors tag. See the copyright.txt in the distribution for a * full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.classloading.spi.helpers; import java.io.Serializable; import javax.xml.bind.annotation.XmlAttribute; import javax.xml.bind.annotation.XmlTransient; import org.jboss.classloading.spi.version.Version; import org.jboss.classloading.spi.version.VersionComparatorRegistry; import org.jboss.managed.api.annotation.ManagementProperty; import org.jboss.metatype.api.annotations.CompositeKey; import org.jboss.metatype.api.annotations.CompositeValue; /** * NameAndVersionSupport. * * @author Adrian Brock * @version $Revision: 1.1 $ */ public class NameAndVersionSupport implements Serializable, Cloneable { /** The serialVersionUID */ private static final long serialVersionUID = 6943685422194480909L; /** The name */ private String name = ""; /** The version */ private Object version = Version.DEFAULT_VERSION; /** * Create a new NameAndVersionSupport with the default version */ public NameAndVersionSupport() { } /** * Create a new NameAndVersionSupport with the default version * * @param name the name * @throws IllegalArgumentException for a null name */ public NameAndVersionSupport(String name) { this(name, null); } /** * Create a new NameAndVersionSupport. * * @param name the name * @param version the version - pass null for default version * @throws IllegalArgumentException for a null name */ public NameAndVersionSupport(String name, Object version) { if (name == null) throw new IllegalArgumentException("Null name"); if (version == null) version = Version.DEFAULT_VERSION; this.name = name; this.version = version; } /** * Get the name. * * @return the name. */ public String getName() { return name; } /** * Set the name. * * @param name the name. */ @CompositeKey @ManagementProperty @XmlAttribute public void setName(String name) { if (name == null) throw new IllegalArgumentException("Null name"); this.name = name; } /** * Get the version. * * @return the version. */ public Object getVersion() { return version; } /** * Set the version. * * @param version the version. */ @CompositeValue(ignore=true) @XmlTransient public void setVersion(Object version) { if (version == null) version = Version.DEFAULT_VERSION; this.version = version; } /** * Get the version. * * @return the version. */ public Version getTheVersion() { Object version = getVersion(); if (version instanceof Version) return (Version) version; if (version instanceof String) return Version.parseVersion((String) version); throw new IllegalStateException(version + " is not an instanceof version"); } /** * Set the version. * * @param version the version. */ @CompositeKey @CompositeValue(name="version") @ManagementProperty(name="version") @XmlAttribute(name="version") public void setTheVersion(Version version) { setVersion(version); } @Override public boolean equals(Object obj) { if (obj == this) return true; if (obj == null || obj instanceof NameAndVersionSupport == false) return false; NameAndVersionSupport other = (NameAndVersionSupport) obj; if (getName().equals(other.getName()) == false) return false; return VersionComparatorRegistry.getInstance().same(getVersion(), other.getVersion()); } @Override public int hashCode() { return getName().hashCode(); } @Override public String toString() { return getClass().getSimpleName() + " " + getName() + ":" + getVersion(); } @Override public NameAndVersionSupport clone() { try { NameAndVersionSupport clone = (NameAndVersionSupport) super.clone(); return clone; } catch (CloneNotSupportedException e) { throw new RuntimeException("Unexpected", e); } } } libjboss-classloader-java-2.0.6.GA.orig/classloading/.settings/0000755000175000017500000000000011620043421024274 5ustar twernertwernerlibjboss-classloader-java-2.0.6.GA.orig/classloading/.settings/org.eclipse.jdt.core.prefs0000644000175000017500000000032010756304141031261 0ustar twernertwerner#Fri Sep 21 17:50:00 BST 2007 org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5 eclipse.preferences.version=1 org.eclipse.jdt.core.compiler.source=1.5 org.eclipse.jdt.core.compiler.compliance=1.5 libjboss-classloader-java-2.0.6.GA.orig/classloading/.project0000644000175000017500000000057611015015610024032 0ustar twernertwerner jboss-classloading JBoss ClassLoading jboss-classloader org.eclipse.jdt.core.javabuilder org.eclipse.jdt.core.javanature