plexus-classworlds-1.5.0/0000755000175000017500000000000011225210154015322 5ustar twernertwernerplexus-classworlds-1.5.0/LICENSE.txt0000644000175000017500000000370311122234006017146 0ustar twernertwerner /* $Id: LICENSE.txt 7933 2008-12-17 17:33:58Z bentmann $ Copyright 2002 (C) The Codehaus. All Rights Reserved. Redistribution and use of this software and associated documentation ("Software"), with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain copyright statements and notices. Redistributions must also contain a copy of this document. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 3. The name "classworlds" must not be used to endorse or promote products derived from this Software without prior written permission of The Codehaus. For written permission, please contact bob@codehaus.org. 4. Products derived from this Software may not be called "classworlds" nor may "classworlds" appear in their names without prior written permission of The Codehaus. "classworlds" is a registered trademark of The Codehaus. 5. Due credit should be given to The Codehaus. (http://classworlds.codehaus.org/). THIS SOFTWARE IS PROVIDED BY THE CODEHAUS AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE CODEHAUS OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ plexus-classworlds-1.5.0/src/0000755000175000017500000000000011225210154016111 5ustar twernertwernerplexus-classworlds-1.5.0/src/site/0000755000175000017500000000000011225210154017055 5ustar twernertwernerplexus-classworlds-1.5.0/src/site/site.xml0000644000175000017500000000130711151613500020544 0ustar twernertwerner Plexus http://plexus.codehaus.org/ /images/plexus-logo.png org.codehaus.plexus plexus-stylus-skin 1.0 plexus-classworlds-1.5.0/src/test-jars/0000755000175000017500000000000011225210154020025 5ustar twernertwernerplexus-classworlds-1.5.0/src/test-jars/component4-1.0.jar0000644000175000017500000000316310415504770023122 0ustar twernertwernerPK0 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݋ă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}H|PPKɦ\PK q:test/PKq:test/Component5.class;o>NvvvF̼F MIJDļtD5#Wp~iQr[fN*#s~nA~^j^H-P$D! 0?)+5YX@,V PK9|PK[q:test/Component5.java+HLNLOU(I-.*(MLV+I-JKLNUp-K+1P̼t Y⟓ 6 PK< zLWPKq:test/DefaultComponent5.classeAO@ߴbL=J?PK6oPKq: META-INF/PKq:[GG=META-INF/MANIFEST.MFPK q:META-INF/plexus/PKq:ɦ\META-INF/plexus/components.xmlPK q:test/PKq:9|test/Component5.classPK[q:< zLW~test/Component5.javaPKq:hr@ test/DefaultComponent5.classPKxq:6o?test/DefaultComponent5.javaPK Rplexus-classworlds-1.5.0/src/test-jars/component2-1.0.jar0000644000175000017500000000316310415504770023120 0ustar twernertwernerPK0 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݋ă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 aplexus-classworlds-1.5.0/src/test-jars/component5-2.0.jar0000644000175000017500000000353611200030212023102 0ustar twernertwernerPKq: META-INF/PKPKq:META-INF/MANIFEST.MFMLK-. K-*ϳR03r.JM,IMu +h)f&W+x%irrPK[GGPK q:META-INF/plexus/PKq:META-INF/plexus/components.xmlI-K+-N-RP "PPQ~N]Ijq3LF, W[ I,σvIMK,)Aք j>H|PPKɦ\PK q:test/PKq:test/Component5.class;o>NvvvF̼rF MIJDļtD5#Wp~iQr[fN*#s~nA~^j^H-P$D! 0?)+5YX@,V PKjm|PKq:test/Component5.java+HLNLOU(I-.*(MLV+I-JKLNUp-K+1P̼t YZ 6 PK! LWPKq:test/DefaultComponent5.classe1OAppwX؁GC%X( {8%9oiebG.$$Ҽ7;۝>Zʨ{hx$Cm}"8ނP%LI8(M~'t{ګ0Vfά V`d_tMe%mbC~ e @B>ּ=A#*YI\rE}9݊x )B-h#9NEEPKX@PKq:test/DefaultComponent5.javaELA 0>G2+eqhxnK! 3;`I+8oYޤe>$#C TN?_%:ځ ˂g?jRQr$nj]O =PKCoPKq: META-INF/PKq:[GG=META-INF/MANIFEST.MFPK q:META-INF/plexus/PKq:ɦ\META-INF/plexus/components.xmlPK q:test/PKq:jm|test/Component5.classPKq:! LW~test/Component5.javaPKq:X@ test/DefaultComponent5.classPKq:Co>test/DefaultComponent5.javaPK Rplexus-classworlds-1.5.0/src/test-jars/component3-1.0.jar0000644000175000017500000000316310415504770023121 0ustar twernertwernerPK0 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/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݋ă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}_zN5i,Rcܡb WobKbY'^k9 Le{sho‰kU 5Ǘ<,~6Ǥ?e#nɂyVl<@B.>Խ|ށe9{\YmfJ}K_֫}_ۢաٍgpI{WrVh4[ Ků. x&dt=Afτ\o9p8Ե{D^PJZv=f`E%?A&g?0 !r4A( $3;DC㔾IgLg@e$Œ؀ H"! _$#4(T-ƖzT%'/Ktmȁȅ- 9"1r{Ìެl 6 dPK-y$PK $84 AMETA-INF/PK#84f_k'META-INF/MANIFEST.MFPKk70lnested.propertiesPK #84Alib/PK#84-y$ =lib/a.jarPK!plexus-classworlds-1.5.0/src/test/test-data/set-using-existent.properties0000644000175000017500000000133511122234006026653 0ustar twernertwerner################################################################################ # # Copyright 2001-2006 The Codehaus Foundation. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # set.using.existent=testSet_Using_Existent plexus-classworlds-1.5.0/src/test/test-data/resources/0000755000175000017500000000000011225210153022767 5ustar twernertwernerplexus-classworlds-1.5.0/src/test/test-data/resources/classworlds.conf0000644000175000017500000000063010530635175026212 0ustar twernertwerner# ------------------------------------------------------------ # Define the main entry-point # ------------------------------------------------------------ main is foo from root # ------------------------------------------------------------ # Start defining realms # ------------------------------------------------------------ [root] load ${basedir}/src/test/test-data/resources/werkflow.jar plexus-classworlds-1.5.0/src/test/test-data/resources/werkflow.jar0000644000175000017500000001241610415504770025344 0ustar twernertwernerPK 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.LISTPK8plexus-classworlds-1.5.0/src/test/test-data/dupe-realm.conf0000644000175000017500000000007410530612507023667 0ustar twernertwerner [cheese] [dupe.realm] [potatoes] [dupe.realm] plexus-classworlds-1.5.0/src/test/test-data/inheritance.conf0000644000175000017500000000103510530612507024123 0ustar twernertwerner# ------------------------------------------------------------ # Define the main entry-point # ------------------------------------------------------------ main is org.apache.maven.app.App from root.maven # ------------------------------------------------------------ # Start defining realms # ------------------------------------------------------------ [root] load ${basedir}/src/test/test-data/a.jar [root.maven] load ${basedir}/src/test/test-data/b.jar [root.maven.plugin] load ${basedir}/src/test/test-data/c.jar plexus-classworlds-1.5.0/src/test/test-data/b_old.jar0000644000175000017500000000231110531572363022544 0ustar twernertwernerPK $84 META-INF/PK#84META-INF/MANIFEST.MFMLK-. K-*ϳR03rCq,HLHU%MxRKRSt*AL ,u L4K|3+KRs<4yxPKf_kPK #84b/PK#84 b/B.classQN0=BBwP)C+1E0IUHN ńQk xsν?? DDZ7RoLyJ8TޭWqdsgR+z*br h)eiUQ3B+䲪^J+11Ckv ["_LkʬF._'e8Eɜ@z]'ն}{ᨵa;`g+F`h9M,xdM8'ж3, PKd4PK#84 b/Bb.classP=K@~IV;`o蠐Ђ *up!&pIO8 U r_yuq\VW V0g"ah2Onu{e4E,PR?CZʒ4ˆO9C WIL)UJi*1/E]8e\lQt nHDDh0x["44+j'RNnF .Z%q4ki,EeFyj.E2pAKPڀKP3`Z/16k[h7PK:M!%PK $84 AMETA-INF/PK#84f_k'META-INF/MANIFEST.MFPK #84Ab/PK#84d4 b/B.classPK#84:M!% >b/Bb.classPKplexus-classworlds-1.5.0/src/test/test-data/nested.properties0000644000175000017500000000130411122234006024352 0ustar twernertwerner################################################################################ # # Copyright 2001-2006 The Codehaus Foundation. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # nested.properties plexus-classworlds-1.5.0/src/test/test-data/a.properties0000644000175000017500000000127711122234006023321 0ustar twernertwerner################################################################################ # # Copyright 2001-2006 The Codehaus Foundation. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # a properties plexus-classworlds-1.5.0/src/test/test-data/d.jar0000644000175000017500000000131610530612507021706 0ustar twernertwernerPK $84 META-INF/PK#84META-INF/MANIFEST.MFMLK-. K-*ϳR03rCq,HLHU%MxRKRSt*AL ,u L4K|3+KRs<4yxPKf_kPK #84d/PK#84 d/D.class-=@ ?(ةZc"Zh{YXxeЙeߛo6<_|x6ZY[p \ZZqDЗAPrs=Dz܋8d"QC: jFwŵLZ3s&0w&^ȏ6NeRae5tl)ڬ@vm( PKDPK $84 AMETA-INF/PK#84f_k'META-INF/MANIFEST.MFPK #84Ad/PK#84D d/D.classPKplexus-classworlds-1.5.0/src/test/test-data/set-using-existent.conf0000644000175000017500000000134210530612507025412 0ustar twernertwerner # ------------------------------------------------------------ # Define the main entry-point # ------------------------------------------------------------ main is org.apache.maven.app.App from opt # ------------------------------------------------------------ # Set properties # ------------------------------------------------------------ set set.using.existent using ${basedir}/src/test/test-data/set-using-existent.properties set set.using.default using ${basedir}/src/test/test-data/set-using-existent.properties default testSet_Using_Existent_Default # ------------------------------------------------------------ # Start defining realms # ------------------------------------------------------------ [opt] plexus-classworlds-1.5.0/src/test/test-data/valid-launch-exitCode.conf0000644000175000017500000000011610530612507025742 0ustar twernertwerner main is a.Aa from app [app] load ${basedir}/src/test/test-data/a.jar plexus-classworlds-1.5.0/src/test/test-data/unhandled.conf0000644000175000017500000000000710530612507023572 0ustar twernertwerner foo plexus-classworlds-1.5.0/src/test/test-data/dupe-main.conf0000644000175000017500000000010410530612507023505 0ustar twernertwerner main is com.werken.Foo from foo main is com.werken.Bar from bar plexus-classworlds-1.5.0/src/test/test-data/optionally-existent.conf0000644000175000017500000000066111017453666025703 0ustar twernertwerner # ------------------------------------------------------------ # Define the main entry-point # ------------------------------------------------------------ main is org.apache.maven.app.App from opt # ------------------------------------------------------------ # Start defining realms # ------------------------------------------------------------ [opt] optionally ${basedir}/target/test-lib/xml-apis-1.3.02.jar plexus-classworlds-1.5.0/src/test/test-data/c.jar0000644000175000017500000000132210530612507021702 0ustar twernertwernerPK $84 META-INF/PK#84META-INF/MANIFEST.MFMLK-. K-*ϳR03rCq,HLHU%MxRKRSt*AL ,u L4K|3+KRs<4yxPKf_kPK #84c/PK#84 c/C.class-PTB&V b[7\6{YI,<s19e2 GAmL B}00KLs,SvzQt' 4ʣ( Uȥ;+O*\0:vTd`dR8j5`5\)x8a`Bml`Ėm\2`ȻC2y @zj xJ~FG9f(ﴩ}0y<񰝙s5$ym6M&j 66:80Q2`{$xnľ4info#1HQݗq*" xG4Am`>.{EBEz]r`z`u>!#,}f6U##Dՙ  -<;|\5&N(􏉅 V 2ePKFPK#84 a/Aa.classmQJAkķ16xPAXTi8a2=(x(g|@EWTW|~haDTQc* `P' icȜFP\LP׼S{\IL|'Ǥq۔\ 5<XpnS!Wn4Qq&-c@-l3XE=iACxүe$?8E@{ S2rh|L&DeMnujUgf=4'-S,P2sR6)rE{@@X"G` UN"S*>HM:#c%B PKW OPKk70 a.propertiesKT((/H-*L-PK PK $84 AMETA-INF/PK#84f_k'META-INF/MANIFEST.MFPK #84Aa/PK#84F a/A.classPK#84W O ea/Aa.classPKk70 a.propertiesPKR5plexus-classworlds-1.5.0/src/test/test-data/b.jar0000644000175000017500000000201210532165607021704 0ustar twernertwernerPK< z5 META-INF/PKPK< z5META-INF/MANIFEST.MFMLK-. K-*ϳR03r.JM,IMu X*h8*8(x%irrPKRWFFPK4 z5 b/B.classMNN0צ v-Kխ0PĐJL`Vp:IbBbQ0|ww~1 EKBx!X[Eڪf)(3?^jKHft'ߤ0b];mEZB"JYU3J,~zq>8L>p=" atv*1EVƐ_Sfb|>Y"ƘmW}Ƹ-PK'o)PK4 z5 b/Bb.classENAN0mB[D"T)C8٩\ rQpBxTźH`3Yo?LO0!4ih|OgR)MVIe) 1[), h)iVBIx)_+gyt<'$u6>8N'{HaVt`۟{#=HƄm1O=Sf? ?sK8cLv?PKg.-PK< z5 META-INF/PK< z5RWFF=META-INF/MANIFEST.MFPK4 z5'o) b/B.classPK4 z5g.- b/Bb.classPKplexus-classworlds-1.5.0/src/test/test-data/valid-launch.conf0000644000175000017500000000011510530612507024177 0ustar twernertwerner main is a.A from app [app] load ${basedir}/src/test/test-data/a.jar plexus-classworlds-1.5.0/src/test/test-data/valid.conf0000644000175000017500000000124111017453666022742 0ustar twernertwerner # ------------------------------------------------------------ # Define the main entry-point # ------------------------------------------------------------ main is org.apache.maven.app.App from maven # ------------------------------------------------------------ # Start defining realms # ------------------------------------------------------------ [xml] load ${basedir}/target/test-lib/xml-apis-1.3.02.jar [ant] import org.xml.sax from xml load ${basedir}/target/test-lib/ant-1.6.5.jar [maven] import org.xml.sax from xml load ${basedir}/target/test-lib/commons-logging-1.0.3.jar [glob] load ${basedir}/src/test/test-data/*.jar plexus-classworlds-1.5.0/src/test/test-data/realm-syntax.conf0000644000175000017500000000001310530612507024251 0ustar twernertwerner [foo ] plexus-classworlds-1.5.0/src/test/test-data/set-using-missing.conf0000644000175000017500000000117510530612507025224 0ustar twernertwerner # ------------------------------------------------------------ # 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] plexus-classworlds-1.5.0/src/test/test-data/set-using-nonexistent.conf0000644000175000017500000000137210530612507026130 0ustar twernertwerner # ------------------------------------------------------------ # Define the main entry-point # ------------------------------------------------------------ main is org.apache.maven.app.App from opt # ------------------------------------------------------------ # Set properties # ------------------------------------------------------------ set set.using.nonexistent using ${basedir}/src/test/test-data/set-using-nonexistent.properties set set.using.nonexistent.default using ${basedir}/src/test/test-data/set-using-nonexistent.properties default testSet_Using_NonExistent_Default # ------------------------------------------------------------ # Start defining realms # ------------------------------------------------------------ [opt] plexus-classworlds-1.5.0/src/test/java/0000755000175000017500000000000011225210153020010 5ustar twernertwernerplexus-classworlds-1.5.0/src/test/java/a/0000755000175000017500000000000011225210153020230 5ustar twernertwernerplexus-classworlds-1.5.0/src/test/java/a/A.java0000644000175000017500000000134711122234006021257 0ustar twernertwernerpackage a; /* * Copyright 2001-2006 Codehaus Foundation. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ public class A { public static void main( String[] args ) { System.err.println( "A.a.main()" ); } } plexus-classworlds-1.5.0/src/test/java/a/Aa.java0000644000175000017500000000137311122234006021417 0ustar twernertwernerpackage a; /* * Copyright 2001-2006 Codehaus Foundation. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ public class Aa { public static int main( String[] args ) { System.err.println( "a.Aa.main()" ); return 15; } } plexus-classworlds-1.5.0/src/test/java/org/0000755000175000017500000000000011225210153020577 5ustar twernertwernerplexus-classworlds-1.5.0/src/test/java/org/codehaus/0000755000175000017500000000000011225210153022372 5ustar twernertwernerplexus-classworlds-1.5.0/src/test/java/org/codehaus/plexus/0000755000175000017500000000000011225210153023712 5ustar twernertwernerplexus-classworlds-1.5.0/src/test/java/org/codehaus/plexus/classworlds/0000755000175000017500000000000011225210153026252 5ustar twernertwerner././@LongLink0000000000000000000000000000015000000000000011561 Lustar rootrootplexus-classworlds-1.5.0/src/test/java/org/codehaus/plexus/classworlds/AbstractClassWorldsTestCase.javaplexus-classworlds-1.5.0/src/test/java/org/codehaus/plexus/classworlds/AbstractClassWorldsTestCase.j0000644000175000017500000000214310531576126034023 0ustar twernertwernerpackage org.codehaus.plexus.classworlds; import junit.framework.TestCase; import java.net.URL; import java.net.MalformedURLException; /* * Copyright 2001-2006 Codehaus Foundation. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ /** * @author Jason van Zyl */ public abstract class AbstractClassWorldsTestCase extends TestCase { public AbstractClassWorldsTestCase( String string ) { super( string ); } public static URL getTestResourceUrl( String resourceName ) throws MalformedURLException { return TestUtil.getTestResourceUrl( resourceName ); } } plexus-classworlds-1.5.0/src/test/java/org/codehaus/plexus/classworlds/strategy/0000755000175000017500000000000011225210153030114 5ustar twernertwernerplexus-classworlds-1.5.0/src/test/java/org/codehaus/plexus/classworlds/strategy/StrategyTest.java0000644000175000017500000001040111122234006033414 0ustar twernertwernerpackage org.codehaus.plexus.classworlds.strategy; /* * Copyright 2001-2006 Codehaus Foundation. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ import junit.framework.TestCase; import org.codehaus.plexus.classworlds.ClassWorld; import org.codehaus.plexus.classworlds.TestUtil; import org.codehaus.plexus.classworlds.realm.ClassRealm; import java.io.File; import java.io.InputStream; import java.net.URL; import java.util.Enumeration; // jars within jars // hierarchy vs graph public class StrategyTest extends TestCase { private ClassWorld world; private ClassRealm realm; private Strategy strategy; public void setUp() throws Exception { this.world = new ClassWorld(); this.realm = this.world.newRealm( "realm" ); this.strategy = this.realm.getStrategy(); realm.addURL( getJarUrl( "component0-1.0.jar" ) ); } public void testLoadingOfApplicationClass() throws Exception { Class c = strategy.loadClass( "org.codehaus.plexus.Component0" ); assertNotNull( c ); } public void testLoadingOfApplicationClassThenDoingItAgain() throws Exception { Class c; c = strategy.loadClass( "org.codehaus.plexus.Component0" ); assertNotNull( c ); c = strategy.loadClass( "org.codehaus.plexus.Component0" ); assertNotNull( c ); } public void testLoadingOfSystemClass() throws Exception { Class c = strategy.loadClass( "java.lang.Object" ); assertNotNull( c ); } public void testLoadingOfNonExistentClass() throws Exception { try { strategy.loadClass( "org.codehaus.plexus.NonExistentComponent" ); fail( "Should have thrown a ClassNotFoundException!" ); } catch ( ClassNotFoundException e ) { // do nothing } } public void testGetApplicationResource() throws Exception { URL resource = strategy.getResource( "META-INF/plexus/components.xml" ); assertNotNull( resource ); String content = getContent( resource.openStream() ); assertTrue( content.startsWith( "" ) ); } public void testGetSystemResource() throws Exception { URL resource = strategy.getResource( "java/lang/Object.class" ); assertNotNull( resource ); } public void testFindResources() throws Exception { realm.addURL( getJarUrl( "component1-1.0.jar" ) ); Enumeration e = strategy.findResources( "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 = strategy.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( TestUtil.getBasedir(), "src/test-jars/" + jarName ); return jarFile.toURI().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(); } } plexus-classworlds-1.5.0/src/test/java/org/codehaus/plexus/classworlds/launcher/0000755000175000017500000000000011225210153030053 5ustar twernertwernerplexus-classworlds-1.5.0/src/test/java/org/codehaus/plexus/classworlds/launcher/LauncherTest.java0000644000175000017500000000677611122234006033336 0ustar twernertwernerpackage org.codehaus.plexus.classworlds.launcher; /* * Copyright 2001-2006 Codehaus Foundation. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ import java.io.File; import java.io.FileInputStream; import org.codehaus.plexus.classworlds.AbstractClassWorldsTestCase; import org.codehaus.plexus.classworlds.TestUtil; public class LauncherTest extends AbstractClassWorldsTestCase { 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 { String basedir = TestUtil.getBasedir(); return new FileInputStream( new File( new File( basedir, "src/test/test-data" ), name ) ); } } ././@LongLink0000000000000000000000000000014600000000000011566 Lustar rootrootplexus-classworlds-1.5.0/src/test/java/org/codehaus/plexus/classworlds/launcher/ConfiguratorTest.javaplexus-classworlds-1.5.0/src/test/java/org/codehaus/plexus/classworlds/launcher/ConfiguratorTest.jav0000644000175000017500000002664211122234006034070 0ustar twernertwernerpackage org.codehaus.plexus.classworlds.launcher; /* * Copyright 2001-2006 Codehaus Foundation. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ import java.io.File; import java.io.FileInputStream; import java.io.FileNotFoundException; import java.net.URL; import java.util.Collection; import org.codehaus.plexus.classworlds.strategy.Strategy; import org.codehaus.plexus.classworlds.AbstractClassWorldsTestCase; import org.codehaus.plexus.classworlds.realm.DuplicateRealmException; import org.codehaus.plexus.classworlds.realm.ClassRealm; import org.codehaus.plexus.classworlds.ClassWorld; import org.codehaus.plexus.classworlds.TestUtil; public class ConfiguratorTest extends AbstractClassWorldsTestCase { 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 Strategy strat = globRealm.getStrategy(); URL[] urls = globRealm.getURLs(); String basedir = TestUtil.getBasedir(); assertArrayContains( urls, new File( basedir, "src/test/test-data/nested.jar" ).toURI().toURL() ); assertArrayContains( urls, new File( basedir, "src/test/test-data/a.jar" ).toURI().toURL() ); assertArrayContains( urls, new File( basedir, "src/test/test-data/b.jar" ).toURI().toURL() ); assertArrayContains( urls, new File( basedir, "src/test/test-data/c.jar" ).toURI().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" ); Strategy strat = optRealm.getStrategy(); URL[] urls = optRealm.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" ); Strategy strat = optRealm.getStrategy(); URL[] urls = optRealm.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 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( TestUtil.getBasedir(), "src/test/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" ); } } ././@LongLink0000000000000000000000000000015500000000000011566 Lustar rootrootplexus-classworlds-1.5.0/src/test/java/org/codehaus/plexus/classworlds/launcher/ConfigurationParserTest.javaplexus-classworlds-1.5.0/src/test/java/org/codehaus/plexus/classworlds/launcher/ConfigurationParserT0000644000175000017500000000563411122234006034115 0ustar twernertwernerpackage org.codehaus.plexus.classworlds.launcher; import org.codehaus.plexus.classworlds.AbstractClassWorldsTestCase; import org.codehaus.plexus.classworlds.launcher.ConfigurationException; import org.codehaus.plexus.classworlds.launcher.ConfigurationParser; public class ConfigurationParserTest extends AbstractClassWorldsTestCase { ConfigurationParser configurator = new ConfigurationParser( null, System.getProperties() ); public ConfigurationParserTest( String string ) { super( string ); } 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 ); } } plexus-classworlds-1.5.0/src/test/java/org/codehaus/plexus/classworlds/TestUtil.java0000644000175000017500000000303511122234006030672 0ustar twernertwernerpackage org.codehaus.plexus.classworlds; /* * Copyright 2001-2006 Codehaus Foundation. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ import java.io.File; import java.net.MalformedURLException; import java.net.URL; /** * @author Ben Walding * @version $Id: TestUtil.java 7933 2008-12-17 17:33:58Z bentmann $ */ public class TestUtil { public static URL getTestResourceUrl( String resourceName ) throws MalformedURLException { File baseDir = new File( getBasedir() ); File testDir = new File( baseDir, "src/test/test-data" ); File resourceFile = new File( testDir, resourceName ); return resourceFile.toURI().toURL(); } public static String getBasedir() { String basedir = System.getProperty( "basedir" ); /* do our best if we are not running from surefire */ if ( basedir == null || basedir.equals( "" ) ) { basedir = ( new File( "" ) ).getAbsolutePath(); } return basedir; } } plexus-classworlds-1.5.0/src/test/java/org/codehaus/plexus/classworlds/ClassWorldTest.java0000644000175000017500000001125311122234006032033 0ustar twernertwernerpackage org.codehaus.plexus.classworlds; /* * Copyright 2001-2006 Codehaus Foundation. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ import java.io.File; import java.net.URL; import java.net.URLClassLoader; import java.util.Enumeration; import org.codehaus.plexus.classworlds.realm.DuplicateRealmException; import org.codehaus.plexus.classworlds.realm.NoSuchRealmException; import org.codehaus.plexus.classworlds.realm.ClassRealm; public class ClassWorldTest extends AbstractClassWorldsTestCase { 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 ) ); } public void testPLX334() throws Exception { ClassLoader loader = new URLClassLoader( new URL[] { getJarUrl( "component1-1.0.jar" ) } ); ClassRealm nb = world.newRealm( "netbeans", loader ); ClassRealm plexus = world.newRealm( "plexus" ); plexus.importFrom( "netbeans", "META-INF/plexus" ); plexus.importFrom( "netbeans", "org.codehaus.plexus" ); Enumeration e = plexus.findResources( "META-INF/plexus/components.xml" ); assertNotNull( e ); int resourceCount = 0; for ( Enumeration resources = e; resources.hasMoreElements(); ) { URL obj = (URL) resources.nextElement(); assertTrue(obj.getPath().indexOf( "src/test-jars/component1-1.0.jar!/META-INF/plexus/components.xml" ) >= 0 ); resourceCount++; } // assertEquals( 2, resourceCount ); // for some reason surefire-plugin 2.3 returned 2 items there: // for example: //jar:file:/home/mkleint/.m2/repository/org/codehaus/plexus/plexus-archiver/1.0-alpha-7/plexus-archiver-1.0-alpha-7.jar!/META-INF/plexus/components.xml //jar:file:/home/mkleint/src/plexus-trunk/plexus-classworlds/src/test-jars/component1-1.0.jar!/META-INF/plexus/components.xml // However only 1 is correct, which is actually returned by the 2.4 surefire-plugin assertEquals( 1, resourceCount ); Class c = plexus.loadClass( "org.codehaus.plexus.Component1" ); assertNotNull( c ); } protected URL getJarUrl( String jarName ) throws Exception { File jarFile = new File( TestUtil.getBasedir(), "src/test-jars/" + jarName ); return jarFile.toURI().toURL(); } } plexus-classworlds-1.5.0/src/test/java/org/codehaus/plexus/classworlds/ClassView.java0000644000175000017500000000751311122234006031022 0ustar twernertwernerpackage org.codehaus.plexus.classworlds; /* * Copyright 2001-2006 Codehaus Foundation. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ 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(); } } plexus-classworlds-1.5.0/src/test/java/org/codehaus/plexus/classworlds/realm/0000755000175000017500000000000011225210153027352 5ustar twernertwerner././@LongLink0000000000000000000000000000015000000000000011561 Lustar rootrootplexus-classworlds-1.5.0/src/test/java/org/codehaus/plexus/classworlds/realm/DefaultClassRealmTest.javaplexus-classworlds-1.5.0/src/test/java/org/codehaus/plexus/classworlds/realm/DefaultClassRealmTest.j0000644000175000017500000001374311200035365033733 0ustar twernertwernerpackage org.codehaus.plexus.classworlds.realm; /* * Copyright 2001-2006 Codehaus Foundation. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ import java.io.File; import java.net.URL; import java.net.URLClassLoader; import java.util.Collections; import org.codehaus.plexus.classworlds.AbstractClassWorldsTestCase; import org.codehaus.plexus.classworlds.ClassWorld; public class DefaultClassRealmTest extends AbstractClassWorldsTestCase { public DefaultClassRealmTest( String name ) { super( name ); } // ---------------------------------------------------------------------- // Class testing // ---------------------------------------------------------------------- public void testLoadClassFromRealm() throws Exception { ClassRealm mainRealm = new ClassRealm( new ClassWorld(), "main" ); mainRealm.addURL( getJarUrl( "component0-1.0.jar" ) ); loadClass( mainRealm, "org.codehaus.plexus.Component0" ); } public void testLoadClassFromChildRealmWhereClassIsLocatedInParentRealm() throws Exception { ClassRealm mainRealm = new ClassRealm( new ClassWorld(), "main" ); mainRealm.addURL( getJarUrl( "component0-1.0.jar" ) ); ClassRealm childRealm = mainRealm.createChildRealm( "child" ); loadClass( childRealm, "org.codehaus.plexus.Component0" ); } public void testLoadClassFromChildRealmWhereClassIsLocatedInGrantParentRealm() throws Exception { ClassRealm mainRealm = new ClassRealm( new ClassWorld(), "main" ); mainRealm.addURL( getJarUrl( "component0-1.0.jar" ) ); ClassRealm childRealm = mainRealm.createChildRealm( "child" ); ClassRealm grandchildRealm = childRealm.createChildRealm( "grandchild" ); loadClass( grandchildRealm, "org.codehaus.plexus.Component0" ); } public void testLoadClassFromChildRealmWhereClassIsLocatedInBothChildRealmAndParentRealm() throws Exception { ClassRealm mainRealm = new ClassRealm( new ClassWorld(), "parent" ); mainRealm.addURL( getJarUrl( "component5-1.0.jar" ) ); ClassRealm childRealm = mainRealm.createChildRealm( "child" ); childRealm.addURL( getJarUrl( "component5-2.0.jar" ) ); Class cls = loadClass( childRealm, "test.Component5" ); assertSame( childRealm, cls.getClassLoader() ); assertEquals( 1, cls.getMethods().length ); assertEquals( "printNew", cls.getMethods()[0].getName() ); } public void testLoadNonExistentClass() throws Exception { ClassRealm mainRealm = new ClassRealm( new ClassWorld(), "main" ); mainRealm.addURL( getJarUrl( "component0-1.0.jar" ) ); try { mainRealm.loadClass( "org.foo.bar.NonExistentClass" ); fail( "A ClassNotFoundException should have been thrown!" ); } catch ( ClassNotFoundException e ) { // expected } } public void testImport() throws Exception { ClassWorld world = new ClassWorld(); ClassRealm r0 = world.newRealm( "r0" ); ClassRealm r1 = world.newRealm( "r1" ); r0.addURL( getJarUrl( "component0-1.0.jar" ) ); r1.importFrom( "r0", "org.codehaus.plexus" ); loadClass( r1, "org.codehaus.plexus.Component0" ); } // ---------------------------------------------------------------------- // Resource testing // ---------------------------------------------------------------------- public void testResource() throws Exception { ClassRealm mainRealm = new ClassRealm( new ClassWorld(), "main" ); mainRealm.addURL( getJarUrl( "component0-1.0.jar" ) ); getResource( mainRealm, "META-INF/plexus/components.xml" ); } // ---------------------------------------------------------------------- // // ---------------------------------------------------------------------- protected URL getJarUrl( String jarName ) throws Exception { File jarFile = new File( System.getProperty( "basedir" ), "src/test-jars/" + jarName ); return jarFile.toURI().toURL(); } private Class loadClass( ClassRealm realm, String name ) throws Exception { Class cls = realm.loadClass( name ); /* * NOTE: Load the class both directly from the realm and indirectly from an (ordinary) child class loader which * uses the specified class realm for parent delegation. The child class loader itself has no additional class * path entries but relies entirely on the provided class realm. Hence, the created child class loader should in * theory be able to load exactly the same classes/resources as the underlying class realm. In practice, it will * test that class realms properly integrate into the standard Java class loader hierarchy. */ ClassLoader childLoader = new URLClassLoader( new URL[0], realm ); assertEquals( cls, childLoader.loadClass( name ) ); return cls; } private void getResource( ClassRealm realm, String name ) throws Exception { ClassLoader childLoader = new URLClassLoader( new URL[0], realm ); assertNotNull( realm.getResource( name ) ); assertEquals( realm.getResource( name ), childLoader.getResource( name ) ); assertEquals( Collections.list( realm.getResources( name ) ), Collections.list( childLoader.getResources( name ) ) ); } } plexus-classworlds-1.5.0/src/test/java/org/codehaus/plexus/classworlds/realm/EntryTest.java0000644000175000017500000000401211200030212032140 0ustar twernertwernerpackage org.codehaus.plexus.classworlds.realm; /* * Copyright 2001-2006 Codehaus Foundation. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ import org.codehaus.plexus.classworlds.AbstractClassWorldsTestCase; import org.codehaus.plexus.classworlds.ClassWorld; /** * @author Ben Walding * @version $Id: EntryTest.java 8169 2009-05-05 12:26:50Z bentmann $ */ public class EntryTest extends AbstractClassWorldsTestCase { /** * Constructor for EntryTest. * * @param name */ public EntryTest( String name ) { super( name ); } public void testCompareTo() throws Exception { ClassWorld cw = new ClassWorld(); ClassRealm r = 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(); ClassRealm r1 = cw.newRealm( "test1" ); ClassRealm r2 = 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() ); } } ././@LongLink0000000000000000000000000000014500000000000011565 Lustar rootrootplexus-classworlds-1.5.0/src/test/java/org/codehaus/plexus/classworlds/realm/ClassRealmImplTest.javaplexus-classworlds-1.5.0/src/test/java/org/codehaus/plexus/classworlds/realm/ClassRealmImplTest.java0000644000175000017500000002755711200030212033732 0ustar twernertwernerpackage org.codehaus.plexus.classworlds.realm; /* * Copyright 2001-2006 Codehaus Foundation. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ import java.net.MalformedURLException; import java.net.URL; import org.codehaus.plexus.classworlds.AbstractClassWorldsTestCase; import org.codehaus.plexus.classworlds.ClassWorld; import org.codehaus.plexus.classworlds.TestUtil; public class ClassRealmImplTest extends AbstractClassWorldsTestCase { 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 { ClassRealm realm = new ClassRealm( this.world, "foo" ); assertSame( realm, realm.locateSourceRealm( "com.werken.Stuff" ) ); } public void testLocateSourceRealm_SimpleImport() throws Exception { ClassRealm mainRealm = 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 { ClassRealm mainRealm = 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 { ClassRealm mainRealm = 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" ); ClassRealm mainRealm = 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.plexus.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.addURL( 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.addURL( 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, classA.getClassLoader() ); Class classMain = mainRealm.loadClass( "a.A" ); assertNotNull( classMain ); assertEquals( realmA, classMain.getClassLoader() ); assertSame( classA, classMain ); } public void testLoadClass_Package() throws Exception { ClassRealm realmA = this.world.newRealm( "realmA" ); realmA.addURL( 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.addURL( getJarUrl( "a.jar" ) ); realmB.addURL( getJarUrl( "b.jar" ) ); realmC.addURL( 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, classA_A.getClassLoader() ); assertEquals( realmB, classB_B.getClassLoader() ); assertEquals( realmC, classC_C.getClassLoader() ); // load from C Class classA_C = realmC.loadClass( "a.A" ); assertNotNull( classA_C ); assertSame( classA_A, classA_C ); assertEquals( realmA, classA_C.getClassLoader() ); Class classB_C = realmC.loadClass( "b.B" ); assertNotNull( classB_C ); assertSame( classB_B, classB_C ); assertEquals( realmB, classB_C.getClassLoader() ); // load from A Class classC_A = realmA.loadClass( "c.C" ); assertNotNull( classC_A ); assertSame( classC_C, classC_A ); assertEquals( realmC, 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.plexus.classworlds.ClassWorld" ); assertNotNull( cls ); assertSame( ClassWorld.class, cls ); } } } plexus-classworlds-1.5.0/src/test/java/org/codehaus/classworlds/0000755000175000017500000000000011225210153024732 5ustar twernertwernerplexus-classworlds-1.5.0/src/test/java/org/codehaus/classworlds/DefaultClassRealmTest.java0000644000175000017500000001254711122234006032000 0ustar twernertwernerpackage org.codehaus.classworlds; /* $Id: DefaultClassRealmTest.java 7933 2008-12-17 17:33:58Z bentmann $ 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.toURI().toURL(); } } plexus-classworlds-1.5.0/src/test/java/org/codehaus/classworlds/LauncherTest.java0000644000175000017500000001127111122234006030177 0ustar twernertwernerpackage org.codehaus.classworlds; /* $Id: LauncherTest.java 7933 2008-12-17 17:33:58Z bentmann $ 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/test-data" ), name ) ); } } plexus-classworlds-1.5.0/src/test/java/org/codehaus/classworlds/ClassWorldTest.java0000644000175000017500000001061611122234006030515 0ustar twernertwernerpackage org.codehaus.classworlds; /* $Id: ClassWorldTest.java 7933 2008-12-17 17:33:58Z bentmann $ 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 // TODO decide if these tests should be re-enabled, usign the wrappers they simply don't make sense // 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 // TODO decide if these tests should be re-enabled, usign the wrappers they simply don't make sense // 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 ) ); } } plexus-classworlds-1.5.0/src/test/java/d/0000755000175000017500000000000011225210153020233 5ustar twernertwernerplexus-classworlds-1.5.0/src/test/java/d/D.java0000644000175000017500000000120211122234006021253 0ustar twernertwernerpackage d; /* * Copyright 2001-2006 Codehaus Foundation. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ public class D { } plexus-classworlds-1.5.0/src/test/java/c/0000755000175000017500000000000011225210153020232 5ustar twernertwernerplexus-classworlds-1.5.0/src/test/java/c/C.java0000644000175000017500000000123611122234006021260 0ustar twernertwernerpackage c; /* * Copyright 2001-2006 Codehaus Foundation. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ public class C { public C() { } } plexus-classworlds-1.5.0/src/test/java/b/0000755000175000017500000000000011225210153020231 5ustar twernertwernerplexus-classworlds-1.5.0/src/test/java/b/Bb.java0000644000175000017500000000152311122234006021417 0ustar twernertwernerpackage b; /* * Copyright 2001-2006 Codehaus Foundation. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ import org.codehaus.plexus.classworlds.ClassWorld; public class Bb { public Bb() { } public static int main( String args[], ClassWorld classworld ) { return 45; } } plexus-classworlds-1.5.0/src/test/java/b/B.java0000644000175000017500000000150011122234006021250 0ustar twernertwernerpackage b; /* * Copyright 2001-2006 Codehaus Foundation. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ import org.codehaus.plexus.classworlds.ClassWorld; public class B { public B() { } public static void main( String args[], ClassWorld classworld ) { } } plexus-classworlds-1.5.0/src/main/0000755000175000017500000000000011225210153017034 5ustar twernertwernerplexus-classworlds-1.5.0/src/main/aspect/0000755000175000017500000000000011225210153020313 5ustar twernertwernerplexus-classworlds-1.5.0/src/main/aspect/org/0000755000175000017500000000000011225210153021102 5ustar twernertwernerplexus-classworlds-1.5.0/src/main/aspect/org/codehaus/0000755000175000017500000000000011225210153022675 5ustar twernertwernerplexus-classworlds-1.5.0/src/main/aspect/org/codehaus/plexus/0000755000175000017500000000000011225210153024215 5ustar twernertwernerplexus-classworlds-1.5.0/src/main/aspect/org/codehaus/plexus/classworlds/0000755000175000017500000000000011225210153026555 5ustar twernertwernerplexus-classworlds-1.5.0/src/main/aspect/org/codehaus/plexus/classworlds/event/0000755000175000017500000000000011225210153027676 5ustar twernertwernerplexus-classworlds-1.5.0/src/main/aspect/org/codehaus/plexus/classworlds/event/ListenerAspect.aj0000644000175000017500000000344011122234006033137 0ustar twernertwernerpackage org.codehaus.plexus.classworlds.event; import java.net.URL; import org.codehaus.plexus.classworlds.strategy.Strategy; /** * A simlple aspect to hook event code in when compiling with debug enabled * * @uthor: Andrew Williams * @since: 1.2-alpha-15 * @version: $Id: ListenerAspect.aj 7933 2008-12-17 17:33:58Z bentmann $ */ aspect ListenerAspect { // TODO: here we want a proper listener registering system, not just a debugger private ClassEventDebug classDebugger = new ClassEventDebug(); private ResourceEventDebug resourceDebugger = new ResourceEventDebug(); pointcut loadClass( String name, Strategy strategy ): args( name ) && target( strategy ) && call( Class Strategy.loadClass( String ) ); before( String name, Strategy strategy ): loadClass( name, strategy ) { classDebugger.lookup( name, strategy ); } after( String name, Strategy strategy ) returning( Class result ): loadClass( name, strategy ) { classDebugger.found( name, strategy, result ); } after( String name, Strategy strategy ) throwing( Exception e ): loadClass( name, strategy ) { classDebugger.failed( name, strategy, e ); } pointcut getResource( String name, Strategy strategy ): args( name ) && target( strategy ) && call( URL Strategy.getResource( String ) ); before( String name, Strategy strategy ): getResource( name, strategy ) { resourceDebugger.lookup( name, strategy ); } after( String name, Strategy strategy ) returning( URL result ): getResource( name, strategy ) { if ( result == null ) resourceDebugger.failed( name, strategy ); else resourceDebugger.found( name, strategy, result ); } } plexus-classworlds-1.5.0/src/main/java/0000755000175000017500000000000011225210153017755 5ustar twernertwernerplexus-classworlds-1.5.0/src/main/java/org/0000755000175000017500000000000011225210153020544 5ustar twernertwernerplexus-classworlds-1.5.0/src/main/java/org/codehaus/0000755000175000017500000000000011225210154022340 5ustar twernertwernerplexus-classworlds-1.5.0/src/main/java/org/codehaus/plexus/0000755000175000017500000000000011225210154023660 5ustar twernertwernerplexus-classworlds-1.5.0/src/main/java/org/codehaus/plexus/classworlds/0000755000175000017500000000000011225210154026220 5ustar twernertwernerplexus-classworlds-1.5.0/src/main/java/org/codehaus/plexus/classworlds/strategy/0000755000175000017500000000000011225210154030062 5ustar twernertwerner././@LongLink0000000000000000000000000000014500000000000011565 Lustar rootrootplexus-classworlds-1.5.0/src/main/java/org/codehaus/plexus/classworlds/strategy/StrategyFactory.javaplexus-classworlds-1.5.0/src/main/java/org/codehaus/plexus/classworlds/strategy/StrategyFactory.java0000644000175000017500000000354611200035365034071 0ustar twernertwernerpackage org.codehaus.plexus.classworlds.strategy; /* * Copyright 2001-2006 Codehaus Foundation. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ import org.codehaus.plexus.classworlds.realm.ClassRealm; /** * StrategyFactory loads a strategy, either default or from a given hint. * * @uthor: Andrew Williams * @since: Nov 19, 2006 * @version: $Id: StrategyFactory.java 8171 2009-05-05 13:11:17Z bentmann $ */ public class StrategyFactory { public static Strategy getStrategy( ClassRealm realm ) { return getStrategy( realm, "default", null ); } public static Strategy getStrategy( ClassRealm realm, ClassLoader foreign ) { return getStrategy( realm, "default", foreign ); } public static Strategy getStrategy( ClassRealm realm, String hint ) { return getStrategy( realm, hint, null ); } public static Strategy getStrategy( ClassRealm realm, String hint, ClassLoader foreign ) { if ( foreign != null ) { return new SelfFirstStrategy( realm ); } // Here we shall check hint to load non-default strategies Strategy ret = new DefaultStrategy( realm ); return ret; } } ././@LongLink0000000000000000000000000000015000000000000011561 Lustar rootrootplexus-classworlds-1.5.0/src/main/java/org/codehaus/plexus/classworlds/strategy/OsgiBundleStrategy.javaplexus-classworlds-1.5.0/src/main/java/org/codehaus/plexus/classworlds/strategy/OsgiBundleStrategy.j0000644000175000017500000000526611177650324034041 0ustar twernertwernerpackage org.codehaus.plexus.classworlds.strategy; import java.io.IOException; import java.io.InputStream; import java.net.URL; import java.util.Enumeration; import java.util.Vector; import org.codehaus.plexus.classworlds.realm.ClassRealm; public class OsgiBundleStrategy extends AbstractStrategy { // java.* from parent // imported packages [Import-Package header with explicit constraints on the exporter] // requires bundle [Required-Bundle] // self [Bundle-Classpath header] // attached fragments // // We need to trya and be OSGi r4 compliant in the loading of all the bundles so that we can try to // load eclipse without requiring equinox. Or any other OSGi container for that matter. public OsgiBundleStrategy( ClassRealm realm ) { super( realm ); } public Class loadClass( String name ) throws ClassNotFoundException { Class clazz = realm.loadClassFromImport( name ); if ( clazz == null ) { clazz = realm.loadClassFromSelf( name ); } if ( clazz == null ) { clazz = realm.loadClassFromParent( name ); } if ( clazz == null ) { throw new ClassNotFoundException( name ); } return clazz; } public URL getResource( String name ) { URL resource = realm.loadResourceFromImport( name ); if ( resource == null ) { resource = realm.loadResourceFromSelf( name ); } if ( resource == null ) { resource = realm.loadResourceFromParent( 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 { Vector resources = new Vector(); loadResourcesFromRealm( resources, realm.loadResourcesFromImport( name ) ); loadResourcesFromRealm( resources, realm.loadResourcesFromSelf( name ) ); loadResourcesFromRealm( resources, realm.loadResourcesFromParent( name ) ); return resources.elements(); } private void loadResourcesFromRealm( Vector v, Enumeration e ) { if ( e != null ) { for ( Enumeration a = e; a.hasMoreElements(); ) { v.addElement( a.nextElement() ); } } } } ././@LongLink0000000000000000000000000000014500000000000011565 Lustar rootrootplexus-classworlds-1.5.0/src/main/java/org/codehaus/plexus/classworlds/strategy/DefaultStrategy.javaplexus-classworlds-1.5.0/src/main/java/org/codehaus/plexus/classworlds/strategy/DefaultStrategy.java0000644000175000017500000001073011122234006034033 0ustar twernertwernerpackage org.codehaus.plexus.classworlds.strategy; /* * Copyright 2001-2006 Codehaus Foundation. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ import org.codehaus.plexus.classworlds.UrlUtils; import org.codehaus.plexus.classworlds.realm.ClassRealm; import java.io.IOException; import java.io.InputStream; import java.net.URL; import java.util.Enumeration; import java.util.Vector; /** * Load classes directly from the Realm first before attempting to get from the parent. * * @uthor: Andrew Williams * @since: Nov 19, 2006 * @version: $Id: DefaultStrategy.java 7933 2008-12-17 17:33:58Z bentmann $ */ public class DefaultStrategy extends AbstractStrategy { public DefaultStrategy( ClassRealm realm ) { super( realm ); } public Class loadClass( String name ) throws ClassNotFoundException { if ( name.startsWith( "org.codehaus.plexus.classworlds." ) || name.startsWith( "org.codehaus.classworlds." ) ) { return getRealm().getWorld().getClass().getClassLoader().loadClass( name ); } try { ClassRealm sourceRealm = getRealm().locateSourceRealm( name ); if ( sourceRealm != getRealm() ) { try { return sourceRealm.loadClass( name ); } catch ( ClassNotFoundException cnfe ) { // Do nothing as we will load directly } } return getRealm().loadRealmClass( name ); } catch ( ClassNotFoundException e ) { if ( getRealm().getParentRealm() != null ) { return getRealm().getParentRealm().loadClass( name ); } throw e; } } public URL getResource( String name ) { name = getNormalizedResource( name ); URL resource = null; ClassRealm sourceRealm = getRealm().locateSourceRealm( name ); if ( !sourceRealm.equals( getRealm() ) ) { resource = sourceRealm.getResource( name ); } if ( resource == null ) { resource = getRealm().getRealmResource( name ); } if ( resource == null && getRealm().getParentRealm() != null ) { resource = getRealm().getParentRealm().getRealmResource( 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(); // Load imports ClassRealm sourceRealm = getRealm().locateSourceRealm( name ); if ( sourceRealm != getRealm() ) { // 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 realm for ( Enumeration direct = getRealm().findRealmResources( name ); direct.hasMoreElements(); ) { resources.addElement( direct.nextElement() ); } // Find resources from the parent realm. if ( getRealm().getParentRealm() != null ) { for ( Enumeration parent = getRealm().getParentRealm().findRealmResources( name ); parent.hasMoreElements(); ) { resources.addElement( parent.nextElement() ); } } return resources.elements(); } } ././@LongLink0000000000000000000000000000015100000000000011562 Lustar rootrootplexus-classworlds-1.5.0/src/main/java/org/codehaus/plexus/classworlds/strategy/ParentFirstStrategy.javaplexus-classworlds-1.5.0/src/main/java/org/codehaus/plexus/classworlds/strategy/ParentFirstStrategy.0000644000175000017500000000565311177650032034071 0ustar twernertwernerpackage org.codehaus.plexus.classworlds.strategy; /* * Copyright 2001-2006 Codehaus Foundation. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except * in compliance with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express * or implied. See the License for the specific language governing permissions and limitations under * the License. */ import org.codehaus.plexus.classworlds.realm.ClassRealm; import java.io.IOException; import java.io.InputStream; import java.net.URL; import java.util.Enumeration; import java.util.Vector; /** * @author Jason van Zyl */ public class ParentFirstStrategy extends AbstractStrategy { public ParentFirstStrategy( ClassRealm realm ) { super( realm ); } public Class loadClass( String name ) throws ClassNotFoundException { Class clazz = realm.loadClassFromImport( name ); if ( clazz == null ) { clazz = realm.loadClassFromParent( name ); } if ( clazz == null ) { clazz = realm.loadClassFromSelf( name ); } if ( clazz == null ) { throw new ClassNotFoundException( name ); } return clazz; } public URL getResource( String name ) { URL resource = realm.loadResourceFromImport( name ); if ( resource == null ) { resource = realm.loadResourceFromParent( name ); } if ( resource == null ) { resource = realm.loadResourceFromSelf( 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 { Vector resources = new Vector(); loadResourcesFromRealm( resources, realm.loadResourcesFromImport( name ) ); loadResourcesFromRealm( resources, realm.loadResourcesFromSelf( name ) ); loadResourcesFromRealm( resources, realm.loadResourcesFromParent( name ) ); return resources.elements(); } private void loadResourcesFromRealm( Vector v, Enumeration e ) { if ( e != null ) { for ( Enumeration a = e; a.hasMoreElements(); ) { v.addElement( a.nextElement() ); } } } } ././@LongLink0000000000000000000000000000014600000000000011566 Lustar rootrootplexus-classworlds-1.5.0/src/main/java/org/codehaus/plexus/classworlds/strategy/AbstractStrategy.javaplexus-classworlds-1.5.0/src/main/java/org/codehaus/plexus/classworlds/strategy/AbstractStrategy.jav0000644000175000017500000000224011177647543034076 0ustar twernertwernerpackage org.codehaus.plexus.classworlds.strategy; import org.codehaus.plexus.classworlds.realm.ClassRealm; import org.codehaus.plexus.classworlds.UrlUtils; /* * Copyright 2001-2006 Codehaus Foundation. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ /** * @author Jason van Zyl */ public abstract class AbstractStrategy implements Strategy { protected ClassRealm realm; public AbstractStrategy( ClassRealm realm ) { this.realm = realm; } protected String getNormalizedResource( String name ) { return UrlUtils.normalizeUrlPath( name ); } public ClassRealm getRealm() { return realm; } } ././@LongLink0000000000000000000000000000014700000000000011567 Lustar rootrootplexus-classworlds-1.5.0/src/main/java/org/codehaus/plexus/classworlds/strategy/SelfFirstStrategy.javaplexus-classworlds-1.5.0/src/main/java/org/codehaus/plexus/classworlds/strategy/SelfFirstStrategy.ja0000644000175000017500000000562711177650032034045 0ustar twernertwernerpackage org.codehaus.plexus.classworlds.strategy; /* * Copyright 2001-2006 Codehaus Foundation. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except * in compliance with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express * or implied. See the License for the specific language governing permissions and limitations under * the License. */ import org.codehaus.plexus.classworlds.realm.ClassRealm; import java.io.IOException; import java.io.InputStream; import java.net.URL; import java.util.Enumeration; import java.util.Vector; /** * @author Jason van Zyl */ public class SelfFirstStrategy extends AbstractStrategy { public SelfFirstStrategy( ClassRealm realm ) { super( realm ); } public Class loadClass( String name ) throws ClassNotFoundException { Class clazz = realm.loadClassFromImport( name ); if ( clazz == null ) { clazz = realm.loadClassFromSelf( name ); } if ( clazz == null ) { clazz = realm.loadClassFromParent( name ); } if ( clazz == null ) { throw new ClassNotFoundException( name ); } return clazz; } public URL getResource( String name ) { URL resource = realm.loadResourceFromImport( name ); if ( resource == null ) { resource = realm.loadResourceFromSelf( name ); } if ( resource == null ) { resource = realm.loadResourceFromParent( 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 { Vector resources = new Vector(); loadResourcesFromRealm( resources, realm.loadResourcesFromImport( name ) ); loadResourcesFromRealm( resources, realm.loadResourcesFromSelf( name ) ); loadResourcesFromRealm( resources, realm.loadResourcesFromParent( name ) ); return resources.elements(); } private void loadResourcesFromRealm( Vector v, Enumeration e ) { if ( e != null ) { for ( Enumeration a = e; a.hasMoreElements(); ) { v.addElement( a.nextElement() ); } } } } ././@LongLink0000000000000000000000000000014500000000000011565 Lustar rootrootplexus-classworlds-1.5.0/src/main/java/org/codehaus/plexus/classworlds/strategy/ForeignStrategy.javaplexus-classworlds-1.5.0/src/main/java/org/codehaus/plexus/classworlds/strategy/ForeignStrategy.java0000644000175000017500000000351411122234006034042 0ustar twernertwernerpackage org.codehaus.plexus.classworlds.strategy; import org.codehaus.plexus.classworlds.realm.ClassRealm; import java.io.IOException; import java.net.URL; import java.util.Enumeration; import java.util.Vector; /** * Created by IntelliJ IDEA. * * @uthor: Andrew Williams * @since: Nov 22, 2006 * @version: $Id: ForeignStrategy.java 7933 2008-12-17 17:33:58Z bentmann $ */ public class ForeignStrategy extends DefaultStrategy { private ClassLoader foreign; public ForeignStrategy( ClassRealm realm, ClassLoader foreign ) { super( realm ); this.foreign = foreign; } public Class loadClass( String name ) throws ClassNotFoundException { try { return foreign.loadClass( name ); } catch ( ClassNotFoundException e ) { return super.loadClass( name ); } } public URL getResource( String name ) { name = getNormalizedResource( name ); URL resource; resource = foreign.getResource( name ); if ( resource == null ) { resource = super.getResource( name ); } return resource; } public Enumeration findResources( String name ) throws IOException { name = getNormalizedResource( name ); Vector resources = new Vector(); // Load from DefaultStrategy for ( Enumeration direct = super.findResources( name ); direct.hasMoreElements(); ) { resources.addElement( direct.nextElement() ); } // Load from foreign classloader for ( Enumeration direct = foreign.getResources( name ); direct.hasMoreElements(); ) { resources.addElement( direct.nextElement() ); } return resources.elements(); } } plexus-classworlds-1.5.0/src/main/java/org/codehaus/plexus/classworlds/strategy/Strategy.java0000644000175000017500000000250611122234006032530 0ustar twernertwernerpackage org.codehaus.plexus.classworlds.strategy; /* * Copyright 2001-2006 Codehaus Foundation. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ import org.codehaus.plexus.classworlds.realm.ClassRealm; import java.net.URL; import java.util.Enumeration; import java.io.IOException; import java.io.InputStream; /** * A strategy is a class for defining how classes and resources are located * in classworlds. * * @uthor: Andrew Williams * @since: Nov 19, 2006 * @version: $Id: Strategy.java 7933 2008-12-17 17:33:58Z bentmann $ */ public interface Strategy { Class loadClass( String name ) throws ClassNotFoundException; URL getResource( String name ); InputStream getResourceAsStream( String name ); Enumeration findResources( String name ) throws IOException; ClassRealm getRealm(); } plexus-classworlds-1.5.0/src/main/java/org/codehaus/plexus/classworlds/launcher/0000755000175000017500000000000011225210154030021 5ustar twernertwerner././@LongLink0000000000000000000000000000015400000000000011565 Lustar rootrootplexus-classworlds-1.5.0/src/main/java/org/codehaus/plexus/classworlds/launcher/ConfigurationException.javaplexus-classworlds-1.5.0/src/main/java/org/codehaus/plexus/classworlds/launcher/ConfigurationExcepti0000644000175000017500000000313611122234006034076 0ustar twernertwernerpackage org.codehaus.plexus.classworlds.launcher; /* * Copyright 2001-2006 Codehaus Foundation. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ /** * Indicates an error during Launcher configuration. * * @author bob mcwhirter * @version $Id: ConfigurationException.java 7933 2008-12-17 17:33:58Z bentmann $ */ 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 ); } protected ConfigurationException( Exception cause ) { super( cause ); } } plexus-classworlds-1.5.0/src/main/java/org/codehaus/plexus/classworlds/launcher/Configurator.java0000644000175000017500000001500511122234006033325 0ustar twernertwernerpackage org.codehaus.plexus.classworlds.launcher; /* * Copyright 2001-2006 Codehaus Foundation. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ import java.io.File; import java.io.IOException; import java.io.InputStream; 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 org.codehaus.plexus.classworlds.ClassWorld; import org.codehaus.plexus.classworlds.realm.ClassRealm; import org.codehaus.plexus.classworlds.realm.DuplicateRealmException; import org.codehaus.plexus.classworlds.realm.NoSuchRealmException; /** * Launcher configurator. * * @author bob mcwhirter * @author Jason van Zyl * @version $Id: Configurator.java 7933 2008-12-17 17:33:58Z bentmann $ */ public class Configurator implements ConfigurationHandler { /** * The launcher to configure. */ private Launcher launcher; private ClassWorld world; /** * Processed Realms. */ private Map configuredRealms; /** * Current Realm. */ private ClassRealm curRealm; private ClassLoader foreignClassLoader = null; /** * Construct. * * @param launcher The launcher to configure. */ public Configurator( Launcher launcher ) { this.launcher = launcher; configuredRealms = new HashMap(); if ( launcher != null ) { this.foreignClassLoader = launcher.getSystemClassLoader(); } } /** * Construct. * * @param world 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 world 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 org.codehaus.plexus.classworlds.realm.DuplicateRealmException If the config file defines two realms with the same id. * @throws org.codehaus.plexus.classworlds.realm.NoSuchRealmException If the config file defines a main entry point in * a non-existent realm. */ public void configure( InputStream is ) throws IOException, ConfigurationException, DuplicateRealmException, NoSuchRealmException { if ( world == null ) { world = new ClassWorld(); } curRealm = null; foreignClassLoader = null; if ( this.launcher != null ) { foreignClassLoader = this.launcher.getSystemClassLoader(); } ConfigurationParser parser = new ConfigurationParser( this, System.getProperties() ); parser.parse( is ); // Associate child realms to their parents. associateRealms(); if ( this.launcher != null ) { this.launcher.setWorld( world ); } } // TODO return this to protected when the legacy wrappers can be removed. /** * Associate parent realms with their children. */ public 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.setParentRealm( parentRealm ); } } } } public void addImportFrom( String relamName, String importSpec ) throws NoSuchRealmException { curRealm.importFrom( relamName, importSpec ); } public void addLoadFile( File file ) { try { curRealm.addURL( file.toURI().toURL() ); } catch ( MalformedURLException e ) { // can't really happen... or can it? } } public void addLoadURL( URL url ) { curRealm.addURL( url ); } public void addRealm( String realmName ) throws DuplicateRealmException { curRealm = world.newRealm( realmName, foreignClassLoader ); // Stash the configured realm for subsequent association processing. configuredRealms.put( realmName, curRealm ); } public void setAppMain( String mainClassName, String mainRealmName ) { if ( this.launcher != null ) { this.launcher.setAppMain( mainClassName, mainRealmName ); } } } plexus-classworlds-1.5.0/src/main/java/org/codehaus/plexus/classworlds/launcher/Launcher.java0000644000175000017500000003342211122234006032427 0ustar twernertwernerpackage org.codehaus.plexus.classworlds.launcher; /* * Copyright 2001-2006 Codehaus Foundation. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ import org.codehaus.plexus.classworlds.ClassWorld; import org.codehaus.plexus.classworlds.realm.DuplicateRealmException; import org.codehaus.plexus.classworlds.realm.NoSuchRealmException; import org.codehaus.plexus.classworlds.realm.ClassRealm; 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 7933 2008-12-17 17:33:58Z bentmann $ */ 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 org.codehaus.plexus.classworlds.realm.DuplicateRealmException If the config file defines two realms * with the same id. * @throws org.codehaus.plexus.classworlds.realm.NoSuchRealmException If the config file defines a main entry * point in a non-existent realm. */ public void configure( InputStream is ) throws IOException, 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 { 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; // ---------------------------------------------------------------------- // 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 // ^ // | // | // [ Strategy ] // ---------------------------------------------------------------------- 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 ); 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; 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.getURLs(); 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(); } } ././@LongLink0000000000000000000000000000015200000000000011563 Lustar rootrootplexus-classworlds-1.5.0/src/main/java/org/codehaus/plexus/classworlds/launcher/ConfigurationHandler.javaplexus-classworlds-1.5.0/src/main/java/org/codehaus/plexus/classworlds/launcher/ConfigurationHandler0000644000175000017500000000237711122234006034060 0ustar twernertwernerpackage org.codehaus.plexus.classworlds.launcher; /* * Copyright 2001-2006 Codehaus Foundation. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ import java.io.File; import java.net.URL; import org.codehaus.plexus.classworlds.realm.DuplicateRealmException; import org.codehaus.plexus.classworlds.realm.NoSuchRealmException; /** * Receive notification of the logical content of launcher configuration. * * @author Igor Fedorenko */ public interface ConfigurationHandler { void setAppMain(String mainClassName, String mainRealmName); void addRealm(String realmName) throws DuplicateRealmException; void addImportFrom(String relamName, String importSpec) throws NoSuchRealmException; void addLoadFile(File file); void addLoadURL(URL url); } ././@LongLink0000000000000000000000000000015100000000000011562 Lustar rootrootplexus-classworlds-1.5.0/src/main/java/org/codehaus/plexus/classworlds/launcher/ConfigurationParser.javaplexus-classworlds-1.5.0/src/main/java/org/codehaus/plexus/classworlds/launcher/ConfigurationParser.0000644000175000017500000003217011122234006034007 0ustar twernertwernerpackage org.codehaus.plexus.classworlds.launcher; /* * Copyright 2001-2006 Codehaus Foundation. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ import java.io.BufferedReader; import java.io.File; import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.FilenameFilter; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.net.MalformedURLException; import java.net.URL; import java.util.Properties; import org.codehaus.plexus.classworlds.realm.DuplicateRealmException; import org.codehaus.plexus.classworlds.realm.NoSuchRealmException; /** * Event based launcher configuration parser. * * @author bob mcwhirter * @author Jason van Zyl * @author Igor Fedorenko * * @version $Id: ConfigurationParser.java 7933 2008-12-17 17:33:58Z bentmann $ */ public class ConfigurationParser { 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"; private ConfigurationHandler handler; private Properties systemProperties; public ConfigurationParser( ConfigurationHandler handler, Properties systemProperties ) { this.handler = handler; this.systemProperties = systemProperties; } /** * Parse launcher configuration file and send events to the handler. */ public void parse( InputStream is ) throws IOException, ConfigurationException, DuplicateRealmException, NoSuchRealmException { BufferedReader reader = new BufferedReader( new InputStreamReader( is, "UTF-8" ) ); String line = null; int lineNo = 0; boolean mainSet = false; String curRealm = null; 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(); this.handler.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 = systemProperties.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 ); systemProperties.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 ); handler.addRealm( realmName ); curRealm = realmName; } 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(); handler.addImportFrom( 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, false /*not optionally*/ ); } else { File file = new File( constituent ); if ( file.exists() ) { handler.addLoadFile( file ); } else { try { handler.addLoadURL( 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, true /*optionally*/ ); } else { File file = new File( constituent ); if ( file.exists() ) { handler.addLoadFile( file ); } else { try { handler.addLoadURL( new URL( constituent ) ); } catch ( MalformedURLException e ) { // swallow } } } } else { throw new ConfigurationException( "Unhandled configuration", lineNo, line ); } } reader.close(); } /** * 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. * @throws ConfigurationException */ protected void loadGlob( String line, boolean optionally ) throws MalformedURLException, FileNotFoundException, ConfigurationException { 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 ) { handler.addLoadFile( matches[i] ); } } /** * 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 = systemProperties.getProperty( propName ); /* do our best if we are not running from surefire */ if ( propName.equals( "basedir" ) && ( propValue == null || propValue.equals( "" ) ) ) { propValue = ( new File( "" ) ).getAbsolutePath(); } 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( "#" ) ); } } plexus-classworlds-1.5.0/src/main/java/org/codehaus/plexus/classworlds/UrlUtils.java0000644000175000017500000000353111122234006030646 0ustar twernertwernerpackage org.codehaus.plexus.classworlds; /* * Copyright 2001-2006 Codehaus Foundation. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ import java.util.Set; import java.util.HashSet; import java.net.URLClassLoader; /** * @author Jason van Zyl * @version $Id: UrlUtils.java 7933 2008-12-17 17:33:58Z bentmann $ */ 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; } public static Set getURLs( URLClassLoader loader ) { Set ret = new HashSet(); for ( int i = 0; i < loader.getURLs().length; i++ ) { ret.add( loader.getURLs()[i] ); } return ret; } } plexus-classworlds-1.5.0/src/main/java/org/codehaus/plexus/classworlds/ClassWorldException.java0000644000175000017500000000403511122234006033017 0ustar twernertwernerpackage org.codehaus.plexus.classworlds; /* * Copyright 2001-2006 Codehaus Foundation. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ /** * Base exception for ClassWorld errors. * * @author bob mcwhirter * @version $Id: ClassWorldException.java 7933 2008-12-17 17:33:58Z bentmann $ */ 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; } } plexus-classworlds-1.5.0/src/main/java/org/codehaus/plexus/classworlds/ClassWorld.java0000644000175000017500000001023711177647543031171 0ustar twernertwernerpackage org.codehaus.plexus.classworlds; /* * Copyright 2001-2006 Codehaus Foundation. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ import java.util.ArrayList; import org.codehaus.plexus.classworlds.realm.DuplicateRealmException; import org.codehaus.plexus.classworlds.realm.ClassRealm; import org.codehaus.plexus.classworlds.realm.NoSuchRealmException; import java.util.Map; import java.util.Collection; import java.util.Collections; import java.util.LinkedHashMap; /** * A collection of ClassRealms, indexed by id. * * @author bob mcwhirter * @version $Id: ClassWorld.java 8163 2009-05-04 20:26:11Z 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 LinkedHashMap(); } public ClassRealm newRealm( String id ) throws DuplicateRealmException { return newRealm( id, null ); } public synchronized ClassRealm newRealm( String id, ClassLoader classLoader ) throws DuplicateRealmException { if ( realms.containsKey( id ) ) { throw new DuplicateRealmException( this, id ); } ClassRealm realm; if ( classLoader != null ) { realm = new ClassRealm( this, id, classLoader ); } else { realm = new ClassRealm( this, id ); } realms.put( id, realm ); return realm; } public synchronized void disposeRealm( String id ) throws NoSuchRealmException { realms.remove( id ); } public synchronized ClassRealm getRealm( String id ) throws NoSuchRealmException { if ( realms.containsKey( id ) ) { return (ClassRealm) realms.get( id ); } throw new NoSuchRealmException( this, id ); } public synchronized Collection getRealms() { return Collections.unmodifiableList( new ArrayList(realms.values()) ); } // from exports branch public synchronized ClassRealm getClassRealm( String id ) { if ( realms.containsKey( id ) ) { return (ClassRealm) realms.get( id ); } return null; } } plexus-classworlds-1.5.0/src/main/java/org/codehaus/plexus/classworlds/realm/0000755000175000017500000000000011225210154027320 5ustar twernertwernerplexus-classworlds-1.5.0/src/main/java/org/codehaus/plexus/classworlds/realm/ClassRealm.java0000644000175000017500000002576011200031770032221 0ustar twernertwernerpackage org.codehaus.plexus.classworlds.realm; /* * Copyright 2001-2006 Codehaus Foundation. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ import org.codehaus.plexus.classworlds.strategy.Strategy; import org.codehaus.plexus.classworlds.strategy.StrategyFactory; import org.codehaus.plexus.classworlds.ClassWorld; import java.io.IOException; import java.io.InputStream; import java.net.URL; import java.net.URLClassLoader; import java.net.MalformedURLException; import java.util.Enumeration; import java.util.Iterator; import java.util.Map; import java.util.TreeSet; /** * 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: ClassRealm.java 8170 2009-05-05 12:41:28Z bentmann $ */ public class ClassRealm extends URLClassLoader { private ClassWorld world; private String id; private TreeSet imports; private Strategy strategy; private ClassRealm parent; public ClassRealm( ClassWorld world, String id ) { this( world, id, null ); } public ClassRealm( ClassWorld world, String id, ClassLoader foreignClassLoader ) { super( new URL[]{}, foreignClassLoader ); this.world = world; this.id = id; imports = new TreeSet(); strategy = StrategyFactory.getStrategy( this, foreignClassLoader ); if ( foreignClassLoader instanceof ClassRealm ) { this.parent = (ClassRealm) foreignClassLoader; } } 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 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 Strategy getStrategy() { return strategy; } public void setParentRealm( ClassRealm realm ) { this.parent = realm; } public ClassRealm getParentRealm() { return parent; } public ClassRealm createChildRealm( String id ) throws DuplicateRealmException { ClassRealm childRealm = getWorld().newRealm( id, this ); childRealm.setParentRealm( this ); return childRealm; } public void addURL( URL url ) { String urlStr = url.toExternalForm(); if ( urlStr.startsWith( "jar:" ) && urlStr.endsWith( "!/" ) ) { urlStr = urlStr.substring( 4, urlStr.length() - 2 ); try { url = new URL( urlStr ); } catch ( MalformedURLException e ) { e.printStackTrace(); } } super.addURL( url ); } // ---------------------------------------------------------------------------- // These are the methods that the Strategy must use to get direct access // the contents of the ClassRealm. // ---------------------------------------------------------------------------- public Class loadRealmClass( String name ) throws ClassNotFoundException { return super.loadClass( name, false ); } public URL getRealmResource( String name ) { return super.getResource( name ); } public InputStream getRealmResourceAsStream( String name ) { return super.getResourceAsStream( name ); } public Enumeration findRealmResources( String name ) throws IOException { return super.findResources( name ); } // ---------------------------------------------------------------------- // We delegate to the Strategy here so that we can change the behavior // of any existing ClassRealm. // ---------------------------------------------------------------------- public Class loadClass( String name ) throws ClassNotFoundException { return loadClass( name, false ); } protected Class loadClass( String name, boolean resolve ) throws ClassNotFoundException { return strategy.loadClass( name ); } public URL getResource( String name ) { return strategy.getResource( name ); } public InputStream getResourceAsStream( String name ) { return strategy.getResourceAsStream( name ); } public Enumeration findResources( String name ) throws IOException { return strategy.findResources( name ); } // ---------------------------------------------------------------------------- // Display methods // ---------------------------------------------------------------------------- public void display() { ClassRealm cr = this; System.out.println( "-----------------------------------------------------" ); while ( cr != null ) { System.out.println( "this realm = " + cr.getId() ); System.out.println( "this strategy = " + this.getStrategy().getClass().getName() ); showUrls( cr ); System.out.println( "\n" ); cr = cr.getParentRealm(); } System.out.println( "-----------------------------------------------------" ); } private void showUrls( ClassRealm classRealm ) { URL[] urls = classRealm.getURLs(); 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() ); } } public boolean equals(Object o) { if ( !( o instanceof ClassRealm ) ) return false; return getId().equals( ( (ClassRealm) o ).getId() ); } public String toString() { return "ClassRealm[" + getId() + ", parent: " + getParentRealm() + "]"; } //--------------------------------------------------------------------------------------------- // Search methods that can be ordered by strategies //--------------------------------------------------------------------------------------------- /** Map of packages to import from given realms */ private Map importRealmMappings; public ClassRealm getImportRealm( String classname ) { for ( Iterator iterator = imports.iterator(); iterator.hasNext(); ) { Entry entry = (Entry) iterator.next(); if ( entry.matches( classname ) || entry.matches( classname.replace( '.', '/' ) ) ) { return world.getClassRealm( (String) importRealmMappings.get( entry.pkgName ) ); } } return null; } public Class loadClassFromImport( String name ) { ClassRealm importRealm = getImportRealm( name ); Class clazz = null; if ( importRealm != null ) { try { clazz = importRealm.loadClass( name ); } catch ( ClassNotFoundException e ) { return null; } } return clazz; } public Class loadClassFromSelf( String name ) { Class clazz; try { clazz = findLoadedClass( name ); if ( clazz == null ) { clazz = findClass( name ); } } catch ( ClassNotFoundException e ) { return null; } resolveClass( clazz ); return clazz; } public Class loadClassFromParent( String name ) { if ( getParent() != null ) { try { return getParent().loadClass( name ); } catch ( ClassNotFoundException e ) { return null; } } return null; } //--------------------------------------------------------------------------------------------- // Resources //--------------------------------------------------------------------------------------------- public URL loadResourceFromImport( String name ) { ClassRealm importRealm = getImportRealm( name ); if ( importRealm != null ) { return importRealm.findResource( name ); } return null; } public URL loadResourceFromSelf( String name ) { URL url = findResource( name ); return url; } public URL loadResourceFromParent( String name ) { if ( getParent() != null ) { return getParent().getResource( name ); } return null; } // Resources public Enumeration loadResourcesFromImport( String name ) { ClassRealm importRealm = getImportRealm( name ); if ( importRealm != null ) { try { return importRealm.findResources( name ); } catch ( IOException e ) { return null; } } return null; } public Enumeration loadResourcesFromSelf( String name ) { try { return super.findResources( name ); } catch ( IOException e ) { return null; } } public Enumeration loadResourcesFromParent( String name ) { if ( getParent() != null ) { try { return getParent().getResources( name ); } catch ( IOException e ) { return null; } } return null; } } ././@LongLink0000000000000000000000000000015200000000000011563 Lustar rootrootplexus-classworlds-1.5.0/src/main/java/org/codehaus/plexus/classworlds/realm/DuplicateRealmException.javaplexus-classworlds-1.5.0/src/main/java/org/codehaus/plexus/classworlds/realm/DuplicateRealmException0000644000175000017500000000404411122234006034015 0ustar twernertwernerpackage org.codehaus.plexus.classworlds.realm; import org.codehaus.plexus.classworlds.ClassWorldException; import org.codehaus.plexus.classworlds.ClassWorld; /* * Copyright 2001-2006 Codehaus Foundation. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ /** * Indicates an attempt to add a ClassRealm to a * ClassWorld with a duplicate id. * * @author bob mcwhirter * @version $Id: DuplicateRealmException.java 7933 2008-12-17 17:33:58Z bentmann $ */ 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; } } ././@LongLink0000000000000000000000000000014700000000000011567 Lustar rootrootplexus-classworlds-1.5.0/src/main/java/org/codehaus/plexus/classworlds/realm/NoSuchRealmException.javaplexus-classworlds-1.5.0/src/main/java/org/codehaus/plexus/classworlds/realm/NoSuchRealmException.ja0000644000175000017500000000403411122234006033672 0ustar twernertwernerpackage org.codehaus.plexus.classworlds.realm; import org.codehaus.plexus.classworlds.ClassWorldException; import org.codehaus.plexus.classworlds.ClassWorld; /* * Copyright 2001-2006 Codehaus Foundation. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ /** * Indicates an attempt to retrieve a ClassRealm from a * ClassWorld with an invalid id. * * @author bob mcwhirter * @version $Id: NoSuchRealmException.java 7933 2008-12-17 17:33:58Z bentmann $ */ 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; } } plexus-classworlds-1.5.0/src/main/java/org/codehaus/plexus/classworlds/realm/Entry.java0000644000175000017500000000744111177647543031320 0ustar twernertwernerpackage org.codehaus.plexus.classworlds.realm; /* * Copyright 2001-2006 Codehaus Foundation. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ /** * Import description entry. * * @author bob mcwhirter */ public class Entry implements Comparable { final ClassRealm realm; 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 package 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(); } public String toString() { return "Entry[import " + getPackageName() + " from realm " + getRealm() + "]"; } } plexus-classworlds-1.5.0/src/main/java/org/codehaus/plexus/classworlds/event/0000755000175000017500000000000011225210154027341 5ustar twernertwerner././@LongLink0000000000000000000000000000015000000000000011561 Lustar rootrootplexus-classworlds-1.5.0/src/main/java/org/codehaus/plexus/classworlds/event/ResourceEventListener.javaplexus-classworlds-1.5.0/src/main/java/org/codehaus/plexus/classworlds/event/ResourceEventListener.j0000644000175000017500000000126311122234006034013 0ustar twernertwernerpackage org.codehaus.plexus.classworlds.event; import org.codehaus.plexus.classworlds.strategy.Strategy; import java.net.URL; /** * Created by IntelliJ IDEA. * * @uthor: Andrew Williams * @since: Nov 29, 2006 * @version: $Id: ResourceEventListener.java 7933 2008-12-17 17:33:58Z bentmann $ */ public interface ResourceEventListener { void lookup( String name, Strategy strategy ); void failed( String name, Strategy strategy ); void found( String name, Strategy strategy, URL found ); /* TODO: decide if these would be useful void findStarted( String name, Strategy strategy ); void findReturned( String name, Strategy strategy, Enumeration returned ); */ } plexus-classworlds-1.5.0/src/main/java/org/codehaus/plexus/classworlds/event/ClassEventDebug.java0000644000175000017500000000247111122234006033224 0ustar twernertwernerpackage org.codehaus.plexus.classworlds.event; import org.codehaus.plexus.classworlds.strategy.Strategy; /** * Created by IntelliJ IDEA. * * @uthor: Andrew Williams * @since: Nov 29, 2006 * @version: $Id: ClassEventDebug.java 7933 2008-12-17 17:33:58Z bentmann $ */ public class ClassEventDebug implements ClassEventListener { protected static String getClassName( Class in ) { String name = in.getName(); int pos = name.lastIndexOf( '.' ); if ( pos == -1 ) return name; return name.substring( pos + 1 ); } private void log( Strategy strategy, String message ) { System.out.println( "[classworlds " + getClassName( strategy.getClass() ) + "] " + message ); } public void lookup( String name, Strategy strategy ) { log( strategy, "Lookup: " + name ); } public void failed( String name, Strategy strategy, Exception reason ) { log( strategy, "Failed: " + name + " (" + reason.getClass().getName() + ": " + reason.getMessage() + ")"); } public void found( String name, Strategy strategy, Class found ) { log( strategy, "Found : " + name ); } } ././@LongLink0000000000000000000000000000014500000000000011565 Lustar rootrootplexus-classworlds-1.5.0/src/main/java/org/codehaus/plexus/classworlds/event/ClassEventListener.javaplexus-classworlds-1.5.0/src/main/java/org/codehaus/plexus/classworlds/event/ClassEventListener.java0000644000175000017500000000076611122234006033770 0ustar twernertwernerpackage org.codehaus.plexus.classworlds.event; import org.codehaus.plexus.classworlds.strategy.Strategy; /** * Created by IntelliJ IDEA. * * @uthor: Andrew Williams * @since: Nov 29, 2006 * @version: $Id: ClassEventListener.java 7933 2008-12-17 17:33:58Z bentmann $ */ public interface ClassEventListener { void lookup( String name, Strategy strategy ); void failed( String name, Strategy strategy, Exception reason ); void found( String name, Strategy strategy, Class found ); } ././@LongLink0000000000000000000000000000014500000000000011565 Lustar rootrootplexus-classworlds-1.5.0/src/main/java/org/codehaus/plexus/classworlds/event/ResourceEventDebug.javaplexus-classworlds-1.5.0/src/main/java/org/codehaus/plexus/classworlds/event/ResourceEventDebug.java0000644000175000017500000000205011122234006033737 0ustar twernertwernerpackage org.codehaus.plexus.classworlds.event; import org.codehaus.plexus.classworlds.strategy.Strategy; import java.net.URL; /** * Created by IntelliJ IDEA. * * @uthor: Andrew Williams * @since: Nov 29, 2006 * @version: $Id: ResourceEventDebug.java 7933 2008-12-17 17:33:58Z bentmann $ */ public class ResourceEventDebug extends ClassEventDebug implements ResourceEventListener { private void log( Strategy strategy, String message ) { System.out.println( "[classworlds " + getClassName( strategy.getClass() ) + "] " + message ); } public void lookup( String name, Strategy strategy ) { log( strategy, "Lookup res: " + name ); } public void failed( String name, Strategy strategy ) { log( strategy, "Failed res: " + name ); } public void found( String name, Strategy strategy, URL found ) { log( strategy, "Found res : " + name + " (" + found + ")" ); } } plexus-classworlds-1.5.0/src/main/java/org/codehaus/classworlds/0000755000175000017500000000000011225210154024700 5ustar twernertwernerplexus-classworlds-1.5.0/src/main/java/org/codehaus/classworlds/ClassRealmAdapter.java0000644000175000017500000000677311122234006031105 0ustar twernertwernerpackage org.codehaus.classworlds; import java.net.URL; import java.util.Enumeration; import java.util.HashMap; import java.io.IOException; import java.io.InputStream; /** * An adapter for ClassRealms * * @author Andrew Williams * @version $Id: ClassRealmAdapter.java 7933 2008-12-17 17:33:58Z bentmann $ */ public class ClassRealmAdapter implements ClassRealm { private static HashMap instances = new HashMap(); public static ClassRealmAdapter getInstance( org.codehaus.plexus.classworlds.realm.ClassRealm newRealm ) { if ( instances.containsKey( newRealm ) ) return (ClassRealmAdapter) instances.get( newRealm ); ClassRealmAdapter adapter = new ClassRealmAdapter( newRealm ); instances.put( newRealm, adapter ); return adapter; } private org.codehaus.plexus.classworlds.realm.ClassRealm realm; private ClassRealmAdapter( org.codehaus.plexus.classworlds.realm.ClassRealm newRealm ) { this.realm = newRealm; } public String getId() { return realm.getId(); } public ClassWorld getWorld() { return ClassWorldAdapter.getInstance( realm.getWorld() ); } public void importFrom( String realmId, String pkgName ) throws NoSuchRealmException { try { realm.importFrom( realmId, pkgName ); } catch ( org.codehaus.plexus.classworlds.realm.NoSuchRealmException e ) { throw new NoSuchRealmException( getWorld(), e.getId() ); } } public void addConstituent( URL constituent ) { realm.addURL( constituent ); } public ClassRealm locateSourceRealm( String className ) { return ClassRealmAdapter.getInstance( realm.locateSourceRealm( className ) ); } public void setParent( ClassRealm classRealm ) { if ( classRealm != null ) { realm.setParentRealm( ClassRealmReverseAdapter.getInstance( classRealm ) ); } } public ClassRealm createChildRealm( String id ) throws DuplicateRealmException { try { return ClassRealmAdapter.getInstance( realm.createChildRealm( id ) ); } catch ( org.codehaus.plexus.classworlds.realm.DuplicateRealmException e ) { throw new DuplicateRealmException( getWorld(), e.getId() ); } } public ClassLoader getClassLoader() { return realm; } public ClassRealm getParent() { return ClassRealmAdapter.getInstance( realm.getParentRealm() ); } public ClassRealm getParentRealm() { return ClassRealmAdapter.getInstance( realm.getParentRealm() ); } public URL[] getConstituents() { return realm.getURLs(); } public Class loadClass( String name ) throws ClassNotFoundException { return realm.loadClass( name ); } public URL getResource( String name ) { return realm.getResource( name ); } public Enumeration findResources( String name ) throws IOException { return realm.findResources( name ); } public InputStream getResourceAsStream( String name ) { return realm.getResourceAsStream( name ); } public void display() { realm.display(); } public boolean equals(Object o) { if ( !( o instanceof ClassRealm ) ) return false; return getId().equals( ( (ClassRealm) o ).getId() ); } } plexus-classworlds-1.5.0/src/main/java/org/codehaus/classworlds/ClassRealm.java0000644000175000017500000000725111122234006027574 0ustar twernertwernerpackage org.codehaus.classworlds; /* $Id: ClassRealm.java 7933 2008-12-17 17:33:58Z bentmann $ 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 7933 2008-12-17 17:33:58Z bentmann $ */ 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(); } plexus-classworlds-1.5.0/src/main/java/org/codehaus/classworlds/ConfigurationException.java0000644000175000017500000000546411122234006032240 0ustar twernertwernerpackage org.codehaus.classworlds; /* $Id: ConfigurationException.java 7933 2008-12-17 17:33:58Z bentmann $ 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 7933 2008-12-17 17:33:58Z bentmann $ */ 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 ); } } plexus-classworlds-1.5.0/src/main/java/org/codehaus/classworlds/DuplicateRealmException.java0000644000175000017500000000646111122234006032322 0ustar twernertwernerpackage org.codehaus.classworlds; /* $Id: DuplicateRealmException.java 7933 2008-12-17 17:33:58Z bentmann $ 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 7933 2008-12-17 17:33:58Z bentmann $ */ 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; } } plexus-classworlds-1.5.0/src/main/java/org/codehaus/classworlds/ClassWorldReverseAdapter.java0000644000175000017500000000616411122234006032462 0ustar twernertwernerpackage org.codehaus.classworlds; import java.util.HashMap; import java.util.Collection; import java.util.Vector; import java.util.Iterator; /** * A reverse adapter for ClassWorlds * * @author Andrew Williams * @version $Id: ClassWorldReverseAdapter.java 7933 2008-12-17 17:33:58Z bentmann $ */ public class ClassWorldReverseAdapter extends org.codehaus.plexus.classworlds.ClassWorld { private static HashMap instances = new HashMap(); public static ClassWorldReverseAdapter getInstance( ClassWorld oldWorld ) { if ( instances.containsKey( oldWorld ) ) return (ClassWorldReverseAdapter) instances.get( oldWorld ); ClassWorldReverseAdapter adapter = new ClassWorldReverseAdapter( oldWorld ); instances.put( oldWorld, adapter ); return adapter; } private ClassWorld world; private ClassWorldReverseAdapter( ClassWorld newWorld ) { super(); this.world = newWorld; } public org.codehaus.plexus.classworlds.realm.ClassRealm newRealm( String id ) throws org.codehaus.plexus.classworlds.realm.DuplicateRealmException { try { return ClassRealmReverseAdapter.getInstance( world.newRealm( id ) ); } catch ( DuplicateRealmException e ) { throw new org.codehaus.plexus.classworlds.realm.DuplicateRealmException( this, e.getId() ); } } public org.codehaus.plexus.classworlds.realm.ClassRealm newRealm( String id, ClassLoader classLoader ) throws org.codehaus.plexus.classworlds.realm.DuplicateRealmException { try { return ClassRealmReverseAdapter.getInstance( world.newRealm( id, classLoader ) ); } catch ( DuplicateRealmException e ) { throw new org.codehaus.plexus.classworlds.realm.DuplicateRealmException( this, e.getId() ); } } public void disposeRealm( String id ) throws org.codehaus.plexus.classworlds.realm.NoSuchRealmException { try { world.disposeRealm( id ); } catch ( NoSuchRealmException e ) { throw new org.codehaus.plexus.classworlds.realm.NoSuchRealmException( this, e.getId() ); } } public org.codehaus.plexus.classworlds.realm.ClassRealm getRealm( String id ) throws org.codehaus.plexus.classworlds.realm.NoSuchRealmException { try { return ClassRealmReverseAdapter.getInstance( world.getRealm( id ) ); } catch ( NoSuchRealmException e ) { throw new org.codehaus.plexus.classworlds.realm.NoSuchRealmException( this, e.getId() ); } } public Collection getRealms() { Collection realms = world.getRealms(); Vector ret = new Vector(); Iterator it = realms.iterator(); while ( it.hasNext() ) { ClassRealm realm = (ClassRealm) it.next(); ret.add( ClassRealmReverseAdapter.getInstance( realm ) ); } return ret; } } plexus-classworlds-1.5.0/src/main/java/org/codehaus/classworlds/NoSuchRealmException.java0000644000175000017500000000644611122234006031612 0ustar twernertwernerpackage org.codehaus.classworlds; /* $Id: NoSuchRealmException.java 7933 2008-12-17 17:33:58Z bentmann $ 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 7933 2008-12-17 17:33:58Z bentmann $ */ 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; } } plexus-classworlds-1.5.0/src/main/java/org/codehaus/classworlds/ClassWorldAdapter.java0000644000175000017500000000570511122234006031126 0ustar twernertwernerpackage org.codehaus.classworlds; import java.util.Collection; import java.util.HashMap; import java.util.Vector; import java.util.Iterator; /** * An adapter for ClassWorlds * * @author Andrew Williams * @version $Id: ClassWorldAdapter.java 7933 2008-12-17 17:33:58Z bentmann $ */ public class ClassWorldAdapter extends ClassWorld { private static HashMap instances = new HashMap(); public static ClassWorldAdapter getInstance( org.codehaus.plexus.classworlds.ClassWorld newWorld ) { if ( instances.containsKey( newWorld ) ) return (ClassWorldAdapter) instances.get( newWorld ); ClassWorldAdapter adapter = new ClassWorldAdapter( newWorld ); instances.put( newWorld, adapter ); return adapter; } private org.codehaus.plexus.classworlds.ClassWorld world; private ClassWorldAdapter( org.codehaus.plexus.classworlds.ClassWorld newWorld ) { super( false ); this.world = newWorld; } public ClassRealm newRealm( String id ) throws DuplicateRealmException { try { return ClassRealmAdapter.getInstance( world.newRealm( id ) ); } catch ( org.codehaus.plexus.classworlds.realm.DuplicateRealmException e ) { throw new DuplicateRealmException( this, e.getId() ); } } public ClassRealm newRealm( String id, ClassLoader classLoader ) throws DuplicateRealmException { try { return ClassRealmAdapter.getInstance( world.newRealm( id, classLoader ) ); } catch ( org.codehaus.plexus.classworlds.realm.DuplicateRealmException e ) { throw new DuplicateRealmException( this, e.getId() ); } } public void disposeRealm( String id ) throws NoSuchRealmException { try { world.disposeRealm( id ); } catch ( org.codehaus.plexus.classworlds.realm.NoSuchRealmException e ) { throw new NoSuchRealmException( this, e.getId() ); } } public ClassRealm getRealm( String id ) throws NoSuchRealmException { try { return ClassRealmAdapter.getInstance( world.getRealm( id ) ); } catch ( org.codehaus.plexus.classworlds.realm.NoSuchRealmException e ) { throw new NoSuchRealmException( this, e.getId() ); } } public Collection getRealms() { Collection realms = world.getRealms(); Vector ret = new Vector(); Iterator it = realms.iterator(); while ( it.hasNext() ) { org.codehaus.plexus.classworlds.realm.ClassRealm realm = (org.codehaus.plexus.classworlds.realm.ClassRealm) it.next(); ret.add( ClassRealmAdapter.getInstance( realm ) ); } return ret; } } plexus-classworlds-1.5.0/src/main/java/org/codehaus/classworlds/ClassRealmReverseAdapter.java0000644000175000017500000000722711122234006032434 0ustar twernertwernerpackage org.codehaus.classworlds; import java.util.HashMap; import java.util.Enumeration; import java.net.URL; import java.io.IOException; import java.io.InputStream; /** * A reverse adapter for ClassRealms * * @author Andrew Williams * @version $Id: ClassRealmReverseAdapter.java 7933 2008-12-17 17:33:58Z bentmann $ */ public class ClassRealmReverseAdapter extends org.codehaus.plexus.classworlds.realm.ClassRealm { private static HashMap instances = new HashMap(); public static ClassRealmReverseAdapter getInstance( ClassRealm oldRealm ) { if ( instances.containsKey( oldRealm ) ) return (ClassRealmReverseAdapter) instances.get( oldRealm ); ClassRealmReverseAdapter adapter = new ClassRealmReverseAdapter( oldRealm ); instances.put( oldRealm, adapter ); return adapter; } private ClassRealm realm; private ClassRealmReverseAdapter( ClassRealm oldRealm ) { super( ClassWorldReverseAdapter.getInstance( oldRealm.getWorld() ), oldRealm.getId(), oldRealm.getClassLoader() ); this.realm = oldRealm; } public String getId() { return realm.getId(); } public org.codehaus.plexus.classworlds.ClassWorld getWorld() { return ClassWorldReverseAdapter.getInstance( realm.getWorld() ); } public void importFrom( String realmId, String pkgName ) throws org.codehaus.plexus.classworlds.realm.NoSuchRealmException { try { realm.importFrom( realmId, pkgName ); } catch ( NoSuchRealmException e ) { throw new org.codehaus.plexus.classworlds.realm.NoSuchRealmException( getWorld(), e.getId() ); } } public void addURL( URL constituent ) { realm.addConstituent( constituent ); } public org.codehaus.plexus.classworlds.realm.ClassRealm locateSourceRealm( String className ) { return getInstance( realm.locateSourceRealm( className ) ); } public void setParentRealm( org.codehaus.plexus.classworlds.realm.ClassRealm classRealm ) { realm.setParent( ClassRealmAdapter.getInstance( classRealm ) ); } public org.codehaus.plexus.classworlds.realm.ClassRealm createChildRealm( String id ) throws org.codehaus.plexus.classworlds.realm.DuplicateRealmException { try { return getInstance( realm.createChildRealm( id ) ); } catch ( DuplicateRealmException e ) { throw new org.codehaus.plexus.classworlds.realm.DuplicateRealmException( getWorld(), e.getId() ); } } public ClassLoader getClassLoader() { return realm.getClassLoader(); } public org.codehaus.plexus.classworlds.realm.ClassRealm getParentRealm() { return getInstance( realm.getParent() ); } public URL[] getURLs() { return realm.getConstituents(); } public Class loadClass( String name ) throws ClassNotFoundException { return realm.loadClass( name ); } public URL getResource( String name ) { return realm.getResource( name ); } public Enumeration findResources( String name ) throws IOException { return realm.findResources( name ); } public InputStream getResourceAsStream( String name ) { return realm.getResourceAsStream( name ); } public void display() { realm.display(); } public boolean equals(Object o) { if ( !( o instanceof ClassRealm ) ) return false; return getId().equals( ( (ClassRealm) o ).getId() ); } } plexus-classworlds-1.5.0/src/main/java/org/codehaus/classworlds/Configurator.java0000644000175000017500000000771611122234006030216 0ustar twernertwernerpackage org.codehaus.classworlds; import java.io.FileNotFoundException; import java.io.IOException; import java.io.InputStream; import java.net.MalformedURLException; /** * A compatibility wrapper for org.codehaus.plexus.classworlds.launcher.Configurator * provided for legacy code * * @author Andrew Williams * @version $Id: Configurator.java 7933 2008-12-17 17:33:58Z bentmann $ */ public class Configurator { private ConfiguratorAdapter config; /** Construct. * * @param launcher The launcher to configure. */ public Configurator( Launcher launcher ) { config = ConfiguratorAdapter.getInstance( new org.codehaus.plexus.classworlds.launcher.Configurator( launcher ), launcher ); } /** Construct. * * @param world The classWorld to configure. */ public Configurator( ClassWorld world ) { config = ConfiguratorAdapter.getInstance( new org.codehaus.plexus.classworlds.launcher.Configurator( ClassWorldReverseAdapter.getInstance( world ) ), world ); } /** set world. * this setter is provided so you can use the same configurator to configure several "worlds" * * @param world The classWorld to configure. */ public void setClassWorld( ClassWorld world ) { config.setClassWorld( 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 { config.configureAdapter( is ); } /** * Associate parent realms with their children. */ protected void associateRealms() { config.associateRealms(); } /** * 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 { config.loadGlob( line, realm, optionally ); } /** * 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 { return config.filter( text ); } } plexus-classworlds-1.5.0/src/main/java/org/codehaus/classworlds/BytesURLStreamHandler.java0000644000175000017500000000106711122234006031670 0ustar twernertwernerpackage 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 ); } }plexus-classworlds-1.5.0/src/main/java/org/codehaus/classworlds/ClassWorldException.java0000644000175000017500000000657411122234006031511 0ustar twernertwernerpackage org.codehaus.classworlds; /* $Id: ClassWorldException.java 7933 2008-12-17 17:33:58Z bentmann $ 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 7933 2008-12-17 17:33:58Z bentmann $ */ 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; } } plexus-classworlds-1.5.0/src/main/java/org/codehaus/classworlds/Launcher.java0000644000175000017500000000246711122234006027313 0ustar twernertwernerpackage org.codehaus.classworlds; /** * A compatibility wrapper for org.codehaus.plexus.classworlds.launcher.Launcher * provided for legacy code * * @author Andrew Williams * @version $Id: Launcher.java 7933 2008-12-17 17:33:58Z bentmann $ */ public class Launcher extends org.codehaus.plexus.classworlds.launcher.Launcher { public Launcher() { } // ------------------------------------------------------------ // 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 ) { org.codehaus.plexus.classworlds.launcher.Launcher.main( args ); } /** * 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 { return org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode( args ); } } plexus-classworlds-1.5.0/src/main/java/org/codehaus/classworlds/BytesURLConnection.java0000644000175000017500000000126311122234006031234 0ustar twernertwernerpackage 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 ); } }plexus-classworlds-1.5.0/src/main/java/org/codehaus/classworlds/ClassWorld.java0000644000175000017500000000271311122234006027621 0ustar twernertwernerpackage org.codehaus.classworlds; import java.util.Collection; /** * A compatibility wrapper for org.codehaus.plexus.classworlds.ClassWorld * provided for legacy code * * @author Andrew Williams * @version $Id: ClassWorld.java 7933 2008-12-17 17:33:58Z bentmann $ */ public class ClassWorld { private ClassWorldAdapter adapter; public ClassWorld( String realmId, ClassLoader classLoader ) { adapter = ClassWorldAdapter.getInstance( new org.codehaus.plexus.classworlds.ClassWorld( realmId, classLoader ) ); } public ClassWorld() { adapter = ClassWorldAdapter.getInstance( new org.codehaus.plexus.classworlds.ClassWorld( ) ); } public ClassWorld( boolean ignore ) { /* fake */ } public ClassRealm newRealm( String id ) throws DuplicateRealmException { return adapter.newRealm( id ); } public ClassRealm newRealm( String id, ClassLoader classLoader ) throws DuplicateRealmException { return adapter.newRealm( id, classLoader ); } public void disposeRealm( String id ) throws NoSuchRealmException { adapter.disposeRealm( id ); } public ClassRealm getRealm( String id ) throws NoSuchRealmException { return adapter.getRealm( id ); } public Collection getRealms() { return adapter.getRealms(); } } plexus-classworlds-1.5.0/src/main/java/org/codehaus/classworlds/DefaultClassRealm.java0000644000175000017500000001012011122234006031066 0ustar twernertwernerpackage org.codehaus.classworlds; /** * A compatibility wrapper for org.codehaus.plexus.classworlds.realm.ClassRealm * provided for legacy code * * @author Andrew Williams * @version $Id: DefaultClassRealm.java 7933 2008-12-17 17:33:58Z bentmann $ */ import java.io.File; import java.io.IOException; import java.io.InputStream; import java.net.URL; import java.util.Enumeration; public class DefaultClassRealm implements ClassRealm { private ClassRealmAdapter adapter; public DefaultClassRealm( ClassWorld world, String id ) { this( world, id, null ); } public DefaultClassRealm( ClassWorld world, String id, ClassLoader foreignClassLoader ) { this.adapter = ClassRealmAdapter.getInstance( new org.codehaus.plexus.classworlds.realm.ClassRealm( ClassWorldReverseAdapter.getInstance( world ), id, foreignClassLoader ) ); } public URL[] getConstituents() { return adapter.getConstituents(); } public ClassRealm getParent() { return adapter.getParentRealm(); } public void setParent( ClassRealm parent ) { adapter.setParent( parent ); } public String getId() { return adapter.getId(); } public ClassWorld getWorld() { return adapter.getWorld(); } public void importFrom( String realmId, String packageName ) throws NoSuchRealmException { adapter.importFrom( realmId, packageName ); } public void addConstituent( URL constituent ) { adapter.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.toURI().toURL().toExternalForm(), new BytesURLStreamHandler(b) ) ); } catch (java.io.IOException e) { throw new ClassNotFoundException( "Couldn't load byte stream.", e ); } } public ClassRealm locateSourceRealm( String classname ) { return adapter.locateSourceRealm( classname ); } public ClassLoader getClassLoader() { return adapter.getClassLoader(); } public ClassRealm createChildRealm( String id ) throws DuplicateRealmException { return adapter.createChildRealm( id ); } // ---------------------------------------------------------------------- // ClassLoader API // ---------------------------------------------------------------------- public Class loadClass( String name ) throws ClassNotFoundException { return adapter.loadClass( name ); } public URL getResource( String name ) { return adapter.getResource( name ); } public InputStream getResourceAsStream( String name ) { return adapter.getResourceAsStream( name ); } public Enumeration findResources(String name) throws IOException { return adapter.findResources( name ); } public void display() { adapter.display(); } } plexus-classworlds-1.5.0/src/main/java/org/codehaus/classworlds/ConfiguratorAdapter.java0000644000175000017500000000527411122234006031514 0ustar twernertwernerpackage org.codehaus.classworlds; import java.io.InputStream; import java.io.IOException; import java.net.MalformedURLException; import java.util.HashMap; /** * Created by IntelliJ IDEA. * * @uthor: Andrew Williams * @since: Nov 25, 2006 * @version: $Id: ConfiguratorAdapter.java 7933 2008-12-17 17:33:58Z bentmann $ */ public class ConfiguratorAdapter extends Configurator { private static HashMap instances = new HashMap(); public static ConfiguratorAdapter getInstance( org.codehaus.plexus.classworlds.launcher.Configurator newConfig, Launcher launcher ) { if ( instances.containsKey( newConfig ) ) return (ConfiguratorAdapter) instances.get( newConfig ); ConfiguratorAdapter adapter = new ConfiguratorAdapter( newConfig, launcher ); instances.put( newConfig, adapter ); return adapter; } public static ConfiguratorAdapter getInstance( org.codehaus.plexus.classworlds.launcher.Configurator newConfig, ClassWorld world ) { if ( instances.containsKey( newConfig ) ) return (ConfiguratorAdapter) instances.get( newConfig ); ConfiguratorAdapter adapter = new ConfiguratorAdapter( newConfig, world ); instances.put( newConfig, adapter ); return adapter; } private org.codehaus.plexus.classworlds.launcher.Configurator config; private ConfiguratorAdapter( org.codehaus.plexus.classworlds.launcher.Configurator config, Launcher launcher ) { super( launcher ); this.config = config; } private ConfiguratorAdapter( org.codehaus.plexus.classworlds.launcher.Configurator config, ClassWorld world ) { super( world ); this.config = config; } public void associateRealms() { config.associateRealms(); } public void configureAdapter( InputStream is ) throws IOException, MalformedURLException, ConfigurationException, DuplicateRealmException, NoSuchRealmException { try { config.configure( is ); } catch ( org.codehaus.plexus.classworlds.launcher.ConfigurationException e ) { throw new ConfigurationException( e.getMessage() ); } catch ( org.codehaus.plexus.classworlds.realm.DuplicateRealmException e ) { throw new DuplicateRealmException( ClassWorldAdapter.getInstance( e.getWorld() ), e.getId() ); } catch ( org.codehaus.plexus.classworlds.realm.NoSuchRealmException e ) { throw new NoSuchRealmException( ClassWorldAdapter.getInstance( e.getWorld() ), e.getId() ); } } } plexus-classworlds-1.5.0/pom.xml0000644000175000017500000001660111202554735016656 0ustar twernertwerner 4.0.0 plexus org.codehaus.plexus 2.0.2 org.codehaus.plexus plexus-classworlds 1.5.0 Plexus Classworlds A class loader framework 2002 scm:svn:http://svn.codehaus.org/plexus/plexus-classworlds/tags/plexus-classworlds-1.5.0 scm:svn:https://svn.codehaus.org/plexus/plexus-classworlds/tags/plexus-classworlds-1.5.0 http://fisheye.codehaus.org/browse/plexus/plexus-classworlds/tags/plexus-classworlds-1.5.0 junit junit 3.8.2 test org.apache.maven.plugins maven-surefire-plugin 2.4.2 true -ea:org.codehaus.classworlds:org.codehaus.plexus.classworlds once org.apache.maven.plugins maven-compiler-plugin org/codehaus/plexus/classworlds/event/* org.apache.maven.plugins maven-dependency-plugin 2.0 generate-test-resources copy ant ant 1.6.5 commons-logging commons-logging 1.0.3 xml-apis xml-apis 1.3.02 ${project.build.directory}/test-lib debug aspectj aspectjrt 1.5.0 org.codehaus.mojo aspectj-maven-plugin compile 1.4 reporting org.apache.maven.plugins maven-project-info-reports-plugin 2.1 org.apache.maven.plugins maven-surefire-report-plugin 2.4.3 org.apache.maven.plugins maven-checkstyle-plugin 2.2 http://svn.apache.org/repos/asf/maven/plugins/trunk/maven-checkstyle-plugin/src/main/resources/config/maven_checks.xml http://svn.apache.org/repos/asf/maven/plugins/trunk/maven-checkstyle-plugin/src/main/resources/config/maven-header.txt org.apache.maven.plugins maven-pmd-plugin 2.4 http://svn.apache.org/repos/asf/maven/plugins/trunk/maven-pmd-plugin/src/main/resources/rulesets/maven.xml org.codehaus.mojo taglist-maven-plugin 2.2 org.apache.maven.plugins maven-jxr-plugin 2.1 ${project.build.sourceEncoding} org.apache.maven.plugins maven-javadoc-plugin 2.5 ${project.build.sourceEncoding} http://java.sun.com/j2ee/1.4/docs/api http://junit.sourceforge.net/javadoc/ javadoc test-javadoc