classworlds-1.1-final.orig/0000755000175000017500000000000010724631543014420 5ustar dokodokoclassworlds-1.1-final.orig/xdocs/0000755000175000017500000000000010724631543015540 5ustar dokodokoclassworlds-1.1-final.orig/xdocs/stylesheets/0000755000175000017500000000000010724631543020114 5ustar dokodokoclassworlds-1.1-final.orig/xdocs/stylesheets/clover-style.css0000644000175000017500000000732610724631434023265 0ustar dokodoko BODY { FONT-FAMILY: verdana, arial, sans-serif } a:link.selfref, a:visited.selfref { color: #555 !important; } a:link, a:visited { font-family: sans-serif; color:#000099; text-decoration: none; } a:active, a:hover { color:#990000; text-decoration: underline; } TABLE { FONT-SIZE: 9px; border-spacing: 2px; } TD { border: 1px solid #555555; } TD.hbreak { border: none; } .navBar { Font-weight: normal; Font-size: 12px; } TD.itemList { Font-weight: normal; Font-size: 12px; FONT-FAMILY: arial, sans-serif; padding:2px; border: none; } TD.itemList a { line-height: 1.4em; } DIV.navBar { font-size: 8pt; padding-top:4px; color:#222222; } DIV.navBar a { color:#222222; } FONT.navBarCurrent { padding: 4px; font-weight: bold; color: #FFFFFF; background-color:#990000; } TD.reportHeader { BACKGROUND: #eeeeee; PADDING: 5px; FONT-WEIGHT: bold; FONT-SIZE: 12px; BORDER: #555555 1px solid; border: none; } .titleText { font-weight: bold; font-size: normal; font-family: sans-serif; color:#990000; line-height: 2em; border: 1px solid #aaaaaa; padding-left:4px; padding-right:4px; padding-top:2px; padding-bottom:2px; } TD.titleText { BACKGROUND: #eff7ff; PADDING-left: 5px; background: #dddddd; font-size: 10pt; } TD.headerStats { border: none; } TD.headerStats table td { border: none; color:#555555; } TD.graphHeaderLeft { BACKGROUND: #cccccc; BORDER: #777777 1px solid; color: #990000; font-size: 8pt; } TD.graphHeader { BACKGROUND: #cccccc; BORDER-BOTTOM: #777777 1px solid; BORDER-TOP: #777777 1px solid; BORDER-RIGHT: #777777 1px solid; color: #990000; font-size: 8pt; } TD.graphItem { BACKGROUND: #eeeeee; BORDER-BOTTOM: #777777 1px solid; BORDER-LEFT: #777777 1px solid; BORDER-RIGHT: #777777 1px solid; PADDING-LEFT: 15px; PADDING-RIGHT: 15px; FONT-WEIGHT: bold; FONT-SIZE: 12px; } TD.graphPercent { font-size:8pt; BACKGROUND: #eeeeee; border-bottom: 1px solid #777777; border-right: 1px solid #777777; } TD.graphBarLeft { font-size:8pt; BACKGROUND: #eeeeee; border-bottom: 1px solid #777777; border-right: 1px solid #777777; } TD.graphBar { BACKGROUND: white; border: none; padding:2px; width: 80%; } TD.hspacer { BORDER-BOTTOM:#dcdcdc 1px solid; BORDER-TOP:#dcdcdc 1px solid; } TABLE.barGraph { WIDTH: 100%; } TD.empty { FONT-SIZE: 2px; BACKGROUND: #c0c0c0; BORDER:#9c9c9c 1px solid; } TD.fullcover { FONT-SIZE: 2px; BACKGROUND: #00df00; BORDER:#9c9c9c 1px solid; } TD.covered { FONT-SIZE: 2px; BACKGROUND: #009900; border:1px solid black; } TD.uncovered { FONT-SIZE: 2px; BACKGROUND: #990000; border:none; border:1px solid black; } TD.tabText { PADDING-RIGHT: 12px; } DIV.timestamp { FONT-SIZE: 10px; font-weight: normal; padding-left: 1px; color:#555555; } SPAN.srcFile { FONT-SIZE: 9px } TABLE.srcView { FONT-SIZE: 12px; BORDER:#555555 1px solid; } TD.lineCount { border: 1px solid #999999; BACKGROUND: #F0F0F0; PADDING-RIGHT: 3px; } TD.lineCountHilight { border: 1px solid #999999; BACKGROUND: #C8C8F0; PADDING-RIGHT: 3px; } SPAN.Hilight { BACKGROUND: #C8C8F0; } SPAN.srcHilight pre { BACKGROUND: #ddaaaa; } TD.coverageCount { border: 1px solid #999999; BACKGROUND: #F0F0F0; PADDING-RIGHT: 3px; } TD.coverageCountHilight { border: 1px solid #999999; BACKGROUND: #F0C8C8; PADDING-RIGHT: 3px; } TD.srcLine { border: none; WIDTH: 100% } TD.srcLineClassStart { border: none; WIDTH: 100%; BORDER-TOP:#dcdcdc 1px solid; FONT-WEIGHT: bold; } PRE.srcLine { BACKGROUND: #ffffff; MARGIN-TOP: 0px; MARGIN-BOTTOM: 0px; } TD.footer { FONT-SIZE: 9px; background-color:#dddddd; } TD.footer td { color:#777777; } classworlds-1.1-final.orig/xdocs/stylesheets/maven_ns4_only.css0000644000175000017500000000070210724631434023557 0ustar dokodokobody { background: #fff; color: #000; } a:active, a:hover, #leftcol a:active, #leftcol a:hover { color: #f30; } #leftcol a:link, #leftcol a:visited { color: blue; } .a td { background: #ddd; color: #000; } .b td { background: #efefef; color: #000; } body .app th { background-color: #bbb; color: #fff; } #navcolumn div strong { background: #fff; color: #555; } #banner, #banner td { background: white; color: #fff; } classworlds-1.1-final.orig/xdocs/stylesheets/print.css0000644000175000017500000000025010724631434021756 0ustar dokodoko#banner, #footer, #leftcol, #breadcrumbs, .docs #toc, .docs .courtesylinks { display: none; } body.docs div.docs { margin: 0 !important; border: none !important } classworlds-1.1-final.orig/xdocs/stylesheets/tigris.css0000644000175000017500000002011110724631434022121 0ustar dokodoko/* contains rules unsuitable for Netscape 4.x; simpler rules are in ns4_only.css. see */ /* colors, backgrounds, borders, link indication */ body { background: #fff; color: #000; } .app h3, .app h4, .app th, .tabs td, .tabs th, .functnbar { /* background-image: url(../images/nw_min.gif); background-repeat: no-repeat; */ } #navcolumn div div, body.docs #toc li li { background-image: url(../images/strich.gif); background-repeat: no-repeat; background-position: .5em .5em; } #navcolumn div div.heading { background-image: none; } .app h3, .app h4 { color: #fff; } .app h3 { background-color: #036; } .app h4 { background-color: #888; } .a td { background: #ddd; } .b td { background: #efefef; } table, th, td { border: none } .mtb { border-top: solid 1px #ddd; } div.colbar { background: #bbb; } div#banner { border-top: 1px solid #369; border-bottom: 1px solid #003; } div#helptext th { border-bottom: 1px solid #996; border-right: 1px solid #996; } div#helptext td { border-bottom: 1px solid #cc9; border-right: 1px solid #cc9; } .tabs { border-bottom: .75em #888 solid; } .tabs th, .tabs td { border-right: 1px solid #333; } .tabs td { border-bottom: 1px solid #ddd; } #navcolumn { background: #eee; border-right: 1px solid #aaa; border-bottom: 1px solid #aaa; } /* #breadcrumbs { border-bottom: 1px solid #aaa; background-color: #ddd; } */ /* #navcolumn, #breadcrumbs { border-top: 1px solid #fff; } */ #rightcol div.www, #rightcol div.help { border: 1px solid #ddd; } div#navcolumn div.focus { border-top: 1px solid #aaa; border-left: 1px solid #aaa; background-color: #fff; } body.docs div.docs { background: #fff; border-left: 1px solid #ddd; border-top: 1px solid #ddd; } body.docs { background: #eee url(../images/help_logo.gif) top right no-repeat !important; } .docs h3, .docs h4 { border-top: solid 1px #000; } #alerterrormessage { background: url(../images/icon_alert.gif) top left no-repeat !important; } .functnbar { background-color: #aaa; } .functnbar2, .functnbar3 { background: #aaa url(../images/sw_min.gif) no-repeat bottom left; } .functnbar3 { background-color: #ddd; } .functnbar, .functnbar2, .functnbar3 { color: #000; } .functnbar a, .functnbar2 a, .functnbar3 a { color: #000; text-decoration: underline; } #topmodule { background: #ddd; border-top: 1px solid #fff; border-bottom: 1px solid #aaa; border-right: 1px solid #aaa; } #topmodule #issueid { border-right: 1px solid #aaa; } /* a:link, #navcolumn a:visited, .app a:visited, .tasknav a:visited { color: blue; } a:active, a:hover, #leftcol a:active, #leftcol a:hover { color: #f30 !important; } */ /* #login a:link, #login a:visited { color: white; text-decoration: underline; } */ /* #banner a:active, #banner a:hover { color: #f90 !important; } */ /* #leftcol a, #breadcrumbs a { text-decoration: none; } */ /* a:link.selfref, a:visited.selfref { color: #555 !important; text-decoration: none; } */ h2 .lastchild { color: #777 } .tabs td, .tabs th { background-color: #ddd; } .app th { background-color: #bbb; } .tabs th { background-color: #888; color: #fff; } .axial th { background-color: #ddd; color: black } .tabs td { background-color: #ddd; } .alert { color: #c00; } .confirm { color: green; } .info { color: blue; } .selection { background: #ffc; } #login { color: #fff; } #helptext th { background: #cc9; } #helptext td { background: #ffc; } .tabs a { text-decoration: none; } #navcolumn div strong { color: #000; } #banner, #banner td { background: #036; color: #fff; } body #banner #login a { color: #fff; } /* font and text properties, exclusive of link indication, alignment, text-indent */ body, th, td, input, select, textarea, h2 small { font-family: Verdana, Helvetica, Arial, sans-serif; } code, pre { font-family: 'Andale Mono', Courier, monospace; } html body, body th, body td, textarea, h2 small, .app h3, .app h4, #rightcol h3, #bodycol pre, #bodycol code { font-size: x-small; voice-family: "\"}\""; voice-family: inherit; font-size: small } html>body, html>body th, html>body td, html>body input, html>body select, html>body textarea, html>body h2 small, html>body .app h3, html>body .app h4, html>body #rightcol h3, html>body #bodycol pre, html>body #bodycol code { font-size: small } small, div#footer td, div#login, div#helptext th, div#helptext td, div.tabs th, div.tabs td, input, select, .paginate, .functnbar, .functnbar2, .functnbar3, #breadcrumbs td, .courtesylinks, #rightcol div.help, .colbar, .tasknav, body.docs div#toc { font-size: xx-small; voice-family: "\"}\""; voice-family: inherit; font-size: x-small } html>body small, html>body div#footer td, html>body div#login, html>body div#helptext td, html>body div#helptext th, html>body div.tabs th, html>body div.tabs td, html>body input, html>body select, html>body .paginate, html>body .functnbar, html>body .functnbar2, html>body .functnbar3, html>body #breadcrumbs td, html>body .courtesylinks, html>body #rightcol div.help, html>body .colbar, html>body .tasknav, html>body.docs #toc { font-size: x-small } #bodycol h2 { font-family: Tahoma, Verdana, Helvetica, Arial, sans-serif; font-size: 1.5em; font-weight: normal; } h2 small { font-weight: bold; letter-spacing: .06em; } dt { font-weight: bold } #login .username { font-weight: bold; } h4 { font-size: 1em; } #breadcrumbs td { font-weight: bold; } .selection { font-weight: bold } /* box properties (exclusive of borders), positioning, alignments, list types, text-indent */ #bodycol h2 { margin-top: .3em; margin-bottom: .5em; } p, ul, ol, dl { margin-top: .67em; margin-bottom: .67em; } h3, h4 { margin-bottom: 0; } form { margin-top: 0; margin-bottom: 0; } #bodycol { padding-left: 12px; padding-right: 12px; width: 100%; voice-family: "\"}\""; voice-family: inherit; width: auto; } html>body #bodycol { width: auto; } .docs { line-height: 1.4; } .app h3, .app h4 { padding: 5px; margin-right: 2px; margin-left: 2px; } .h3 p, .h4 p, .h3 dt, .h4 dt { margin-right: 7px; margin-left: 7px; } .tasknav { margin-bottom: 1.33em } div.colbar { padding: 4px; margin: 2px 2px 0; } .tabs { margin-top: .67em; margin-right: 2px; margin-left: 2px; } #leftcol { padding-bottom: .5em; } #breadcrumbs td { vertical-align: middle; padding: 2px 8px; } #rightcol div.www, #rightcol div.help { padding: 0 .5em } #navcolumn { margin: -8px -8px 0 -8px; padding: 4px; } #navcolumn div { padding-left: 5px } div#navcolumn div div { margin-top: .3em; margin-bottom: .3em; } div#navcolumn div.focus { margin-top: -.1em; padding: .2em 4px; } body.docs #toc { position: absolute; top: 15px; left: 0px; width: 120px; padding: 0 20px 0 0 } body.docs #toc ul, #toc ol { margin-left: 0; padding-left: 0; } body.docs #toc li { margin-top: 7px; padding-left: 10px; list-style-type: none; } body.docs div.docs { margin: 61px 0 0 150px; padding: 1em 2em 1em 1em !important; } .docs p+p { text-indent: 5%; margin-top: -.67em } .docs h3, .docs h4 { margin-bottom: .1em; padding-top: .3em; } #alerterrormessage { padding-left: 100px; } .functnbar, .functnbar2, .functnbar3 { padding: 5px; margin: .67em 2px; } #topmodule td { vertical-align: middle; padding: 2px 8px } body { padding: 1em; } body.composite, body.docs { margin: 0; padding: 0; } th, td { text-align: left; vertical-align: top } .right { text-align: right !important; } .center { text-align: center !important; } .tabs td, .tabs th { padding-left: 7px; padding-right: 7px; } .axial th { text-align: right; } .app .axial td th { text-align: left; } body td .stb { margin-top: 1em; text-indent: 0; } body td .mtb { margin-top: 2em; text-indent: 0; } dd { margin-bottom: .67em; } #footer { margin: 4px } #helptext { margin-top: 1em } #helptext td div { margin: .5em } .courtesylinks { margin-top: 1em; padding-top: 1em } #navcolumn div { margin-bottom: .5em; } #navcolumn div div { margin-top: .3em } #navcolumn div div { padding-left: 1em; } #banner, #banner td { vertical-align: middle; } body.docs, body.nonav { margin: 1em } classworlds-1.1-final.orig/xdocs/stylesheets/javadoc-style.css0000644000175000017500000000516510724631434023401 0ustar dokodoko/* Javadoc style sheet */ /* Define colors, fonts and other style attributes here to override the defaults */ /* Page background color */ body { background-color: #FFFFFF } a:link.selfref, a:visited.selfref { color: #555 !important; } a:link, a:visited { font-family: sans-serif; color:#000099; text-decoration: none; } a:active, a:hover { color:#990000; text-decoration: underline; } font.FrameItemFont { font-size:10pt; } a:link.selfref, a:visited.selfref { font-family: sans-serif; color: #555 !important; } .a td { background: #ddd; color: #000; font-family: sans-serif; } h2 { font-family: sans-serif; border:solid 1px #999999; padding:10px; background-color:#EEEEEE; } table { border: none; border-spacing: 2px; } tr.TableHeadingColor td { font-family: sans-serif; font-size: 9pt; border: 1px solid #555555; } tr.TableRowColor td { font-family: sans-serif; font-size: 9pt; border: 1px solid #999999; cell-padding: 2px; } td.NavBarCell1 table { border: none; } td.NavBarCell1 { border: none; } td.NavBarCell2 { border: 4px green; } dt { font-family: sans-serif; font-size: 10pt; } dt b { color:#990000; } dd { font-size:10pt; margin-top:4px; margin-bottom:4px; } dd code { color:#333333; font-size:9pt; font-size:normal; } /* Table colors */ .TableHeadingColor { background: #cccccc; color:#990000} .TableSubHeadingColor { background: #bbbbbb; color:black;} .TableRowColor { background: #EEEEEE } /* Font used in left-hand frame lists */ .FrameTitleFont { font-weight: 900; font-size: normal; font-family: sans-serif; color:#FFFFFF } .FrameHeadingFont { font-weight: bold; font-size: normal; font-family: sans-serif; color:#990000; line-height: 2em; border: 1px solid #aaaaaa; padding-left:4px; padding-right:4px; padding-top:2px; padding-bottom:2px; } .FrameItemFont { font-size: normal; font-family: sans-serif; color:#FFFFFF } /* Example of smaller, sans-serif font in frames */ /* .FrameItemFont { font-size: 10pt; font-family: Helvetica, Arial, sans-serif } */ /* Navigation bar fonts and colors */ .NavBarCell1 { background-color:#ddd; border:none; padding: 2px; } .NavBarCell1Rev { background-color:#990000; border:none; padding: 2px; } .NavBarFont1 { font-family: Arial, Helvetica, sans-serif; font-size: 8pt; color:#000000; } .NavBarFont1Rev { font-family: Arial, Helvetica, sans-serif; font-size: 8pt; color:#FFFFFF; } .NavBarCell2 { font-family: Arial, Helvetica, sans-serif; background-color:#FFFFFF; border:none;} .NavBarCell3 { font-family: Arial, Helvetica, sans-serif; background-color:#FFFFFF; border:none;} classworlds-1.1-final.orig/xdocs/stylesheets/ns4_only.css0000644000175000017500000000466610724631434022406 0ustar dokodoko/* simple rules suitable for Netscape 4.x only; richer rules are in tigris.css. see */ /* colors, backgrounds, borders, link indication */ body { background: #fff; color: #000; } #leftcol a:link, #leftcol a:visited { color: blue; } a:active, a:hover, #leftcol a:active, #leftcol a:hover { color: #f30; } #login a:link, #login a:visited { color: white; text-decoration: underline; } #banner a:active, #banner a:hover { color: #f90; } #leftcol a, #breadcrumbs a { text-decoration: none; } h2 .lastchild { color: #777 } .a td { background: #ddd; } .b td { background: #efefef; } .tabs td, .tabs th { background-color: #ddd; } body .app th { background-color: #bbb; } body .tabs th { background-color: #888; color: #fff; } body .app .axial th { background-color: #ddd; color: black } .tabs td { background-color: #ddd; } .alert { color: #c00; } .confirm { color: green; } .info { color: blue; } .selection { background: #ffc; } #login { color: #fff; } #helptext th { background: #cc9; } #helptext td { background: #ffc; } .tabs a { text-decoration: none; } #navcolumn div strong { color: #555; } #banner, #banner td { background: #036; color: #fff; } body #banner #login a { color: white; } /* font and text properties, exclusive of link indication, alignment, text-indent */ body, div, p, th, td, li, dl, dd { font-family: Lucida, Arial, Helvetica, sans-serif; } code, pre { font-family: 'Andale Mono', Courier, monospace; } h2, h3, h4 { font-family: Tahoma, Verdana, Helvetica, Arial, sans-serif; } .selection { font-weight: bold } #login .username { font-weight: bold; } /* box properties (exclusive of borders), positioning, alignments, list types, text-indent */ th, td { text-align: left; vertical-align: top } .right { text-align: right; } .center { text-align: center; } body .app .axial th { text-align: right; } .app .axial td th { text-align: left; } body td .stb { margin-top: 1em; text-indent: 0; } body td .mtb { margin-top: 2em; text-indent: 0; } dd { margin-bottom: .67em; } #footer { margin: 4px } #helptext { margin-top: 1em } #helptext td div { margin: .5em } .courtesylinks { margin-top: 1em; padding-top: 1em } #navcolumn div { margin-bottom: .5em; } #navcolumn div div { margin-top: .3em } #navcolumn div div { padding-left: 1em; } #banner, #banner td { vertical-align: middle; } body.docs, body.nonav { margin: 1em } classworlds-1.1-final.orig/xdocs/stylesheets/maven.css0000644000175000017500000000672210724631434021742 0ustar dokodokobody { background: #fff; color: #000; letter-spacing:1px; } a { font-weight: normal; } table { border: none; margin: 0px; padding: 0px; } .app h3 { font-family: sans-serif; border: solid 1px #999999; padding:6px; background-color:#dddddd; color:#990000; font-size:14pt; margin: 1pt; margin-top: 6pt; margin-left: -10px; } .app h3 a { font-size:14pt; font-stretch:expanded; } .app h3 a:before { content: "[ "; } .app h3 a:after { content: " ]"; } .app h4 { font-family: sans-serif; border:#bbbbbb solid 1px; padding:2px; background-color:#eeeeee; color:#990000; margin-left: -5px; padding-left: 10px; } .app h4 a { font-size:8pt; } .app h4 a:before { content: "..."; } .app h4 a:after { content: "..."; } .app th { background-color: #cccccc; color: #990000; font-family: sans-serif; font-size: 8pt; border: solid #777777 1px; padding: 4px; letter-spacing: normal; font-weight:normal; } .app td { font-family: sans-serif; font-size: 8pt; border: solid #777777 1px; padding: 4px; } div#banner { border: none; } code { color: #990000; } .b td { background: #dddddd; color: #000; border: solid #555555 1px; font-family: sans-serif; } .a td { background: #eeeeee; color: #000; font-family: sans-serif; } div#banner { /* border-top: 1px solid #369; border-bottom: 1px solid #003; */ } #bodycol div.h3 p { max-width: 5in; margin-left: 20px; line-height: 1.6em; font-size: 8pt; color:#777777; letter-spacing:normal; } #banner, #banner td { background: white; color: #fff; } #leftcol { background: #eeeeee; color: #000; border-right: 1px solid #777777; border-bottom: 1px solid #777777; /* border-bottom: 1px solid #aaa; border-top: 1px solid #fff; */ } #navcolumn { background: #eeeeee; color: #000; border-right: none; border-bottom: none; border-top: none; min-width:1.5in; margin-left:10px; } #navcolumn div strong { color:#990000; padding: 4px; line-height:20pt; border-bottom: 1px solid #bbbbbb; font-weight: normal; letter-spacing: normal; } #navcolumn div { margin-top:10px; } #navcolumn div div { margin-bottom:10px; } #breadcrumbs { border: 1px solid #777777; } #breadcrumbs { background-color: #dddddd; } #breadcrumbs td { border: none; color: #777777; padding-left: 1em; } #source { background-color: #fff; color: #000; border-right: 1px solid #888; border-left: 1px solid #888; border-top: 1px solid #888; border-bottom: 1px solid #888; margin-right: 7px; margin-left: 7px; margin-top: 1em; } pre { margin-right: 7px; margin-left: 7px; } #footer { background: #eeeeee; border: 1px solid #777777; margin-left: 0px; margin-right: 0px; padding-top: 3px; padding-bottom: 3px; padding-left: 1em; color:#777777; } #footer table { } #footer table tr td { border: none; padding: 0px; margin: 4px; } a:link, #breadcrumbs a:visited, #navcolumn a:visited, .tasknav a:visited { font-family: sans-serif; color:#000099; text-decoration: none; } a:active, a:hover, #leftcol a:active, #leftcol a:hover { font-family: sans-serif; color:#990000; text-decoration: none; } a:link.selfref, a:visited.selfref { color: #555 !important; } .app a:link, .app a:visited { font-family: sans-serif; color:#000099; text-decoration: none; } .app a:active, .app a:hover { color:#990000; text-decoration: underline; } h3, h4 { margin-top: 1em; margin-bottom: 0; } classworlds-1.1-final.orig/xdocs/releases.xml0000644000175000017500000000221410724631434020063 0ustar dokodoko bob mcwhirter Releases

Official builds can be found in the classworlds distribution directory.

The latest official build is 1.0.

classworlds-1.1-final.orig/xdocs/index.xml0000644000175000017500000000361710724631434017377 0ustar dokodoko classworlds bob mcwhirter

classworlds is a framework for container developers who require complex manipulation of Java's ClassLoaders. Java's native ClassLoader mechanims and classes can cause much headache and confusion for certain types of application developers. Projects which involve dynamic loading of components or otherwise represent a 'container' can benefit from the classloading control provided by classworlds.

classworlds provides a richer set of semantics for class loading than Java's normal mechanisms, while still being able to provide a ClassLoader interface to integrate seamlessly with the Java environment.

The classworlds model does away with the hierarchy normally associated with ClassLoaders. Instead, there is a pool of ClassRealms which can import arbitrary packages from other ClassRealms. Effectively, classworlds turns the old-style hierarchy into a directed graph.

In a application container environment, the container may have a realm capable of loading on the container/component contract interfaces and classes. Another realm is created for each component which imports the contract classes from the container realm.

This model allows for fine-grained control of which classloader loads any particular class. This form of partial isolation can reduce the myriad strange errors that are produced by loading classes from multiple loaders.

classworlds-1.1-final.orig/xdocs/changes.xml0000644000175000017500000000265710724631434017703 0ustar dokodoko Changes Jason van Zyl Added support for ClassRealms that inherit from an existing ClassLoader. This allows ClassWorlds to work in situations where it isn't being used to bootstrap the application. Fixed the handling of URLs that contain ".." and URLs that start with a leading slash. Apply Stephen Haberman's patch so that getJarFile decodes the getFile() contents correctly. Refer to CLASSWORDS-7 in JIRA. Added support better support for resources. Classloading happens now in this order:
  • Imports
  • Local class realm
  • Parent realm
This is subject to change and will probably be configurable in the future.
classworlds-1.1-final.orig/xdocs/uberjar.xml0000644000175000017500000000771110724631434017721 0ustar dokodoko bob mcwhirter Uberjar

Pete Kazmier has written the uberjar plugin for maven.

Simply set (in your project.properties) the maven.uberjar.main property to the name of your "main" class, and type:

maven uberjar

An uberjar containing your project's jar and all dependencies will be created for you.

classworlds allows the creation of a single standalone jar for your project which may internally include any other additional jars that are required for your application. This allows for easy java -jar myapp.jar type of execution.

To create a standalone jar (aka, an uberjar), simply build your application's jar as normal. Gather up all dependent jars and create a classworlds.conf for your application. Similar to other jar formats, a meta-directory is created within the uberjar, named WORLDS-INF/. It contains two directories:

  • WORLDS-INF/lib/

    to contain all jars required by your application.

  • WORLDS-INF/conf/

    to hold your classworld.conf file.

The classworlds.conf should be created as normal, with the special exception that the property ${classworlds.lib} points to the internal library directory WORLDS-INF/lib/ so that jars can be loaded from within the uberjar:

[app] ${classworlds.lib}/myApp.jar ${classworlds.lib}/someDependency.jar

The core classworlds jar needs to be placed at the root of the WORLDS-INF directory, named exactly classworlds.jar

Create the required directory structure, and populate it with the appropriate files. For example:

./assembly-dir/ WORLDS-INF/ classworlds.jar lib/ myApp.jar someDependency.jar anotherDependency.jar conf/ classworlds.conf

All that remains is unjaring the classes from classworlds-boot.jar into your assembly directory and creating your final jar. The final layout should appear like:

./assembly-dir/ WORLDS-INF/ classworlds.jar lib/ myApp.jar someDependency.jar anotherDependency.jar conf/ classworlds.conf com/ werken/ classworlds/ boot/ Bootstrapper.class InitialClassLoader.class protocol/ jar/ Handler.class JarUrlConnection.class

Now, simply create and distribute your standalone uberjar:

cd assembly-dir/ jar cvf myapp-standalone.jar . java -jar myapp-standalone.jar
classworlds-1.1-final.orig/xdocs/cvs.xml0000644000175000017500000000217610724631434017062 0ustar dokodoko bob mcwhirter CVS

This project's CVS repository can be checked out through anonymous (pserver) CVS with the following instruction set. When prompted for a password for anonymous, simply press the Enter key.

cvs -d:pserver:anonymous@cvs.codehaus.org:/scm/cvspublic login cvs -z3 -d:pserver:anonymous@cvs.codehaus.org:/scm/cvspublic co classworlds

Updates from within the module's directory do not need the -d parameter.

Only project developers can access the CVS tree via this method. SSH1 must be installed on your client machine. Substitute developername with the proper value. Enter your site password when prompted.

export CVS_RSH=ssh cvs -z3 -ddevelopername@cvs.codehaus.org:/scm/cvs co classworlds
classworlds-1.1-final.orig/xdocs/irc.xml0000644000175000017500000000132510724631434017037 0ustar dokodoko bob mcwhirter IRC

The Werken Company runs an IRC server to support the interactive efforts of project members.

To access the IRC server, point an appropriate IRC client at:

            server: irc.werken.com
              port: 6667
        

You may find folks hanging out in either #werken or #classworlds.

classworlds-1.1-final.orig/xdocs/apiusage.xml0000644000175000017500000000463010724631434020062 0ustar dokodoko API Usage bob mcwhirter

The Java API can be used to create new realms and connect realms together through importation of specific packages.

The core of the classworlds infrastructure is the ClassWorld class. An application must create a ClassWorld instance. It is advisable to store the instance as a singleton or some other handy location.

Once a ClassWorld is created, realms within it can be created. These realms effectively only allow loading of the core JVM classes.

In order to make each ClassRealm useful, constituent must be added to that each can provide certain classes.

Now, links between the various realms need to be created to allow classes loaded from one to be available to classes loaded in another.

The container implementation can then be loaded from it's realm and used.

Ideally, the container itself would be responsible for creating a ClassRealm for each component that's loaded, and importing the component contract interfaces into the component's ClassRealm and using loadClass(..) to gain entry into the sandboxed component realm.

classworlds-1.1-final.orig/xdocs/launchusage.xml0000644000175000017500000001051010724631434020555 0ustar dokodoko App Launching bob mcwhirter

In order to reduce the number of classloading projects, classworlds replaces forehead for application launching.

The main problems to solve in application launching include locating all of application's JARs, configuring the initial classloaders, and invoking the main entry method.

The launcher facilities of classworlds simplify the process of locating application jars. A common idiom is to have a script which starts the JVM with only the classworlds.jar in the classpath and a system property to specify the location of a launcher configuration. Additionally, typically a property specifying the installation location is passed on the command-line.

The entry-point class and realm must be specified using the main is directive before specifying realm definitions.

At least one classworlds realm must be defined within the configuration file. The syntax for starting a realm definition is [realm.name]. All lines following the realm header are considered directives for that realm. The realm definition continues either until another realm is defined or until the end of the file is reached.

Within a realm definition, two directives are available: load and import.

The load directive specifies a class source to be used for loading classes in the realm. Any loaded source that ends with the / character is considered a directory hierarchy of classes and resources and all others are considered to be JAR files. System properties may be referred to using ${propname} notation. The load directive is equivelent to the addConstituent(..) method of ClassRealm.

The import directive specifies that certain packages should be imported and loaded by way of another realm. The import directive is equivelent to the importFrom(..) method of ClassRealm.

classworlds can be used to invoke any existing application's main() method. Using the standard entry point does not allow for gaining access to the ClassWorld of the application, but not all applications will need it at run-time.

For those applications that do require the ClassWorld instance, an alternative entry-point method signature can be provide. Simply add a ClassWorld parameter to the standard main parameter list.

classworlds-1.1-final.orig/xdocs/navigation.xml0000644000175000017500000000176510724631434020431 0ustar dokodoko classworlds: classloader framework classworlds-1.1-final.orig/lib/0000755000175000017500000000000010724631572015170 5ustar dokodokoclassworlds-1.1-final.orig/src/0000755000175000017500000000000010724631543015207 5ustar dokodokoclassworlds-1.1-final.orig/src/java/0000755000175000017500000000000010724631543016130 5ustar dokodokoclassworlds-1.1-final.orig/src/java/test/0000755000175000017500000000000010724631543017107 5ustar dokodokoclassworlds-1.1-final.orig/src/java/test/org/0000755000175000017500000000000010724631543017676 5ustar dokodokoclassworlds-1.1-final.orig/src/java/test/org/codehaus/0000755000175000017500000000000010724631543021471 5ustar dokodokoclassworlds-1.1-final.orig/src/java/test/org/codehaus/classworlds/0000755000175000017500000000000010724631543024031 5ustar dokodokoclassworlds-1.1-final.orig/src/java/test/org/codehaus/classworlds/uberjar/0000755000175000017500000000000010724631543025463 5ustar dokodokoclassworlds-1.1-final.orig/src/java/test/org/codehaus/classworlds/uberjar/protocol/0000755000175000017500000000000010724631543027324 5ustar dokodokoclassworlds-1.1-final.orig/src/java/test/org/codehaus/classworlds/uberjar/protocol/jar/0000755000175000017500000000000010724631543030100 5ustar dokodoko././@LongLink0000000000000000000000000000016100000000000011563 Lustar rootrootclassworlds-1.1-final.orig/src/java/test/org/codehaus/classworlds/uberjar/protocol/jar/JarUrlConnectionTest.javaclassworlds-1.1-final.orig/src/java/test/org/codehaus/classworlds/uberjar/protocol/jar/JarUrlConnect0000644000175000017500000000660510724631434032542 0ustar dokodokopackage org.codehaus.classworlds.uberjar.protocol.jar; import junit.framework.TestCase; import java.io.File; import java.net.MalformedURLException; import java.net.URL; import org.codehaus.classworlds.uberjar.protocol.jar.JarUrlConnection; public class JarUrlConnectionTest extends TestCase { public void setUp() { System.setProperty( "java.protocol.handler.pkgs", "org.codehaus.classworlds.uberjar.protocol" ); } public void testConstruct() throws Exception { URL url = buildUrl( "nested.jar", "!/lib/a.jar!/a/A.class" ); JarUrlConnection connection = new JarUrlConnection( url ); String[] segments = connection.getSegments(); assertEquals( 2, segments.length ); assertEquals( "/lib/a.jar", segments[0] ); assertEquals( "/a/A.class", segments[1] ); URL baseResource = connection.getBaseResource(); assertTrue( baseResource.toExternalForm().startsWith( "file:" ) ); assertTrue( baseResource.toExternalForm().endsWith( "nested.jar" ) ); } public void testConnect_Simple() throws Exception { URL url = buildUrl( "nested.jar", "" ); JarUrlConnection connection = new JarUrlConnection( url ); connection.connect(); } protected URL buildUrl( String jarName, String path ) throws Exception { File testDir = new File( System.getProperty( "basedir" ), "target/test-data" ); File jarFile = new File( testDir, jarName ); URL jarUrl = jarFile.toURL(); String urlText = "jar:" + jarUrl + path; System.err.println( "url-text: " + urlText ); URL url = new URL( urlText ); System.err.println( "url: " + url ); return url; } public void testNormaliseURL() throws MalformedURLException { testNormaliseURL( "jar:http://localhost/ted.jar!/", "http://localhost/ted.jar" ); } public void testNormaliseURL( String expected, String input ) throws MalformedURLException { assertEquals( "JarUrlConnection.normaliseURL(" + input + ")", new URL( expected ), JarUrlConnection.normaliseURL( new URL( input ) ) ); } public void testConstructionMalformed( String expected, String input, Class exception ) throws Exception { String method = "JarUrlConnection.normaliseURL(" + input + ")"; try { new JarUrlConnection( new URL( input ) ); if ( exception != null ) { fail( method + " should have thrown exception - " + exception.getName() ); } } catch ( Exception e ) { if ( exception != null && exception.isInstance( e ) ) { //Success return; } throw e; } } public void testMalformedURL() throws Exception { testConstructionMalformed( "", "http://!!!", MalformedURLException.class ); testConstructionMalformed( "", "jar://!!!/", MalformedURLException.class ); testConstructionMalformed( "", "jar:flan://!/", MalformedURLException.class ); testConstructionMalformed( "", "jar:file:///fred.jar!/", null ); } } ././@LongLink0000000000000000000000000000015000000000000011561 Lustar rootrootclassworlds-1.1-final.orig/src/java/test/org/codehaus/classworlds/uberjar/protocol/jar/HandlerTest.javaclassworlds-1.1-final.orig/src/java/test/org/codehaus/classworlds/uberjar/protocol/jar/HandlerTest.j0000644000175000017500000000342610724631434032474 0ustar dokodokopackage org.codehaus.classworlds.uberjar.protocol.jar; import junit.framework.TestCase; import java.net.URL; public class HandlerTest extends TestCase { public void setUp() { System.setProperty( "java.protocol.handler.pkgs", "org.codehaus.classworlds.uberjar.protocol" ); } public void testSimpleImplicit() throws Exception { URL url = new URL( "jar:/foo.jar" ); assertEquals( "jar:/foo.jar", url.toExternalForm() ); } public void testRelativeFile() throws Exception { URL url = buildUrl( "jar:/path/to/foo.jar", "bar.jar" ); assertEquals( "jar:/path/to/bar.jar", url.toExternalForm() ); } public void testRelativeSegment() throws Exception { URL url = buildUrl( "jar:/path/to/foo.jar!/segment.jar", "!/other-segment.jar" ); assertEquals( "jar:/path/to/foo.jar!/other-segment.jar", url.toExternalForm() ); } public void testRelativeMultiSegment() throws Exception { URL url = buildUrl( "jar:/path/to/foo.jar!/segment-a.jar!/segment-b.jar", "!/other-segment.jar#cheese" ); assertEquals( "jar:/path/to/foo.jar!/segment-a.jar!/other-segment.jar", url.toExternalForm() ); } protected URL buildUrl( String contextText, String urlText ) throws Exception { URL context = new URL( contextText ); URL url = new URL( context, urlText ); System.err.println( "build('" + context + "', '" + urlText + "') -- " + url ); return url; } } classworlds-1.1-final.orig/src/java/test/org/codehaus/classworlds/ClassView.java0000644000175000017500000000622710724631434026602 0ustar dokodokopackage org.codehaus.classworlds; public class ClassView { /** * * Formats Class information for debug output purposes. * * * * @param clz the Class to print information for * * * * @return a String describing the Class in detail */ public static String toString( Class clz ) { if ( clz.isPrimitive() ) { return clz.toString(); } else if ( clz.isArray() ) { return "Array of " + toString( clz.getComponentType() ); } else if ( clz.isInterface() ) { return toInterfaceString( clz, "" ); } else { return toClassString( clz, "" ); } } /** * * Formats Class information for debug output purposes. * * * * @param clz the Class to print information for * * @param sIndent the indentation to precede each line of output * * * * @return a String describing the Class in detail */ private static String toClassString( Class clz, String sIndent ) { StringBuffer sb = new StringBuffer(); sb.append( sIndent ) .append( "Class " ) .append( clz.getName() ) .append( " (" ) .append( toString( clz.getClassLoader() ) ) .append( ')' ); sIndent += " "; Class[] aclz = clz.getInterfaces(); for ( int i = 0, c = aclz.length; i < c; ++i ) { sb.append( '\n' ) .append( toInterfaceString( aclz[i], sIndent ) ); } clz = clz.getSuperclass(); if ( clz != null ) { sb.append( '\n' ) .append( toClassString( clz, sIndent ) ); } return sb.toString(); } /** * * Formats interface information for debug output purposes. * * * * @param clz the interface Class to print information for * * @param sIndent the indentation to precede each line of output * * * * @return a String describing the interface Class in detail */ private static String toInterfaceString( Class clz, String sIndent ) { StringBuffer sb = new StringBuffer(); sb.append( sIndent ) .append( "Interface " ) .append( clz.getName() ) .append( " (" ) .append( toString( clz.getClassLoader() ) ) .append( ')' ); Class[] aclz = clz.getInterfaces(); for ( int i = 0, c = aclz.length; i < c; ++i ) { clz = aclz[i]; sb.append( '\n' ) .append( toInterfaceString( clz, sIndent + " " ) ); } return sb.toString(); } /** * * Format a description for the specified ClassLoader object. * * * * @param loader the ClassLoader instance (or null) * * * * @return a String description of the ClassLoader */ private static String toString( ClassLoader loader ) { if ( loader == null ) { return "System ClassLoader"; } return "ClassLoader class=" + loader.getClass().getName() + ", hashCode=" + loader.hashCode(); } } classworlds-1.1-final.orig/src/java/test/org/codehaus/classworlds/EntryTest.java0000644000175000017500000000255310724631434026641 0ustar dokodokopackage org.codehaus.classworlds; import junit.framework.TestCase; /** * @author Ben Walding * @version $Id: EntryTest.java 78 2004-07-01 13:59:13Z jvanzyl $ */ public class EntryTest extends TestCase { /** * Constructor for EntryTest. * * @param arg0 */ public EntryTest( String name ) { super( name ); } public void testCompareTo() throws Exception { ClassWorld cw = new ClassWorld(); DefaultClassRealm r = (DefaultClassRealm) cw.newRealm( "test1" ); Entry entry1 = new Entry( r, "org.test" ); Entry entry2 = new Entry( r, "org.test.impl" ); assertTrue( "org.test > org.test.impl", entry1.compareTo( entry2 ) > 0 ); } /** * Tests the equality is realm independant * * @throws Exception */ public void testEquals() throws Exception { ClassWorld cw = new ClassWorld(); DefaultClassRealm r1 = (DefaultClassRealm) cw.newRealm( "test1" ); DefaultClassRealm r2 = (DefaultClassRealm) cw.newRealm( "test2" ); Entry entry1 = new Entry( r1, "org.test" ); Entry entry2 = new Entry( r2, "org.test" ); assertTrue( "entry1 == entry2", entry1.equals( entry2 ) ); assertTrue( "entry1.hashCode() == entry2.hashCode()", entry1.hashCode() == entry2.hashCode() ); } } classworlds-1.1-final.orig/src/java/test/org/codehaus/classworlds/LauncherTest.java0000644000175000017500000001126210724631434027276 0ustar dokodokopackage org.codehaus.classworlds; /* $Id: LauncherTest.java 126 2006-01-12 04:17:51Z $ Copyright 2002 (C) The Werken Company. All Rights Reserved. Redistribution and use of this software and associated documentation ("Software"), with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain copyright statements and notices. Redistributions must also contain a copy of this document. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 3. The name "classworlds" must not be used to endorse or promote products derived from this Software without prior written permission of The Werken Company. For written permission, please contact bob@werken.com. 4. Products derived from this Software may not be called "classworlds" nor may "classworlds" appear in their names without prior written permission of The Werken Company. "classworlds" is a registered trademark of The Werken Company. 5. Due credit should be given to The Werken Company. (http://classworlds.werken.com/). THIS SOFTWARE IS PROVIDED BY THE WERKEN COMPANY AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE WERKEN COMPANY OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ import junit.framework.TestCase; import java.io.File; import java.io.FileInputStream; public class LauncherTest extends TestCase { private Launcher launcher; public LauncherTest( String name ) { super( name ); } public void setUp() { System.setProperty( "java.protocol.handler.pkgs", "org.codehaus.classworlds.protocol" ); this.launcher = new Launcher(); } public void tearDown() { this.launcher = null; } public void testConfigure_Valid() throws Exception { launcher.configure( getConfigPath( "valid-launch.conf" ) ); Class mainClass = launcher.getMainClass(); assertNotNull( mainClass ); assertEquals( "a.A", mainClass.getName() ); assertEquals( "app", launcher.getMainRealm().getId() ); } public void testLaunch_ValidStandard() throws Exception { launcher.configure( getConfigPath( "valid-launch.conf" ) ); launcher.launch( new String[]{} ); } public void testLaunch_ValidStandardExitCode() throws Exception { launcher.configure( getConfigPath( "valid-launch-exitCode.conf" ) ); launcher.launch( new String[]{} ); assertEquals( "check exit code", 15, launcher.getExitCode() ); } public void testLaunch_ValidEnhanced() throws Exception { launcher.configure( getConfigPath( "valid-enh-launch.conf" ) ); launcher.launch( new String[]{} ); } public void testLaunch_ValidEnhancedExitCode() throws Exception { launcher.configure( getConfigPath( "valid-enh-launch-exitCode.conf" ) ); launcher.launch( new String[]{} ); assertEquals( "check exit code", 45, launcher.getExitCode() ); } public void testLaunch_NoSuchMethod() throws Exception { launcher.configure( getConfigPath( "launch-nomethod.conf" ) ); try { launcher.launch( new String[]{} ); fail( "should have thrown NoSuchMethodException" ); } catch ( NoSuchMethodException e ) { // expected and correct } } public void testLaunch_ClassNotFound() throws Exception { launcher.configure( getConfigPath( "launch-noclass.conf" ) ); try { launcher.launch( new String[]{} ); fail( "throw ClassNotFoundException" ); } catch ( ClassNotFoundException e ) { // expected and correct } } private FileInputStream getConfigPath( String name ) throws Exception { return new FileInputStream( new File( new File( System.getProperty( "basedir" ), "src/test-data" ), name ) ); } } classworlds-1.1-final.orig/src/java/test/org/codehaus/classworlds/ConfiguratorTest.java0000644000175000017500000003650410724631434030205 0ustar dokodokopackage org.codehaus.classworlds; /* $Id: ConfiguratorTest.java 126 2006-01-12 04:17:51Z $ Copyright 2002 (C) The Werken Company. All Rights Reserved. Redistribution and use of this software and associated documentation ("Software"), with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain copyright statements and notices. Redistributions must also contain a copy of this document. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 3. The name "classworlds" must not be used to endorse or promote products derived from this Software without prior written permission of The Werken Company. For written permission, please contact bob@werken.com. 4. Products derived from this Software may not be called "classworlds" nor may "classworlds" appear in their names without prior written permission of The Werken Company. "classworlds" is a registered trademark of The Werken Company. 5. Due credit should be given to The Werken Company. (http://classworlds.werken.com/). THIS SOFTWARE IS PROVIDED BY THE WERKEN COMPANY AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE WERKEN COMPANY OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ import junit.framework.TestCase; import java.io.File; import java.io.FileInputStream; import java.io.FileNotFoundException; import java.net.URL; import java.util.Collection; public class ConfiguratorTest extends TestCase { private Launcher launcher; private Configurator configurator; public ConfiguratorTest(String name) { super( name ); } public void setUp() { this.launcher = new Launcher(); this.configurator = new Configurator( this.launcher ); } public void tearDown() { this.launcher = null; this.configurator = null; System.getProperties().remove( "set.using.existent" ); System.getProperties().remove( "set.using.default" ); System.getProperties().remove( "set.using.nonexistent" ); System.getProperties().remove( "set.using.nonexistent.default" ); System.getProperties().remove( "set.using.missing" ); System.getProperties().remove( "set.using.filtered.default" ); } public void testConfigure_Nonexistent() throws Exception { try { this.configurator.configure( getConfigPath( "notfound.conf" ) ); fail( "throw FileNotFoundException" ); } catch (FileNotFoundException e) { // expected and correct } } public void testConfigure_DuplicateMain() throws Exception { try { this.configurator.configure( getConfigPath( "dupe-main.conf" ) ); fail( "throw ConfigurationException" ); } catch (ConfigurationException e) { // expected and correct assertTrue( e.getMessage().startsWith( "Duplicate main" ) ); } } public void testConfigure_DuplicateRealm() throws Exception { try { this.configurator.configure( getConfigPath( "dupe-realm.conf" ) ); fail( "throw DuplicateRealmException" ); } catch (DuplicateRealmException e) { // expected and correct assertEquals( "dupe.realm", e.getId() ); } } public void testConfigure_EarlyImport() throws Exception { try { this.configurator.configure( getConfigPath( "early-import.conf" ) ); fail( "throw ConfigurationException" ); } catch (ConfigurationException e) { // expected and correct assertTrue( e.getMessage().startsWith( "Unhandled import" ) ); } } public void testConfigure_RealmSyntax() throws Exception { try { this.configurator.configure( getConfigPath( "realm-syntax.conf" ) ); fail( "throw ConfigurationException" ); } catch (ConfigurationException e) { // expected and correct assertTrue( e.getMessage().startsWith( "Invalid realm" ) ); } } public void testConfigure_Valid() throws Exception { this.configurator.configure( getConfigPath( "valid.conf" ) ); assertEquals( "org.apache.maven.app.App", this.launcher.getMainClassName() ); assertEquals( "maven", this.launcher.getMainRealmName() ); ClassWorld world = this.launcher.getWorld(); Collection realms = world.getRealms(); assertEquals( 4, realms.size() ); assertNotNull( world.getRealm( "ant" ) ); assertNotNull( world.getRealm( "maven" ) ); assertNotNull( world.getRealm( "xml" ) ); ClassRealm antRealm = world.getRealm( "ant" ); ClassRealm mavenRealm = world.getRealm( "maven" ); ClassRealm xmlRealm = world.getRealm( "xml" ); ClassRealm globRealm = world.getRealm( "glob" ); assertSame( antRealm, antRealm.locateSourceRealm( "org.apache.tools.Ant" ) ); assertSame( xmlRealm, antRealm.locateSourceRealm( "org.xml.sax.SAXException" ) ); assertSame( mavenRealm, mavenRealm.locateSourceRealm( "org.apache.maven.app.App" ) ); assertSame( xmlRealm, mavenRealm.locateSourceRealm( "org.xml.sax.SAXException" ) ); // Test the glob support RealmClassLoader cl = (RealmClassLoader) globRealm.getClassLoader(); URL[] urls = cl.getURLs(); assertArrayContains(urls, new File(System.getProperty("basedir") + "/target/test-data/nested.jar").toURL()); assertArrayContains(urls, new File(System.getProperty("basedir") + "/target/test-data/a.jar").toURL()); assertArrayContains(urls, new File(System.getProperty("basedir") + "/target/test-data/b.jar").toURL()); assertArrayContains(urls, new File(System.getProperty("basedir") + "/target/test-data/c.jar").toURL()); } public void testConfigure_Optionally_NonExistent() throws Exception { this.configurator.configure( getConfigPath( "optionally-nonexistent.conf" ) ); assertEquals( "org.apache.maven.app.App", this.launcher.getMainClassName() ); assertEquals( "opt", this.launcher.getMainRealmName() ); ClassWorld world = this.launcher.getWorld(); Collection realms = world.getRealms(); assertEquals( 1, realms.size() ); assertNotNull( world.getRealm( "opt" ) ); ClassRealm optRealm = world.getRealm( "opt" ); RealmClassLoader cl = (RealmClassLoader) optRealm.getClassLoader(); URL[] urls = cl.getURLs(); assertEquals( "no urls", 0, urls.length ); } public void testConfigure_Optionally_Existent() throws Exception { this.configurator.configure( getConfigPath( "optionally-existent.conf" ) ); assertEquals( "org.apache.maven.app.App", this.launcher.getMainClassName() ); assertEquals( "opt", this.launcher.getMainRealmName() ); ClassWorld world = this.launcher.getWorld(); Collection realms = world.getRealms(); assertEquals( 1, realms.size() ); assertNotNull( world.getRealm( "opt" ) ); ClassRealm optRealm = world.getRealm( "opt" ); RealmClassLoader cl = (RealmClassLoader) optRealm.getClassLoader(); URL[] urls = cl.getURLs(); assertEquals( "one url", 1, urls.length ); assertSame( optRealm, optRealm.locateSourceRealm( "org.xml.sax.SAXException" ) ); } public void testConfigure_Unhandled() throws Exception { try { this.configurator.configure( getConfigPath( "unhandled.conf" ) ); fail( "throw ConfigurationException" ); } catch (ConfigurationException e) { // expected and correct assertTrue( e.getMessage().startsWith( "Unhandled configuration" ) ); } } public void testFilter_Unterminated() throws Exception { try { this.configurator.filter( "${cheese" ); fail( "throw ConfigurationException" ); } catch (ConfigurationException e) { // expected and correct assertTrue( e.getMessage().startsWith( "Unterminated" ) ); } } public void testFilter_Solitary() throws Exception { System.setProperty( "classworlds.test.prop", "test prop value" ); String result = this.configurator.filter( "${classworlds.test.prop}" ); assertEquals( "test prop value", result ); } public void testFilter_AtStart() throws Exception { System.setProperty( "classworlds.test.prop", "test prop value" ); String result = this.configurator.filter( "${classworlds.test.prop}cheese" ); assertEquals( "test prop valuecheese", result ); } public void testFilter_AtEnd() throws Exception { System.setProperty( "classworlds.test.prop", "test prop value" ); String result = this.configurator.filter( "cheese${classworlds.test.prop}" ); assertEquals( "cheesetest prop value", result ); } public void testFilter_Multiple() throws Exception { System.setProperty( "classworlds.test.prop.one", "test prop value one" ); System.setProperty( "classworlds.test.prop.two", "test prop value two" ); String result = this.configurator.filter( "I like ${classworlds.test.prop.one} and ${classworlds.test.prop.two} a lot" ); assertEquals( "I like test prop value one and test prop value two a lot", result ); } public void testFilter_NonExistent() throws Exception { try { this.configurator.filter( "${gollygeewillikers}" ); fail( "throw ConfigurationException" ); } catch (ConfigurationException e) { // expected and correct assertTrue( e.getMessage().startsWith( "No such property" ) ); } } public void testFilter_InMiddle() throws Exception { System.setProperty( "classworlds.test.prop", "test prop value" ); String result = this.configurator.filter( "cheese${classworlds.test.prop}toast" ); assertEquals( "cheesetest prop valuetoast", result ); } public void testSet_Using_Existent() throws Exception { assertNull( System.getProperty( "set.using.existent" ) ); this.configurator.configure( getConfigPath( "set-using-existent.conf" ) ); assertEquals( "testSet_Using_Existent", System.getProperty( "set.using.existent" ) ); } public void testSet_Using_NonExistent() throws Exception { assertNull( System.getProperty( "set.using.nonexistent" ) ); this.configurator.configure( getConfigPath( "set-using-nonexistent.conf" ) ); assertNull( System.getProperty( "set.using.nonexistent" ) ); } public void testSet_Using_NonExistent_Default() throws Exception { assertNull( System.getProperty( "set.using.nonexistent.default" ) ); this.configurator.configure( getConfigPath( "set-using-nonexistent.conf" ) ); assertEquals( "testSet_Using_NonExistent_Default", System.getProperty( "set.using.nonexistent.default" ) ); } public void testSet_Using_NonExistent_Override() throws Exception { assertNull( System.getProperty( "set.using.default" ) ); System.setProperty( "set.using.default", "testSet_Using_NonExistent_Override" ); this.configurator.configure( getConfigPath( "set-using-nonexistent.conf" ) ); assertEquals( "testSet_Using_NonExistent_Override", System.getProperty( "set.using.default" ) ); } public void testSet_Using_Existent_Override() throws Exception { assertNull( System.getProperty( "set.using.existent" ) ); System.setProperty( "set.using.existent", "testSet_Using_Existent_Override" ); this.configurator.configure( getConfigPath( "set-using-existent.conf" ) ); assertEquals( "testSet_Using_Existent_Override", System.getProperty( "set.using.existent" ) ); } public void testSet_Using_Existent_Default() throws Exception { assertNull( System.getProperty( "set.using.default" ) ); this.configurator.configure( getConfigPath( "set-using-existent.conf" ) ); assertEquals( "testSet_Using_Existent_Default", System.getProperty( "set.using.default" ) ); } public void testSet_Using_Missing_Default() throws Exception { assertNull( System.getProperty( "set.using.missing" ) ); this.configurator.configure( getConfigPath( "set-using-missing.conf" ) ); assertEquals( "testSet_Using_Missing_Default", System.getProperty( "set.using.missing" ) ); } public void testSet_Using_Missing_Override() throws Exception { assertNull( System.getProperty( "set.using.missing" ) ); System.setProperty( "set.using.missing", "testSet_Using_Missing_Override" ); this.configurator.configure( getConfigPath( "set-using-missing.conf" ) ); assertEquals( "testSet_Using_Missing_Override", System.getProperty( "set.using.missing" ) ); } public void testSet_Using_Filtered_Default() throws Exception { assertNull( System.getProperty( "set.using.filtered.default" ) ); this.configurator.configure( getConfigPath( "set-using-missing.conf" ) ); assertEquals( System.getProperty( "user.home" ) + "/m2", System.getProperty( "set.using.filtered.default" ) ); } private FileInputStream getConfigPath(String name) throws Exception { return new FileInputStream( new File( new File( System.getProperty( "basedir" ), "target/test-data" ), name ) ) ; } private void assertArrayContains(URL[] array, URL url) throws Exception { for (int i = 0; i < array.length; ++i) if (url.equals(array[i])) return; fail("URL (" + url + ") not found in array of URLs"); } } classworlds-1.1-final.orig/src/java/test/org/codehaus/classworlds/ClassRealmImplTest.java0000644000175000017500000003307710724631434030415 0ustar dokodokopackage org.codehaus.classworlds; /* $Id: ClassRealmImplTest.java 78 2004-07-01 13:59:13Z jvanzyl $ Copyright 2002 (C) The Werken Company. All Rights Reserved. Redistribution and use of this software and associated documentation ("Software"), with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain copyright statements and notices. Redistributions must also contain a copy of this document. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 3. The name "classworlds" must not be used to endorse or promote products derived from this Software without prior written permission of The Werken Company. For written permission, please contact bob@werken.com. 4. Products derived from this Software may not be called "classworlds" nor may "classworlds" appear in their names without prior written permission of The Werken Company. "classworlds" is a registered trademark of The Werken Company. 5. Due credit should be given to The Werken Company. (http://classworlds.werken.com/). THIS SOFTWARE IS PROVIDED BY THE WERKEN COMPANY AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE WERKEN COMPANY OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ import junit.framework.TestCase; import java.net.MalformedURLException; import java.net.URL; public class ClassRealmImplTest extends TestCase { private ClassWorld world; public ClassRealmImplTest( String name ) { super( name ); } public void setUp() { this.world = new ClassWorld(); } public void tearDown() { this.world = null; } public void testNewRealm() throws Exception { ClassRealm realm = this.world.newRealm( "foo" ); assertNotNull( realm ); assertSame( this.world, realm.getWorld() ); assertEquals( "foo", realm.getId() ); } public void testLocateSourceRealm_NoImports() throws Exception { DefaultClassRealm realm = new DefaultClassRealm( this.world, "foo" ); assertSame( realm, realm.locateSourceRealm( "com.werken.Stuff" ) ); } public void testLocateSourceRealm_SimpleImport() throws Exception { DefaultClassRealm mainRealm = (DefaultClassRealm) this.world.newRealm( "main" ); ClassRealm werkflowRealm = this.world.newRealm( "werkflow" ); mainRealm.importFrom( "werkflow", "com.werken.werkflow" ); assertSame( werkflowRealm, mainRealm.locateSourceRealm( "com.werken.werkflow.WerkflowEngine" ) ); assertSame( werkflowRealm, mainRealm.locateSourceRealm( "com.werken.werkflow.process.ProcessManager" ) ); assertSame( mainRealm, mainRealm.locateSourceRealm( "com.werken.blissed.Process" ) ); assertSame( mainRealm, mainRealm.locateSourceRealm( "java.lang.Object" ) ); assertSame( mainRealm, mainRealm.locateSourceRealm( "NoviceProgrammerClass" ) ); } public void testLocateSourceRealm_MultipleImport() throws Exception { DefaultClassRealm mainRealm = (DefaultClassRealm) this.world.newRealm( "main" ); ClassRealm werkflowRealm = this.world.newRealm( "werkflow" ); ClassRealm blissedRealm = this.world.newRealm( "blissed" ); mainRealm.importFrom( "werkflow", "com.werken.werkflow" ); mainRealm.importFrom( "blissed", "com.werken.blissed" ); assertSame( werkflowRealm, mainRealm.locateSourceRealm( "com.werken.werkflow.WerkflowEngine" ) ); assertSame( werkflowRealm, mainRealm.locateSourceRealm( "com.werken.werkflow.process.ProcessManager" ) ); assertSame( blissedRealm, mainRealm.locateSourceRealm( "com.werken.blissed.Process" ) ); assertSame( blissedRealm, mainRealm.locateSourceRealm( "com.werken.blissed.guard.BooleanGuard" ) ); assertSame( mainRealm, mainRealm.locateSourceRealm( "java.lang.Object" ) ); assertSame( mainRealm, mainRealm.locateSourceRealm( "NoviceProgrammerClass" ) ); } public void testLocateSourceRealm_Hierachy() throws Exception { DefaultClassRealm mainRealm = (DefaultClassRealm) this.world.newRealm( "main" ); ClassRealm fooRealm = this.world.newRealm( "foo" ); ClassRealm fooBarRealm = this.world.newRealm( "fooBar" ); ClassRealm fooBarBazRealm = this.world.newRealm( "fooBarBaz" ); mainRealm.importFrom( "foo", "foo" ); mainRealm.importFrom( "fooBar", "foo.bar" ); mainRealm.importFrom( "fooBarBaz", "foo.bar.baz" ); assertSame( fooRealm, mainRealm.locateSourceRealm( "foo.Goober" ) ); assertSame( fooRealm, mainRealm.locateSourceRealm( "foo.cheese.Goober" ) ); assertSame( fooBarRealm, mainRealm.locateSourceRealm( "foo.bar.Goober" ) ); assertSame( fooBarRealm, mainRealm.locateSourceRealm( "foo.bar.cheese.Goober" ) ); assertSame( fooBarBazRealm, mainRealm.locateSourceRealm( "foo.bar.baz.Goober" ) ); assertSame( fooBarBazRealm, mainRealm.locateSourceRealm( "foo.bar.baz.cheese.Goober" ) ); assertSame( mainRealm, mainRealm.locateSourceRealm( "java.lang.Object" ) ); assertSame( mainRealm, mainRealm.locateSourceRealm( "NoviceProgrammerClass" ) ); } public void testLocateSourceRealm_Hierachy_Reverse() throws Exception { ClassRealm fooBarBazRealm = this.world.newRealm( "fooBarBaz" ); ClassRealm fooBarRealm = this.world.newRealm( "fooBar" ); ClassRealm fooRealm = this.world.newRealm( "foo" ); DefaultClassRealm mainRealm = (DefaultClassRealm) this.world.newRealm( "main" ); mainRealm.importFrom( "fooBarBaz", "foo.bar.baz" ); mainRealm.importFrom( "fooBar", "foo.bar" ); mainRealm.importFrom( "foo", "foo" ); assertSame( fooRealm, mainRealm.locateSourceRealm( "foo.Goober" ) ); assertSame( fooRealm, mainRealm.locateSourceRealm( "foo.cheese.Goober" ) ); assertSame( fooBarRealm, mainRealm.locateSourceRealm( "foo.bar.Goober" ) ); assertSame( fooBarRealm, mainRealm.locateSourceRealm( "foo.bar.cheese.Goober" ) ); assertSame( fooBarBazRealm, mainRealm.locateSourceRealm( "foo.bar.baz.Goober" ) ); assertSame( fooBarBazRealm, mainRealm.locateSourceRealm( "foo.bar.baz.cheese.Goober" ) ); assertSame( mainRealm, mainRealm.locateSourceRealm( "java.lang.Object" ) ); assertSame( mainRealm, mainRealm.locateSourceRealm( "NoviceProgrammerClass" ) ); } public void testLoadClass_SystemClass() throws Exception { ClassRealm mainRealm = this.world.newRealm( "main" ); Class cls = mainRealm.loadClass( "java.lang.Object" ); assertNotNull( cls ); } public void testLoadClass_NonSystemClass() throws Exception { ClassRealm mainRealm = this.world.newRealm( "main" ); try { Class c = mainRealm.loadClass( "com.werken.projectz.UberThing" ); System.out.println( "c = " + c ); fail( "A ClassNotFoundException should be thrown!" ); } catch ( ClassNotFoundException e ) { // expected and correct } } public void testLoadClass_ClassWorldsClass() throws Exception { ClassRealm mainRealm = this.world.newRealm( "main" ); Class cls = mainRealm.loadClass( "org.codehaus.classworlds.ClassWorld" ); assertNotNull( cls ); assertSame( ClassWorld.class, cls ); } public void testLoadClass_Local() throws Exception { ClassRealm mainRealm = this.world.newRealm( "main" ); try { mainRealm.loadClass( "a.A" ); } catch ( ClassNotFoundException e ) { // expected and correct } mainRealm.addConstituent( getJarUrl( "a.jar" ) ); Class classA = mainRealm.loadClass( "a.A" ); assertNotNull( classA ); ClassRealm otherRealm = this.world.newRealm( "other" ); try { otherRealm.loadClass( "a.A" ); } catch ( ClassNotFoundException e ) { // expected and correct } } public void testLoadClass_Imported() throws Exception { ClassRealm mainRealm = this.world.newRealm( "main" ); ClassRealm realmA = this.world.newRealm( "realmA" ); try { realmA.loadClass( "a.A" ); fail( "realmA.loadClass(a.A) should have thrown a ClassNotFoundException" ); } catch ( ClassNotFoundException e ) { // expected and correct } realmA.addConstituent( getJarUrl( "a.jar" ) ); try { mainRealm.loadClass( "a.A" ); fail( "mainRealm.loadClass(a.A) should have thrown a ClassNotFoundException" ); } catch ( ClassNotFoundException e ) { // expected and correct } mainRealm.importFrom( "realmA", "a" ); Class classA = realmA.loadClass( "a.A" ); assertNotNull( classA ); assertEquals( realmA.getClassLoader(), classA.getClassLoader() ); Class classMain = mainRealm.loadClass( "a.A" ); assertNotNull( classMain ); assertEquals( realmA.getClassLoader(), classMain.getClassLoader() ); assertSame( classA, classMain ); } public void testLoadClass_Package() throws Exception { ClassRealm realmA = this.world.newRealm( "realmA" ); realmA.addConstituent( getJarUrl( "a.jar" ) ); Class clazz = realmA.loadClass( "a.A" ); assertNotNull( clazz ); assertEquals( "a.A", clazz.getName() ); Package p = clazz.getPackage(); assertNotNull( p ); assertEquals( "p.getName()", "a", p.getName() ); } public void testLoadClass_Complex() throws Exception { ClassRealm realmA = this.world.newRealm( "realmA" ); ClassRealm realmB = this.world.newRealm( "realmB" ); ClassRealm realmC = this.world.newRealm( "realmC" ); realmA.addConstituent( getJarUrl( "a.jar" ) ); realmB.addConstituent( getJarUrl( "b.jar" ) ); realmC.addConstituent( getJarUrl( "c.jar" ) ); realmC.importFrom( "realmA", "a" ); realmC.importFrom( "realmB", "b" ); realmA.importFrom( "realmC", "c" ); Class classA_A = realmA.loadClass( "a.A" ); Class classB_B = realmB.loadClass( "b.B" ); Class classC_C = realmC.loadClass( "c.C" ); assertNotNull( classA_A ); assertNotNull( classB_B ); assertNotNull( classC_C ); assertEquals( realmA.getClassLoader(), classA_A.getClassLoader() ); assertEquals( realmB.getClassLoader(), classB_B.getClassLoader() ); assertEquals( realmC.getClassLoader(), classC_C.getClassLoader() ); // load from C Class classA_C = realmC.loadClass( "a.A" ); assertNotNull( classA_C ); assertSame( classA_A, classA_C ); assertEquals( realmA.getClassLoader(), classA_C.getClassLoader() ); Class classB_C = realmC.loadClass( "b.B" ); assertNotNull( classB_C ); assertSame( classB_B, classB_C ); assertEquals( realmB.getClassLoader(), classB_C.getClassLoader() ); // load from A Class classC_A = realmA.loadClass( "c.C" ); assertNotNull( classC_A ); assertSame( classC_C, classC_A ); assertEquals( realmC.getClassLoader(), classC_A.getClassLoader() ); try { realmA.loadClass( "b.B" ); fail( "throw ClassNotFoundException" ); } catch ( ClassNotFoundException e ) { // expected and correct } // load from B try { realmB.loadClass( "a.A" ); fail( "throw ClassNotFoundException" ); } catch ( ClassNotFoundException e ) { // expected and correct } try { realmB.loadClass( "c.C" ); fail( "throw ClassNotFoundException" ); } catch ( ClassNotFoundException e ) { // expected and correct } } protected URL getJarUrl( String jarName ) throws MalformedURLException { return TestUtil.getTestResourceUrl( jarName ); } public void testLoadClass_ClassWorldsClassRepeatedly() throws Exception { ClassRealm mainRealm = this.world.newRealm( "main" ); for ( int i = 0; i < 100; i++ ) { Class cls = mainRealm.loadClass( "org.codehaus.classworlds.ClassWorld" ); assertNotNull( cls ); assertSame( ClassWorld.class, cls ); } } } classworlds-1.1-final.orig/src/java/test/org/codehaus/classworlds/UberJarRealmClassLoaderTest.java0000644000175000017500000001500010724631434032157 0ustar dokodokopackage org.codehaus.classworlds; import junit.framework.TestCase; import java.io.File; import java.io.InputStream; import java.net.URL; import java.util.Enumeration; import org.codehaus.classworlds.ClassWorld; import org.codehaus.classworlds.ClassRealm; import org.codehaus.classworlds.RealmClassLoader; public class UberJarRealmClassLoaderTest extends TestCase { private ClassWorld world; private ClassRealm realm; public void setUp() throws Exception { System.setProperty( "java.protocol.handler.pkgs", "org.codehaus.classworlds.uberjar.protocol" ); System.setProperty( "classworlds.bootstrapped", "true" ); world = new ClassWorld(); ClassLoader cl = Thread.currentThread().getContextClassLoader(); realm = this.world.newRealm( "realm", cl ); } public void testFindResource_Simple() throws Exception { URL url = getJarUrl( "nested.jar" ); this.realm.addConstituent( url ); RealmClassLoader cl = (RealmClassLoader) this.realm.getClassLoader(); URL resource = cl.findResource( "nested.properties" ); assertNotNull( resource ); byte[] buffer = new byte[1024]; int read = 0; StringBuffer content = new StringBuffer(); InputStream in = resource.openStream(); while ( ( read = in.read( buffer, 0, 1024 ) ) >= 0 ) { content.append( new String( buffer, 0, read ) ); } assertTrue( content.toString().startsWith( "nested.properties" ) ); } public void testFindResources_Simple() throws Exception { URL url = getJarUrl( "nested.jar" ); this.realm.addConstituent( url ); RealmClassLoader cl = (RealmClassLoader) this.realm.getClassLoader(); Enumeration e = cl.findResources( "nested.properties" ); assertNotNull( e ); int resourceCount = 0; for ( Enumeration resources = e; resources.hasMoreElements(); ) { resources.nextElement(); resourceCount++; } assertEquals( 1, resourceCount ); } public void testGetResourceAsStream_Simple() throws Exception { URL url = getJarUrl( "nested.jar" ); this.realm.addConstituent( url ); RealmClassLoader cl = (RealmClassLoader) this.realm.getClassLoader(); InputStream in = cl.getResourceAsStream( "nested.properties" ); assertNotNull( in ); String content = getContent( in ); assertTrue( content.startsWith( "nested.properties" ) ); } public void testLoadClass_Simple() throws Exception { URL url = getJarUrl( "a.jar" ); this.realm.addConstituent( url ); RealmClassLoader cl = (RealmClassLoader) this.realm.getClassLoader(); Class cls = cl.loadClass( "a.A" ); assertNotNull( cls ); cls = cl.loadClass( "java.lang.Object" ); assertNotNull( cls ); } public void testFindResource_NotFound() throws Exception { URL url = getJarUrl( "nested.jar" ); this.realm.addConstituent( url ); RealmClassLoader cl = (RealmClassLoader) this.realm.getClassLoader(); URL resource = cl.findResource( "deadbeef" ); assertNull( resource ); } public void testGetResourceAsStream_NotFound() throws Exception { URL url = getJarUrl( "nested.jar" ); this.realm.addConstituent( url ); RealmClassLoader cl = (RealmClassLoader) this.realm.getClassLoader(); InputStream in = cl.getResourceAsStream( "deadbeef" ); assertNull( in ); } protected String getContent( InputStream in ) throws Exception { byte[] buffer = new byte[1024]; int read = 0; StringBuffer content = new StringBuffer(); while ( ( read = in.read( buffer, 0, 1024 ) ) >= 0 ) { content.append( new String( buffer, 0, read ) ); } return content.toString(); } public void testFindResource_Nested() throws Exception { URL url = buildUrl( "nested.jar", "!/lib/a.jar" ); this.realm.addConstituent( url ); RealmClassLoader cl = (RealmClassLoader) this.realm.getClassLoader(); URL resource = cl.findResource( "a.properties" ); assertNotNull( resource ); InputStream in = resource.openStream(); assertNotNull( in ); String content = getContent( in ); assertTrue( content.startsWith( "a properties" ) ); } public void testFindResources_Nested() throws Exception { URL url = buildUrl( "nested.jar", "!/lib/a.jar" ); this.realm.addConstituent( url ); RealmClassLoader cl = (RealmClassLoader) this.realm.getClassLoader(); Enumeration e = cl.findResources( "a.properties" ); assertNotNull( e ); int resourceCount = 0; for ( Enumeration resources = e; resources.hasMoreElements(); ) { resources.nextElement(); resourceCount++; } assertEquals( 1, resourceCount ); } public void testGetResourceAsStream_Nested() throws Exception { URL url = buildUrl( "nested.jar", "!/lib/a.jar" ); this.realm.addConstituent( url ); RealmClassLoader cl = (RealmClassLoader) this.realm.getClassLoader(); InputStream in = cl.getResourceAsStream( "a.properties" ); assertNotNull( in ); String content = getContent( in ); assertTrue( content.startsWith( "a properties" ) ); } public void testLoadClass_Nested() throws Exception { URL url = buildUrl( "nested.jar", "!/lib/a.jar" ); this.realm.addConstituent( url ); RealmClassLoader cl = (RealmClassLoader) this.realm.getClassLoader(); Class cls = cl.loadClass( "a.A" ); assertNotNull( cls ); cls = cl.loadClass( "java.lang.Object" ); assertNotNull( cls ); } protected URL getJarUrl( String jarName ) throws Exception { File testDir = new File( System.getProperty( "basedir" ), "target/test-data" ); File jarFile = new File( testDir, jarName ); String urlText = "jar:" + jarFile.toURL(); return new URL( urlText ); } protected URL buildUrl( String jarName, String path ) throws Exception { URL jarUrl = getJarUrl( jarName ); String urlText = jarUrl.toExternalForm() + path; URL url = new URL( urlText ); return url; } } classworlds-1.1-final.orig/src/java/test/org/codehaus/classworlds/ResourcesTest.java0000644000175000017500000000666610724631434027523 0ustar dokodokopackage org.codehaus.classworlds; /* $Id: ResourcesTest.java 78 2004-07-01 13:59:13Z jvanzyl $ Copyright 2002 (C) The Werken Company. All Rights Reserved. Redistribution and use of this software and associated documentation ("Software"), with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain copyright statements and notices. Redistributions must also contain a copy of this document. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 3. The name "classworlds" must not be used to endorse or promote products derived from this Software without prior written permission of The Werken Company. For written permission, please contact bob@werken.com. 4. Products derived from this Software may not be called "classworlds" nor may "classworlds" appear in their names without prior written permission of The Werken Company. "classworlds" is a registered trademark of The Werken Company. 5. Due credit should be given to The Werken Company. (http://classworlds.werken.com/). THIS SOFTWARE IS PROVIDED BY THE WERKEN COMPANY AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE WERKEN COMPANY OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ import junit.framework.TestCase; import java.io.File; import java.io.FileInputStream; public class ResourcesTest extends TestCase { private Launcher launcher; private Configurator configurator; public ResourcesTest( String name ) { super( name ); } public void setUp() { this.launcher = new Launcher(); this.configurator = new Configurator( this.launcher ); } public void tearDown() { this.launcher = null; this.configurator = null; } public void testConfigure_Inheritance() throws Exception { this.configurator.configure( getConfigPath( "classworlds.conf" ) ); ClassWorld classWorld = launcher.getWorld(); ClassRealm rootMavenPlugin = classWorld.getRealm( "root" ); assertNotNull( rootMavenPlugin.getResource( "org/codehaus/werkflow/personality/common/core-idioms.xml" ) ); assertNotNull( rootMavenPlugin.getResource( "/org/codehaus/werkflow/personality/common/core-idioms.xml" ) ); assertNotNull( "Double dot path element is not working!", rootMavenPlugin.getResource( "org/codehaus/werkflow/personality/basic/../common/core-idioms.xml" ) ); } private FileInputStream getConfigPath( String name ) throws Exception { return new FileInputStream( new File( new File( System.getProperty( "basedir" ), "src/test-data/resources" ), name ) ); } } classworlds-1.1-final.orig/src/java/test/org/codehaus/classworlds/DefaultClassRealmTest.java0000644000175000017500000001253310724631434031072 0ustar dokodokopackage org.codehaus.classworlds; /* $Id: DefaultClassRealmTest.java 78 2004-07-01 13:59:13Z jvanzyl $ Copyright 2002 (C) The Werken Company. All Rights Reserved. Redistribution and use of this software and associated documentation ("Software"), with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain copyright statements and notices. Redistributions must also contain a copy of this document. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 3. The name "classworlds" must not be used to endorse or promote products derived from this Software without prior written permission of The Werken Company. For written permission, please contact bob@werken.com. 4. Products derived from this Software may not be called "classworlds" nor may "classworlds" appear in their names without prior written permission of The Werken Company. "classworlds" is a registered trademark of The Werken Company. 5. Due credit should be given to The Werken Company. (http://classworlds.werken.com/). THIS SOFTWARE IS PROVIDED BY THE WERKEN COMPANY AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE WERKEN COMPANY OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ import junit.framework.TestCase; import java.io.File; import java.net.URL; public class DefaultClassRealmTest extends TestCase { public DefaultClassRealmTest( String name ) { super( name ); } // ---------------------------------------------------------------------- // Class testing // ---------------------------------------------------------------------- public void testLoadClassFromRealm() throws Exception { DefaultClassRealm mainRealm = new DefaultClassRealm( new ClassWorld(), "main" ); mainRealm.addConstituent( getJarUrl( "component0-1.0.jar" ) ); mainRealm.loadClass( "org.codehaus.plexus.Component0" ); } public void testLoadClassFromChildRealmWhereClassIsLocatedInParentRealm() throws Exception { DefaultClassRealm mainRealm = new DefaultClassRealm( new ClassWorld(), "main" ); mainRealm.addConstituent( getJarUrl( "component0-1.0.jar" ) ); ClassRealm childRealm = mainRealm.createChildRealm( "child" ); childRealm.loadClass( "org.codehaus.plexus.Component0" ); } public void testLoadClassFromChildRealmWhereClassIsLocatedInGrantParentRealm() throws Exception { DefaultClassRealm mainRealm = new DefaultClassRealm( new ClassWorld(), "main" ); mainRealm.addConstituent( getJarUrl( "component0-1.0.jar" ) ); ClassRealm childRealm = mainRealm.createChildRealm( "child" ); ClassRealm grandchildRealm = childRealm.createChildRealm( "grandchild" ); grandchildRealm.loadClass( "org.codehaus.plexus.Component0" ); } public void testLoadNonExistentClass() throws Exception { DefaultClassRealm mainRealm = new DefaultClassRealm( new ClassWorld(), "main" ); mainRealm.addConstituent( getJarUrl( "component0-1.0.jar" ) ); try { mainRealm.loadClass( "org.foo.bar.NonExistentClass" ); fail( "A ClassNotFoundException should have been thrown!" ); } catch ( ClassNotFoundException e ) { } } public void testImport() throws Exception { ClassWorld world = new ClassWorld(); ClassRealm r0 = world.newRealm( "r0" ); ClassRealm r1 = world.newRealm( "r1" ); r0.addConstituent( getJarUrl( "component0-1.0.jar" ) ); r1.importFrom( "r0", "org.codehaus.plexus" ); r1.loadClass( "org.codehaus.plexus.Component0" ); } // ---------------------------------------------------------------------- // Resource testing // ---------------------------------------------------------------------- public void testResource() throws Exception { DefaultClassRealm mainRealm = new DefaultClassRealm( new ClassWorld(), "main" ); mainRealm.addConstituent( getJarUrl( "component0-1.0.jar" ) ); URL resource = mainRealm.getResource( "META-INF/plexus/components.xml" ); assertNotNull( resource ); } // ---------------------------------------------------------------------- // // ---------------------------------------------------------------------- protected URL getJarUrl( String jarName ) throws Exception { File jarFile = new File( System.getProperty( "basedir" ), "src/test-jars/" + jarName ); return jarFile.toURL(); } } classworlds-1.1-final.orig/src/java/test/org/codehaus/classworlds/ConfiguratorInheritanceTest.java0000644000175000017500000001161610724631434032354 0ustar dokodokopackage org.codehaus.classworlds; /* $Id: ConfiguratorInheritanceTest.java 126 2006-01-12 04:17:51Z $ Copyright 2002 (C) The Werken Company. All Rights Reserved. Redistribution and use of this software and associated documentation ("Software"), with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain copyright statements and notices. Redistributions must also contain a copy of this document. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 3. The name "classworlds" must not be used to endorse or promote products derived from this Software without prior written permission of The Werken Company. For written permission, please contact bob@werken.com. 4. Products derived from this Software may not be called "classworlds" nor may "classworlds" appear in their names without prior written permission of The Werken Company. "classworlds" is a registered trademark of The Werken Company. 5. Due credit should be given to The Werken Company. (http://classworlds.werken.com/). THIS SOFTWARE IS PROVIDED BY THE WERKEN COMPANY AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE WERKEN COMPANY OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ import junit.framework.TestCase; import java.io.File; import java.io.FileInputStream; import java.net.URL; import java.net.MalformedURLException; public class ConfiguratorInheritanceTest extends TestCase { private Launcher launcher; private Configurator configurator; public ConfiguratorInheritanceTest(String name) { super( name ); } public void setUp() { this.launcher = new Launcher(); this.configurator = new Configurator( this.launcher ); } public void tearDown() { this.launcher = null; this.configurator = null; } public void testConfigure_Inheritance() throws Exception { this.configurator.configure( getConfigPath( "inheritance.conf" ) ); ClassWorld classWorld = launcher.getWorld(); // Now let's look for a class in: // // 1. root.maven.plugin // 2. root.maven.plugins's parent which is root.maven // 3. root.maven's parent which is root // ClassRealm rootMavenPlugin = classWorld.getRealm( "root.maven.plugin" ); // Comes form root.maven.plugin realm. assertNotNull( rootMavenPlugin.loadClass( "c.C") ); // Comes from the root.maven realm. assertNotNull( rootMavenPlugin.loadClass( "b.B") ); // Comes from the root realm. assertNotNull( rootMavenPlugin.loadClass( "a.A") ); // Create a child realm that inherits from mommy. ClassRealm checkstyleRealm = rootMavenPlugin.createChildRealm( "checkstyle" ); assertNotNull( checkstyleRealm ); // Add a constituent. checkstyleRealm.addConstituent( getJarUrl( "d.jar" ) ); // Load from class from the child realm. We are looking for // a class in the constituent we just added. assertNotNull( checkstyleRealm.loadClass( "d.D" ) ); // Now load a class that we hope to find in a parent realm. assertNotNull( checkstyleRealm.loadClass( "a.A" ) ); // Now make sure the classloaders themselves are inheriting correctly. assertNotNull( checkstyleRealm.getClassLoader().loadClass( "d.D" ) ); assertNotNull( checkstyleRealm.getClassLoader().loadClass( "a.A" ) ); // Test inherited search for resources. assertNotNull( checkstyleRealm.getResource( "a.properties" ) ); } private FileInputStream getConfigPath(String name) throws Exception { return new FileInputStream( new File( new File( System.getProperty( "basedir" ), "target/test-data" ), name ) ) ; } protected URL getJarUrl(String jarName) throws MalformedURLException { return new File( new File( System.getProperty( "basedir" ), "target/test-data" ), jarName ).toURL(); } } classworlds-1.1-final.orig/src/java/test/org/codehaus/classworlds/ClassWorldTest.java0000644000175000017500000001030210724631434027604 0ustar dokodokopackage org.codehaus.classworlds; /* $Id: ClassWorldTest.java 78 2004-07-01 13:59:13Z jvanzyl $ Copyright 2002 (C) The Werken Company. All Rights Reserved. Redistribution and use of this software and associated documentation ("Software"), with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain copyright statements and notices. Redistributions must also contain a copy of this document. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 3. The name "classworlds" must not be used to endorse or promote products derived from this Software without prior written permission of The Werken Company. For written permission, please contact bob@werken.com. 4. Products derived from this Software may not be called "classworlds" nor may "classworlds" appear in their names without prior written permission of The Werken Company. "classworlds" is a registered trademark of The Werken Company. 5. Due credit should be given to The Werken Company. (http://classworlds.werken.com/). THIS SOFTWARE IS PROVIDED BY THE WERKEN COMPANY AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE WERKEN COMPANY OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ import junit.framework.TestCase; public class ClassWorldTest extends TestCase { private ClassWorld world; public ClassWorldTest( String name ) { super( name ); } public void setUp() { this.world = new ClassWorld(); } public void tearDown() { this.world = null; } public void testEmpty() { assertTrue( this.world.getRealms().isEmpty() ); } public void testNewRealm() throws Exception { ClassRealm realm = this.world.newRealm( "foo" ); assertNotNull( realm ); } public void testGetRealm() throws Exception { ClassRealm realm = this.world.newRealm( "foo" ); assertSame( realm, this.world.getRealm( "foo" ) ); } public void testNewRealm_Duplicate() throws Exception { try { this.world.newRealm( "foo" ); this.world.newRealm( "foo" ); fail( "throw DuplicateRealmException" ); } catch ( DuplicateRealmException e ) { // expected and correct assertSame( this.world, e.getWorld() ); assertEquals( "foo", e.getId() ); } } public void testGetRealm_NoSuch() throws Exception { try { this.world.getRealm( "foo" ); fail( "throw NoSuchRealmException" ); } catch ( NoSuchRealmException e ) { // expected and correct assertSame( this.world, e.getWorld() ); assertEquals( "foo", e.getId() ); } } public void testGetRealms() throws Exception { assertTrue( this.world.getRealms().isEmpty() ); ClassRealm foo = this.world.newRealm( "foo" ); assertEquals( 1, this.world.getRealms().size() ); assertTrue( this.world.getRealms().contains( foo ) ); ClassRealm bar = this.world.newRealm( "bar" ); assertEquals( 2, this.world.getRealms().size() ); assertTrue( this.world.getRealms().contains( bar ) ); } } classworlds-1.1-final.orig/src/java/test/org/codehaus/classworlds/RealmClassLoaderTest.java0000644000175000017500000000712010724631434030710 0ustar dokodokopackage org.codehaus.classworlds; import junit.framework.TestCase; import java.io.File; import java.io.InputStream; import java.net.URL; import java.util.Enumeration; // jars within jars // hierarchy vs graph public class RealmClassLoaderTest extends TestCase { private ClassWorld world; private ClassRealm realm; private RealmClassLoader classLoader; public void setUp() throws Exception { this.world = new ClassWorld(); this.realm = this.world.newRealm( "realm" ); this.classLoader = (RealmClassLoader) this.realm.getClassLoader(); classLoader.addConstituent( getJarUrl( "component0-1.0.jar" ) ); } public void testLoadingOfApplicationClass() throws Exception { Class c = classLoader.loadClass( "org.codehaus.plexus.Component0" ); assertNotNull( c ); } public void testLoadingOfApplicationClassThenDoingItAgain() throws Exception { Class c; c = classLoader.loadClass( "org.codehaus.plexus.Component0" ); assertNotNull( c ); c = classLoader.loadClass( "org.codehaus.plexus.Component0" ); assertNotNull( c ); } public void testLoadingOfSystemClass() throws Exception { Class c = classLoader.loadClass( "java.lang.Object" ); assertNotNull( c ); } public void testLoadingOfNonExistentClass() throws Exception { try { classLoader.loadClass( "org.codehaus.plexus.NonExistentComponent" ); fail( "Should have thrown a ClassNotFoundException!" ); } catch ( ClassNotFoundException e ) { // do nothing } } public void testGetApplicationResource() throws Exception { URL resource = classLoader.getResource( "META-INF/plexus/components.xml" ); assertNotNull( resource ); String content = getContent( resource.openStream() ); assertTrue( content.startsWith( "" ) ); } public void testGetSystemResource() throws Exception { URL resource = classLoader.getResource( "java/lang/Object.class" ); assertNotNull( resource ); } public void testGetResources() throws Exception { classLoader.addConstituent( getJarUrl( "component1-1.0.jar" ) ); Enumeration e = classLoader.getResources( "META-INF/plexus/components.xml" ); assertNotNull( e ); int resourceCount = 0; for ( Enumeration resources = e; resources.hasMoreElements(); ) { resources.nextElement(); resourceCount++; } assertEquals( 2, resourceCount ); } public void testGetResourceAsStream() throws Exception { InputStream is = classLoader.getResourceAsStream( "META-INF/plexus/components.xml" ); assertNotNull( is ); String content = getContent( is ); assertTrue( content.startsWith( "" ) ); } protected URL getJarUrl( String jarName ) throws Exception { File jarFile = new File( System.getProperty( "basedir" ), "src/test-jars/" + jarName ); return jarFile.toURL(); } protected String getContent( InputStream in ) throws Exception { byte[] buffer = new byte[1024]; int read = 0; StringBuffer content = new StringBuffer(); while ( ( read = in.read( buffer, 0, 1024 ) ) >= 0 ) { content.append( new String( buffer, 0, read ) ); } return content.toString(); } } classworlds-1.1-final.orig/src/java/test/org/codehaus/classworlds/TestUtil.java0000644000175000017500000000137010724631434026451 0ustar dokodoko/* * Created on Jul 31, 2003 * * To change this generated comment go to * Window>Preferences>Java>Code Generation>Code Template */ package org.codehaus.classworlds; import java.io.File; import java.net.MalformedURLException; import java.net.URL; /** * @author Ben Walding * @version $Id: TestUtil.java 78 2004-07-01 13:59:13Z jvanzyl $ */ public class TestUtil { public static URL getTestResourceUrl( String resourceName ) throws MalformedURLException { File baseDir = new File( System.getProperty( "basedir" ) ); File testDir = new File( baseDir, "target/test-data" ); File resourceFile = new File( testDir, resourceName ); return resourceFile.toURL(); } } classworlds-1.1-final.orig/src/java/main/0000755000175000017500000000000010724631543017054 5ustar dokodokoclassworlds-1.1-final.orig/src/java/main/org/0000755000175000017500000000000010724631543017643 5ustar dokodokoclassworlds-1.1-final.orig/src/java/main/org/codehaus/0000755000175000017500000000000010724631543021436 5ustar dokodokoclassworlds-1.1-final.orig/src/java/main/org/codehaus/classworlds/0000755000175000017500000000000010724631543023776 5ustar dokodokoclassworlds-1.1-final.orig/src/java/main/org/codehaus/classworlds/uberjar/0000755000175000017500000000000010724631543025430 5ustar dokodokoclassworlds-1.1-final.orig/src/java/main/org/codehaus/classworlds/uberjar/protocol/0000755000175000017500000000000010724631543027271 5ustar dokodokoclassworlds-1.1-final.orig/src/java/main/org/codehaus/classworlds/uberjar/protocol/jar/0000755000175000017500000000000010724631543030045 5ustar dokodoko././@LongLink0000000000000000000000000000015500000000000011566 Lustar rootrootclassworlds-1.1-final.orig/src/java/main/org/codehaus/classworlds/uberjar/protocol/jar/JarUrlConnection.javaclassworlds-1.1-final.orig/src/java/main/org/codehaus/classworlds/uberjar/protocol/jar/JarUrlConnect0000644000175000017500000002033310724631435032502 0ustar dokodokopackage org.codehaus.classworlds.uberjar.protocol.jar; /* $Id: JarUrlConnection.java 78 2004-07-01 13:59:13Z jvanzyl $ Copyright 2002 (C) The Werken Company. All Rights Reserved. Redistribution and use of this software and associated documentation ("Software"), with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain copyright statements and notices. Redistributions must also contain a copy of this document. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 3. The name "classworlds" must not be used to endorse or promote products derived from this Software without prior written permission of The Werken Company. For written permission, please contact bob@werken.com. 4. Products derived from this Software may not be called "classworlds" nor may "classworlds" appear in their names without prior written permission of The Werken Company. "classworlds" is a registered trademark of The Werken Company. 5. Due credit should be given to The Werken Company. (http://classworlds.werken.com/). THIS SOFTWARE IS PROVIDED BY THE WERKEN COMPANY AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE WERKEN COMPANY OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ import org.codehaus.classworlds.UrlUtils; import java.io.IOException; import java.io.InputStream; import java.net.JarURLConnection; import java.net.MalformedURLException; import java.net.URL; import java.net.URLDecoder; import java.util.ArrayList; import java.util.List; import java.util.StringTokenizer; import java.util.jar.JarEntry; import java.util.jar.JarFile; import java.util.jar.JarInputStream; /** * URLConnection capable of handling multiply-nested jars. * * @author bob mcwhirter * @version $Id: JarUrlConnection.java 78 2004-07-01 13:59:13Z jvanzyl $ */ public class JarUrlConnection extends JarURLConnection { // ---------------------------------------------------------------------- // Instance members // ---------------------------------------------------------------------- /** * Base resource. */ private URL baseResource; /** * Additional nested segments. */ private String[] segments; /** * Terminal input-stream. */ private InputStream in; // ---------------------------------------------------------------------- // Constructors // ---------------------------------------------------------------------- /** * Construct. * * @param url Target URL of the connections. * @throws java.io.IOException If an error occurs while attempting to initialize * the connection. */ JarUrlConnection( URL url ) throws IOException { super( url = normaliseURL( url ) ); String baseText = url.getPath(); int bangLoc = baseText.indexOf( "!" ); String baseResourceText = baseText.substring( 0, bangLoc ); String extraText = ""; if ( bangLoc <= ( baseText.length() - 2 ) && baseText.charAt( bangLoc + 1 ) == '/' ) { if ( bangLoc + 2 == baseText.length() ) { extraText = ""; } else { extraText = baseText.substring( bangLoc + 1 ); } } else { throw new MalformedURLException( "No !/ in url: " + url.toExternalForm() ); } List segments = new ArrayList(); StringTokenizer tokens = new StringTokenizer( extraText, "!" ); while ( tokens.hasMoreTokens() ) { segments.add( tokens.nextToken() ); } this.segments = (String[]) segments.toArray( new String[segments.size()] ); this.baseResource = new URL( baseResourceText ); } protected static URL normaliseURL( URL url ) throws MalformedURLException { String text = UrlUtils.normalizeUrlPath( url.toString() ); if ( !text.startsWith( "jar:" ) ) { text = "jar:" + text; } if ( text.indexOf( '!' ) < 0 ) { text = text + "!/"; } return new URL( text ); } // ---------------------------------------------------------------------- // Instance methods // ---------------------------------------------------------------------- /** * Retrieve the nesting path segments. * * @return The segments. */ protected String[] getSegments() { return this.segments; } /** * Retrieve the base resource URL. * * @return The base resource url. */ protected URL getBaseResource() { return this.baseResource; } /** * @see java.net.URLConnection */ public void connect() throws IOException { if ( this.segments.length == 0 ) { setupBaseResourceInputStream(); } else { setupPathedInputStream(); } } /** * Setup the InputStream purely from the base resource. * * @throws java.io.IOException If an I/O error occurs. */ protected void setupBaseResourceInputStream() throws IOException { this.in = getBaseResource().openStream(); } /** * Setup the InputStream for URL with nested segments. * * @throws java.io.IOException If an I/O error occurs. */ protected void setupPathedInputStream() throws IOException { InputStream curIn = getBaseResource().openStream(); for ( int i = 0; i < this.segments.length; ++i ) { curIn = getSegmentInputStream( curIn, segments[i] ); } this.in = curIn; } /** * Retrieve the InputStream for the nesting * segment relative to a base InputStream. * * @param baseIn The base input-stream. * @param segment The nesting segment path. * @return The input-stream to the segment. * @throws java.io.IOException If an I/O error occurs. */ protected InputStream getSegmentInputStream( InputStream baseIn, String segment ) throws IOException { JarInputStream jarIn = new JarInputStream( baseIn ); JarEntry entry = null; while ( jarIn.available() != 0 ) { entry = jarIn.getNextJarEntry(); if ( entry == null ) { break; } if ( ( "/" + entry.getName() ).equals( segment ) ) { return jarIn; } } throw new IOException( "unable to locate segment: " + segment ); } /** * @see java.net.URLConnection */ public InputStream getInputStream() throws IOException { if ( this.in == null ) { connect(); } return this.in; } /** * @return JarFile * @throws java.io.IOException * @see java.net.JarURLConnection#getJarFile() */ public JarFile getJarFile() throws IOException { String url = baseResource.toExternalForm(); if ( url.startsWith( "file:/" ) ) { url = url.substring( 6 ); } return new JarFile( URLDecoder.decode( url, "UTF-8" ) ); } } classworlds-1.1-final.orig/src/java/main/org/codehaus/classworlds/uberjar/protocol/jar/Handler.java0000644000175000017500000001247410724631435032275 0ustar dokodokopackage org.codehaus.classworlds.uberjar.protocol.jar; /* $Id: Handler.java 126 2006-01-12 04:17:51Z $ Copyright 2002 (C) The Werken Company. All Rights Reserved. Redistribution and use of this software and associated documentation ("Software"), with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain copyright statements and notices. Redistributions must also contain a copy of this document. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 3. The name "classworlds" must not be used to endorse or promote products derived from this Software without prior written permission of The Werken Company. For written permission, please contact bob@werken.com. 4. Products derived from this Software may not be called "classworlds" nor may "classworlds" appear in their names without prior written permission of The Werken Company. "classworlds" is a registered trademark of The Werken Company. 5. Due credit should be given to The Werken Company. (http://classworlds.werken.com/). THIS SOFTWARE IS PROVIDED BY THE WERKEN COMPANY AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE WERKEN COMPANY OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ import java.io.IOException; import java.net.URL; import java.net.URLConnection; import java.net.URLStreamHandler; /** * URLStreamHandler for jar: protocol URLs. * * @author bob mcwhirter * @version $Id: Handler.java 126 2006-01-12 04:17:51Z $ */ public class Handler extends URLStreamHandler { // ---------------------------------------------------------------------- // Class members // ---------------------------------------------------------------------- /** * Singleton instance. */ private static final Handler INSTANCE = new Handler(); // ---------------------------------------------------------------------- // Class methods // ---------------------------------------------------------------------- /** * Retrieve the singleton instance. * * @return The singleton instance. */ public static Handler getInstance() { return INSTANCE; } // ---------------------------------------------------------------------- // Constructors // ---------------------------------------------------------------------- /** * Construct. */ public Handler() { // intentionally left blank } // ---------------------------------------------------------------------- // Instance methods // ---------------------------------------------------------------------- /** * @see java.net.URLStreamHandler */ public URLConnection openConnection( URL url ) throws IOException { return new JarUrlConnection( url ); } /** * @see java.net.URLStreamHandler */ public void parseURL( URL url, String spec, int start, int limit ) { String specPath = spec.substring( start, limit ); String urlPath = null; if ( specPath.charAt( 0 ) == '/' ) { urlPath = specPath; } else if ( specPath.charAt( 0 ) == '!' ) { String relPath = url.getFile(); int bangLoc = relPath.lastIndexOf( "!" ); if ( bangLoc < 0 ) { urlPath = relPath + specPath; } else { urlPath = relPath.substring( 0, bangLoc ) + specPath; } } else { String relPath = url.getFile(); if ( relPath != null ) { int lastSlashLoc = relPath.lastIndexOf( "/" ); if ( lastSlashLoc < 0 ) { urlPath = "/" + specPath; } else { urlPath = relPath.substring( 0, lastSlashLoc + 1 ) + specPath; } } else { urlPath = specPath; } } setURL( url, "jar", "", 0, null, null, urlPath, null, null ); } } classworlds-1.1-final.orig/src/java/main/org/codehaus/classworlds/uberjar/boot/0000755000175000017500000000000010724631543026373 5ustar dokodokoclassworlds-1.1-final.orig/src/java/main/org/codehaus/classworlds/uberjar/boot/Bootstrapper.java0000644000175000017500000001517710724631435031735 0ustar dokodokopackage org.codehaus.classworlds.uberjar.boot; /* $Id: Bootstrapper.java 78 2004-07-01 13:59:13Z jvanzyl $ Copyright 2002 (C) The Werken Company. All Rights Reserved. Redistribution and use of this software and associated documentation ("Software"), with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain copyright statements and notices. Redistributions must also contain a copy of this document. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 3. The name "classworlds" must not be used to endorse or promote products derived from this Software without prior written permission of The Werken Company. For written permission, please contact bob@werken.com. 4. Products derived from this Software may not be called "classworlds" nor may "classworlds" appear in their names without prior written permission of The Werken Company. "classworlds" is a registered trademark of The Werken Company. 5. Due credit should be given to The Werken Company. (http://classworlds.werken.com/). THIS SOFTWARE IS PROVIDED BY THE WERKEN COMPANY AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE WERKEN COMPANY OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ import java.lang.reflect.Method; import java.lang.reflect.Modifier; /** * Bootstrapping entry-point. *

*

* The Bootstrapper is to be used for standalone jars * which carry all dependency jars within them. The layout for * the dependency jar should be similar to: *

*

*

 *    myjar/
 *          classworlds.conf
 *          org/
 *              codehaus/
 *                     classworlds/
 *                                 boot/
 *                                 protocol/
 *          lib/
 *              myapp.jar
 *              depOne.jar
 *              depTwo.jar
 *  
* * @author Jason van Zyl * @author bob mcwhirter * @version $Id: Bootstrapper.java 78 2004-07-01 13:59:13Z jvanzyl $ */ public class Bootstrapper { // ---------------------------------------------------------------------- // Constants // ---------------------------------------------------------------------- /** * Main classworlds entry class. */ public static final String LAUNCHER_CLASS_NAME = "org.codehaus.classworlds.Launcher"; // ---------------------------------------------------------------------- // Instance members // ---------------------------------------------------------------------- /** * Command-line args. */ private String[] args; /** * Initial bootstrapping classloader. */ private InitialClassLoader classLoader; // ---------------------------------------------------------------------- // Class methods // ---------------------------------------------------------------------- /** * Main entry-point. * * @param args Command-line arguments. * @throws Exception If an error occurs. */ public static void main( String[] args ) throws Exception { System.setProperty( "java.protocol.handler.pkgs", "org.codehaus.classworlds.uberjar.protocol" ); Bootstrapper bootstrapper = new Bootstrapper( args ); bootstrapper.bootstrap(); } // ---------------------------------------------------------------------- // Constructors // ---------------------------------------------------------------------- /** * Construct. * * @param args Command-line arguments. * @throws Exception If an error occurs attempting to perform * bootstrap initialization. */ public Bootstrapper( String[] args ) throws Exception { this.args = args; this.classLoader = new InitialClassLoader(); } // ---------------------------------------------------------------------- // Instance methods // ---------------------------------------------------------------------- /** * Retrieve the initial bootstrapping ClassLoader. * * @return The classloader. */ protected ClassLoader getInitialClassLoader() { return this.classLoader; } /** * Perform bootstrap. * * @throws Exception If an error occurs while bootstrapping. */ public void bootstrap() throws Exception { ClassLoader cl = getInitialClassLoader(); Class launcherClass = cl.loadClass( LAUNCHER_CLASS_NAME ); Method[] methods = launcherClass.getMethods(); Method mainMethod = null; for ( int i = 0; i < methods.length; ++i ) { if ( !"main".equals( methods[i].getName() ) ) { continue; } int modifiers = methods[i].getModifiers(); if ( !( Modifier.isStatic( modifiers ) && Modifier.isPublic( modifiers ) ) ) { continue; } if ( methods[i].getReturnType() != Void.TYPE ) { continue; } Class[] paramTypes = methods[i].getParameterTypes(); if ( paramTypes.length != 1 ) { continue; } if ( paramTypes[0] != String[].class ) { continue; } mainMethod = methods[i]; break; } if ( mainMethod == null ) { throw new NoSuchMethodException( LAUNCHER_CLASS_NAME + "::main(String[] args)" ); } System.setProperty( "classworlds.bootstrapped", "true" ); mainMethod.invoke( launcherClass, new Object[]{this.args} ); } } ././@LongLink0000000000000000000000000000014700000000000011567 Lustar rootrootclassworlds-1.1-final.orig/src/java/main/org/codehaus/classworlds/uberjar/boot/InitialClassLoader.javaclassworlds-1.1-final.orig/src/java/main/org/codehaus/classworlds/uberjar/boot/InitialClassLoader.ja0000644000175000017500000001515010724631435032417 0ustar dokodokopackage org.codehaus.classworlds.uberjar.boot; /* $Id: InitialClassLoader.java 78 2004-07-01 13:59:13Z jvanzyl $ Copyright 2002 (C) The Werken Company. All Rights Reserved. Redistribution and use of this software and associated documentation ("Software"), with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain copyright statements and notices. Redistributions must also contain a copy of this document. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 3. The name "classworlds" must not be used to endorse or promote products derived from this Software without prior written permission of The Werken Company. For written permission, please contact bob@werken.com. 4. Products derived from this Software may not be called "classworlds" nor may "classworlds" appear in their names without prior written permission of The Werken Company. "classworlds" is a registered trademark of The Werken Company. 5. Due credit should be given to The Werken Company. (http://classworlds.werken.com/). THIS SOFTWARE IS PROVIDED BY THE WERKEN COMPANY AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE WERKEN COMPANY OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ import java.io.ByteArrayOutputStream; import java.io.IOException; import java.net.URL; import java.security.SecureClassLoader; import java.util.Map; import java.util.HashMap; import java.util.jar.JarInputStream; import java.util.jar.JarEntry; /** * Initial bootstrapping ClassLoader. * * @author Jason van Zyl * @author bob mcwhirter * @version $Id: InitialClassLoader.java 78 2004-07-01 13:59:13Z jvanzyl $ */ public class InitialClassLoader extends SecureClassLoader { // ---------------------------------------------------------------------- // Instance members // ---------------------------------------------------------------------- /** * Class index. */ private Map index; /** * Classworlds jar URL. */ private URL classworldsJarUrl; // ---------------------------------------------------------------------- // Constructors // ---------------------------------------------------------------------- /** * Construct. * * @throws Exception If an error occurs while attempting to perform * bootstrap initialization. */ public InitialClassLoader() throws Exception { this.index = new HashMap(); ClassLoader cl = Thread.currentThread().getContextClassLoader(); URL classUrl = getClass().getResource( "InitialClassLoader.class" ); String urlText = classUrl.toExternalForm(); int bangLoc = urlText.indexOf( "!" ); System.setProperty( "classworlds.lib", urlText.substring( 0, bangLoc ) + "!/WORLDS-INF/lib" ); this.classworldsJarUrl = new URL( urlText.substring( 0, bangLoc ) + "!/WORLDS-INF/classworlds.jar" ); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - /** * @see ClassLoader */ public synchronized Class findClass( String className ) throws ClassNotFoundException { String classPath = className.replace( '.', '/' ) + ".class"; if ( this.index.containsKey( classPath ) ) { return (Class) this.index.get( classPath ); } try { JarInputStream in = new JarInputStream( this.classworldsJarUrl.openStream() ); try { JarEntry entry = null; while ( ( entry = in.getNextJarEntry() ) != null ) { if ( entry.getName().equals( classPath ) ) { ByteArrayOutputStream out = new ByteArrayOutputStream(); try { byte[] buffer = new byte[2048]; int read = 0; while ( in.available() > 0 ) { read = in.read( buffer, 0, buffer.length ); if ( read < 0 ) { break; } out.write( buffer, 0, read ); } buffer = out.toByteArray(); Class cls = defineClass( className, buffer, 0, buffer.length ); this.index.put( className, cls ); return cls; } finally { out.close(); } } } } finally { in.close(); } } catch ( IOException e ) { e.printStackTrace(); throw new ClassNotFoundException( "io error reading stream for: " + className ); } throw new ClassNotFoundException( className ); } } classworlds-1.1-final.orig/src/java/main/org/codehaus/classworlds/NoSuchRealmException.java0000644000175000017500000000644710724631435030713 0ustar dokodokopackage org.codehaus.classworlds; /* $Id: NoSuchRealmException.java 78 2004-07-01 13:59:13Z jvanzyl $ Copyright 2002 (C) The Werken Company. All Rights Reserved. Redistribution and use of this software and associated documentation ("Software"), with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain copyright statements and notices. Redistributions must also contain a copy of this document. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 3. The name "classworlds" must not be used to endorse or promote products derived from this Software without prior written permission of The Werken Company. For written permission, please contact bob@werken.com. 4. Products derived from this Software may not be called "classworlds" nor may "classworlds" appear in their names without prior written permission of The Werken Company. "classworlds" is a registered trademark of The Werken Company. 5. Due credit should be given to The Werken Company. (http://classworlds.werken.com/). THIS SOFTWARE IS PROVIDED BY THE WERKEN COMPANY AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE WERKEN COMPANY OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ /** * Indicates an attempt to retrieve a ClassRealm from a * ClassWorld with an invalid id. * * @author bob mcwhirter * @version $Id: NoSuchRealmException.java 78 2004-07-01 13:59:13Z jvanzyl $ */ public class NoSuchRealmException extends ClassWorldException { // ------------------------------------------------------------ // Instance members // ------------------------------------------------------------ /** * The realm id. */ private String id; // ------------------------------------------------------------ // Constructors // ------------------------------------------------------------ /** * Construct. * * @param world The world. * @param id The realm id. */ public NoSuchRealmException( ClassWorld world, String id ) { super( world, id ); this.id = id; } // ------------------------------------------------------------ // Instance methods // ------------------------------------------------------------ /** * Retrieve the invalid realm id. * * @return The id. */ public String getId() { return this.id; } } classworlds-1.1-final.orig/src/java/main/org/codehaus/classworlds/RealmDelegatingClassLoader.java0000644000175000017500000000154310724631435032005 0ustar dokodokopackage org.codehaus.classworlds; import java.io.IOException; import java.io.InputStream; import java.net.URL; import java.util.Enumeration; /** * @author jdcasey */ public class RealmDelegatingClassLoader extends ClassLoader { private final ClassRealm realm; public RealmDelegatingClassLoader(ClassRealm realm) { this.realm = realm; } protected Enumeration findResources( String name ) throws IOException { return realm.findResources( name ); } public URL getResource( String name ) { return realm.getResource( name ); } public InputStream getResourceAsStream( String name ) { return realm.getResourceAsStream( name ); } public Class loadClass( String name ) throws ClassNotFoundException { return realm.loadClass( name ); } } classworlds-1.1-final.orig/src/java/main/org/codehaus/classworlds/Launcher.java0000644000175000017500000003565610724631435026421 0ustar dokodokopackage org.codehaus.classworlds; /* $Id: Launcher.java 126 2006-01-12 04:17:51Z $ Copyright 2002 (C) The Werken Company. All Rights Reserved. Redistribution and use of this software and associated documentation ("Software"), with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain copyright statements and notices. Redistributions must also contain a copy of this document. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 3. The name "classworlds" must not be used to endorse or promote products derived from this Software without prior written permission of The Werken Company. For written permission, please contact bob@werken.com. 4. Products derived from this Software may not be called "classworlds" nor may "classworlds" appear in their names without prior written permission of The Werken Company. "classworlds" is a registered trademark of The Werken Company. 5. Due credit should be given to The Werken Company. (http://classworlds.werken.com/). THIS SOFTWARE IS PROVIDED BY THE WERKEN COMPANY AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE WERKEN COMPANY OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ import java.io.IOException; import java.io.InputStream; import java.io.FileInputStream; import java.lang.reflect.Method; import java.lang.reflect.Modifier; import java.lang.reflect.InvocationTargetException; import java.net.MalformedURLException; import java.net.URL; /** * Command-line invokable application launcher. *

*

* This launcher class assists in the creation of classloaders and ClassRealms * from a configuration file and the launching of the application's main * method from the correct class loaded through the correct classloader. *

*

*

* The path to the configuration file is specified using the classworlds.conf * system property, typically specified using the -D switch to * java. *

* * @author bob mcwhirter * @version $Id: Launcher.java 126 2006-01-12 04:17:51Z $ */ public class Launcher { protected static final String CLASSWORLDS_CONF = "classworlds.conf"; protected static final String UBERJAR_CONF_DIR = "WORLDS-INF/conf/"; protected ClassLoader systemClassLoader; protected String mainClassName; protected String mainRealmName; protected ClassWorld world; private int exitCode = 0; public Launcher() { } public void setSystemClassLoader( ClassLoader loader ) { this.systemClassLoader = loader; } public ClassLoader getSystemClassLoader() { return this.systemClassLoader; } public int getExitCode() { return exitCode; } public void setAppMain( String mainClassName, String mainRealmName ) { this.mainClassName = mainClassName; this.mainRealmName = mainRealmName; } public String getMainRealmName() { return this.mainRealmName; } public String getMainClassName() { return this.mainClassName; } public void setWorld( ClassWorld world ) { this.world = world; } public ClassWorld getWorld() { return this.world; } /** * Configure from a file. * * @param is The config input stream. * @throws IOException If an error occurs reading the config file. * @throws MalformedURLException If the config file contains invalid URLs. * @throws ConfigurationException If the config file is corrupt. * @throws DuplicateRealmException If the config file defines two realms * with the same id. * @throws NoSuchRealmException If the config file defines a main entry * point in a non-existent realm. */ public void configure( InputStream is ) throws IOException, MalformedURLException, ConfigurationException, DuplicateRealmException, NoSuchRealmException { Configurator configurator = new Configurator( this ); configurator.configure( is ); } /** * Retrieve the main entry class. * * @return The main entry class. * @throws ClassNotFoundException If the class cannot be found. * @throws NoSuchRealmException If the specified main entry realm does not exist. */ public Class getMainClass() throws ClassNotFoundException, NoSuchRealmException { return getMainRealm().loadClass( getMainClassName() ); } /** * Retrieve the main entry realm. * * @return The main entry realm. * @throws NoSuchRealmException If the specified main entry realm does not exist. */ public ClassRealm getMainRealm() throws NoSuchRealmException { return getWorld().getRealm( getMainRealmName() ); } /** * Retrieve the enhanced main entry method. * * @return The enhanced main entry method. * @throws ClassNotFoundException If the main entry class cannot be found. * @throws NoSuchMethodException If the main entry method cannot be found. * @throws NoSuchRealmException If the main entry realm cannot be found. */ protected Method getEnhancedMainMethod() throws ClassNotFoundException, NoSuchMethodException, NoSuchRealmException { Method[] methods = getMainClass().getMethods(); Class cwClass = getMainRealm().loadClass( ClassWorld.class.getName() ); Method m = getMainClass().getMethod( "main", new Class[] { String[].class, cwClass } ); int modifiers = m.getModifiers(); if ( Modifier.isStatic( modifiers ) && Modifier.isPublic( modifiers ) ) { if ( m.getReturnType() == Integer.TYPE || m.getReturnType() == Void.TYPE ) { return m; } } throw new NoSuchMethodException( "public static void main(String[] args, ClassWorld world)" ); } /** * Retrieve the main entry method. * * @return The main entry method. * @throws ClassNotFoundException If the main entry class cannot be found. * @throws NoSuchMethodException If the main entry method cannot be found. * @throws NoSuchRealmException If the main entry realm cannot be found. */ protected Method getMainMethod() throws ClassNotFoundException, NoSuchMethodException, NoSuchRealmException { Method m = getMainClass().getMethod( "main", new Class[] { String[].class } ); int modifiers = m.getModifiers(); if ( Modifier.isStatic( modifiers ) && Modifier.isPublic( modifiers ) ) { if ( m.getReturnType() == Integer.TYPE || m.getReturnType() == Void.TYPE ) { return m; } } throw new NoSuchMethodException( "public static void main(String[] args) in " + getMainClass() ); } /** * Launch the application. * * @param args The application args. * @throws ClassNotFoundException If the main entry class cannot be found. * @throws IllegalAccessException If the method cannot be accessed. * @throws InvocationTargetException If the target of the invokation is invalid. * @throws NoSuchMethodException If the main entry method cannot be found. * @throws NoSuchRealmException If the main entry realm cannot be found. */ public void launch( String[] args ) throws ClassNotFoundException, IllegalAccessException, InvocationTargetException, NoSuchMethodException, NoSuchRealmException { try { launchEnhanced( args ); return; } catch ( NoSuchMethodException e ) { // ignore } launchStandard( args ); } /** * Attempt to launch the application through the enhanced main method. *

*

* This will seek a method with the exact signature of: *

*

*

     *  public static void main(String[] args, ClassWorld world)
     *  
* * @param args The application args. * @throws ClassNotFoundException If the main entry class cannot be found. * @throws IllegalAccessException If the method cannot be accessed. * @throws InvocationTargetException If the target of the invokation is * invalid. * @throws NoSuchMethodException If the main entry method cannot be found. * @throws NoSuchRealmException If the main entry realm cannot be found. */ protected void launchEnhanced( String[] args ) throws ClassNotFoundException, IllegalAccessException, InvocationTargetException, NoSuchMethodException, NoSuchRealmException { ClassRealm mainRealm = getMainRealm(); Class mainClass = getMainClass(); Method mainMethod = getEnhancedMainMethod(); ClassLoader cl = mainRealm.getClassLoader(); // ---------------------------------------------------------------------- // This is what the classloader for the main realm looks like when we // boot from the command line: // ---------------------------------------------------------------------- // [ AppLauncher$AppClassLoader ] : $CLASSPATH envar // ^ // | // | // [ AppLauncher$ExtClassLoader ] : ${java.home}/jre/lib/ext/*.jar // ^ // | // | // [ RealmClassLoader ] // ---------------------------------------------------------------------- Thread.currentThread().setContextClassLoader( cl ); Object ret = mainMethod.invoke( mainClass, new Object[]{args, getWorld()} ); if ( ret instanceof Integer ) { exitCode = ( ( Integer ) ret ).intValue(); } } /** * Attempt to launch the application through the standard main method. *

*

* This will seek a method with the exact signature of: *

*

*

     *  public static void main(String[] args)
     *  
* * @param args The application args. * @throws ClassNotFoundException If the main entry class cannot be found. * @throws IllegalAccessException If the method cannot be accessed. * @throws InvocationTargetException If the target of the invokation is * invalid. * @throws NoSuchMethodException If the main entry method cannot be found. * @throws NoSuchRealmException If the main entry realm cannot be found. */ protected void launchStandard( String[] args ) throws ClassNotFoundException, IllegalAccessException, InvocationTargetException, NoSuchMethodException, NoSuchRealmException { ClassRealm mainRealm = getMainRealm(); Class mainClass = getMainClass(); Method mainMethod = getMainMethod(); Thread.currentThread().setContextClassLoader( mainRealm.getClassLoader() ); Object ret = mainMethod.invoke( mainClass, new Object[]{args} ); if ( ret instanceof Integer ) { exitCode = ( ( Integer ) ret ).intValue(); } } // ------------------------------------------------------------ // Class methods // ------------------------------------------------------------ /** * Launch the launcher from the command line. * Will exit using System.exit with an exit code of 0 for success, 100 if there was an unknown exception, * or some other code for an application error. * * @param args The application command-line arguments. */ public static void main( String[] args ) { try { int exitCode = mainWithExitCode( args ); System.exit( exitCode ); } catch ( Exception e ) { e.printStackTrace(); System.exit( 100 ); } } /** * Launch the launcher. * * @param args The application command-line arguments. * @return an integer exit code * @throws Exception If an error occurs. */ public static int mainWithExitCode( String[] args ) throws Exception { String classworldsConf = System.getProperty( CLASSWORLDS_CONF ); InputStream is = null; Launcher launcher = new Launcher(); ClassLoader cl = Thread.currentThread().getContextClassLoader(); launcher.setSystemClassLoader( cl ); if ( classworldsConf != null ) { is = new FileInputStream( classworldsConf ); } else { if ( "true".equals( System.getProperty( "classworlds.bootstrapped" ) ) ) { is = cl.getResourceAsStream( UBERJAR_CONF_DIR + CLASSWORLDS_CONF ); } else { is = cl.getResourceAsStream( CLASSWORLDS_CONF ); } } if ( is == null ) { throw new Exception( "classworlds configuration not specified nor found in the classpath" ); } launcher.configure( is ); try { launcher.launch( args ); } catch ( InvocationTargetException e ) { ClassRealm realm = launcher.getWorld().getRealm( launcher.getMainRealmName() ); URL[] constituents = realm.getConstituents(); System.out.println( "---------------------------------------------------" ); for ( int i = 0; i < constituents.length; i++ ) { System.out.println( "constituent[" + i + "]: " + constituents[i] ); } System.out.println( "---------------------------------------------------" ); // Decode ITE (if we can) Throwable t = e.getTargetException(); if ( t instanceof Exception ) { throw (Exception) t; } if ( t instanceof Error ) { throw (Error) t; } // Else just toss the ITE throw e; } return launcher.getExitCode(); } } classworlds-1.1-final.orig/src/java/main/org/codehaus/classworlds/Entry.java0000644000175000017500000001200310724631435025736 0ustar dokodokopackage org.codehaus.classworlds; /* $Id: Entry.java 126 2006-01-12 04:17:51Z $ Copyright 2002 (C) The Werken Company. All Rights Reserved. Redistribution and use of this software and associated documentation ("Software"), with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain copyright statements and notices. Redistributions must also contain a copy of this document. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 3. The name "classworlds" must not be used to endorse or promote products derived from this Software without prior written permission of The Werken Company. For written permission, please contact bob@werken.com. 4. Products derived from this Software may not be called "classworlds" nor may "classworlds" appear in their names without prior written permission of The Werken Company. "classworlds" is a registered trademark of The Werken Company. 5. Due credit should be given to The Werken Company. (http://classworlds.werken.com/). THIS SOFTWARE IS PROVIDED BY THE WERKEN COMPANY AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE WERKEN COMPANY OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ /** * Import description entry. * * @author bob mcwhirter */ class Entry implements Comparable { private final ClassRealm realm; private final String pkgName; Entry( ClassRealm realm, String pkgName ) { this.realm = realm; this.pkgName = pkgName; } // ------------------------------------------------------------ // Instance methods // ------------------------------------------------------------ /** * Retrieve the realm. * * @return The realm. */ ClassRealm getRealm() { return this.realm; } /** * Retrieve the page name. * * @return The package name. */ String getPackageName() { return this.pkgName; } /** * Determine if the classname matches the package * described by this entry. * * @param classname The class name to test. * @return true if this entry matches the * classname, otherwise false. */ boolean matches( String classname ) { return classname.startsWith( getPackageName() ); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // java.lang.Comparable // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - /** * Compare this entry to another for relative ordering. *

*

* The natural ordering of Entry objects is reverse-alphabetical * based upon package name. *

* * @param thatObj The object to compare. * @return -1 if this object sorts before that object, 0 * if they are equal, or 1 if this object sorts * after that object. */ public int compareTo( Object thatObj ) { Entry that = (Entry) thatObj; // We are reverse sorting this list, so that // we get longer matches first: // // com.werken.foo.bar // com.werken.foo // com.werken return ( getPackageName().compareTo( that.getPackageName() ) ) * -1; } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // java.lang.Object // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - /** * Test this entry for equality to another. *

*

* Consistent with {@link #compareTo}, this method tests * for equality purely on the package name. *

* * @param thatObj The object to compare * @return true if the two objects are * semantically equivalent, otherwise false. */ public boolean equals( Object thatObj ) { Entry that = (Entry) thatObj; return getPackageName().equals( that.getPackageName() ); } /** *

* Consistent with {@link #equals}, this method creates a hashCode * based on the packagename. *

*/ public int hashCode() { return getPackageName().hashCode(); } } classworlds-1.1-final.orig/src/java/main/org/codehaus/classworlds/Configurator.java0000644000175000017500000004360710724631435027315 0ustar dokodokopackage org.codehaus.classworlds; /* $Id: Configurator.java 126 2006-01-12 04:17:51Z $ Copyright 2002 (C) The Werken Company. All Rights Reserved. Redistribution and use of this software and associated documentation ("Software"), with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain copyright statements and notices. Redistributions must also contain a copy of this document. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 3. The name "classworlds" must not be used to endorse or promote products derived from this Software without prior written permission of The Werken Company. For written permission, please contact bob@werken.com. 4. Products derived from this Software may not be called "classworlds" nor may "classworlds" appear in their names without prior written permission of The Werken Company. "classworlds" is a registered trademark of The Werken Company. 5. Due credit should be given to The Werken Company. (http://classworlds.werken.com/). THIS SOFTWARE IS PROVIDED BY THE WERKEN COMPANY AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE WERKEN COMPANY OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ import java.io.BufferedReader; import java.io.File; import java.io.FileNotFoundException; import java.io.FilenameFilter; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.FileInputStream; import java.net.MalformedURLException; import java.net.URL; import java.util.ArrayList; import java.util.Collections; import java.util.Comparator; import java.util.HashMap; import java.util.Iterator; import java.util.List; import java.util.Map; import java.util.Properties; /** * Launcher configurator. * * @author bob mcwhirter * @author Jason van Zyl * @version $Id: Configurator.java 126 2006-01-12 04:17:51Z $ */ public class Configurator { public static final String MAIN_PREFIX = "main is"; public static final String SET_PREFIX = "set"; public static final String IMPORT_PREFIX = "import"; public static final String LOAD_PREFIX = "load"; /** Optionally spec prefix. */ public static final String OPTIONALLY_PREFIX = "optionally"; /** The launcher to configure. */ private Launcher launcher; private ClassWorld world; /** Processed Realms. */ private Map configuredRealms; /** Construct. * * @param launcher The launcher to configure. */ public Configurator( Launcher launcher ) { this.launcher = launcher; configuredRealms = new HashMap(); } /** Construct. * * @param classWorld The classWorld to configure. */ public Configurator( ClassWorld world ) { setClassWorld( world ); } /** set world. * this setter is provided so you can use the same configurator to configure several "worlds" * * @param classWorld The classWorld to configure. */ public void setClassWorld( ClassWorld world ) { this.world = world; configuredRealms = new HashMap(); } /** * Configure from a file. * * @param is The config input stream * @throws IOException If an error occurs reading the config file. * @throws MalformedURLException If the config file contains invalid URLs. * @throws ConfigurationException If the config file is corrupt. * @throws DuplicateRealmException If the config file defines two realms with the same id. * @throws NoSuchRealmException If the config file defines a main entry point in * a non-existent realm. */ public void configure( InputStream is ) throws IOException, MalformedURLException, ConfigurationException, DuplicateRealmException, NoSuchRealmException { BufferedReader reader = new BufferedReader( new InputStreamReader( is ) ); if ( world == null ) { world = new ClassWorld(); } ClassLoader foreignClassLoader = null; if ( this.launcher != null ) foreignClassLoader = this.launcher.getSystemClassLoader(); ClassRealm curRealm = null; String line = null; int lineNo = 0; boolean mainSet = false; while ( true ) { line = reader.readLine(); if ( line == null ) { break; } ++lineNo; line = line.trim(); if ( canIgnore( line ) ) { continue; } if ( line.startsWith( MAIN_PREFIX ) ) { if ( mainSet ) { throw new ConfigurationException( "Duplicate main configuration", lineNo, line ); } String conf = line.substring( MAIN_PREFIX.length() ).trim(); int fromLoc = conf.indexOf( "from" ); if ( fromLoc < 0 ) { throw new ConfigurationException( "Missing from clause", lineNo, line ); } String mainClassName = conf.substring( 0, fromLoc ).trim(); String mainRealmName = conf.substring( fromLoc + 4 ).trim(); if ( this.launcher != null ) { this.launcher.setAppMain( mainClassName, mainRealmName ); } mainSet = true; } else if ( line.startsWith( SET_PREFIX ) ) { String conf = line.substring( SET_PREFIX.length() ).trim(); int usingLoc = conf.indexOf( " using" ) + 1; String property = null; String propertiesFileName = null; if ( usingLoc > 0 ) { property = conf.substring( 0, usingLoc ).trim(); propertiesFileName = filter( conf.substring( usingLoc + 5 ).trim() ); conf = propertiesFileName; } String defaultValue = null; int defaultLoc = conf.indexOf( " default" ) + 1; if ( defaultLoc > 0 ) { defaultValue = conf.substring( defaultLoc + 7 ).trim(); if ( property == null ) { property = conf.substring( 0, defaultLoc ).trim(); } else { propertiesFileName = conf.substring( 0, defaultLoc ).trim(); } } String value = System.getProperty( property ); if ( value != null ) { continue; } if ( propertiesFileName != null ) { File propertiesFile = new File( propertiesFileName ); if ( propertiesFile.exists() ) { Properties properties = new Properties(); try { properties.load( new FileInputStream( propertiesFileName ) ); value = properties.getProperty( property ); } catch ( Exception e ) { // do nothing } } } if ( value == null && defaultValue != null ) { value = defaultValue; } if ( value != null ) { value = filter( value ); System.setProperty( property, value ); } } else if ( line.startsWith( "[" ) ) { int rbrack = line.indexOf( "]" ); if ( rbrack < 0 ) { throw new ConfigurationException( "Invalid realm specifier", lineNo, line ); } String realmName = line.substring( 1, rbrack ); curRealm = world.newRealm( realmName, foreignClassLoader ); // Stash the configured realm for subsequent association processing. configuredRealms.put( realmName, curRealm ); } else if ( line.startsWith( IMPORT_PREFIX ) ) { if ( curRealm == null ) { throw new ConfigurationException( "Unhandled import", lineNo, line ); } String conf = line.substring( IMPORT_PREFIX.length() ).trim(); int fromLoc = conf.indexOf( "from" ); if ( fromLoc < 0 ) { throw new ConfigurationException( "Missing from clause", lineNo, line ); } String importSpec = conf.substring( 0, fromLoc ).trim(); String relamName = conf.substring( fromLoc + 4 ).trim(); curRealm.importFrom( relamName, importSpec ); } else if ( line.startsWith( LOAD_PREFIX ) ) { String constituent = line.substring( LOAD_PREFIX.length() ).trim(); constituent = filter( constituent ); if ( constituent.indexOf( "*" ) >= 0 ) { loadGlob( constituent, curRealm ); } else { File file = new File( constituent ); if ( file.exists() ) { curRealm.addConstituent( file.toURL() ); } else { try { curRealm.addConstituent( new URL( constituent ) ); } catch ( MalformedURLException e ) { throw new FileNotFoundException( constituent ); } } } } else if ( line.startsWith( OPTIONALLY_PREFIX ) ) { String constituent = line.substring( OPTIONALLY_PREFIX.length() ).trim(); constituent = filter( constituent ); if ( constituent.indexOf( "*" ) >= 0 ) { loadGlob( constituent, curRealm, true ); } else { File file = new File( constituent ); if ( file.exists() ) { curRealm.addConstituent( file.toURL() ); } else { try { curRealm.addConstituent( new URL( constituent ) ); } catch (MalformedURLException e) { // swallow } } } } else { throw new ConfigurationException( "Unhandled configuration", lineNo, line ); } } // Associate child realms to their parents. associateRealms(); if ( this.launcher != null ) this.launcher.setWorld( world ); reader.close(); } /** * Associate parent realms with their children. */ protected void associateRealms() { List sortRealmNames = new ArrayList( configuredRealms.keySet() ); // sort by name Comparator comparator = new Comparator() { public int compare( Object o1, Object o2 ) { String g1 = (String) o1; String g2 = (String) o2; return g1.compareTo( g2 ); } }; Collections.sort( sortRealmNames, comparator ); // So now we have something like the following for defined // realms: // // root // root.maven // root.maven.plugin // // Now if the name of a realm is a superset of an existing realm // the we want to make child/parent associations. for ( Iterator i = sortRealmNames.iterator(); i.hasNext(); ) { String realmName = (String) i.next(); int j = realmName.lastIndexOf( '.' ); if ( j > 0 ) { String parentRealmName = realmName.substring( 0, j ); ClassRealm parentRealm = (ClassRealm) configuredRealms.get( parentRealmName ); if ( parentRealm != null ) { ClassRealm realm = (ClassRealm) configuredRealms.get( realmName ); realm.setParent( parentRealm ); } } } } /** * Load a glob into the specified classloader. * * @param line The path configuration line. * @param realm The realm to populate * @throws MalformedURLException If the line does not represent * a valid path element. * @throws FileNotFoundException If the line does not represent * a valid path element in the filesystem. */ protected void loadGlob( String line, ClassRealm realm ) throws MalformedURLException, FileNotFoundException { loadGlob( line, realm, false ); } /** * Load a glob into the specified classloader. * * @param line The path configuration line. * @param realm The realm to populate * @param optionally Whether the path is optional or required * @throws MalformedURLException If the line does not represent * a valid path element. * @throws FileNotFoundException If the line does not represent * a valid path element in the filesystem. */ protected void loadGlob( String line, ClassRealm realm, boolean optionally ) throws MalformedURLException, FileNotFoundException { File globFile = new File( line ); File dir = globFile.getParentFile(); if ( ! dir.exists() ) { if ( optionally ) { return; } else { throw new FileNotFoundException( dir.toString() ); } } String localName = globFile.getName(); int starLoc = localName.indexOf( "*" ); final String prefix = localName.substring( 0, starLoc ); final String suffix = localName.substring( starLoc + 1 ); File[] matches = dir.listFiles( new FilenameFilter() { public boolean accept( File dir, String name ) { if ( !name.startsWith( prefix ) ) { return false; } if ( !name.endsWith( suffix ) ) { return false; } return true; } } ); for ( int i = 0; i < matches.length; ++i ) { realm.addConstituent( matches[i].toURL() ); } } /** * Filter a string for system properties. * * @param text The text to filter. * @return The filtered text. * @throws ConfigurationException If the property does not * exist or if there is a syntax error. */ protected String filter( String text ) throws ConfigurationException { String result = ""; int cur = 0; int textLen = text.length(); int propStart = -1; int propStop = -1; String propName = null; String propValue = null; while ( cur < textLen ) { propStart = text.indexOf( "${", cur ); if ( propStart < 0 ) { break; } result += text.substring( cur, propStart ); propStop = text.indexOf( "}", propStart ); if ( propStop < 0 ) { throw new ConfigurationException( "Unterminated property: " + text.substring( propStart ) ); } propName = text.substring( propStart + 2, propStop ); propValue = System.getProperty( propName ); if ( propValue == null ) { throw new ConfigurationException( "No such property: " + propName ); } result += propValue; cur = propStop + 1; } result += text.substring( cur ); return result; } /** * Determine if a line can be ignored because it is * a comment or simply blank. * * @param line The line to test. * @return true if the line is ignorable, * otherwise false. */ private boolean canIgnore( String line ) { return ( line.length() == 0 || line.startsWith( "#" ) ); } } classworlds-1.1-final.orig/src/java/main/org/codehaus/classworlds/DuplicateRealmException.java0000644000175000017500000000646210724631435031423 0ustar dokodokopackage org.codehaus.classworlds; /* $Id: DuplicateRealmException.java 78 2004-07-01 13:59:13Z jvanzyl $ Copyright 2002 (C) The Werken Company. All Rights Reserved. Redistribution and use of this software and associated documentation ("Software"), with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain copyright statements and notices. Redistributions must also contain a copy of this document. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 3. The name "classworlds" must not be used to endorse or promote products derived from this Software without prior written permission of The Werken Company. For written permission, please contact bob@werken.com. 4. Products derived from this Software may not be called "classworlds" nor may "classworlds" appear in their names without prior written permission of The Werken Company. "classworlds" is a registered trademark of The Werken Company. 5. Due credit should be given to The Werken Company. (http://classworlds.werken.com/). THIS SOFTWARE IS PROVIDED BY THE WERKEN COMPANY AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE WERKEN COMPANY OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ /** * Indicates an attempt to add a ClassRealm to a * ClassWorld with a duplicate id. * * @author bob mcwhirter * @version $Id: DuplicateRealmException.java 78 2004-07-01 13:59:13Z jvanzyl $ */ public class DuplicateRealmException extends ClassWorldException { // ------------------------------------------------------------ // Instance members // ------------------------------------------------------------ /** * The realm id. */ private String id; // ------------------------------------------------------------ // Constructors // ------------------------------------------------------------ /** * Construct. * * @param world The world. * @param id The realm id. */ public DuplicateRealmException( ClassWorld world, String id ) { super( world, id ); this.id = id; } // ------------------------------------------------------------ // Instance methods // ------------------------------------------------------------ /** * Retrieve the duplicate realm id. * * @return The id. */ public String getId() { return this.id; } } classworlds-1.1-final.orig/src/java/main/org/codehaus/classworlds/EmbeddedLauncher.java0000644000175000017500000002167610724631435030030 0ustar dokodokopackage org.codehaus.classworlds; /* $Id: EmbeddedLauncher.java 78 2004-07-01 13:59:13Z jvanzyl $ Copyright 2002 (C) The Werken Company. All Rights Reserved. Redistribution and use of this software and associated documentation ("Software"), with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain copyright statements and notices. Redistributions must also contain a copy of this document. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 3. The name "classworlds" must not be used to endorse or promote products derived from this Software without prior written permission of The Werken Company. For written permission, please contact bob@werken.com. 4. Products derived from this Software may not be called "classworlds" nor may "classworlds" appear in their names without prior written permission of The Werken Company. "classworlds" is a registered trademark of The Werken Company. 5. Due credit should be given to The Werken Company. (http://classworlds.werken.com/). THIS SOFTWARE IS PROVIDED BY THE WERKEN COMPANY AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE WERKEN COMPANY OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ import java.io.FileInputStream; import java.io.InputStream; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; import java.lang.reflect.Modifier; /** * Command-line invokable application launcher. *

*

* This launcher class assists in the creation of classloaders and ClassRealms * from a configuration file and the launching of the application's main * method from the correct class loaded through the correct classloader. *

*

*

* The path to the configuration file is specified using the classworlds.conf * system property, typically specified using the -D switch to * java. *

* * @author bob mcwhirter * @version $Id: EmbeddedLauncher.java 78 2004-07-01 13:59:13Z jvanzyl $ */ public class EmbeddedLauncher extends Launcher { private static String LAUNCH_METHOD = "execute"; public EmbeddedLauncher() { super(); } // ------------------------------------------------------------ // Instance methods // ------------------------------------------------------------ /** * Set the application's main entrypoint. * * @param mainClassName The main class name. * @param mainRealmName The realm to load the class from. */ public void setAppMain( String mainClassName, String mainRealmName ) { this.mainClassName = mainClassName; this.mainRealmName = mainRealmName; } /** * Retrieve the main entry realm name. * * @return The main entry realm name. */ public String getMainRealmName() { return this.mainRealmName; } /** * Retrieve the main entry class name. * * @return The main entry class name. */ public String getMainClassName() { return this.mainClassName; } /** * Retrieve the main entry class. * * @return The main entry class. * @throws ClassNotFoundException If the class cannot be found. * @throws NoSuchRealmException If the specified main entry realm does not exist. */ public Class getMainClass() throws ClassNotFoundException, NoSuchRealmException { return getMainRealm().loadClass( getMainClassName() ); } /** * Retrieve the main entry realm. * * @return The main entry realm. * @throws NoSuchRealmException If the specified main entry realm does not exist. */ public ClassRealm getMainRealm() throws NoSuchRealmException { return getWorld().getRealm( getMainRealmName() ); } /** * Retrieve the enhanced main entry method. * * @return The enhanced main entry method. * @throws ClassNotFoundException If the main entry class cannot be found. * @throws NoSuchMethodException If the main entry method cannot be found. * @throws NoSuchRealmException If the main entry realm cannot be found. */ protected Method getEnhancedMainMethod() throws ClassNotFoundException, NoSuchMethodException, NoSuchRealmException { Method[] methods = getMainClass().getMethods(); for ( int i = 0; i < methods.length; ++i ) { final Method method = methods[i]; if ( !LAUNCH_METHOD.equals( method.getName() ) ) { continue; } int modifiers = method.getModifiers(); if ( !( Modifier.isPublic( modifiers ) ) ) { continue; } if ( method.getReturnType() != Void.TYPE ) { continue; } Class[] paramTypes = method.getParameterTypes(); if ( paramTypes.length != 2 ) { continue; } if ( paramTypes[0] != String[].class ) { continue; } if ( paramTypes[1] != ClassWorld.class ) { continue; } return method; } throw new NoSuchMethodException( "public void execute(ClassWorld world)" ); } /** * Attempt to launch the application through the enhanced main method. *

*

* This will seek a method with the exact signature of: *

*

*

     *  public static void main(String[] args, ClassWorld world)
     *  
* * @throws ClassNotFoundException If the main entry class cannot be found. * @throws IllegalAccessException If the method cannot be accessed. * @throws java.lang.reflect.InvocationTargetException * If the target of the invokation is * invalid. * @throws NoSuchMethodException If the main entry method cannot be found. * @throws NoSuchRealmException If the main entry realm cannot be found. */ protected void launchX() throws ClassNotFoundException, IllegalAccessException, InvocationTargetException, NoSuchMethodException, NoSuchRealmException { ClassRealm mainRealm = getMainRealm(); Class mainClass = getMainClass(); Method mainMethod = getEnhancedMainMethod(); Thread.currentThread().setContextClassLoader( mainRealm.getClassLoader() ); mainMethod.invoke( mainClass, new Object[]{getWorld()} ); } // ------------------------------------------------------------ // Class methods // ------------------------------------------------------------ public void launch() throws Exception { String classworldsConf = System.getProperty( CLASSWORLDS_CONF ); InputStream is = null; if ( classworldsConf != null ) { is = new FileInputStream( classworldsConf ); } else { ClassLoader cl = Thread.currentThread().getContextClassLoader(); if ( "true".equals( System.getProperty( "classworlds.bootstrapped" ) ) ) { is = cl.getResourceAsStream( UBERJAR_CONF_DIR + CLASSWORLDS_CONF ); } else { is = cl.getResourceAsStream( CLASSWORLDS_CONF ); } } if ( is == null ) { throw new Exception( "classworlds configuration not specified nor found " + "in the classpath" ); } configure( is ); try { launchX(); } catch ( InvocationTargetException e ) { // Decode ITE (if we can) Throwable t = e.getTargetException(); if ( t instanceof Exception ) { throw (Exception) t; } if ( t instanceof Error ) { throw (Error) t; } // Else just toss the ITE throw e; } } } classworlds-1.1-final.orig/src/java/main/org/codehaus/classworlds/RealmClassLoader.java0000644000175000017500000002027710724631435030026 0ustar dokodokopackage org.codehaus.classworlds; /* $Id: RealmClassLoader.java 126 2006-01-12 04:17:51Z $ Copyright 2002 (C) The Werken Company. All Rights Reserved. Redistribution and use of this software and associated documentation ("Software"), with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain copyright statements and notices. Redistributions must also contain a copy of this document. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 3. The name "classworlds" must not be used to endorse or promote products derived from this Software without prior written permission of The Werken Company. For written permission, please contact bob@werken.com. 4. Products derived from this Software may not be called "classworlds" nor may "classworlds" appear in their names without prior written permission of The Werken Company. "classworlds" is a registered trademark of The Werken Company. 5. Due credit should be given to The Werken Company. (http://classworlds.werken.com/). THIS SOFTWARE IS PROVIDED BY THE WERKEN COMPANY AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE WERKEN COMPANY OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ import java.io.ByteArrayOutputStream; import java.io.DataInputStream; import java.io.IOException; import java.net.MalformedURLException; import java.net.URL; import java.net.URLClassLoader; import java.util.Enumeration; /** Classloader for ClassRealms. * * @author bob mcwhirter * * @version $Id: RealmClassLoader.java 126 2006-01-12 04:17:51Z $ */ class RealmClassLoader extends URLClassLoader { // ------------------------------------------------------------ // Instance members // ------------------------------------------------------------ /** The realm. */ protected DefaultClassRealm realm; // ------------------------------------------------------------ // Constructors // ------------------------------------------------------------ /** Construct. * * @param realm The realm for which this loads. */ RealmClassLoader(DefaultClassRealm realm) { this( realm, null ); } /** Construct. * * @param realm The realm for which this loads. * * @param classLoader The parent ClassLoader. */ RealmClassLoader(DefaultClassRealm realm, ClassLoader classLoader) { super( new URL[0], classLoader ); this.realm = realm; } // ------------------------------------------------------------ // Instance methods // ------------------------------------------------------------ /** Retrieve the realm. * * @return The realm. */ DefaultClassRealm getRealm() { return this.realm; } /** Add a constituent to this realm for locating classes. * If the url definition ends in .class its a BytesURLStreamHandler * so use defineClass insead. addURL is still called for byte[] * even though it has no affect and we use defineClass instead, * this is for consistentency and to allow access to the class * with getURLs() * * @param constituent URL to contituent jar or directory. */ void addConstituent(URL constituent) { String urlStr = constituent.toExternalForm(); if (!urlStr.endsWith(".class")) { if ( urlStr.startsWith( "jar:" ) && urlStr.endsWith( "!/" ) ) { urlStr = urlStr.substring( 4, urlStr.length() - 2 ); try { constituent = new URL( urlStr ); } catch (MalformedURLException e) { e.printStackTrace(); } } addURL( constituent ); } else { try { byte[] b = getBytesToEndOfStream( new DataInputStream( constituent.openStream() ) ); int start = urlStr.lastIndexOf("byteclass") + 10; int end = urlStr.lastIndexOf(".class"); String className = urlStr.substring(start, end); super.defineClass(className, b, 0, b.length); addURL(constituent); } catch (IOException e) { e.printStackTrace(); } } } /** * Helper method for addConstituent that reads in a DataInputStream and returns it as a byte[] * It attempts to use in.available - the size of the file - else defaults to 2048 */ public byte[] getBytesToEndOfStream(DataInputStream in) throws IOException { final int chunkSize = (in.available() > 0) ? in.available() : 2048; byte[] buf = new byte[chunkSize]; ByteArrayOutputStream byteStream = new ByteArrayOutputStream(chunkSize); int count; while ((count=in.read(buf)) != -1) { byteStream.write(buf, 0, count); } return byteStream.toByteArray(); } /** Load a class directly from this classloader without * defering through any other ClassRealm. * * @param name The name of the class to load. * * @return The loaded class. * * @throws ClassNotFoundException If the class could not be found. */ Class loadClassDirect(String name) throws ClassNotFoundException { return super.loadClass( name, false ); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // java.lang.ClassLoader // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - /** Load a class. * * @param name The name of the class to load. * @param resolve If true then resolve the class. * * @return The loaded class. * * @throws ClassNotFoundException If the class cannot be found. */ protected Class loadClass(String name, boolean resolve) throws ClassNotFoundException { return getRealm().loadClass( name ); } /** Retrieve the URLs used by this ClassLoader. * * @return The urls. */ public URL[] getURLs() { return super.getURLs(); } /** Find a resource within this ClassLoader only (don't delegate to the parent). * * @return The resource. */ public URL findResource( String name ) { return super.findResource( name ); } public URL getResource(String name) { return getRealm().getResource( name ); } /** Get a resource from this ClassLoader, and don't search the realm. * Otherwise we'd recurse indefinitely. * * @return The resource. */ public URL getResourceDirect(String name) { return super.getResource( name ); } public Enumeration findResources(String name) throws IOException { return getRealm().findResources( name ); } /** Find resources from this ClassLoader, and don't search the realm. * Otherwise we'd recurse indefinitely. * * @return The resource. */ public Enumeration findResourcesDirect(String name) throws IOException { return super.findResources( name ); } } classworlds-1.1-final.orig/src/java/main/org/codehaus/classworlds/ClassWorld.java0000644000175000017500000001020710724631435026716 0ustar dokodokopackage org.codehaus.classworlds; /* $Id: ClassWorld.java 78 2004-07-01 13:59:13Z jvanzyl $ Copyright 2002 (C) The Werken Company. All Rights Reserved. Redistribution and use of this software and associated documentation ("Software"), with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain copyright statements and notices. Redistributions must also contain a copy of this document. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 3. The name "classworlds" must not be used to endorse or promote products derived from this Software without prior written permission of The Werken Company. For written permission, please contact bob@werken.com. 4. Products derived from this Software may not be called "classworlds" nor may "classworlds" appear in their names without prior written permission of The Werken Company. "classworlds" is a registered trademark of The Werken Company. 5. Due credit should be given to The Werken Company. (http://classworlds.werken.com/). THIS SOFTWARE IS PROVIDED BY THE WERKEN COMPANY AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE WERKEN COMPANY OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ import java.util.Map; import java.util.HashMap; import java.util.Collection; /** * A collection of ClassRealms, indexed by id. * * @author bob mcwhirter * @version $Id: ClassWorld.java 78 2004-07-01 13:59:13Z jvanzyl $ */ public class ClassWorld { private Map realms; public ClassWorld( String realmId, ClassLoader classLoader ) { this(); try { newRealm( realmId, classLoader ); } catch ( DuplicateRealmException e ) { // Will never happen as we are just creating the world. } } public ClassWorld() { this.realms = new HashMap(); } public ClassRealm newRealm( String id ) throws DuplicateRealmException { return newRealm( id, null ); } public ClassRealm newRealm( String id, ClassLoader classLoader ) throws DuplicateRealmException { if ( realms.containsKey( id ) ) { throw new DuplicateRealmException( this, id ); } ClassRealm realm = null; if ( classLoader != null ) { realm = new DefaultClassRealm( this, id, classLoader ); realms.put( id, realm ); } else { realm = new DefaultClassRealm( this, id ); } realms.put( id, realm ); return realm; } public void disposeRealm( String id ) throws NoSuchRealmException { realms.remove( id ); } public ClassRealm getRealm( String id ) throws NoSuchRealmException { if ( realms.containsKey( id ) ) { return (ClassRealm) realms.get( id ); } throw new NoSuchRealmException( this, id ); } public Collection getRealms() { return realms.values(); } Class loadClass( String name ) throws ClassNotFoundException { // Use the classloader that was used to load classworlds itself to // load anything classes within org.codehaus.classworlds.* return getClass().getClassLoader().loadClass( name ); } } classworlds-1.1-final.orig/src/java/main/org/codehaus/classworlds/BytesURLStreamHandler.java0000644000175000017500000000106710724631435030770 0ustar dokodokopackage org.codehaus.classworlds; import java.net.URLStreamHandler; import java.net.URLConnection; import java.net.URL; /** * @author Hani Suleiman (hani@formicary.net) * Date: Oct 20, 2003 * Time: 12:45:18 AM */ public class BytesURLStreamHandler extends URLStreamHandler { byte[] content; int offset; int length; public BytesURLStreamHandler( byte[] content ) { this.content = content; } public URLConnection openConnection( URL url ) { return new BytesURLConnection( url, content ); } }classworlds-1.1-final.orig/src/java/main/org/codehaus/classworlds/UrlUtils.java0000644000175000017500000000164410724631435026431 0ustar dokodokopackage org.codehaus.classworlds; /** * @author Jason van Zyl * @version $Id: UrlUtils.java 78 2004-07-01 13:59:13Z jvanzyl $ */ public class UrlUtils { public static String normalizeUrlPath( String name ) { if ( name.startsWith( "/" ) ) { name = name.substring( 1 ); } // Looking for org/codehaus/werkflow/personality/basic/../common/core-idioms.xml // | i | // +-------+ remove // int i = name.indexOf( "/.." ); // Can't be at the beginning because we have no root to refer to so // we start at 1. if ( i > 0 ) { int j = name.lastIndexOf( "/", i - 1 ); name = name.substring( 0, j ) + name.substring( i + 3 ); } return name; } } classworlds-1.1-final.orig/src/java/main/org/codehaus/classworlds/ConfigurationException.java0000644000175000017500000000546510724631435031341 0ustar dokodokopackage org.codehaus.classworlds; /* $Id: ConfigurationException.java 78 2004-07-01 13:59:13Z jvanzyl $ Copyright 2002 (C) The Werken Company. All Rights Reserved. Redistribution and use of this software and associated documentation ("Software"), with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain copyright statements and notices. Redistributions must also contain a copy of this document. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 3. The name "classworlds" must not be used to endorse or promote products derived from this Software without prior written permission of The Werken Company. For written permission, please contact bob@werken.com. 4. Products derived from this Software may not be called "classworlds" nor may "classworlds" appear in their names without prior written permission of The Werken Company. "classworlds" is a registered trademark of The Werken Company. 5. Due credit should be given to The Werken Company. (http://classworlds.werken.com/). THIS SOFTWARE IS PROVIDED BY THE WERKEN COMPANY AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE WERKEN COMPANY OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ /** * Indicates an error during Launcher configuration. * * @author bob mcwhirter * @version $Id: ConfigurationException.java 78 2004-07-01 13:59:13Z jvanzyl $ */ public class ConfigurationException extends Exception { /** * Construct. * * @param msg The message. */ public ConfigurationException( String msg ) { super( msg ); } /** * Construct. * * @param msg The message. * @param lineNo The number of configuraton line where the problem occured. * @param line The configuration line where the problem occured. */ public ConfigurationException( String msg, int lineNo, String line ) { super( msg + " (" + lineNo + "): " + line ); } } classworlds-1.1-final.orig/src/java/main/org/codehaus/classworlds/ClassRealm.java0000644000175000017500000000722610724631435026676 0ustar dokodokopackage org.codehaus.classworlds; /* $Id: ClassRealm.java 126 2006-01-12 04:17:51Z $ Copyright 2002 (C) The Werken Company. All Rights Reserved. Redistribution and use of this software and associated documentation ("Software"), with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain copyright statements and notices. Redistributions must also contain a copy of this document. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 3. The name "classworlds" must not be used to endorse or promote products derived from this Software without prior written permission of The Werken Company. For written permission, please contact bob@werken.com. 4. Products derived from this Software may not be called "classworlds" nor may "classworlds" appear in their names without prior written permission of The Werken Company. "classworlds" is a registered trademark of The Werken Company. 5. Due credit should be given to The Werken Company. (http://classworlds.werken.com/). THIS SOFTWARE IS PROVIDED BY THE WERKEN COMPANY AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE WERKEN COMPANY OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ import java.io.IOException; import java.io.InputStream; import java.net.URL; import java.util.Enumeration; /** * Autonomous sub-portion of a ClassWorld. *

*

* This class most closed maps to the ClassLoader * role from Java and in facts can provide a ClassLoader * view of itself using {@link #getClassLoader}. *

* * @author bob mcwhirter * @author Jason van Zyl * @version $Id: ClassRealm.java 126 2006-01-12 04:17:51Z $ */ public interface ClassRealm { String getId(); ClassWorld getWorld(); void importFrom( String realmId, String pkgName ) throws NoSuchRealmException; void addConstituent( URL constituent ); ClassRealm locateSourceRealm( String className ); void setParent( ClassRealm classRealm ); ClassRealm createChildRealm( String id ) throws DuplicateRealmException; ClassLoader getClassLoader(); ClassRealm getParent(); URL[] getConstituents(); // ---------------------------------------------------------------------- // Classloading // ---------------------------------------------------------------------- Class loadClass( String name ) throws ClassNotFoundException; // ---------------------------------------------------------------------- // Resource handling // ---------------------------------------------------------------------- URL getResource( String name ); Enumeration findResources( String name ) throws IOException; InputStream getResourceAsStream( String name ); void display(); } classworlds-1.1-final.orig/src/java/main/org/codehaus/classworlds/UberJarRealmClassLoader.java0000644000175000017500000002166010724631435031276 0ustar dokodokopackage org.codehaus.classworlds; /* $Id: UberJarRealmClassLoader.java 126 2006-01-12 04:17:51Z $ Copyright 2002 (C) The Werken Company. All Rights Reserved. Redistribution and use of this software and associated documentation ("Software"), with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain copyright statements and notices. Redistributions must also contain a copy of this document. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 3. The name "classworlds" must not be used to endorse or promote products derived from this Software without prior written permission of The Werken Company. For written permission, please contact bob@werken.com. 4. Products derived from this Software may not be called "classworlds" nor may "classworlds" appear in their names without prior written permission of The Werken Company. "classworlds" is a registered trademark of The Werken Company. 5. Due credit should be given to The Werken Company. (http://classworlds.werken.com/). THIS SOFTWARE IS PROVIDED BY THE WERKEN COMPANY AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE WERKEN COMPANY OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ import java.io.ByteArrayOutputStream; import java.io.IOException; import java.io.InputStream; import java.net.URL; import java.util.ArrayList; import java.util.Enumeration; import java.util.HashMap; import java.util.Iterator; import java.util.List; import java.util.Map; import java.util.Vector; import java.util.jar.JarEntry; import java.util.jar.JarInputStream; /** * Classloader for ClassRealms. *

* Loads classes from an "uberjar". * * @author bob mcwhirter * @version $Id: UberJarRealmClassLoader.java 126 2006-01-12 04:17:51Z $ */ public class UberJarRealmClassLoader extends RealmClassLoader { private Map classIndex; private List urls; private Map jarIndexes; public UberJarRealmClassLoader( DefaultClassRealm realm ) { super( realm ); this.urls = new ArrayList(); this.classIndex = new HashMap(); this.jarIndexes = new HashMap(); } public void addConstituent( URL constituent ) { // If the constituent is a jar, build an index for it. if ( "jar".equals( constituent.getProtocol() ) || constituent.toExternalForm().endsWith( ".jar" ) ) { buildIndexForJar( constituent ); } // Add the constituent to the urls collection this.urls.add( constituent ); super.addConstituent( constituent ); } private void buildIndexForJar( URL inUrl ) { HashMap index = new HashMap(); String urlText = null; if ( inUrl.getProtocol().equals( "jar" ) ) { urlText = inUrl.toExternalForm(); } else { urlText = "jar:" + inUrl.toExternalForm(); } String resourceName; URL resourceUrl = null; try { JarInputStream in = new JarInputStream( inUrl.openStream() ); try { JarEntry entry = null; while ( ( entry = in.getNextJarEntry() ) != null ) { resourceName = entry.getName(); resourceUrl = new URL( urlText + "!/" + resourceName ); index.put( resourceName, resourceUrl ); } } finally { in.close(); } } catch ( IOException e ) { // swallow } jarIndexes.put( inUrl, index ); } /** * Load a class directly from this classloader without * defering through any other ClassRealm. * * @param className The name of the class to load. * @return The loaded class. * @throws ClassNotFoundException If the class could not be found. */ public Class loadClassDirect( String className ) throws ClassNotFoundException { String classPath = className.replace( '.', '/' ) + ".class"; if ( this.classIndex.containsKey( classPath ) ) { return (Class) this.classIndex.get( classPath ); } Iterator urlIter = this.urls.iterator(); URL eachUrl = null; byte[] classBytes = null; while ( ( classBytes == null ) && ( urlIter.hasNext() ) ) { eachUrl = (URL) urlIter.next(); if ( "jar".equals( eachUrl.getProtocol() ) || eachUrl.toExternalForm().endsWith( ".jar" ) ) { classBytes = findClassInJarStream( eachUrl, classPath ); } else { classBytes = findClassInDirectoryUrl( eachUrl, classPath ); } } if ( classBytes == null ) { //!!!return super.loadClassDirect( className ); return null; } else { Class cls = defineClass( className, classBytes, 0, classBytes.length ); this.classIndex.put( classPath, cls ); return cls; } } public URL findResource( String name ) { URL resourceUrl = null; Iterator urlIter = this.urls.iterator(); URL eachUrl = null; while ( urlIter.hasNext() ) { eachUrl = (URL) urlIter.next(); if ( "jar".equals( eachUrl.getProtocol() ) || eachUrl.toExternalForm().endsWith( ".jar" ) ) { resourceUrl = findResourceInJarStream( eachUrl, name ); } else { resourceUrl = findResourceInDirectoryUrl( eachUrl, name ); } if ( resourceUrl != null ) { return resourceUrl; } } return null; } public Enumeration findResourcesDirect( String name ) { Vector list = new Vector(); URL resourceUrl = null; Iterator urlIter = this.urls.iterator(); URL eachUrl = null; while ( urlIter.hasNext() ) { eachUrl = (URL) urlIter.next(); if ( "jar".equals( eachUrl.getProtocol() ) || eachUrl.toExternalForm().endsWith( ".jar" ) ) { resourceUrl = findResourceInJarStream( eachUrl, name ); } else { resourceUrl = findResourceInDirectoryUrl( eachUrl, name ); } if ( resourceUrl != null ) { list.add( resourceUrl ); } } return list.elements(); } protected URL findResourceInJarStream( URL inUrl, String path ) { return (URL) ( (Map) jarIndexes.get( inUrl ) ).get( path ); } protected URL findResourceInDirectoryUrl( URL inUrl, String path ) { return null; } protected byte[] findClassInJarStream( URL inUrl, String path ) { URL classUrl = (URL) ( (Map) jarIndexes.get( inUrl ) ).get( path ); if ( classUrl != null ) { try { return readStream( classUrl.openStream() ); } catch ( IOException e ) { // Swallow } } return null; } protected byte[] findClassInDirectoryUrl( URL url, String path ) { try { URL classUrl = new URL( url, path ); } catch ( IOException e ) { // swallow } return null; } private byte[] readStream( InputStream in ) throws IOException { ByteArrayOutputStream out = new ByteArrayOutputStream(); try { byte[] buffer = new byte[2048]; int read = 0; while ( in.available() > 0 ) { read = in.read( buffer, 0, buffer.length ); if ( read < 0 ) { break; } out.write( buffer, 0, read ); } return out.toByteArray(); } finally { out.close(); } } } classworlds-1.1-final.orig/src/java/main/org/codehaus/classworlds/BytesURLConnection.java0000644000175000017500000000126310724631435030334 0ustar dokodokopackage org.codehaus.classworlds; import java.net.URLConnection; import java.net.URL; import java.io.InputStream; import java.io.ByteArrayInputStream; /** * @author Hani Suleiman (hani@formicary.net) *

* Date: Oct 20, 2003 * Time: 12:46:01 AM */ public class BytesURLConnection extends URLConnection { protected byte[] content; protected int offset; protected int length; public BytesURLConnection( URL url, byte[] content ) { super( url ); this.content = content; } public void connect() { } public InputStream getInputStream() { return new ByteArrayInputStream( content ); } }classworlds-1.1-final.orig/src/java/main/org/codehaus/classworlds/DefaultClassRealm.java0000644000175000017500000002731710724631435030206 0ustar dokodokopackage org.codehaus.classworlds; /* $Id: DefaultClassRealm.java 126 2006-01-12 04:17:51Z $ Copyright 2002 (C) The Werken Company. All Rights Reserved. Redistribution and use of this software and associated documentation ("Software"), with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain copyright statements and notices. Redistributions must also contain a copy of this document. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 3. The name "classworlds" must not be used to endorse or promote products derived from this Software without prior written permission of The Werken Company. For written permission, please contact bob@werken.com. 4. Products derived from this Software may not be called "classworlds" nor may "classworlds" appear in their names without prior written permission of The Werken Company. "classworlds" is a registered trademark of The Werken Company. 5. Due credit should be given to The Werken Company. (http://classworlds.werken.com/). THIS SOFTWARE IS PROVIDED BY THE WERKEN COMPANY AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE WERKEN COMPANY OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ import java.io.File; import java.io.IOException; import java.io.InputStream; import java.net.URL; import java.util.Enumeration; import java.util.Iterator; import java.util.TreeSet; import java.util.Vector; /** * Implementation of ClassRealm. The realm is the class loading gateway. * The search is proceded as follows: *

    *
  1. Search the parent class loader (passed via the constructor) if there * is one.
  2. *
  3. Search the imports.
  4. *
  5. Search this realm's constituents.
  6. *
  7. Search the parent realm.
  8. *
* * @author bob mcwhirter * @author Jason van Zyl * @version $Id: DefaultClassRealm.java 126 2006-01-12 04:17:51Z $ * @todo allow inheritance to be turn on/off at runtime. * @todo allow direction of search */ public class DefaultClassRealm implements ClassRealm { private ClassWorld world; private String id; private TreeSet imports; private ClassLoader foreignClassLoader; private RealmClassLoader classLoader; private ClassRealm parent; public DefaultClassRealm( ClassWorld world, String id ) { this( world, id, null ); } public DefaultClassRealm( ClassWorld world, String id, ClassLoader foreignClassLoader ) { this.world = world; this.id = id; imports = new TreeSet(); if ( foreignClassLoader != null ) { this.foreignClassLoader = foreignClassLoader; } if ( "true".equals( System.getProperty( "classworlds.bootstrapped" ) ) ) { classLoader = new UberJarRealmClassLoader( this ); } else { classLoader = new RealmClassLoader( this ); } } public URL[] getConstituents() { return classLoader.getURLs(); } public ClassRealm getParent() { return parent; } public void setParent( ClassRealm parent ) { this.parent = parent; } public String getId() { return this.id; } public ClassWorld getWorld() { return this.world; } public void importFrom( String realmId, String packageName ) throws NoSuchRealmException { imports.add( new Entry( getWorld().getRealm( realmId ), packageName ) ); imports.add( new Entry( getWorld().getRealm( realmId ), packageName.replace('.', '/') ) ); } public void addConstituent( URL constituent ) { classLoader.addConstituent( constituent ); } /** * Adds a byte[] class definition as a constituent for locating classes. * Currently uses BytesURLStreamHandler to hold a reference of the byte[] in memory. * This ensures we have a unifed URL resource model for all constituents. * The code to cache to disk is commented out - maybe a property to choose which method? * * @param constituent class name * @param b the class definition as a byte[] */ public void addConstituent(String constituent, byte[] b) throws ClassNotFoundException { try { File path, file; if (constituent.lastIndexOf('.') != -1) { path = new File("byteclass/" + constituent.substring(0, constituent.lastIndexOf('.') + 1).replace('.', File.separatorChar)); file = new File(path, constituent.substring(constituent.lastIndexOf('.') + 1) + ".class"); } else { path = new File("byteclass/"); file = new File(path, constituent + ".class"); } addConstituent( new URL( null, file.toURL().toExternalForm(), new BytesURLStreamHandler(b) ) ); } catch (java.io.IOException e) { throw new ClassNotFoundException( "Couldn't load byte stream.", e ); } } public ClassRealm locateSourceRealm( String classname ) { for ( Iterator iterator = imports.iterator(); iterator.hasNext(); ) { Entry entry = (Entry) iterator.next(); if ( entry.matches( classname ) ) { return entry.getRealm(); } } return this; } public ClassLoader getClassLoader() { return classLoader; } public ClassRealm createChildRealm( String id ) throws DuplicateRealmException { ClassRealm childRealm = getWorld().newRealm( id ); childRealm.setParent( this ); return childRealm; } // ---------------------------------------------------------------------- // ClassLoader API // ---------------------------------------------------------------------- public Class loadClass( String name ) throws ClassNotFoundException { if ( name.startsWith( "org.codehaus.classworlds." ) ) { return getWorld().loadClass( name ); } try { if ( foreignClassLoader != null ) { try { return foreignClassLoader.loadClass( name ); } catch ( ClassNotFoundException e ) { // Do nothing as we will now look in the realm. } } ClassRealm sourceRealm = locateSourceRealm( name ); if ( sourceRealm == this ) { return classLoader.loadClassDirect( name ); } else { try { return sourceRealm.loadClass( name ); } catch ( ClassNotFoundException cnfe ) { // If we can't find it in an import, try loading directly. return classLoader.loadClassDirect( name ); } } } catch ( ClassNotFoundException e ) { if ( getParent() != null ) { return getParent().loadClass( name ); } throw e; } } public URL getResource( String name ) { URL resource = null; name = UrlUtils.normalizeUrlPath( name ); if ( foreignClassLoader != null ) { resource = foreignClassLoader.getResource( name ); if ( resource != null ) { return resource; } } ClassRealm sourceRealm = locateSourceRealm( name ); if ( sourceRealm == this ) { resource = classLoader.getResourceDirect( name ); } else { resource = sourceRealm.getResource( name ); if ( resource == null ) { resource = classLoader.getResourceDirect( name ); } } if ( resource == null && getParent() != null ) { resource = getParent().getResource( name ); } return resource; } public InputStream getResourceAsStream( String name ) { URL url = getResource( name ); InputStream is = null; if ( url != null ) { try { is = url.openStream(); } catch ( IOException e ) { // do nothing } } return is; } public Enumeration findResources(String name) throws IOException { name = UrlUtils.normalizeUrlPath(name); Vector resources = new Vector(); // Find resources from the parent class loader if ( foreignClassLoader != null ) { for ( Enumeration res = foreignClassLoader.getResources(name); res.hasMoreElements(); ) { resources.addElement(res.nextElement()); } } // Load imports ClassRealm sourceRealm = locateSourceRealm( name ); if ( sourceRealm != this ) { // Attempt to load directly first, then go to the imported packages. for ( Enumeration res = sourceRealm.findResources(name); res.hasMoreElements(); ) { resources.addElement(res.nextElement()); } } // Load from our classloader for ( Enumeration direct = classLoader.findResourcesDirect(name); direct.hasMoreElements(); ) { resources.addElement(direct.nextElement()); } // Find resources from the parent realm. if (parent != null) { for ( Enumeration parent = getParent().findResources(name); parent.hasMoreElements(); ) { resources.addElement(parent.nextElement()); } } return resources.elements(); } public void display() { ClassRealm cr = this; System.out.println( "-----------------------------------------------------" ); showUrls( cr ); while( cr.getParent() != null ) { System.out.println( "\n" ); cr = cr.getParent(); showUrls( cr ); } System.out.println( "-----------------------------------------------------" ); } private void showUrls( ClassRealm classRealm ) { System.out.println( "this realm = " + classRealm.getId() ); URL[] urls = classRealm.getConstituents(); for ( int i = 0; i < urls.length; i++ ) { System.out.println( "urls[" + i + "] = " + urls[i] ); } System.out.println( "Number of imports: " + imports.size() ); for ( Iterator i = imports.iterator(); i.hasNext(); ) { System.out.println( "import: " + i.next() ); } } } classworlds-1.1-final.orig/src/java/main/org/codehaus/classworlds/ClassWorldException.java0000644000175000017500000000660110724631435030600 0ustar dokodokopackage org.codehaus.classworlds; /* $Id: ClassWorldException.java 78 2004-07-01 13:59:13Z jvanzyl $ Copyright 2002 (C) The Werken Company. All Rights Reserved. Redistribution and use of this software and associated documentation ("Software"), with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain copyright statements and notices. Redistributions must also contain a copy of this document. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 3. The name "classworlds" must not be used to endorse or promote products derived from this Software without prior written permission of The Werken Company. For written permission, please contact bob@werken.com. 4. Products derived from this Software may not be called "classworlds" nor may "classworlds" appear in their names without prior written permission of The Werken Company. "classworlds" is a registered trademark of The Werken Company. 5. Due credit should be given to The Werken Company. (http://classworlds.werken.com/). THIS SOFTWARE IS PROVIDED BY THE WERKEN COMPANY AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE WERKEN COMPANY OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ /** * Base exception for ClassWorld errors. * * @author bob mcwhirter * @version $Id: ClassWorldException.java 78 2004-07-01 13:59:13Z jvanzyl $ */ public class ClassWorldException extends Exception { // ------------------------------------------------------------ // Instance members // ------------------------------------------------------------ /** * The world. */ private ClassWorld world; // ------------------------------------------------------------ // Constructors // ------------------------------------------------------------ /** * Construct. * * @param world The world. */ public ClassWorldException( final ClassWorld world ) { this.world = world; } /** * Construct. * * @param world The world. * @param msg The detail message. */ public ClassWorldException( final ClassWorld world, final String msg ) { super( msg ); this.world = world; } // ------------------------------------------------------------ // Instance methods // ------------------------------------------------------------ /** * Retrieve the world. * * @return The world. */ public ClassWorld getWorld() { return this.world; } } classworlds-1.1-final.orig/src/java/abcd/0000755000175000017500000000000010724631543017021 5ustar dokodokoclassworlds-1.1-final.orig/src/java/abcd/a/0000755000175000017500000000000010724631543017241 5ustar dokodokoclassworlds-1.1-final.orig/src/java/abcd/a/A.java0000644000175000017500000000413010724631435020262 0ustar dokodokopackage a; /* $Id: A.java 78 2004-07-01 13:59:13Z jvanzyl $ Copyright 2002 (C) The Werken Company. All Rights Reserved. Redistribution and use of this software and associated documentation ("Software"), with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain copyright statements and notices. Redistributions must also contain a copy of this document. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 3. The name "classworlds" must not be used to endorse or promote products derived from this Software without prior written permission of The Werken Company. For written permission, please contact bob@werken.com. 4. Products derived from this Software may not be called "classworlds" nor may "classworlds" appear in their names without prior written permission of The Werken Company. "classworlds" is a registered trademark of The Werken Company. 5. Due credit should be given to The Werken Company. (http://classworlds.werken.com/). THIS SOFTWARE IS PROVIDED BY THE WERKEN COMPANY AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE WERKEN COMPANY OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ public class A { public static void main(String[] args) { System.err.println( "A.a.main()" ); } } classworlds-1.1-final.orig/src/java/abcd/a/Aa.java0000644000175000017500000000414410724631435020430 0ustar dokodokopackage a; /* $Id: Aa.java 126 2006-01-12 04:17:51Z $ Copyright 2002 (C) The Werken Company. All Rights Reserved. Redistribution and use of this software and associated documentation ("Software"), with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain copyright statements and notices. Redistributions must also contain a copy of this document. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 3. The name "classworlds" must not be used to endorse or promote products derived from this Software without prior written permission of The Werken Company. For written permission, please contact bob@werken.com. 4. Products derived from this Software may not be called "classworlds" nor may "classworlds" appear in their names without prior written permission of The Werken Company. "classworlds" is a registered trademark of The Werken Company. 5. Due credit should be given to The Werken Company. (http://classworlds.werken.com/). THIS SOFTWARE IS PROVIDED BY THE WERKEN COMPANY AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE WERKEN COMPANY OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ public class Aa { public static int main(String[] args) { System.err.println( "a.Aa.main()" ); return 15; } } classworlds-1.1-final.orig/src/java/abcd/b/0000755000175000017500000000000010724631543017242 5ustar dokodokoclassworlds-1.1-final.orig/src/java/abcd/b/B.java0000644000175000017500000000422610724631435020272 0ustar dokodokopackage b; /* $Id: B.java 78 2004-07-01 13:59:13Z jvanzyl $ Copyright 2002 (C) The Werken Company. All Rights Reserved. Redistribution and use of this software and associated documentation ("Software"), with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain copyright statements and notices. Redistributions must also contain a copy of this document. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 3. The name "classworlds" must not be used to endorse or promote products derived from this Software without prior written permission of The Werken Company. For written permission, please contact bob@werken.com. 4. Products derived from this Software may not be called "classworlds" nor may "classworlds" appear in their names without prior written permission of The Werken Company. "classworlds" is a registered trademark of The Werken Company. 5. Due credit should be given to The Werken Company. (http://classworlds.werken.com/). THIS SOFTWARE IS PROVIDED BY THE WERKEN COMPANY AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE WERKEN COMPANY OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ import org.codehaus.classworlds.ClassWorld; public class B { public B() { } public static void main(String args[], ClassWorld classworld) { } } classworlds-1.1-final.orig/src/java/abcd/b/Bb.java0000644000175000017500000000424510724631435020435 0ustar dokodokopackage b; /* $Id: Bb.java 126 2006-01-12 04:17:51Z $ Copyright 2002 (C) The Werken Company. All Rights Reserved. Redistribution and use of this software and associated documentation ("Software"), with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain copyright statements and notices. Redistributions must also contain a copy of this document. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 3. The name "classworlds" must not be used to endorse or promote products derived from this Software without prior written permission of The Werken Company. For written permission, please contact bob@werken.com. 4. Products derived from this Software may not be called "classworlds" nor may "classworlds" appear in their names without prior written permission of The Werken Company. "classworlds" is a registered trademark of The Werken Company. 5. Due credit should be given to The Werken Company. (http://classworlds.werken.com/). THIS SOFTWARE IS PROVIDED BY THE WERKEN COMPANY AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE WERKEN COMPANY OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ import org.codehaus.classworlds.ClassWorld; public class Bb { public Bb() { } public static int main(String args[], ClassWorld classworld) { return 45; } } classworlds-1.1-final.orig/src/java/abcd/c/0000755000175000017500000000000010724631543017243 5ustar dokodokoclassworlds-1.1-final.orig/src/java/abcd/c/C.java0000644000175000017500000000403210724631435020267 0ustar dokodokopackage c; /* $Id: C.java 78 2004-07-01 13:59:13Z jvanzyl $ Copyright 2002 (C) The Werken Company. All Rights Reserved. Redistribution and use of this software and associated documentation ("Software"), with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain copyright statements and notices. Redistributions must also contain a copy of this document. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 3. The name "classworlds" must not be used to endorse or promote products derived from this Software without prior written permission of The Werken Company. For written permission, please contact bob@werken.com. 4. Products derived from this Software may not be called "classworlds" nor may "classworlds" appear in their names without prior written permission of The Werken Company. "classworlds" is a registered trademark of The Werken Company. 5. Due credit should be given to The Werken Company. (http://classworlds.werken.com/). THIS SOFTWARE IS PROVIDED BY THE WERKEN COMPANY AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE WERKEN COMPANY OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ public class C { public C() { } } classworlds-1.1-final.orig/src/java/abcd/d/0000755000175000017500000000000010724631543017244 5ustar dokodokoclassworlds-1.1-final.orig/src/java/abcd/d/D.java0000644000175000017500000000377610724631435020307 0ustar dokodokopackage d; /* $Id: D.java 78 2004-07-01 13:59:13Z jvanzyl $ Copyright 2002 (C) The Werken Company. All Rights Reserved. Redistribution and use of this software and associated documentation ("Software"), with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain copyright statements and notices. Redistributions must also contain a copy of this document. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 3. The name "classworlds" must not be used to endorse or promote products derived from this Software without prior written permission of The Werken Company. For written permission, please contact bob@werken.com. 4. Products derived from this Software may not be called "classworlds" nor may "classworlds" appear in their names without prior written permission of The Werken Company. "classworlds" is a registered trademark of The Werken Company. 5. Due credit should be given to The Werken Company. (http://classworlds.werken.com/). THIS SOFTWARE IS PROVIDED BY THE WERKEN COMPANY AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE WERKEN COMPANY OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ public class D { } classworlds-1.1-final.orig/src/java/revolt/0000755000175000017500000000000010724631543017443 5ustar dokodokoclassworlds-1.1-final.orig/src/java/revolt/revolt/0000755000175000017500000000000010724631543020756 5ustar dokodokoclassworlds-1.1-final.orig/src/java/revolt/revolt/Main1.java0000644000175000017500000000216710724631435022574 0ustar dokodokopackage revolt; import java.util.Properties; public class Main1 { public static void main(String[] args) throws Exception { try { System.err.println( Main1.class.getClassLoader().getResource( "revolt/revolt.properties" ) ); System.err.println( Main1.class.getResource("revolt.properties")); { Properties props = new Properties(); props.load( Main1.class.getClassLoader().getResourceAsStream( "revolt/revolt.properties" ) ); System.err.println( "bob -> " + props.getProperty( "bob" ) ); System.err.println( "jason -> " + props.getProperty( "jason" ) ); } { Properties props = new Properties(); props.load( Main1.class.getResourceAsStream( "revolt.properties" ) ); System.err.println( "bob -> " + props.getProperty( "bob" ) ); System.err.println( "jason -> " + props.getProperty( "jason" ) ); } } catch (Throwable e) { e.printStackTrace(); } } } classworlds-1.1-final.orig/src/java/revolt/revolt/revolt.properties0000644000175000017500000000003410724631435024404 0ustar dokodokobob=mcwhirter jason=van zyl classworlds-1.1-final.orig/src/test-data/0000755000175000017500000000000010724631543017075 5ustar dokodokoclassworlds-1.1-final.orig/src/test-data/uberjar/0000755000175000017500000000000010724631543020527 5ustar dokodokoclassworlds-1.1-final.orig/src/test-data/uberjar/WORLDS-INF/0000755000175000017500000000000010724631543022153 5ustar dokodokoclassworlds-1.1-final.orig/src/test-data/uberjar/WORLDS-INF/conf/0000755000175000017500000000000010724631543023100 5ustar dokodokoclassworlds-1.1-final.orig/src/test-data/uberjar/WORLDS-INF/conf/classworlds.conf0000644000175000017500000000036410724631435026312 0ustar dokodokomain is revolt.Main1 from app [app] load ${classworlds.lib}/revolt.jar load ${classworlds.lib}/a.jar load ${classworlds.lib}/b.jar load ${classworlds.lib}/c.jar load ${classworlds.lib}/d.jar classworlds-1.1-final.orig/src/test-data/resources/0000755000175000017500000000000010724631543021107 5ustar dokodokoclassworlds-1.1-final.orig/src/test-data/resources/classworlds.conf0000644000175000017500000000060710724631435024321 0ustar dokodoko# ------------------------------------------------------------ # Define the main entry-point # ------------------------------------------------------------ main is foo from root # ------------------------------------------------------------ # Start defining realms # ------------------------------------------------------------ [root] load ${basedir}/src/test-data/resources/werkflow.jar classworlds-1.1-final.orig/src/test-data/resources/werkflow.jar0000644000175000017500000001241610724631435023451 0ustar dokodokoPK k5/ META-INF/PKk5/META-INF/MANIFEST.MFuAn0E|#hi$PvY $qƑc" gl jzZ9SH A|Ay dԬ?%V" R_u@+,)L{C;ܷYG*N$&s 1juҶ@϶r$Ǐ4&]CLnAO1IE8@:RD|sfU-#)~PKdPK k5/org/PK k5/ org/codehaus/PK k5/org/codehaus/werkflow/PK k5/"org/codehaus/werkflow/personality/PK k5/(org/codehaus/werkflow/personality/basic/PK k5/*org/codehaus/werkflow/personality/bpel4ws/PK k5/)org/codehaus/werkflow/personality/common/PKk5/8org/codehaus/werkflow/personality/basic/basic-syntax.xmlWn SXV/֋QiŸ!4;`:-/(L^]~!T7}B.^چqI\ 1Bf!B]rh0V2 ,:v\(EQb޶Crs.DJF*yG3Zv'W+}i TFA#\E3_axִaa5Sx.0_H"(Q/H0[ZgHS/'LP YW^.b,Ve?߼t?Zi*Z U)j f3#"f5m2FM8J ?.H84@,&",&)bSZÇYL)ۮ݆jEDKR5,qTgjO5$欢cLYa `*|2;{|+ L:(|_ IC$MA6Un# m#Ϟ( GK3h̬q0c k=_7&\,z4|E nIxD\h dX[%QG?7U.V?Zy).F-xƍtsu þ{ƍtsU(Z%akUzGl7n`O.&>wʮ1&@T.ܿSy2XE}3KGH6 څ Gp?Epi߼4ԫ@ܶ>oЫq K0ݻk }tP VҡC;znP.޿aPK\8PKk5/<org/codehaus/werkflow/personality/bpel4ws/bpel4ws-syntax.xmlMn0F9E%Fl*EE;$S@&&DHk~EٸT[Y{SR$sI )mjO9TXNIWK+ro>ƋMX2 /- X.F-f7d"4QT((RjE@LJYP3l^93ۂ3cqu*Pf%/gڜac V|Ø1qN-Z'B=oVrOFpY% 1H{pB~V p4 9kLʼ]h~ZHuG:C %‡mІj}j/LSecrN5EyAE١[pg|FOɞM?F,ߎH%ot}%DI U1Ţsgf Vv~7]d;T]yáh+$l{BĿV^`_0EovmV…n\ʖ;4 Ax9j+Ps} Ө9L{ Kw}V;Wi&!0*y>*":Ls?PKw;}]dPKT.META-INF/LICENSE.txtU]O8}ϯB# -]}4qtc KiqasPu{׽  (1ٟ6|ф.'?Ǔ z5A-} 4k+4>#Vx\uGm6T + U756i++릧^se^/ʪjܵ D OBzn운zguj6$UmԪWY)ZF?7#-uW7]W|1,ZjzKF٪`L@xP;m |@զN<{M琂 *4=4]e^`ɴUp\V=bԛ̽p`'݇޷TMu1c$7Ʒ4p:anȆ6eVɳ2?V`= A.=(4Iu6nmz Rp9Xdend!ʩ\u'Nr@g#4>R2@VyZ SdEQ.$ϳrL?EV0=1eR"E)ۘp d9q!Bq5GDowd=b&q`s"3a^+8AZ} G<&`cōLg^3 %#FMm 9a Z3U9&@CnHڏRD]LмPK xPK k5/ AMETA-INF/PKk5/d'META-INF/MANIFEST.MFPK k5/ARorg/PK k5/ Atorg/codehaus/PK k5/Aorg/codehaus/werkflow/PK k5/"Aorg/codehaus/werkflow/personality/PK k5/(Aorg/codehaus/werkflow/personality/basic/PK k5/*AYorg/codehaus/werkflow/personality/bpel4ws/PK k5/)Aorg/codehaus/werkflow/personality/common/PKk5/\88org/codehaus/werkflow/personality/basic/basic-syntax.xmlPKk5//E[<org/codehaus/werkflow/personality/bpel4ws/bpel4ws-syntax.xmlPKk5/w;}]d85org/codehaus/werkflow/personality/common/core-idioms.xmlPKT.'2 META-INF/LICENSE.txtPKk5/ x`META-INF/INDEX.LISTPK8classworlds-1.1-final.orig/src/test-data/optionally-existent.conf0000644000175000017500000000062510724631435024002 0ustar dokodoko # ------------------------------------------------------------ # Define the main entry-point # ------------------------------------------------------------ main is org.apache.maven.app.App from opt # ------------------------------------------------------------ # Start defining realms # ------------------------------------------------------------ [opt] optionally ${basedir}/lib/xmlApis-2.0.2.jar classworlds-1.1-final.orig/src/test-data/dupe-realm.conf0000644000175000017500000000006310724631435021776 0ustar dokodoko [cheese] [dupe.realm] [potatoes] [dupe.realm] classworlds-1.1-final.orig/src/test-data/valid.conf0000644000175000017500000000112710724631435021044 0ustar dokodoko # ------------------------------------------------------------ # Define the main entry-point # ------------------------------------------------------------ main is org.apache.maven.app.App from maven # ------------------------------------------------------------ # Start defining realms # ------------------------------------------------------------ [xml] load ${basedir}/lib/xmlApis-2.0.2.jar [ant] import org.xml.sax from xml load ${basedir}/lib/jakarta-ant-1.5.jar [maven] import org.xml.sax from xml load ${basedir}/lib/maven.jar [glob] load ${basedir}/target/test-data/*.jar classworlds-1.1-final.orig/src/test-data/unhandled.conf0000644000175000017500000000000510724631435021701 0ustar dokodoko foo classworlds-1.1-final.orig/src/test-data/optionally-nonexistent.conf0000644000175000017500000000061410724631435024513 0ustar dokodoko # ------------------------------------------------------------ # Define the main entry-point # ------------------------------------------------------------ main is org.apache.maven.app.App from opt # ------------------------------------------------------------ # Start defining realms # ------------------------------------------------------------ [opt] optionally /non/existant/path/*.jar classworlds-1.1-final.orig/src/test-data/valid-launch.conf0000644000175000017500000000010610724631435022310 0ustar dokodoko main is a.A from app [app] load ${basedir}/target/test-data/a.jar classworlds-1.1-final.orig/src/test-data/valid-launch-exitCode.conf0000644000175000017500000000010710724631435024053 0ustar dokodoko main is a.Aa from app [app] load ${basedir}/target/test-data/a.jar classworlds-1.1-final.orig/src/test-data/launch-noclass.conf0000644000175000017500000000016410724631435022657 0ustar dokodoko main is b.Goober from app [app] load ${basedir}/target/test-data/a.jar load ${basedir}/target/test-data/b.jar classworlds-1.1-final.orig/src/test-data/set-using-existent.conf0000644000175000017500000000131310724631435023521 0ustar dokodoko # ------------------------------------------------------------ # Define the main entry-point # ------------------------------------------------------------ main is org.apache.maven.app.App from opt # ------------------------------------------------------------ # Set properties # ------------------------------------------------------------ set set.using.existent using ${basedir}/target/test-data/set-using-existent.properties set set.using.default using ${basedir}/target/test-data/set-using-existent.properties default testSet_Using_Existent_Default # ------------------------------------------------------------ # Start defining realms # ------------------------------------------------------------ [opt] classworlds-1.1-final.orig/src/test-data/dupe-main.conf0000644000175000017500000000010110724631435021613 0ustar dokodoko main is com.werken.Foo from foo main is com.werken.Bar from bar classworlds-1.1-final.orig/src/test-data/valid-enh-launch.conf0000644000175000017500000000015710724631435023066 0ustar dokodoko main is b.B from app [app] load ${basedir}/target/test-data/a.jar load ${basedir}/target/test-data/b.jar classworlds-1.1-final.orig/src/test-data/valid-enh-launch-exitCode.conf0000644000175000017500000000016010724631435024622 0ustar dokodoko main is b.Bb from app [app] load ${basedir}/target/test-data/a.jar load ${basedir}/target/test-data/b.jar classworlds-1.1-final.orig/src/test-data/realm-syntax.conf0000644000175000017500000000001010724631435022357 0ustar dokodoko [foo ] classworlds-1.1-final.orig/src/test-data/early-import.conf0000644000175000017500000000003610724631435022367 0ustar dokodoko import org.xml.sax from root classworlds-1.1-final.orig/src/test-data/set-using-missing.conf0000644000175000017500000000115210724631435023330 0ustar dokodoko # ------------------------------------------------------------ # Define the main entry-point # ------------------------------------------------------------ main is org.apache.maven.app.App from opt # ------------------------------------------------------------ # Set properties # ------------------------------------------------------------ set set.using.missing default testSet_Using_Missing_Default set set.using.filtered.default default ${user.home}/m2 # ------------------------------------------------------------ # Start defining realms # ------------------------------------------------------------ [opt] classworlds-1.1-final.orig/src/test-data/launch-nomethod.conf0000644000175000017500000000023010724631435023024 0ustar dokodoko main is c.C from app [app] load ${basedir}/target/test-data/a.jar load ${basedir}/target/test-data/b.jar load ${basedir}/target/test-data/c.jar classworlds-1.1-final.orig/src/test-data/set-using-existent.properties0000644000175000017500000000005310724631435024770 0ustar dokodokoset.using.existent=testSet_Using_Existent classworlds-1.1-final.orig/src/test-data/a.properties0000644000175000017500000000001510724631435021427 0ustar dokodokoa properties classworlds-1.1-final.orig/src/test-data/nested.properties0000644000175000017500000000002210724631435022467 0ustar dokodokonested.properties classworlds-1.1-final.orig/src/test-data/inheritance.conf0000644000175000017500000000100510724631435022231 0ustar dokodoko# ------------------------------------------------------------ # Define the main entry-point # ------------------------------------------------------------ main is org.apache.maven.app.App from root.maven # ------------------------------------------------------------ # Start defining realms # ------------------------------------------------------------ [root] load ${basedir}/target/test-data/a.jar [root.maven] load ${basedir}/target/test-data/b.jar [root.maven.plugin] load ${basedir}/target/test-data/c.jar classworlds-1.1-final.orig/src/test-data/set-using-nonexistent.conf0000644000175000017500000000134310724631435024237 0ustar dokodoko # ------------------------------------------------------------ # Define the main entry-point # ------------------------------------------------------------ main is org.apache.maven.app.App from opt # ------------------------------------------------------------ # Set properties # ------------------------------------------------------------ set set.using.nonexistent using ${basedir}/target/test-data/set-using-nonexistent.properties set set.using.nonexistent.default using ${basedir}/target/test-data/set-using-nonexistent.properties default testSet_Using_NonExistent_Default # ------------------------------------------------------------ # Start defining realms # ------------------------------------------------------------ [opt] classworlds-1.1-final.orig/src/test-jars/0000755000175000017500000000000010724631543017123 5ustar dokodokoclassworlds-1.1-final.orig/src/test-jars/component0-1.0.jar0000644000175000017500000000316310724631435022202 0ustar dokodokoPK0 META-INF/PKPK0META-INF/MANIFEST.MFMLK-. K-*ϳR03r.JM,IMu )h)f&W+x%irrPKLэJDDPK 0META-INF/plexus/PK0META-INF/plexus/components.xmlI-K+-N-RP>P(?'.(]/9?%5#X 'H9ÔtdU%K2uIMK,)A6M9(A݋ăPK4hPK 0org/PK 0 org/codehaus/PK 0org/codehaus/plexus/PK0$org/codehaus/plexus/Component0.class;o>=vvVv6FҢT̜TF~܂ԼIJDFtԌb P R\4$ PK2\ 7qɩDnEDc}P(?'.(]/9?%5#X 'H9ÔtdU%K2uIMK,)A6M9(A݋ăPKOphPK 0org/PK 0 org/codehaus/PK 0org/codehaus/plexus/PK0$org/codehaus/plexus/Component1.class;o>=vvVv6FҢT̜TF~܂ԼCIJDFtԌb P R\4$ PKǰpiyPK0+org/codehaus/plexus/DefaultComponent1.classm?`ƟSZd#1H0hb!&a R+Պe|J\%wy{~<QahdlB0tׄXo$:GW+ܱ:=9Qȭh'r0 mE|vNr!qv=H/"4_-d?gqX5R zw-9i3A \3?PK PK0 META-INF/PK0LэJDD=META-INF/MANIFEST.MFPK 0META-INF/plexus/PK0OphMETA-INF/plexus/components.xmlPK 0org/PK 0 org/codehaus/PK 0org/codehaus/plexus/PK0ǰpiy$$org/codehaus/plexus/Component1.classPK0 +org/codehaus/plexus/DefaultComponent1.classPK aclassworlds-1.1-final.orig/src/test-jars/component2-1.0.jar0000644000175000017500000000316310724631435022204 0ustar dokodokoPK0 META-INF/PKPK0META-INF/MANIFEST.MFMLK-. K-*ϳR03r.JM,IMu )h)f&W+x%irrPKLэJDDPK 0META-INF/plexus/PK0META-INF/plexus/components.xmlI-K+-N-RP>P(?'.(]/9?%5#X 'H9ÔtdU%K2uIMK,)A6M9(A݋ăPKhPK 0org/PK 0 org/codehaus/PK 0org/codehaus/plexus/PK0$org/codehaus/plexus/Component2.class;o>=vvVv6FҢT̜TF~܂Լ#IJDFtԌb P R\4$ PKliyPK0+org/codehaus/plexus/DefaultComponent2.classm?`ƟSZd#1H0hb 1 z_V|-P@.ss E % e 9F&dz# ՙ<>2\ 7qɩDnEDc}P(?'.(]/9?%5#X 'H9ÔtdU%K2uIMK,)A6M9(A݋ăPKhPK 0org/PK 0 org/codehaus/PK 0org/codehaus/plexus/PK0$org/codehaus/plexus/Component3.class;o>=vvVv6FҢT̜TF~܂ԼcIJDFtԌb P R\4$ PKpiyPK0+org/codehaus/plexus/DefaultComponent3.classm?`ƟSZd#1H0` 1 z_V|-P@.ss E % e 9F&dz# ՙ<>2\ 7qɩDnEDc}P(?'.(]/9?%5#X 'H9ÔtdU%K2uIMK,)A6M9(A݋ăPK5G hPK 0org/PK 0 org/codehaus/PK 0org/codehaus/plexus/PK0$org/codehaus/plexus/Component4.class;o>=vvVv6FҢT̜TF~܂ԼIJDFtԌb P R\4$ PK2\ 7qɩDnEDc} Creating ${maven.build.dir}/uberjar-test.jar classworlds-1.1-final.orig/project.xml0000644000175000017500000000733110724631435016614 0ustar dokodoko 3 classworlds classworlds 1.1 The Codehaus http://codehaus.org/ http://codehaus.org/codehaus-small.gif 2002 org.codehaus.classworlds classworlds: Java(tm) ClassLoader Management Framework http://images.werken.com/classworlds.gif http://classworlds.codehaus.org/ classworlds.codehaus.org /www/classworlds.codehaus.org classworlds users http://lists.codehaus.org/pipermail/classworlds-user/ http://lists.codehaus.org/mailman/listinfo/classworlds-user http://lists.codehaus.org/mailman/listinfo/classworlds-user classworlds developers http://lists.codehaus.org/pipermail/classworlds-dev/ http://lists.codehaus.org/mailman/listinfo/classworlds-dev http://lists.codehaus.org/mailman/listinfo/classworlds-dev classworlds commit messages http://lists.codehaus.org/pipermail/classworlds-scm/ http://lists.codehaus.org/mailman/listinfo/classworlds-scm http://lists.codehaus.org/mailman/listinfo/classworlds-scm scm:cvs:pserver:anonymous@cvs.classworlds.codehaus.org:/home/projects/classworlds/scm/:classworlds scm:cvs:ext:${maven.username}@cvs.classworlds.codehaus.org:/home/projects/classworlds/scm/:classworlds http://cvs.classworlds.codehaus.org/ bob mcwhirter bob bob@werken.com The Werken Company Founder Jason van Zyl jvanzyl jason@zenplex.com Zenplex Developer Ben Walding bwalding ben@walding.com Walding Consulting Services Developer classworlds-scm@lists.codehaus.org src/java/main src/java/test **/*Test.java maven-jdepend-plugin maven-changes-plugin maven-changelog-plugin maven-javadoc-plugin maven-jxr-plugin maven-junit-report-plugin maven-tasklist-plugin maven-pmd-plugin maven-simian-plugin maven-clover-plugin 1.1 1.1 CLASSWORLDS_1_1 classworlds-1.1-final.orig/pom.xml0000644000175000017500000001202510724631435015735 0ustar dokodoko 4.0.0 classworlds classworlds jar classworlds 1.1-beta-1-SNAPSHOT http://cvs.classworlds.codehaus.org/ 2002 classworlds users http://lists.codehaus.org/mailman/listinfo/classworlds-user http://lists.codehaus.org/mailman/listinfo/classworlds-user http://lists.codehaus.org/pipermail/classworlds-user/ classworlds developers http://lists.codehaus.org/mailman/listinfo/classworlds-dev http://lists.codehaus.org/mailman/listinfo/classworlds-dev http://lists.codehaus.org/pipermail/classworlds-dev/ classworlds commit messages http://lists.codehaus.org/mailman/listinfo/classworlds-scm http://lists.codehaus.org/mailman/listinfo/classworlds-scm http://lists.codehaus.org/pipermail/classworlds-scm/ bob bob mcwhirter bob@werken.com The Werken Company Founder jvanzyl Jason van Zyl jason@zenplex.com Zenplex Developer bwalding Ben Walding ben@walding.com Walding Consulting Services Developer junit junit 3.8.1 jar compile src/java/main src/java/test maven-surefire-plugin 2.1.2 true maven-antrun-plugin 1.1 generate-test-resources run The Codehaus http://codehaus.org/ classworlds-1.1-final.orig/.cvsignore0000644000175000017500000000006710724631435016423 0ustar dokodokotarget .classpath .project maven.log *.ipr *.iml *.iws