knopflerfish-osgi-2.3.3/0000755000175000017500000000000011400541206015077 5ustar twernertwernerknopflerfish-osgi-2.3.3/knopflerfish_red400pxl.gif0000644000175000017500000001573511252437356022114 0ustar twernertwernerGIF89aK!)!))))1)11119!19!99!9B)99)9B)BB)BJ1BB1BJ1JJ9BJ9JJ9JR9RRBJRBRRBRZBZZJRZJZZJZcRZZRZcRccRckZccZckZkkZksckkckscsskssks{k{{s{{s{s{{{{{ƽ,KH*\ȰÇ#JHŋ3jx1 ? Irɒ(OLr˖0_ʌIs͚8osϞ@ 9#AE "TQPJM:iTXVu֮M^J֫Y[т{ڲoۦuKwݵwF5*Ҿ&&ˆ +X/~,qĖ+SƼyeϚ?g,hФCNM:+_ƞ l۴oݿ{.xđO|sؖ-`%u)]>w৆'|ß~w2% :@tpB .|U}avކ~v("kX"*".fpJup LX1  e6vRXA雔QIOwY2%w[zycrYkd!PBM@m`0C]0mt'z)&UQ*U>(|*i!Zަ:Ji8ş-ed!v iXiJc#"I,g(ڤf: G41) Y D{nꬡl rݻo -G.(Q+T yH- D]ȀHA:<006֬,𑹝ܢ%<%< ]`CMXd(QRt sLuy(_}YWz[ܫ IF< "Jх"vKxY4=pc)h]yѐx7>82JvaE @K+a4YXwW02cV^-5Q{ +\"E ]; ctx}aPW)Iظy;{sa#@ "T`dqAʠ=p\Zv0IIHfK|HPg\E"$AݹW"އnQL)^\` Dpia0BE W1 /UDBv_!%t!0)8b^PK+94,RHHDreߺ1G "& B'q !x pDs SƓ8ZYLtyFF)h)1# B0G@w  KPi.ON\ ¾R_ #TK>X|E8ўZa'_f: @Us "EI_o"gKrŐk^Oo@#`$Q )A|Qfvf)'+-EkfEzQyou♒=1 y JLq[8EOˉL4DtcיQx}ceٴ0RTX@$Uܬr VM+.pfCF8y Ҩ$/ h7܋~p>`u N D pb͔z[EnJ10aK yrc  C,D ?]3fQL;@ |,p ns̕b>i! MIt` Ax-Y':W K#V { rط.x) Ve8jUjl6/Ə/"UJ:]H:,8K4E? ym]&`2xVU| l2G,DG M0t #V>P_D9 ҢB&4 Rtׂ+Mtr/HfiB0hB5̹ۘow _ɚl;4Vh/n5^pZLP:~F'kw4sV:yr5`dFZe}hyGY^r,]m|-ɾ [E-? g<@΍tmNWsA:ϩ|VGw ȂL*pu=:NB#2x) <8 .u`"*$ @8B)o!@bA<" A }pxN@P$ .0qx@3$$A H0࿝[@wAeP.>Z)PWP=^wD6p2D@y}!|Vml[@7wTW&RtzWZ!_@c1b0ӂ6HP(c] t]`?`;Pb>haY`BP l%p Ƃ.80Y\&J]K CQWgK-KWMEW#Oca`?Y0$PJ,b2@&vDJsƂhX>:R`u%VƄ^01.0ZFxa2z:2@bvDYPg4uFQ#{i30wLF[vD\@dq+hK37Jm7nT7H]@m"o"Bxb=Fg]_eߘ:XZES`Jb1yBio7U(P#1~|`$PS hA@@$6J,5jS%&VgP pR`30*B>=0OK:WGk3>HRL`XPMcS/4c[cXPɔQy>@Z@gSPZ ~B )=L=J@IHIE&#>(@t_QtFG!ZJQ0H@PRZu6y&p`Ud9$whI1 %V:DDr6e~`UK۸4R`(3[ ~)Yu0Xtf0>$Y*`$/r1 PM_FZfT@ZqE1UQ.Gd yfFMHrդpuf? E0P?#7 z14>$g@<ڣXR[Pg9IVyoZ`N0d>Tg"PFZz&@t}6Qu=@FGN7x) D#% pEgHѡդљ`Re)5h.!Igp >S`)eU676c;AcJ"p\JZUIZXQwh{e}Zg#iJgQՔޤմdUYg;]pb&dFa$P]FʎڱZ՗6#&WXԦ U#|lL@UB0 r\Fm~>xDd $iUy &*AK nDWuE-]zD J*= P"P$0$/rՄMQ`/*ZM9qo!P[a^}ItfRQP=J852RVAhJ*JBFe4 up [Hw JF`V+u#1s :;ZR{D @RpP?pՔJ}iѰ}c+!e(Le|oZgG#:@+F9;hF ))@EPa #RB+&]Pl Z:P`>0207:ER0e$QOP:+p&P( D&ƻ4cg&p17R@q]ֆF1ñ!p+2$xjqq%[*jYP;q*zתHp@ER:}$_bhBįbA!=`8T9\gpkAYW hMw< C  >0&)Pt@rdd+@~\qxth7SV}C9Yc&Ax,pGg;n @g+,A |) \ @0qGA P/@7B6@+@V  r 80,ipK! iC(5p6p:}g <;I2(3pF:p ] ldD[BfK{T1xۈ/ 5,f;0eqѯ5(F7(Y]8PC\GxaAEzQqEvDXVhW Q9%q`LgƋU5is6Y #E#ELz:U@\[ >&$7Pe|KMM#5vفدcq$ĕXKؼmA59e;avXRk.!hWMv)E8241)vnaQM8h85qa}Q5n}eK^U@P/Kfތq,P]{Nnv±SQ"R>k8@CUvD`ֆGuYk@g5V)]Aۣ6aNm'dSÊ.?PS&Ф}?DrkwD@eȍAZ3fO]&!}杼2Kr2p8q_qmdt5Y8s^SYNTߓ/C87SPEl~Yf`Blhe$Wa;Xn/6CM.Rrx`¡\A6h)#B'^EK}>vXGA,Bpd3+!1S9J@1fY7BH$~k%VVKcJPlmvc?t7i{!@UVxP*_I0Ulմ-ٗFߝQCn/Rn~ U L1 UFbVk@@l,M|@Uݪ1B+ۢ&oV7502`S1itQ4/UD?>m\M85Sw\PPAdPJ+dcEKn&r/Ÿp0A aX P!*&"4qACz )$I"%\QI._a˙#Aܙ%ϛ6s9ΣI- iʈ2N5igXd(e͈\,ESI2 ХJiMi\s8`,1\ 7eʖ RK A6s$8r1w!g.WlvN~nͰ׶-0ɍ.<^|xHta@):IGzNq8*-`궫?zـk)$[? 0?ߦ.V"Š%Lp x2!6 X.|@kPc?+1;=擱+N@6 С1`q (F >>ނ4oH3\ǽ @q3wmP:g}\njɹsT^U9Lo67{cOg^ϵ%xsw}}kuqe6OyBl}~k 6H!% ;knopflerfish-osgi-2.3.3/kf_32x32.gif0000644000175000017500000000246011252437356017050 0ustar twernertwernerGIF89a !)!))))1)11119!19!99!9B)9B)BB1BJ1JJ9JJ9JRBRRBRZJZZJZcRccRckZckZkkckscsscs{ks{k{{s{s{{ƽ, HPpÆJ`E 3 FC^ĈQ .0A@Gc`!TH0%D@ vphiC*Z0ب  =G*DѣF ?j(X>+Zx@P D:@(*2wa@Z, N ~rl^ & 60 p7 =PH]%1AʩhB1@Nsp}-ޡ3/lҺEU㡔Zv|y2ϞCw͹dr9ZѯU˾smڮFogA6}Hڨ'bMVF&H*eS~I6m Y"j&#)pY(lyhv)!_zZp*Z!FGhbUnzyicj*t 29驝Ϊ_ށ(M jH6 ҵ{^.[f2*ZI*!d$ _9Nӣ& xV br{!r;j~:. pPr(,Žvȁ*y0{K~;V3z3mS;!))slp.J:mY*Dj3mU#Dۓv}lMBƌ7vUS]V)G~򄜂(|ʭMZNA+m^,֢dSXCrHX+5\TQ;YkR1|mK6&AqΑv5(\)ҕ+TBxBP(0A3r҂9yu51eA < F©ɰ*Pz .f!P+`a ]bl$Z #@R\M4:;SA $*\a[N` kT6D0Be205s` 8x~ `|`~J 4"@|(Ѐ@|` A@P4 .@̀2X0r `'PHA{ 8`x&ȝjh %8 J7unD\°$ |/|! H0``X࿰-|AP($ v#_T {Z AGw^ T B y cлȋh-pB@,^ cp~ij X!"Ђ @ – V_1P$ LAk[`8 4 U@;pU lHp5>tve@`$WL[bPNJ4x{;7p;0F7}=q7zF0>0pI~F`7AjXvwwB3(>3E`n9,P1pA@m<@xjX32]p{Ie 2  `xz70_= %&l.@AxjTsgn3XXel9azg!&`)pNm'!l&JP&|{&Fqh ƊA5wDyZ 𧊖UaCw8Xv0vx{B r1o0ކ 0utXW` 8(=0~F(PDy @oh8w  )PXJ`mFa,I3}!ew(z kFw{O@+3b`4N }Fp4pC{V%`j[14pJncP9PqW; @}QOk!FЙ))p8 bkWБuhj}4Pb>ӈ3{&xޖJ00]^Px?@h P<}z'l%KNPȷJ `e60WАu@@U1J vWj t` $u A醤X0r1JP3=Z3 Pp0>*Viף)  iZ $M#=!$c).e֧?-8QC&hK:.`EszUPq5Wyfq#ea0`!0l^CFO8\\UU9Q R]HUkYcuGE&F~0n_̖J%3N#V[UwaRؤSn4\34kF>[UY$TQV<@X85fd\4VE#TZ9bcI"؂6*!4]iuTHTϤj&[ bլGڮb2eR{ïY*NޥfP\U[9JK{,Uy5<Ie.dwBPUư"H6R,;=5c*NQJZbLXvVwfN/fJ+Yf:jw[3"U%HF/81yTq 0,QmE4QYRk[~M5pX}l):P|AkDQX qK̈GJS`z(pŒA&}"PyQ!,vije7dۮUVT3p*x{D]=W00uj۰szYITҳ!M,6|{@\Q\8:mlvN$`w(LX{?݄,02MÌԴeeIwѹwd#mDecK5f^q3ɕPb!ݡmO!}jOv. FnnFlm1p< j3\v]Bpb\ Wi\p<@z[7g͍Іn!]LFq}&apN,:0[@2,#0! ޶ gQU]dQ; lwG=8):lXA k d\LLblb^w;e\+u5ۉ}HwU miD̊k>t~0`z<Pn߽Ñmn6tӺ$^]۔e:~+$y+TsUA9b߸AQ 9n*`҇L.a7 ڊ?xt`BQjMܦ_N(%mk`= 0h pLQK&:Z&m=B<ˎС.b9uEbB`cRFA8a7 ^߹/}K)պP+9DBW%6ʅ,m *ܼzm.f%Ec@13 @ Z*FOv-CryT䡟vΌ?S󚂐KQ`Xa$83)$ESC ,FuOX@`bZŰ* + uAcd/#$U:C 4iI\H(P#ˬ[sݽr8i5Z)^YO՛@a"`B^($|0R Hnρ=F-fȕ>H&uI_7&'6_|]aqe34`B/|QVM;U%z+7u[׻$8 +O Ѡ/C( k/{PfwziY~>F r@"TB;@QD d 0d0RQXKY x@<ė te `\EժJS/ŝ~Ŵii AR*< LY' ⇤&ChؙQ{:1H.bJ)|$<ٵo`1e= H?@3PJHF/KP¢х'1By""(   y2q9e@;|!H JITك)s"@ |P-T (P0 3P0lf@e%Qє+XH@?+ԣ)D|M@6 ,1b"wduAN1la0e#'RLYJ+vjQҐ SPU@C()p2脛Ҕ:.Rb-A\X IAqƷȢ S BZp(BcPe4q/0=|2P@@4`)5 3@lOkT YXʱ G=h @&#X`c*.Dkj=&>$`y^R rM})QM;Z2= D>dbBuAf!(HsqLdr"^86r75niE2}UOwI$ɺ3\k0758 ،k ,dabXEqLV$k*m%_xGs\*u(+Ox. Vur{;T0ʀy`)6c)Yys|Cǎ60Ŝiav0LfaQ96ČNpfrrc>ʠt$ߴB8a|+ؖu zӄ^`\K:׿&!]}WԠouuzS Պf]os.M1}qi䖌 ?ocB,^;2\vq7^:;q5x)\،,}A774;f|o}߰f9NlSoK o5GMS|Ţ}a]:yA8d=K7:k|.7*en#aTk}'umLGӉkWkx8AhRڣoJiRPznrC{WKӃzk]=\vgv_W~SogF[ wHǏaS־}Mgsw3+6?+@g<83S%Fsd;@bu¨k4B5÷$ӽ3@=60D–;DRLB3K*S6*F DEDY LE"=04F9 CkLl;+Ei2 ACk>ϫ4(< T%tC#ƒEs6G{3[G*5ÄABXl+d šl54FHDAJEE{GJ=dƸl=~6[Ź|@$,ʞ6koD3L,ML.,CļJ漽T7 tGBLO/䔦= OJ&NɕTNdΑ乤̃ HO۬kI$3ˁtH3GeDPOo4\8<(A, TBJrĸ|Od$Y6D,DDŽsBĽ+Hͼ4\dPPE4RttF,̟ƿ#KP ;knopflerfish-osgi-2.3.3/fish32x32.gif0000644000175000017500000000246011252437356017242 0ustar twernertwernerGIF89a !)!))))1)11119!19!99!9B)9B)BB1BJ1JJ9JJ9JRBRRBRZJZZJZcRccRckZckZkkckscsscs{ks{k{{s{s{{ƽ, HPpÆJ`E 3 FC^ĈQ .0A@Gc`!TH0%D@ vphiC*Z0ب  =G*DѣF ?j(X>+Zx@P D:@(*2wa@Z, N ~rl^ & 60 p7 =PH]%1AʩhB1@Nsp}-ޡ3/wJ;T):02 |ز>_x-az;/$ppЂ ^>yӧO߼y߿;w۷_tGضZYŀ͋/wo4Cݐ F6B gϞr#G?~[nz˗/?ÇߵkE _x>Sp߇ыsk;s@tӧ߸ql)(@=zٳO</Z9}2Y_+[3z[2.40|p<ŏ?J 'Nߴi+V_0wCH_3|=_1]\l !tk/^G(Alp8Zɒ%gΜZDb⁋.SO@w@t(ݻJP P4AQsp(_ŋ[%/0}1O_:a~o@ r'O?ZxuŰl 9(رcիWゅg_:3ϝ=soX{Ϙ>|~F}o@=wlɍ7+;7lʕΝƌԩSx޼yeee `@X'`._ ;(A|rCq0-06Hݔ)S@(Bv@au7o@YB݃瀇 |JP9s 8Q- {Ϟ=ѣOr@1} -(,9_| N \*@b׮];T:B C@r!{A"''WtԱ@ R%U Ǣ'uDB褹吝I58 ]$yffS@MwmUu}sy a  , X(J@9-a hP`B d` AV,t> I=:Υb(% Uv `OT p@xaP(d ASN @jn pڵ֮`GظFv@auY]x  5G !B Ad9(A@Yc@!t@-.}2p` 2T  A|P(  $Jt۶mR˗/XS )PrrDx ڣ@CaA ѠH ܹRrҥ:P9lc6"; : @>߲e 8}PJkP0heY vPps _O6  ذmBv@auХA x@A KAyd9$r H-( @;av0M455[@{;d!PaѠ%8bPŴl2pЃ@lP]l 0.  fIp\ W 2$@@>Y &oiia5NU6 'bQ6WXb# r@[ycIhc X@|/(^AaXaԎPA9 C` `oNNNQ?2X?@X0,:@ 5 (x'MAlcc~dXXXkx,d (mii9WLL,v}[׀ yd.3>b9@6PJIIENDB`knopflerfish-osgi-2.3.3/noia/32x32/mimetypes/misc_doc.gif0000644000175000017500000000304311252437356023110 0ustar twernertwernerGIF89a zzz{{{JPPSZ#O-U-Y5[-^#_%a'd)b(g-g+k2n8n=wHjWn[r@nIsYvo}IG~Vnqy{ctyVGF\Wgdzz{{|¯ôıűǴÿ!,  H*\HЕ+VWRiÄvC]:vHh(b9ԩo`4*iS#>O逃 3tA"JGd<ߘ=SHR(daANX5:|3H@)Xť0"uM7LL/DQ%`QBo,3Ta3bK*?KXH!U{P %}/">,(BUDA 7D ! 7,ʰ= (b"@E(,B&Pmw1(J(SI* &$Bx:8 &(`&ES"7!]LBnE_!\s=axTD1R .v p-q u7A;knopflerfish-osgi-2.3.3/noia/32x32/mimetypes/imaga.gif0000644000175000017500000000303111252437356022403 0ustar twernertwernerGIF89a 9}UUU]]ZJUgbb\aaakkjlrsutmuut{{u||z=EHKJTOST\WY[i N!P$S)V.Z6["U#Z$[)^"]#_)_=c,a#c$a'l(d/r=g8g9i|v"e&h)f+h,k,m&v&~2m8r7uLjPdUrFrMwNy^~S{f}jwl{`DuByG/**62)+-54<=;>\[nlpsllmzNMGV\JZS[FVSku}bkgjxoo~y|v}y~˝҆͝ꔾΤ֯ճ˛ʳצƱɹ˶̾Ѽ!,  H*\H04l"b-X#Ԏ~ FF54M޼y{nڙ =ڬ9SA '-<ڼ1'~&kՏ 7YÐӨJ5|a)LQP$$X"!+eJ͚ dRiz ? $A)~ .>}Me S g`iBQw^=zu:taU 2СA "@hG2C$ qq "L,C ;E7 828r0B :PE26 ǨI b%b,JCYd èSJ Hqp:PA4P-@@ 619$`+GLXȁlЌ9̒ @`+ bωP3J3lpǭ;knopflerfish-osgi-2.3.3/noia/32x32/mimetypes/misc_doc.png0000644000175000017500000000417111252437356023132 0ustar twernertwernerPNG  IHDR szz pHYs  gAMA|Q cHRMz%u0`:o_FIDATxb?@bB@;{>732+' #f'@auoÇyWPׯ{˷Ԯ"?紴[la-~R@XUs @Ç?~`/==+-}aމ՝: p:ի`ׯ|vg߾uK]noS~mA7;!.Ԃ o߂}۷o߽{ݻO<'Z_ٿfҎMO,cu. G| dѧO߿"trwkyKm)~kEP-<==k\v(A| GѣGϜ9޽7oeu#gWM_#S|=_1]\l Y ~eGѣG;w~gςiV5|Ԧ;K//0C9~)'; pFKr½{J ,]t'Nscǎ߱c5k߸vȲEf7?| Aq ˗/ϟ?頡ŋٽ];ؾv ޵k8<eee V \i  M c ǀJhkkzjp(`u@̌"---k@yӧć |rHu/_={_x?( E!!ӦM9555}9TFx-`9(m,\Sn޼ N/ 6ӧO/''WB朜( yPCbŊ޾}PEe 4 $$ gBVJTT @ttt8<8 :t dY͛wTЀ !Xɇ @ ~< AeƪU =AP߼y3rPR r0 ; pU͠ VP%`>`UUU`1A r(f9-?eʔZZZm@+`v. ݖ-[5k8UWW0a8t@@,%8P,$l:::@W@FZm SG}\UCE_36~φ^ 7 InwOnU- ! AJ @|<U2 BT@eu#; :ϯ|9s ':?>XSe3fg9P (KI#; :Xa8033 ij`+c\j@fYZZZ : ؁T `B.rAIENDB`knopflerfish-osgi-2.3.3/noia/32x32/mimetypes/xml_ant.gif0000644000175000017500000000300511252437356022770 0ustar twernertwernerGIF89a   """***666CCCLKCNNNWWW```jjfmmerripppxxxzzzLNPQS"Q.[!T Z!]#_>`9b(e)g*h1l8n6r6r0qNl[r\q@nNtUtX}o}M}F^qswytUUGNS\ghzz{{|~÷¿¯¶ĵðűǴǹ˷!,  H*\8,Y"jICMȱ5غXPiֲi[Y*"\CR"h(mۦcx|hQӛmӌrC !CrbZm޾-.P^xHC E \8pٔ*eN(X!rG\ͻW$Ft cš!nRP":`Bysgpږ2鑏+"Y"U+MЪiKzaRu (Sr03rl0_xk1՛ gƹ3h̔%3f1Ԅl_tv7)U# 4!CL0d $c%C 4|M6@첆) 5l@d82Ë.kt&P0Xc=4XKrkp(ҐQ<07Xn!4c#.A4aI1*e5yX/Z)L@UJ0H#M4(0''A,M3@eX20|:Z&EA$F$@h2 ĉʩ0ƪa 44@C37L0܈ ([Ȱ@ 4 1m%&0" gLaPȌW.h*z®~aYn1L. /$"raF]x2[)@gJ)l $o<nB q!ttkqFVXQEL$XcKdHQ;knopflerfish-osgi-2.3.3/noia/32x32/mimetypes/mime_html.png0000644000175000017500000000563111252437356023327 0ustar twernertwernerPNG  IHDR szz pHYs  gAMA|Q cHRMz%u0`:o_F IDATxb?@bB0899؄X (+'!9f/@a8@EEf˖-.\̙3ٳg?;wK?-xmƲ~sHXs˘0ppCOׯ_A{̟_)nu5MIg#.vŋ^?~;7oׯ?zeg(߽÷t 9 ݻ,z=RC@׮]vnU8忤9GuZu,@x,߿'aoȑ۷miK,q{wkW#^~0A=? w?v[AXu kvu9 ,6V_@e?ضmkV`yUwWM_&tmv7/:S_>ǧ~~_ }>֮tٲC!xAY}#rLpC UU5wKv {,|v^__wƍWZ?|̚^e7_mmoIXdU\7lbv_mo9N_{֜wĦMܾoݲO2忬L>i cOYלt®ö7?{NP|ѣGM z@a @H hu(r}Gmzϼ;:,|K.xO8ڴi0C jc`<~@kcvgbqͮW'9߿.#_v 3f/''WB8Ks>?.( N< _zS?n}Ε?-ny?}W/_7o P4@PBr@A³?oߛ>.=߿~PԩS41} X˲7 mG}|S@_O^Ͼ?/+=o7UA d\y'9Z![ q~3@G}{1SQ1E]~б Wfo߼[m p܃{@AA 9܅gZ7S=wZ`tTŪtTKt@Ȃo*NmY}lĀ߾}ܹ5 ]*ˌ `( MFAI`Bѓ`L\qQ,#g/SxB7\g?P8p?hUXlt@-F'I,?` 0A 0}Y-?aw~`H_w/=rP)|#9@YY|RbEG.C{90!n;`6L' ?&dާeKFM|Ξ;rP |͚5NX5"; PbtI_J`9D`v:"E0Zʀ {;06߰a+V f/@,<ΘNeR`?O֖K|?׈i?Ǐgp%9%K455[C 0*#Qu( ^o?og߉]/־-O9f7ZEՊ Uώ)s{u}ΓO L l9Cvi?ځ} x/_ŋ/XyN>V-qeS\߽cL9?p>ͫO_<:`Sl-^l9 .?wg;@WW +Vbv߿{m7_t)s:Y ]ݵ`po޼u|̙`u#; e0 ;6lcj =,xpP\rw3k/u)G\"9^<<=7Rcope X ƥhlsbְ @K#0u IENDB`knopflerfish-osgi-2.3.3/noia/32x32/mimetypes/mime_html.gif0000644000175000017500000000276511252437356023315 0ustar twernertwernerGIF89a MZO_RUb(\*V!U"^9j7a%b=nq(g%z)v,}1l8t@`@kMkMwUkPmRr[s]wNvi|@yG?*??%*1>=52:>=LGNUV][Q[q`kuvJBJTRP_VGCNGGNODS^TN[]\KCJKKP_TQQ[UWZ[kgnamu~ryel``emndgeaojkuztwxekjmrrq}z{u{όȐŜǚׂ덼৲»¾ȽՋ®İ˶!,  H*\(0ܬu"J\ÍO ~O>~ ݣ7k CPem{>vW* *cKC) '%Pz0ShvbP3DV)d*3>ZiJB8Qz"kS4hPj߼J1 : 6+dv`Er^bS)V^Au@0bf͊vY.Y:k"h#F j*'ܻ &X2e4ak[Qq :<}?k7^ݸLtE7`'!0HL35ҠMc8TR9[ #|R#2M4k-4c^n|Q M48Í4n4lS0X (̔mTN;3K& Z$) E5΅rIqBf(G"|qHs,8dvgA7 SAGF8ʣyr\aEJ!A\8fI OAF|"p@rJ)Hr-d{ -tBήӎRAD0`5DM<,Iy Di00웙J(8r+ 3QD2d)B,q&T|q)6&l hbr((lAġ"49_b%>>JJJSSSVVVZZZaaadddiiijjjlllvvnppprrrtttwww|{tzzz|||~~~KPPSZ"N/V,X1V-^$`%a'd)b(g-g*k2n8n=wGiVmYoXtEn@newjzJGVrsyzftVGF\Wgdzz{{||}}¯ôıű¾ǴԿտ!,  H*\8i`f"*K BY>{乛I$.ԅC_ϟ>z{pDmѐ!.iHnܬ41tQZ_x"5 q{H%N0Xbǰe+'kh0%V3 i~خD,`̰"׏?~T,֨)^8ㆩ篶" -t1d4zjH4z BIK9/޹sΑFOŌ2sa%p/7sX r1f]6sN9bM5{rLt4ն>#6y1M!kt %X"K8;ؓ>l;|3|GiM*vB;;p / s9䘓=(y6LF6%LU xL76Tc 1y!J'z]l1yQ\ds5xQH!y$‹/),S‹,p "Ha 1h.E^t1B!؀P4$:@xGj荐QL!9TXUP^S?~P@;knopflerfish-osgi-2.3.3/noia/32x32/mimetypes/image.png0000644000175000017500000000603211252437356022432 0ustar twernertwernerPNG  IHDR szz pHYs  gAMA|Q cHRMz%u0`:o_F IDATxb?@bbXYY988؄Ѱ((;;#  *ԩΝ{s̙w0|Νx…ZtRN-JV,,: Jz{{޿/_ׯ_O?{'4-~ᕿi{N3s *Usʕ/_߿[ rϞ=Μ_׳bfEosnx<3!.^zW}ǏBǏPx;w?qCv/n_gÜ#:__-x&.Q)| x "A߿ 5>;wle~9K/q{?xUHUg=(Ad9'O&vumW]_#u#m/_[좚V@0>rAͥKQ [n߻we˖1}Z+a  `bb|w[pȑ;wn ?}SL?ms9NYB47ȇ9ٹy˹]x߼~7?zpgzo{wi`Ǯ=׬Ƃ ,k-v_pݝ-kkk߱q!; q"//w_?||ڗO?wϫmϝ|PE:f|׭_^^uu{`i;(`>~QyYٕ֕[V\od_fg+20#VW[ċ+i-G𿥥UUvvvr”:un_6zsurҺ |}v;oZ;_gr#jjj>=Bvwvv|P6k]tDZ H7ݬuҏ-=_3ԃL_#y@^%g׮xO&?Bv]ߟo>tlJ[$,XTŬz-|[3(@i  $Y w]mgpBܒ&Sz`f0afsE:G;U^߾]׿x!!!Qb`1R֝?u2zѾKff:|I2}WX_=a AՓH?iK/%L{l\ ĠéX'lL___̙3/^-Z .Ո!@am999 y׉__6ln_={='Ooo%K)xʕ.] xܹxF#((/h6m5_`d]O6B_YYĉWZӦM7l͚5WX|޼ygϞ֬Y` E ; :ϯo~߾y[wvvUPΘ1lȷv!(@=|AɓO:d_QQhdVGIkks@?Zr++>>>GŽFDDqxx8CCCX c 8 :\ 'Ćjjj ***@(}*+QE@p \vj wIENDB`knopflerfish-osgi-2.3.3/noia/32x32/mimetypes/java_src.png0000644000175000017500000000472511252437356023147 0ustar twernertwernerPNG  IHDR szz pHYs  gAMA|Q cHRMz%u0`:o_F KIDATxb?,^ 0)bccS 766sbO>@''HBss oӧO{ׯzǏyۏ'֯<[la-`~R@p}e-[yC?߿~Wܽ-uV>(CYNvYUb@p ]dYYY333SS˗/p7ny:`LHw޽4gg99,0(d10Y|Up߹s?(@Y677;;v޼y`G*E  /2P^֭[ϟ.@YKVZXxWRRӦM|1<5@%#GUUUAuTT%<<<711/.. Txv9w;;;9s6} hÙ3g T2`Xs-.#@Rw@bbPb`e/[=meff6 Aq GP|X -p @l///p1 r<@Q*ΧL~XLL>4P`5|p>J͠D&""0 `0)pΨ'JPP T s@ eeey`by `hQ\Jd KAU۷otp Q.=z.AA X\jFv@ `Kh+...'mPJ|qFp%JP -PTre 6L 0!%%L@b!аn:/@JD ߀ ?aXàɁPr(BCv@ `+ -AT"Κ5ŋAT} F@T`B$*A 9 UdĉUTT@\`oo r10%wtPP%DP0* 6H sϟg_PT  ՛@pgzzV@ ( `M1P5 ʖ ǀa%%H P =(*%c@I&lAv@(l/ZT܂ (@A` ,Y=\ =PO:PZZZm&(.sAE.Rv=j|ZHA>9tɃTڎ4ӁU7_d (Ae)P~ E| 6H (A 9TϞ=` Fi (a+% 2D(tMM%%%`ԂJ@ r2خsnU涬@+6>1α-)zOYPFXVJx n`lii9 L[XXAlt1 A;Pj"13o0 ZmM^IENDB`knopflerfish-osgi-2.3.3/noia/32x32/mimetypes/mime_empty.gif0000644000175000017500000000301511252437356023474 0ustar twernertwernerGIF89a LNPQS"Q.[!T Z!]#_>`9b(e)g*h1l8n6r6r0qNl[r\q@nNtUtX}o}M}F^qswytUUGNS\ghzz{{|÷¿¯ĵðűǴǹ˷!,  H*\8T(P"r4(CY۸M6lhk۾ .3MP(ᅤ9P7`Dpsan9s[)(R|47qЩC筘F*x 8 Hm9u}; R -8BlmWݺvzBŀ`'!h˥cyo?uXp`\qo}yq[rǴ.[#_!]QP@n8n!T(e)g6rg\웥NlS*hFhUޣ¿sL1lNS^ĵw"Q6rGM}ƟUt Z0qUNtX}ǹ˷űð¯4MtRNS@fIDATxڍ[PƯ"&]"%!uV0Mm:T8q{{xV{{r/8\$7{>a׎]{1j!WKp>:.̊6"ӔQB LJHrtc10cfo TAU0r cf .;^`tGA]^72cuHFQh&eh^G>Z{T%|(2ȋ"/<|g6NHјW^P aIVdC8xǎh`EyAז[acͦ[!ҶB !ܕqVHXwhY7.ZLsє/pjfca(#)KGs')Sv/ɲ!aÝRcִX{#G3b{hcq]~y%ܭsa4N`RS+g@qCm^H$vc75'){n![gddjZgi7)LIENDB`knopflerfish-osgi-2.3.3/noia/32x32/mimetypes/mime_empty.png0000644000175000017500000000406411252437356023520 0ustar twernertwernerPNG  IHDR szz pHYs  gAMA|Q cHRMz%u0`:o_FIDATxb?@b`bbbҲ500pbOb_30ve`bfad   Z۷oz ~oo?xcҷ>wJ;T):02 |IJwOA{-Y_!jRw^3Ic!666 |) ˿|ׯp<~8~yJiΡ"! l@ٳg߼y`KAAlPt\~ѣGڿq˜R>Sp߇ыsk;s@uȧ>|d_Lo߾ȑ#wl˦r^_+[3z[2.40|@ϟ?L޽رcwv@넅CH_30JO7ts9 A pywW_"pŁ|J  %Bd{ذ+[&/7]1N_:a~o@ r`*Gw 'O߽{[_vE;'r֯5{vmӧO/#'f@@k0r=;кCN|f eZ̉`f 7oD7 ^| /^`hq0>q GBPl! QDwy$b02†o=7s`SUZ ?pݓCD6٨&$" BDxP P:\ 9Zu ݹs78wӧO/''W9s;P((CPԀA"ݻ͛` ˗!; p9-(nA3(@>EώB\Q@qyp8t ={[UJ:X+A|P:EJ.]ipqo>*`@X0k֬wD#@>Pt,E rCAwUp܃|pv9@QQC#@!Y 6RJ%x JCc`M A;n%:d׮]ʕN_]] z;PJ J5Pa 8 5T,Ւ˖-;@SS@ (A1Y 6H $RJqk֬[dɒ-?eʔ&l0"J< G d 0"9$R56ܺu+mr`?WF::: [#@d8 d d1(7oW^`ˁM?p;@WW (J@0 Anٲl1(A)rρ`;Fv@a8SX>\ ` O@,`aA 5 @q>iҤ` b#; 0enn^ijf!c@Ԁ0PlKK˹bbb1@ *L@ļ4 sa@w GĎQIENDB`knopflerfish-osgi-2.3.3/META-INF/0000755000175000017500000000000011252440220016236 5ustar twernertwernerknopflerfish-osgi-2.3.3/META-INF/MANIFEST.MF0000644000175000017500000000051011252440216017671 0ustar twernertwernerManifest-Version: 1.0 Ant-Version: Apache Ant 1.7.1 Created-By: 1.4.2_18-b06 (Sun Microsystems Inc.) Main-class: org.knopflerfish.tools.jarunpacker.Main jarunpacker-destdir: knopflerfish_osgi_2.3.3 jarunpacker-opendir: ${destdir}/knopflerfish.org/osgi jarunpacker-licensepath: /LICENSE.txt knopflerfish-version: 2.3.3 knopflerfish-osgi-2.3.3/knopflerfish.org/0000755000175000017500000000000011252440220020356 5ustar twernertwernerknopflerfish-osgi-2.3.3/knopflerfish.org/ant/0000755000175000017500000000000011252437630021153 5ustar twernertwernerknopflerfish-osgi-2.3.3/knopflerfish.org/ant/lib/0000755000175000017500000000000011400541206021707 5ustar twernertwernerknopflerfish-osgi-2.3.3/knopflerfish.org/ant/bundle_junit.xml0000644000175000017500000000655011252437456024373 0ustar twernertwerner knopflerfish-osgi-2.3.3/knopflerfish.org/ant/bundlebuild.xml0000644000175000017500000011117011252437456024175 0ustar twernertwerner knopflerfish-osgi-2.3.3/knopflerfish.org/ant/bundlebuild_include.xml0000644000175000017500000000513111252437456025677 0ustar twernertwerner knopflerfish-osgi-2.3.3/knopflerfish.org/ant/bundletasks.xml0000644000175000017500000001665611252437456024240 0ustar twernertwerner knopflerfish-osgi-2.3.3/knopflerfish.org/ant/readme.txt0000644000175000017500000000620211252437456023157 0ustar twernertwernerThis directory contains ant related code ant build files. Ant version 1.6 or higher is required. build_example.xml Example of bundle build.xml bundlebuild_include.xml ant build file to be included in build.xml. bundletasks.xml ant build file included by bundlebuild_include.xml Defines and compiles the bundle build tasks. html_template HTML templates for generated bundle docs src source code for bundle build task Note: As of Knopflerfish 2.0 all the properties used to specify the bundle manifest have been renamed. The new naming scheme gives three major advantages: 1 The properties can now be specified in a bundle manifest template file, named bundle.manifest, that may be created using the Knopflerfish Eclipse plug in while their values are still available for use in the ant build script. 2 You can now add any manifest header you like to the generated bundle manifest (previously there where only support for a fixed predefined set of manifest attributes). 3 Easy to remember mapping from ant property name to bundle manifest attribute name. To get the name of the ant property that corresponds to the manifest attribute named "Xy-Zz" simply add the prefix "bmfa." to it. E.g., Manifest Attribute name ant property name ======================= ================= Bundle-Name bmfa.Bundle-Name Bundle-SymbolicName bmfa.Bundle-SymbolicName Bundle-Version bmfa.Bundle-Version Bundle-Classpath bmfa.Bundle-Classpath and so on. The default prefix, "bmfa", is a short hand for Bundle ManiFest Attribute. To add a non-standard attribute to the generated manifest simple create a property with a name that starts with "bmfa." followed by the manifest attribute name. E.g., the property definition will add the attribute Main-Class: org.knopflerfish.Main to all the bundle manifests generated from the build file it was defined in. Another method to do this is to create a template bundle manifest file that contains the main section attribute definition you want. The template manifest file shall be named "bundle.manifest" and placed in the same directory as the build.xml file that shall use it. The format of the manifest template file is that of a normal manifest file with one exception: Line length must not obey the 72 characters per line requirement. The character encoding of the template manifest file expected to be UTF-8, but you may specify another encoding in the build.xml file. The relaxed line length requirement makes it possible to format the template manifest file in a readable way. E.g., the Import-Package and Export-Package can be written with one package per line as in: Import-Service: org.knopflerfish.service.log.LogService, org.osgi.service.cm.ManagedService, org.osgi.service.cm.ManagedServiceFactory, org.osgi.service.cm.ConfigurationPlugin Export-Package: org.osgi.service.cm;specification-version=1.2.0, org.knopflerfish.shared.cm;specification-version=1.0 knopflerfish-osgi-2.3.3/knopflerfish.org/ant/src/0000755000175000017500000000000011252437454021746 5ustar twernertwernerknopflerfish-osgi-2.3.3/knopflerfish.org/ant/src/org/0000755000175000017500000000000011252437454022535 5ustar twernertwernerknopflerfish-osgi-2.3.3/knopflerfish.org/ant/src/org/knopflerfish/0000755000175000017500000000000011252437454025227 5ustar twernertwernerknopflerfish-osgi-2.3.3/knopflerfish.org/ant/src/org/knopflerfish/ant/0000755000175000017500000000000011252437454026011 5ustar twernertwernerknopflerfish-osgi-2.3.3/knopflerfish.org/ant/src/org/knopflerfish/ant/taskdefs/0000755000175000017500000000000011252437454027615 5ustar twernertwernerknopflerfish-osgi-2.3.3/knopflerfish.org/ant/src/org/knopflerfish/ant/taskdefs/bundle/0000755000175000017500000000000011252437456031070 5ustar twernertwerner././@LongLink0000000000000000000000000000015500000000000011566 Lustar rootrootknopflerfish-osgi-2.3.3/knopflerfish.org/ant/src/org/knopflerfish/ant/taskdefs/bundle/ByteFormatterTask.javaknopflerfish-osgi-2.3.3/knopflerfish.org/ant/src/org/knopflerfish/ant/taskdefs/bundle/ByteFormatterT0000644000175000017500000001626711252437456033742 0ustar twernertwerner/* * Copyright (c) 2008-2008, KNOPFLERFISH project * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * - Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * - 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. * * - Neither the name of the KNOPFLERFISH project nor the names of its * contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS 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 * COPYRIGHT OWNER OR 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. */ package org.knopflerfish.ant.taskdefs.bundle; import java.io.File; import org.apache.tools.ant.Project; import org.apache.tools.ant.Task; /** * Sets a property to a formatted value in ki, Mi, Gi, ... with an * optional unit. Here ki is short for kibi, (a * contraction of kilo binary) see http://en.wikipedia.org/wiki/Kibibyte * for a detailed explanation. *

* *

Parameters

* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
AttributeDescriptionRequired
property * The name of the property to assign the formatted value to.Yes.
binaryPrefixURLAn URL pointing to a page explaining the binary * unit suffixes. * http://en.wikipedia.org/wiki/Binary_prefix#IEC_standard_prefixes *
unitThe unit to append to the formatted value. E.g., byte * No, default is the empty string.
sepThe string placed between the number and the * unit. * No, default is the HTML non-breaking space, "&nbsp;".
valueThe value to format. * One of value and file must be given.
fileThe file whose size is the value to format. * One of value and file must be given.
* *

Nested elements

* * Not applicable. * *

Examples

* *

Format a value as bytes

* *
 *  <byteformatter value="9093663"
 *                    property="myFormatedFilesize"
 *                    unit="B" />
 * 
* * *

Format the size of the file archive.jar appending the * unit B

* *
 *  <byteformatter file="archive.jar"
 *                    property="archive.size"
 *                    unit="B" />
 * 
* * * */ public class ByteFormatterTask extends Task { /** * Default constructor. */ public ByteFormatterTask() { super(); } private String property; /** * The name of the property to save the formatted value to. * * @param property the name of the property to set. */ public void setProperty(String property) { this.property = property; } private String unit = ""; /** * The unit to append to the formatted value. * * @param unit the unit text to append to the formatted value. */ public void setUnit(String unit) { this.unit = unit; } private String binaryPrefixURL = "http://en.wikipedia.org/wiki/Binary_prefix#IEC_standard_prefixes"; /** * The URL that explains binary prefixes. * * @param url The url to let the binary prefix point to. */ public void setBinaryPrefixURL(String url) { this.binaryPrefixURL = url; } private String sep = " "; /** * The separator between the numeral and the prefixed unit. * * @param sep the separator string. */ public void setSep(String sep) { this.sep = sep; } private long value; /** * Set the value to format. * * @param value the value to format */ public void setValue(long value) { this.value = value; } private File file; /** * Set the file to get the size of as the the value to format. * * @param file the file to return a formatted file size for. */ public void setFile(File file) { this.file = file; this.value = file.length(); } static final long step = 1024; /** * Format value using ki, Mi, Gi, ... using multiples of 1024. I.e., * binary "bytes". * * @throws BuildException if the manifest cannot be written. */ public void execute() { String formatedValue = ""; String[] suffixes = new String[]{ "", "Ki","Mi", "Gi","Ti","Pi", "Ei","Zi","Yi"}; if (binaryPrefixURL!=null && binaryPrefixURL.length()>0) { for (int i=0; i0) { suffixes[i] = "" +suffixes[i] + ""; } } } int ix = 0; long factor = 1; while(value/factor>step && ix * Task that analyzes a set of bundle jar files and builds OBR XML * documentation from these bundles. *

* *

* Bundle jar files files are analyzed using the static manifest attributes. *

* *

Parameters

* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *

Parameters specified as nested elements

*

fileset

* * (required)
*

* All jar files must be specified as a fileset. If there exists * jar files * [prefix]_all-[suffix].jar and * [prefix]-[suffix].jar, * only * [prefix]-_all-[suffix].jar will be included. *

* */ public class OBRExtractorTask extends Task { private Vector filesets = new Vector(); private FileUtils fileUtils; private File baseDir = new File("."); private String baseURL = ""; private String outFile = "repository.xml"; private String repoName = "Knopflerfish bundle repository"; private String repoXSLURL = ""; private String externRepoURLs = null; public OBRExtractorTask() { fileUtils = FileUtils.newFileUtils(); } public void setBaseDir(String s) { this.baseDir = new File((new File(s)).getAbsolutePath()); } public void setBaseURL(String s) { this.baseURL = s; } public void setRepoXSLURL(String s) { this.repoXSLURL = s; } public void setOutFile(String s) { this.outFile = s; } public void setRepoName(String s) { this.repoName = s; } public void setExternRepoURLs(String s) { this.externRepoURLs = s; } public void addFileset(FileSet set) { filesets.addElement(set); } // File -> BundleInfo Map jarMap = new HashMap(); // Implements Task public void execute() throws BuildException { if (filesets.size() == 0) { throw new BuildException("No fileset specified"); } jarMap = new HashMap(); System.out.println("loading bundle info..."); try { for (int i = 0; i < filesets.size(); i++) { FileSet fs = (FileSet) filesets.elementAt(i); DirectoryScanner ds = fs.getDirectoryScanner(project); File projDir = fs.getDir(project); String[] srcFiles = ds.getIncludedFiles(); String[] srcDirs = ds.getIncludedDirectories(); for (int j = 0; j < srcFiles.length ; j++) { File file = new File(projDir, srcFiles[j]); if(file.getName().endsWith(".jar")) { jarMap.put(file, new BundleInfo(file)); } } } Set removeSet = new HashSet(); for(Iterator it = jarMap.keySet().iterator(); it.hasNext();) { File file = (File)it.next(); String name = file.getAbsolutePath(); if(-1 != name.indexOf("_all-")) { File f2 = new File(Util.replace(name, "_all-", "-")); removeSet.add(f2); System.out.println("skip " + f2); } } if(removeSet.size() > 0) { System.out.println("skipping " + removeSet.size() + " bundles"); } for(Iterator it = removeSet.iterator(); it.hasNext();) { File f = (File)it.next(); jarMap.remove(f); } System.out.println("analyzing " + jarMap.size() + " bundles"); for(Iterator it = jarMap.keySet().iterator(); it.hasNext();) { File file = (File)it.next(); BundleInfo info = (BundleInfo)jarMap.get(file); info.load(); } System.out.println("writing bundle OBR to " + outFile); OutputStream out = null; try { out = new FileOutputStream(outFile); PrintStream ps = new PrintStream(out); ps.println(""); if(repoXSLURL != null && !"".equals(repoXSLURL)) { ps.println(""); } ps.println(""); ps.println(""); ps.println(""); ps.println(""); ps.println(" 1.0"); ps.println(" "); ps.println(" " +repoName +""); ps.println(" " + (new Date()) + ""); if (externRepoURLs!=null && 0"); while (st.hasMoreTokens()) { String repoURL = st.nextToken().trim(); ps.println(" " +repoURL +""); } ps.println(" "); } ps.println(" "); for(Iterator it = jarMap.keySet().iterator(); it.hasNext();) { File file = (File)it.next(); BundleInfo info = (BundleInfo)jarMap.get(file); info.writeBundleXML(ps); } ps.println(""); ps.close(); } catch (Exception e) { e.printStackTrace(); } finally { try { out.close(); } catch (Exception ignored) { } } } catch (Exception e) { e.printStackTrace(); throw new BuildException("Failed to extract bundle info: " + e, e); } } class BundleInfo { File file; Attributes attribs; String path; Map pkgExportMap; Map pkgImportMap; Set optionalPkgs = new HashSet(); public BundleInfo(File file) throws IOException { this.file = file; path = Util.replace(file.getCanonicalPath().substring(1 + baseDir.getCanonicalPath().length()), "\\", "/"); } public void load() throws Exception { JarFile jarFile = new JarFile(file); Manifest mf = jarFile.getManifest(); attribs = mf.getMainAttributes(); pkgExportMap = parseNames(attribs.getValue("Export-Package")); pkgImportMap = parseNames(attribs.getValue("Import-Package")); } Map parseNames(String s) { Map map = new TreeMap(); // System.out.println(file + ": " + s); if(s != null) { s = s.trim(); String[] lines = Util.splitwords(s, ",", '\"'); for(int i = 0; i < lines.length; i++) { String[] words = Util.splitwords(lines[i].trim(), ";", '\"'); if(words.length < 1) { throw new RuntimeException("bad package spec '" + s + "'"); } String spec = "0"; String name = words[0].trim(); for(int j = 1; j < words.length; j++) { String[] info = Util.splitwords(words[j], "=", '\"'); if(info.length == 2) { String lhs = info[0].trim(); boolean isDirective = lhs.charAt(lhs.length()-1) == ':'; if("specification-version".equals(lhs) || "version".equals(lhs)) { spec = info[1].trim(); } else if (isDirective) { lhs = lhs.substring(0, lhs.length()-1).trim(); if ("resolution".equals(lhs) && "optional".equals(info[1].trim())) { optionalPkgs.add(name); } } } } map.put(name, new VersionRange(spec)); } } return map; } public void writeBundleXML(PrintStream out) throws IOException { out.println(""); out.println(" "); out.println(" "); printAttrib(out, "bundle-name", "Bundle-Name"); printAttrib(out, "bundle-version", "Bundle-Version"); printAttrib(out, "bundle-docurl", "Bundle-DocURL"); printAttrib(out, "bundle-category", "Bundle-Category"); printAttrib(out, "bundle-vendor", "Bundle-Vendor"); printAttrib(out, "bundle-description", "Bundle-Description"); printAttrib(out, "bundle-subversionurl", "Bundle-SubversionURL"); printAttrib(out, "bundle-apivendor", "Bundle-APIVendor"); printAttrib(out, "bundle-uuid", "Bundle-UUID"); printAttrib(out, "application-icon", "Application-Icon"); out.print(" "); out.print(baseURL + path); out.println(""); dumpPackages(out, "export-package", pkgExportMap); dumpPackages(out, "import-package", pkgImportMap); out.print(" "); out.print(Long.toString(file.length())); out.println(""); out.println(" "); } void dumpPackages(PrintStream out, String tag, Map map) { for(Iterator it = map.keySet().iterator(); it.hasNext();) { String pkg = (String)it.next(); VersionRange spec = (VersionRange) map.get(pkg); boolean bSkip = false; String skipReason = null; if("import-package".equals(tag)) { VersionRange exportSpec = (VersionRange) pkgExportMap.get(pkg); if(exportSpec != null && spec.contains(exportSpec.lowerBound)) { // Skip import of exported packages bSkip = true; skipReason = "own import since exported with same version "; } if(optionalPkgs.contains(pkg)) { // Skip import of package with optional resolution bSkip = true; skipReason = "pkg with optional resolution "; } } if(bSkip) { out.println(" "); } else { out.print(" <" + tag + " package=\"" + pkg + "\""); if("".equals(spec)) { out.println("/>"); } else { out.println("\n specification-version=\"" + spec + "\"/>"); } } } } void printAttrib(PrintStream out, String tag, String key) { String val = attribs.getValue(key); if(val == null) { val = ""; } out.println(" <" + tag + ">" + val + ""); } } } ././@LongLink0000000000000000000000000000015600000000000011567 Lustar rootrootknopflerfish-osgi-2.3.3/knopflerfish.org/ant/src/org/knopflerfish/ant/taskdefs/bundle/ExtraBundleDocTask.javaknopflerfish-osgi-2.3.3/knopflerfish.org/ant/src/org/knopflerfish/ant/taskdefs/bundle/ExtraBundleDoc0000644000175000017500000001315411252437456033662 0ustar twernertwernerpackage org.knopflerfish.ant.taskdefs.bundle; import java.io.File; import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.io.PrintStream; import java.util.ArrayList; import java.util.Iterator; import java.util.Properties; import org.apache.tools.ant.BuildException; import org.apache.tools.ant.DirectoryScanner; import org.apache.tools.ant.Task; import org.apache.tools.ant.types.FileSet; /** *

* This task is currently used in conjunction with MakeHTMLTask, which * is used to create the htdocs directory in the Knopflerfish * distribtions. *

* *

* The task is used to create extra documentation of bundles. The task * is given a set of files it searches them for documentation, and * generates a index-file that links to these sites. *

* *
AttributeDescriptionRequired
baseDir * Base directory for scanning for jar files. * No.
Default value is "."
baseURL * Base URL for generated bundleupdate locations. * No.
Default value is ""
outFile * File name of generated repository XML file * No.
Default value is "repository.xml"
repoName * Repository name * No.
Default value is "Knopflerfish bundle repository"
externRepoURLs * Comma separated list of URLs to external repositories. * No.
No default value.
* * * * * * * * * * *
AttributeDescriptionRequired
* outdir * * Directory where the task copies the directories * * Yes *
* *

* The task includes the directories that contains an index.html, * others are not included. *

* *

* If a directory contains an index.html and doc.properties * the task will read the doc.properties file. * The properties used are Title and Description. These * properties will be used when creating the main index site. *

* *

* If the directory does not contain any doc.properties the task * will attempt to create a valid link name. *

* */ public class ExtraBundleDocTask extends Task { private static final String TITLE = "Title"; private static final String BODY = "Description"; private static final String INDEX_FILE = "index.html"; private static final String PROPS_FILE = "doc.properties"; private ArrayList filesets = new ArrayList(); private File outputDir; private String template; private String pattern; public void setOut(String s) { outputDir = new File(s); } public void setTemplate(String template) { this.template = template; } public void setPattern(String pattern) { this.pattern = pattern; } public void addFileset(FileSet set) { filesets.add(set); } public void execute() { StringBuffer buf = new StringBuffer(); for (Iterator iter=filesets.iterator(); iter.hasNext(); ) { FileSet set = (FileSet) iter.next(); File dir = set.getDir(getProject()); DirectoryScanner ds = set.getDirectoryScanner(getProject()); String[] dirs = ds.getIncludedDirectories(); // copy the files for (int i = 0; i < dirs.length; i++) { try { File sourceDir = new File(dir, dirs[i]); if (!new File(sourceDir, INDEX_FILE).isFile()) { System.out.println(sourceDir + " does not contain any index.html. Skipping."); continue; } copyDirectory(sourceDir, new File(outputDir, dirs[i])); } catch (IOException e) { e.printStackTrace(); throw new BuildException(e); } } // create the index-file for (int i = 0; i < dirs.length; i++) { File sourceDir = new File(dir, dirs[i]); if (!new File(sourceDir, INDEX_FILE).isFile()) { System.out.println(sourceDir + " does not contain any " + INDEX_FILE + ". Skipping."); continue; } String p = pattern; Properties props = new Properties(); props.put(TITLE, sourceDir.getParentFile().getName()); props.put(BODY, ""); File propsFile = new File(sourceDir, PROPS_FILE); if (propsFile.isFile() && propsFile.canRead()) { try { props.load(new FileInputStream(propsFile)); } catch (IOException e) { throw new BuildException(e); } } p = Util.replace(p, "$(URL)", new File(dirs[i], INDEX_FILE).toString()); p = Util.replace(p, "$(TITLE)", props.getProperty(TITLE)); p = Util.replace(p, "$(BODY)", props.getProperty(BODY)); buf.append(p); buf.append("\n"); } } try { Util.writeStringToFile(new File(outputDir, INDEX_FILE), Util.replace(Util.loadFile(template), "$(EXTRA_DOC_BODY)", buf.toString())); } catch (IOException e) { throw new BuildException(e); } } private void copyDirectory(File sourceLocation, File targetLocation) throws IOException { if (sourceLocation.isHidden()) { return ; } if (sourceLocation.isDirectory()) { if (!targetLocation.exists()) { if (!targetLocation.mkdirs()) { throw new IOException("Could not create directory " + targetLocation); } } String[] children = sourceLocation.list(); for (int i=0; i 0) { out.write(buf, 0, len); } in.close(); out.close(); } } } ././@LongLink0000000000000000000000000000014600000000000011566 Lustar rootrootknopflerfish-osgi-2.3.3/knopflerfish.org/ant/src/org/knopflerfish/ant/taskdefs/bundle/BIndexTask.javaknopflerfish-osgi-2.3.3/knopflerfish.org/ant/src/org/knopflerfish/ant/taskdefs/bundle/BIndexTask.jav0000644000175000017500000001743011252437456033573 0ustar twernertwerner/* * Copyright (c) 2003-2008, KNOPFLERFISH project * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * - Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * - 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. * * - Neither the name of the KNOPFLERFISH project nor the names of its * contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS 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 * COPYRIGHT OWNER OR 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. */ package org.knopflerfish.ant.taskdefs.bundle; import java.io.ByteArrayOutputStream; import java.io.File; import java.io.PrintStream; import java.lang.reflect.Field; import java.lang.reflect.Method; import java.util.ArrayList; import java.util.HashSet; import java.util.Iterator; import java.util.List; import java.util.Set; import java.util.Vector; import org.apache.tools.ant.BuildException; import org.apache.tools.ant.DirectoryScanner; import org.apache.tools.ant.Project; import org.apache.tools.ant.Task; import org.apache.tools.ant.types.FileSet; public class BIndexTask extends Task { private Vector filesets = new Vector(); private File baseDir = new File(""); private String baseURL = ""; private String repoName = null; private String outFile = "bindex.xml"; /** * The working directory of the BIndex process. The bundle URLs will * be on the form * BaseURL/<relative path to JAR> * where the relative path to JAR is computed relative to this base * dir. * @param f The base dir for relative part of the generated URLs. */ public void setBaseDir(File f) { this.baseDir = f; } public void setBaseURL(String s) { this.baseURL = s; } public void setOutFile(String s) { this.outFile = s; } public void setRepoName(String s) { this.repoName = s; } public void addFileset(FileSet set) { filesets.addElement(set); } // Implements Task public void execute() throws BuildException { if (filesets.size() == 0) { throw new BuildException("No fileset specified"); } Set jarSet = new HashSet(); log("loading bundle info...", Project.MSG_VERBOSE); try { for (int i = 0; i < filesets.size(); i++) { FileSet fs = (FileSet) filesets.elementAt(i); DirectoryScanner ds = fs.getDirectoryScanner(project); File projDir = fs.getDir(project); String[] srcFiles = ds.getIncludedFiles(); for (int j = 0; j < srcFiles.length ; j++) { File file = new File(projDir, srcFiles[j]); if(file.getName().endsWith(".jar")) { jarSet.add(file); } } } Set removeSet = new HashSet(); for(Iterator it = jarSet.iterator(); it.hasNext();) { File file = (File)it.next(); String name = file.getAbsolutePath(); if(-1 != name.indexOf("_all-")) { File f2 = new File(Util.replace(name, "_all-", "-")); removeSet.add(f2); log("skip " + f2, Project.MSG_VERBOSE); } } if(removeSet.size() > 0) { log("skipping " + removeSet.size() + " bundles", Project.MSG_INFO); } for(Iterator it = removeSet.iterator(); it.hasNext();) { File f = (File)it.next(); jarSet.remove(f); } log("writing bundle repository to " + outFile, Project.MSG_VERBOSE); List cmdList = new ArrayList( 10 + jarSet.size() ); cmdList.add("-t"); cmdList.add(baseURL +"/%p/%f "); // -d here cmdList.add("-r"); cmdList.add(outFile); // Don't print the resulting XML documnet on System.out. cmdList.add("-q"); if (null!=repoName && repoName.length()>0) { cmdList.add("-n"); cmdList.add(repoName); } for (Iterator iter = jarSet.iterator(); iter.hasNext(); ) { String file = ((File) iter.next()).getAbsolutePath(); cmdList.add(file); } try { // Call org.osgi.impl.bundle.bindex.Index.main(args) to // generate the bindex.xml file. Class bIndexClazz = Class.forName("org.osgi.impl.bundle.bindex.Index"); //if (isBindexRootFileSettable(bIndexClazz)) { // Prepend the -d option cmdList.add(2,baseDir.getAbsolutePath()); cmdList.add(2,"-d"); } //else try { // Hack for older bindex without -d option. Use reflection // to set org.osgi.impl.bundle.bindex.Index.rootFile to // baseDir to get correctly computed paths in the bundle // URLs. Field rootFileField = bIndexClazz.getDeclaredField("rootFile"); if (null!=rootFileField) { rootFileField.setAccessible(true); rootFileField.set(null, baseDir.getAbsoluteFile()); } } catch (NoSuchFieldException _nsfe) { } // Call the main method String[] args = (String[]) cmdList.toArray(new String[cmdList.size()]); Method mainMethod = bIndexClazz .getDeclaredMethod("main", new Class[]{args.getClass()}); { StringBuffer argSb = new StringBuffer(); for (int ix=0; ix -1; log("Using 'bindex -d rootFile' is " +(res?"":"not ") +"supported. ", Project.MSG_INFO); } catch (Exception e) { log("Failed to execute BIndex: " +e.getMessage(), Project.MSG_ERR); e.printStackTrace(); } return res; } } ././@LongLink0000000000000000000000000000016300000000000011565 Lustar rootrootknopflerfish-osgi-2.3.3/knopflerfish.org/ant/src/org/knopflerfish/ant/taskdefs/bundle/BundleHTMLExtractorTask.javaknopflerfish-osgi-2.3.3/knopflerfish.org/ant/src/org/knopflerfish/ant/taskdefs/bundle/BundleHTMLExtr0000644000175000017500000012016611252437456033562 0ustar twernertwerner/* * Copyright (c) 2003-2009, KNOPFLERFISH project * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * - Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * - 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. * * - Neither the name of the KNOPFLERFISH project nor the names of its * contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS 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 * COPYRIGHT OWNER OR 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. */ package org.knopflerfish.ant.taskdefs.bundle; import java.io.BufferedInputStream; import java.io.BufferedOutputStream; import java.io.File; import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.util.ArrayList; import java.util.Comparator; import java.util.Enumeration; import java.util.HashSet; import java.util.Iterator; import java.util.List; import java.util.Map; import java.util.Set; import java.util.TreeMap; import java.util.TreeSet; import java.util.Vector; import java.util.SortedSet; import java.util.jar.Attributes; import java.util.jar.JarFile; import java.util.jar.Manifest; import java.util.zip.ZipEntry; import java.util.zip.ZipFile; import org.apache.tools.ant.BuildException; import org.apache.tools.ant.DirectoryScanner; import org.apache.tools.ant.Task; import org.apache.tools.ant.types.FileSet; import org.apache.tools.ant.util.FileUtils; import org.osgi.framework.Version; /** * Task that analyzes a set of bundle jar files and builds HTML documentation * from these bundles. Also creates cross-references to bundle dependencies. * *

* All generated HTML will be stored in the same directory structure as * the scanned jars, e.g a jar file *

 *  baseDir/log/log-api.jar
 * 
* will have a corresponding *
 *  outDir/log/log-api.html
 * 
* in the directory specified with the attribute outDir. * The part of the original bundle jar path to remove when creating * the output directory structure in outDir is specified * by the baseDir attribute. * *

* Bundle jar files files are analyzed using the static manifest attributes. *

* *

Parameters

* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
AttributeDescriptionRequired
javadocRelPathRelative path (from outDir) to javadocs. * No.
Default value is "."
outDir * Directory to place resulting files in. * No.
Default value is "."
baseDir * Remove this part of the path from the specified jar-files and * use the remainder as file name in the outDir. * No.
Default value is ""
templateHTMLDir * Directory containing HTML template files. This directory must * contain the files: *
 *    bundle_index.html
 *    bundle_list.html
 *    bundle_main.html
 *    style.css
 *   
*
No.
Default value is "."
systemPackageSet * Comma-separated set of packages which are system packages and * thus globally available. * These are not cross-referenced. * No.
* Default value is javax.swing, javax.accessibility, * javax.servlet, javax.xml,org.xml, org.w3c, java, com.sun *
skipAttribSet * Comma-separated set of manifest attributes which shouldn't be printed. * No.
* Default value is Manifest-Version, Ant-Version, * Bundle-Config, Created-By, Built-From *
includeSourceFiles * Controls if Java source files shall be copied and linked into * the HTML structure. * No.
* Default value "False" *
listHeader * Heading to print at the top of the bundle list in the left frame * of the page. * No.
Default value is ""
* *

Parameters specified as nested elements

*

fileset

* * (required)
*

* All jar files must be specified as a fileset. No jar files * are ignored. *

* *

Examples

* *
 * <bundlehtml templateHTMLDir    = "${ant.dir}/html_template"
 *                outDir             = "${release.dir}/docs"
 *                baseDir            = "${release.dir}/osgi"
 *                javadocRelPath     = "../javadoc"
 *   >
 *
 *     <fileset dir="${release.dir}/osgi/jars">
 *       <include name = "**/*.jar"/>
 *     </fileset>
 * 
* */ public class BundleHTMLExtractorTask extends Task { private Vector filesets = new Vector(); private FileUtils fileUtils; private File templateHTMLDir = new File("."); private String listSeparator = "
\n"; private File outDir = new File("."); private File baseDir = null; private String javadocRelPath = null; private String listHeader = ""; private String indexListHeader = "

${bundle.list.header}

"; private String indexListRow = "${FILE.short}
"; private String indexMainRow = "" + "${FILE.short}" + "${Bundle-Description}" + "\n"; private String bundleRow = "${FILE.short}${what}\n"; private String packageListRow = "${namelink} ${version}${providers}\n"; private String missingRow = "${name}${version}\n"; private String rowHTML = "${FILE.short}
\n"; private String pkgHTML = "${namelink} ${version}
"; private boolean bCheckJavaDoc = true; private boolean include_source_files = false; Map jarMap = new TreeMap(new FileNameComparator()); Map globalVars = new TreeMap(); Map missingDocs = new TreeMap(); public BundleHTMLExtractorTask() { fileUtils = FileUtils.newFileUtils(); setListProps("Export-Package," + "Import-Package," + "Import-Service," + "Export-Service"); setSystemPackageSet("javax.swing," + "javax.accessibility," + "javax.servlet," + "javax.xml," + "org.xml," + "org.w3c," + "java," + "com.sun," + "com.apple.eawt"); setSkipAttribSet("Manifest-Version," + "Ant-Version," + "Bundle-Config," + "Created-By" // "Built-From", ); setAlwaysProps("Bundle-Activator," + "Bundle-Vendor," + "Bundle-Name," + "Bundle-Description," + "Export-Package," + "Import-Package," + "Import-Service," + "Export-Service," + "Main-class," + "Build-Date," + "Bundle-DocURL," + "Bundle-Classpath," + "Bundle-ContactAddress," + "Bundle-Activator"); } public void setCheckJavaDoc(String s) { this.bCheckJavaDoc = "true".equals(s); } public void setTemplateHTMLDir(String s) { this.templateHTMLDir = new File(s); if(!templateHTMLDir.exists()) { throw new BuildException("templateHTMLDir: " + s + " does not exist"); } if(!templateHTMLDir.isDirectory()) { throw new BuildException("templateHTMLDir: " + s + " is not a directory"); } } public void setIncludeSourceFiles(String s) { this.include_source_files = "true".equals(s); } File getBundleInfoTemplate() { return new File(templateHTMLDir, "bundle_info.html"); } File getBundleCSSTemplate() { return new File(templateHTMLDir, "style.css"); } File getBundleListTemplate() { return new File(templateHTMLDir, "bundle_list.html"); } File getPackageListTemplate() { return new File(templateHTMLDir, "package_list.html"); } File getBundleMainTemplate() { return new File(templateHTMLDir, "bundle_main.html"); } File getBundleIndexTemplate() { return new File(templateHTMLDir, "bundle_index.html"); } File getBundleHeaderTemplate() { return new File(templateHTMLDir, "bundle_header.html"); } public void setOutDir(String s) { this.outDir = new File((new File(s)).getAbsolutePath()); } public void setBaseDir(String s) { this.baseDir = new File((new File(s)).getAbsolutePath()); } public void setJavadocRelPath(String s) { this.javadocRelPath = s; } public void addFileset(FileSet set) { filesets.addElement(set); } Set listPropSet = new HashSet(); Set skipAttribSet = new HashSet(); Set alwaysPropSet = new HashSet(); Set systemPackageSet = new HashSet(); public void setListProps(String s) { listPropSet = Util.makeSetFromStringList(s); } public void setAlwaysProps(String s) { alwaysPropSet = Util.makeSetFromStringList(s); } public void setSkipAttribSet(String s) { skipAttribSet = Util.makeSetFromStringList(s); } public void setSystemPackageSet(String s) { systemPackageSet = Util.makeSetFromStringList(s); } public void setListHeader(String s) { listHeader = s; } // Implements Task public void execute() throws BuildException { if (filesets.size() == 0) { throw new BuildException("No fileset specified"); } try { for (int i = 0; i < filesets.size(); i++) { FileSet fs = (FileSet) filesets.elementAt(i); DirectoryScanner ds = fs.getDirectoryScanner(project); File projDir = fs.getDir(project); String[] srcFiles = ds.getIncludedFiles(); String[] srcDirs = ds.getIncludedDirectories(); for (int j = 0; j < srcFiles.length ; j++) { File file = new File(projDir, srcFiles[j]); if(file.getName().endsWith(".jar")) { jarMap.put(file, new BundleInfo(file)); } } } log("analyzing " + jarMap.size() + " bundles"); if (include_source_files) { log("including source files in jardoc"); } else { log("includeSourceFiles is not set, skipping sources"); } for(Iterator it = jarMap.keySet().iterator(); it.hasNext();) { File file = (File)it.next(); BundleInfo info = (BundleInfo)jarMap.get(file); info.load(); } System.out.println("writing bundle info html pages"); for(Iterator it = jarMap.keySet().iterator(); it.hasNext();) { File file = (File)it.next(); BundleInfo info = (BundleInfo)jarMap.get(file); info.writeInfo(); } makeListPage(getBundleMainTemplate(), new File(outDir, "main.html"), indexMainRow); makeListPage(getBundleListTemplate(), new File(outDir, "list.html"), indexListRow); makePackageListPage(getPackageListTemplate(), new File(outDir, "package_list.html"), packageListRow); copyFile(getBundleIndexTemplate(), new File(outDir, "index.html")); copyFile(getBundleHeaderTemplate(), new File(outDir, "header.html")); copyFile(getBundleCSSTemplate(), new File(outDir, "style.css")); for(Iterator it = missingDocs.keySet().iterator(); it.hasNext();) { String name = (String)it.next(); System.out.println("Missing javadoc for " + name); } } catch (Exception e) { e.printStackTrace(); throw new BuildException("Failed to extract bundle info: " + e, e); } } void makeListPage(File templateFile, File outFile, String rowTemplate) throws IOException { int unresolvedCount = 0; String html = Util.loadFile(templateFile.getAbsolutePath()); String listHeaderRow = (null!=listHeader && listHeader.length()>0) ? replace(indexListHeader, "${bundle.list.header}", listHeader) : listHeader; html = replace(html, "${bundle.list.header}", listHeaderRow); StringBuffer sb = new StringBuffer(); for(Iterator it = jarMap.keySet().iterator(); it.hasNext();) { File file = (File)it.next(); BundleInfo info = (BundleInfo)jarMap.get(file); unresolvedCount += info.unresolvedMap.size(); String row = rowTemplate; row = info.stdReplace(row, false); row = replace(row, "${bundledoc}", info.relPath +".html"); sb.append(row); } html = replace(html, "${bundle.list}", sb.toString()); sb = new StringBuffer(); if(unresolvedCount > 0) { sb.append("\n"); sb.append("\n" + " \n" + "\n"); for(Iterator it = jarMap.keySet().iterator(); it.hasNext();) { File file = (File)it.next(); BundleInfo info = (BundleInfo)jarMap.get(file); if(info.unresolvedMap.size() > 0) { sb.append("\n" + " \n"); sb.append(""); sb.append(""); } } sb.append("
Unresolved packages
" + info.file.getName() + ""); for(Iterator it2 = info.unresolvedMap.keySet().iterator(); it2.hasNext();) { String pkgName = (String)it2.next(); Object version = info.unresolvedMap.get(pkgName); boolean optional = info.pkgImportOptional.contains(pkgName); sb.append(pkgName +" " +version +(optional ? " optional" : "") +"
\n"); } sb.append("
\n"); } html = replace(html, "${unresolved.list}", sb.toString()); Util.writeStringToFile(outFile, html); System.out.println("wrote " + outFile); } void makePackageListPage(File templateFile, File outFile, String rowTemplate) throws IOException { String html = Util.loadFile(templateFile.getAbsolutePath()); SortedSet pkgs = new TreeSet(); for (Iterator it=jarMap.values().iterator(); it.hasNext();) { BundleInfo info = (BundleInfo) it.next(); pkgs.addAll(info.pkgExportMap.keySet()); } StringBuffer sb = new StringBuffer(); for(Iterator it = pkgs.iterator(); it.hasNext();) { String pkg = (String) it.next(); TreeMap pkgVersions = new TreeMap(); for (Iterator it2=jarMap.values().iterator(); it2.hasNext();) { BundleInfo info = (BundleInfo) it2.next(); Version ver = (Version) info.pkgExportMap.get(pkg); if (null!=ver) { TreeSet providers = (TreeSet) pkgVersions.get(ver); if (null==providers) { providers = new TreeSet(new BundleInfoComparator()); } providers.add(info); pkgVersions.put(ver,providers); } } for (Iterator it3=pkgVersions.keySet().iterator(); it3.hasNext();) { String row = rowTemplate; Version version = (Version) it3.next(); String docFile = replace(pkg, ".", "/") +"/package-summary.html"; String docPath = javadocRelPath +"/index.html?" +docFile; File f = new File(outDir +File.separator +javadocRelPath +File.separator +docFile); if(javadocRelPath != null && !"".equals(javadocRelPath)) { if( isSystemPackage(pkg) ) { row = replace(row, "${namelink}", "${name}"); } else if ( (bCheckJavaDoc && !f.exists()) ) { row = replace(row, "${namelink}", "${name}"); } else { row = replace(row, "${namelink}", "${name}"); } } else { row = replace(row, "${namelink}", "${name}"); } row = replace(row, "${name}", pkg); row = replace(row, "${version}", version.toString()); row = replace(row, "${javadoc}", docPath); TreeSet providers = (TreeSet) pkgVersions.get(version); StringBuffer sbProviders = new StringBuffer(); for (Iterator it4=providers.iterator(); it4.hasNext();) { BundleInfo info = (BundleInfo) it4.next(); String providerRow = indexListRow; providerRow = info.stdReplace(providerRow, false); providerRow = replace(providerRow, "${bundledoc}", info.relPath +".html"); sbProviders.append(providerRow); } row = replace(row, "${providers}", sbProviders.toString()); sb.append(row); } } html = replace(html, "${package.list}", sb.toString()); Util.writeStringToFile(outFile, html); System.out.println("wrote " + outFile); } void copyFile(File templateFile, File outFile) throws IOException { String src = Util.loadFile(templateFile.getAbsolutePath()); Util.writeStringToFile(outFile, src); System.out.println("copied " + outFile); } interface MapSelector { public Map getMap(BundleInfo info); } class BundleInfo { File file; Attributes attribs; Map vars = new TreeMap(); // String (package name) -> Version Map pkgExportMap = new TreeMap(); // String (package name) -> VersionRange Map pkgImportMap = new TreeMap(); // String (package name) List pkgImportOptional = new ArrayList(); // String (service interface) -> Version Map serviceExportMap = new TreeMap(); // String (service interface) -> VersionRange Map serviceImportMap = new TreeMap(); String relPath = ""; String relPathUp = ""; String path = ""; String jarRelPath = ""; Map unresolvedMap = new TreeMap(); public BundleInfo(File file) throws IOException { this.file = file; String filePath = file.getCanonicalPath(); String basePath = baseDir.getCanonicalPath(); if (filePath.startsWith(basePath)) { relPath = filePath.substring(basePath.length()+1); if (relPath.endsWith(".jar")) { relPath = relPath.substring(0,relPath.length()-4); } path = outDir.getCanonicalPath() + File.separator + relPath; int sepIx = relPath.indexOf(File.separator); while (sepIx>-1) { relPathUp += ".." +File.separator;; sepIx = relPath.indexOf(File.separator,sepIx+1); } jarRelPath = createRelPath(new File(path).getParentFile(), filePath); } else { String fileDir = file.getParentFile().getCanonicalPath(); if (basePath.startsWith(fileDir)) { // Outside baseDir, place resulting file directly in outDir relPath = file.getName(); if (relPath.endsWith(".jar")) { relPath = relPath.substring(0,relPath.length()-4); } path = outDir.getCanonicalPath() + File.separator + relPath; relPathUp = ""; jarRelPath = createRelPath(new File(path).getParentFile(), filePath); } else { throw new BuildException("The file '"+filePath +"' does not reside in baseDir (" +basePath +")!"); } } } /** * Derive relative path from fromDir to the file given by * filePath. */ private String createRelPath(File fromDir, String filePath) { String res = ""; while (fromDir!=null && !filePath.startsWith(fromDir.toString())) { if (res.length()>0) { res += File.separator; } res += ".."; fromDir = fromDir.getParentFile(); } if (res.length()>0) { res += File.separator; } res += filePath.substring(fromDir.toString().length()+1); return res; } public void load() throws Exception { JarFile jarFile = new JarFile(file); Manifest mf = jarFile.getManifest(); attribs = mf.getMainAttributes(); vars.put("html.file", path +".html"); vars.put("html.uri", replace(relPath, "\\", "/")); pkgExportMap = parseNames(attribs.getValue("Export-Package"), false, null); pkgImportMap = parseNames(attribs.getValue("Import-Package"), true, pkgImportOptional); serviceExportMap = parseNames(attribs.getValue("Export-Service"), false, null); serviceImportMap = parseNames(attribs.getValue("Import-Service"), true, null); extractSource(jarFile, new File( path +"/src")); } // String -> String Map sourceMap = new TreeMap(); boolean bSourceInside = false; void extractSource(JarFile jarFile, File destDir) throws IOException { if (!include_source_files) { return; } String prefix = "OSGI-OPT/src"; int count = 0; for(Enumeration e = jarFile.entries(); e.hasMoreElements(); ) { ZipEntry entry = (ZipEntry)e.nextElement(); if(entry.getName().startsWith(prefix)) { count++; } } if(count > 0) { bSourceInside = true; //System.out.println("found " + count + " source files in " + jarFile.getName()); //System.out.println("creating "+ destDir.getAbsolutePath()); destDir.mkdirs(); for(Enumeration e = jarFile.entries(); e.hasMoreElements(); ) { ZipEntry entry = (ZipEntry)e.nextElement(); if(entry.getName().startsWith(prefix)) { if(entry.isDirectory()) { makeDir(jarFile, entry, destDir, prefix); } else { copyEntry(jarFile, entry, destDir, prefix); String s = replace(entry.getName(), prefix + "/", ""); sourceMap.put(s, s); } count++; } } } else { // Check if we can copy source from original pos String sourceDir = (String)attribs.getValue("Built-From"); if(sourceDir != null && !"".equals(sourceDir)) { File src = new File(sourceDir, "src"); copyTree(src, destDir, src.toString() + File.separator, ".java"); } } } void copyTree(File src, File dest, String prefix, String suffix) throws IOException { if(src.isDirectory()) { if(!dest.exists()) { dest.mkdirs(); } String[] files = src.list(); for(int i = 0; i < files.length; i++) { copyTree(new File(src, files[i]), new File(dest, files[i]), prefix, suffix); } } else if(src.isFile()) { if(src.getName().endsWith(suffix)) { String path = src.getAbsolutePath(); String s = replace(replace(path, prefix, ""), "\\", "/"); copyStream(new FileInputStream(src), new FileOutputStream(dest)); sourceMap.put(s, s); } } } void makeDir(ZipFile file, ZipEntry entry, File destDir, String prefix) throws IOException { File d = new File(destDir, replace(entry.getName(), prefix, "")); d.mkdirs(); //System.out.println("created dir " + d.getAbsolutePath()); } void copyEntry(ZipFile file, ZipEntry entry, File destDir, String prefix) throws IOException { File d = new File(destDir, replace(entry.getName(), prefix, "")); File dir = d.getParentFile(); if(!dir.exists()) { dir.mkdirs(); } //System.out.println("extracting to " + d.getAbsolutePath()); copyStream(new BufferedInputStream(file.getInputStream(entry)), new BufferedOutputStream(new FileOutputStream(d))); } void copyStream(InputStream is, OutputStream os) throws IOException { byte[] buf = new byte[1024]; BufferedInputStream in = null; BufferedOutputStream out = null; try { in = new BufferedInputStream(is); out = new BufferedOutputStream(os); int n; int total = 0; while ((n = in.read(buf)) > 0) { out.write(buf, 0, n); total += n; } } finally { try { in.close(); } catch (Exception ignored) { } try { out.close(); } catch (Exception ignored) { } } } Map parseNames(String s, boolean range, List optionals) { Map map = new TreeMap(); //System.out.println(file + ": " + s); if(s != null) { s = s.trim(); String[] lines = Util.splitwords(s, ",", '\"'); for(int i = 0; i < lines.length; i++) { String[] words = Util.splitwords(lines[i].trim(), ";", '\"'); if(words.length < 1) { throw new RuntimeException("bad package spec '" + s + "'"); } String spec = "0"; String name = words[0].trim(); for(int j = 1; j < words.length; j++) { String[] info = Util.splitwords(words[j], "=", '\"'); if(info.length == 2) { if("specification-version".equals(info[0].trim())) { spec = info[1].trim(); } else if("version".equals(info[0].trim())) { spec = info[1].trim(); } else if (null!=optionals) { if(info[0].endsWith(":")) { final String directive = info[0].substring(0,info[0].length()-1).trim(); if ("resolution".equals(directive) && "optional".equals(info[1].trim())) { pkgImportOptional.add(name); } } } } } if (range) { map.put(name, new VersionRange(spec)); } else { map.put(name, new Version(spec)); } } } return map; } public void writeInfo() throws IOException { String template = stdReplace(Util.load(getBundleInfoTemplate().getAbsolutePath())); String outName = (String)vars.get("html.file"); //System.out.println("jar info from " + file + " to " +outName); Util.writeStringToFile(new File(outName), template); } public String stdReplace(String template) throws IOException { return stdReplace(template, true); } public String stdReplace(String template, boolean bDepend) throws IOException { for(Iterator it = globalVars.keySet().iterator(); it.hasNext(); ) { Object key = it.next(); Object val = globalVars.get(key); template = replace(template, "${" + key + "}", "" + val); //System.out.println(key + "->" + val); } for(Iterator it = vars.keySet().iterator(); it.hasNext(); ) { Object key = it.next(); Object val = vars.get(key); template = replace(template, "${" + key + "}", "" + val); //System.out.println(key + "->" + val); } Set handledSet = new TreeSet(); for(Iterator it = attribs.keySet().iterator(); it.hasNext(); ) { Object key = it.next(); if(-1 != template.indexOf("${" + key.toString() + "}")) { handledSet.add(key.toString()); } } for(Iterator it = attribs.keySet().iterator(); it.hasNext(); ) { Object key = it.next(); Object val = attribs.get(key); String str = (String)attribs.get(key); if("Export-Package".equals(key.toString()) || "Import-Package".equals(key.toString()) || "Import-Service".equals(key.toString()) || "Export-Service".equals(key.toString())) { } else { if(listPropSet.contains(key.toString())) { str = replace(str, ",", listSeparator); } template = replace(template, "${" + key + "}", str); } } template = replace(template, "${Export-Package}", getPackagesString(pkgExportMap, "/package-summary.html")); template = replace(template, "${Import-Package}", getPackagesString(pkgImportMap, "/package-summary.html")); template = replace(template, "${Export-Service}", getPackagesString(serviceExportMap, ".html")); template = replace(template, "${Import-Service}", getPackagesString(serviceImportMap, ".html")); for(Iterator it = alwaysPropSet.iterator(); it.hasNext(); ) { String key = (String)it.next(); String val = ""; template = replace(template, "${" + key + "}", val); } StringBuffer sb = new StringBuffer(); for(Iterator it = attribs.keySet().iterator(); it.hasNext(); ) { Object key = it.next(); if(!handledSet.contains(key.toString())) { if(!skipAttribSet.contains(key.toString())) { sb.append("\n" + " " + key + "\n" + " " + attribs.getValue(key.toString()) + "\n" + "\n"); } } } template = replace(template, "${MF.UNHANDLED}", sb.toString()); template = replace(template, "${FILE}", file.getName()); template = replace(template, "${FILE.short}", replace(file.getName(), ".jar", "")); template = replace(template, "${BYTES}", "" + file.length()); template = replace(template, "${KBYTES}", "" + (file.length() / 1024)); template = replace(template, "${relpathup}", relPathUp); template = replace(template, "${jarRelPath}", jarRelPath); template = replace(template, "${javadocdir}", javadocRelPath != null ? javadocRelPath : ""); if(bDepend) { unresolvedMap = new TreeMap(); template = replace(template, "${depending.list}", getDepend( new MapSelector() { public Map getMap(BundleInfo info) { return info.pkgExportMap; } }, new MapSelector() { public Map getMap(BundleInfo info) { return info.pkgImportMap; } }, null, false)); template = replace(template, "${depends.list}", getDepend( new MapSelector() { public Map getMap(BundleInfo info) { return info.pkgImportMap; } }, new MapSelector() { public Map getMap(BundleInfo info) { return info.pkgExportMap; } }, unresolvedMap, true)); } sb = new StringBuffer(); if(sourceMap.size() > 0) { String srcBase = replace(file.getName(), ".jar", "") + "/src"; sb.append(""); for(Iterator it = sourceMap.keySet().iterator(); it.hasNext();) { String name = (String)it.next(); sb.append(" \n"); sb.append(" \n"); sb.append(" \n"); } sb.append("
\n"); sb.append(" " + name + "\n"); sb.append("
"); } else{ sb.append("None found"); } template = replace(template, "${sources.list}", sb.toString()); if(bSourceInside && sourceMap.size() > 0) { template = replace(template, "${FILEINFO}", file.length() +" bytes, includes source"); } else { template = replace(template, "${FILEINFO}", file.length() +" bytes"); } return template; } String getDepend(MapSelector importMap, MapSelector exportMap, Map unresolvedMapDest, boolean bShowUnresolved) throws IOException { Map map = new TreeMap(); if(unresolvedMapDest == null) { unresolvedMapDest = new TreeMap(); } for(Iterator it = importMap.getMap(this).keySet().iterator(); it.hasNext(); ) { String name = (String)it.next(); Object version = importMap.getMap(this).get(name); boolean bFound = false; for(Iterator it2 = jarMap.keySet().iterator(); it2.hasNext();) { File jarFile = (File)it2.next(); BundleInfo info = (BundleInfo)jarMap.get(jarFile); for(Iterator it3 = exportMap.getMap(info).keySet().iterator(); it3.hasNext(); ) { String name2 = (String) it3.next(); Object version2 = exportMap.getMap(info).get(name); if(name.equals(name2)) { VersionRange versions = (version instanceof VersionRange) ? (VersionRange) version : (VersionRange) version2; Version ver = (version instanceof Version) ? (Version) version : (Version) version2; if(versions.contains(ver)) { bFound = true; String pkgNames = (String) map.get(jarFile); pkgNames = null==pkgNames ? name : (pkgNames +", "+name); map.put(jarFile, pkgNames); } else { System.out.println(file +": need " +name +" version " +version +", found version " +version2); } } } } if(!bFound && !isSystemPackage(name)) { unresolvedMapDest.put(name, version); } } StringBuffer sb = new StringBuffer(); if(map.size() == 0 && unresolvedMapDest.size() == 0) { sb.append("None found"); } else { for(Iterator it = map.keySet().iterator(); it.hasNext();) { Object key = it.next(); File jarFile = (File)key; BundleInfo info = (BundleInfo)jarMap.get(jarFile); String what = (String)map.get(jarFile); String row = info.stdReplace(bundleRow, false); row = replace(row, "${what}", what); row = replace(row, "${bundledoc}", relPathUp +info.relPath +".html"); sb.append(row); } if(bShowUnresolved) { if(unresolvedMapDest.size() > 0) { String row = missingRow; row = replace(row, "${name}", "Unresolved"); row = replace(row, "${version}", ""); sb.append(row); } for(Iterator it = unresolvedMapDest.keySet().iterator(); it.hasNext();) { String name = (String) it.next(); Object version = unresolvedMapDest.get(name); String row = missingRow; row = replace(row, "${name}", name); row = replace(row, "${version}", version.toString()); sb.append(row); } } } return sb.toString(); } String getPackageString(String pkg, Object version, String linkSuffix) { String row = pkgHTML; String docFile = replace(pkg, ".", "/") + linkSuffix; String docPath = relPathUp + javadocRelPath + "/index.html?" + docFile; File f = new File(outDir + File.separator + javadocRelPath + File.separator + docFile); if(javadocRelPath != null && !"".equals(javadocRelPath)) { if( isSystemPackage(pkg) ) { row = replace(row, "${namelink}", "${name}"); } else if ( (bCheckJavaDoc && !f.exists()) ) { row = replace(row, "${namelink}", "${name}"); missingDocs.put(pkg, this); } else { row = replace(row, "${namelink}", "${name}"); } } else { row = replace(row, "${namelink}", "${name}"); } row = replace(row, "${name}", pkg); row = replace(row, "${version}", version.toString()); row = replace(row, "${javadoc}", docPath); return row; } String getPackagesString(Map map, String linkSuffix) { StringBuffer sb = new StringBuffer(); for(Iterator it = map.keySet().iterator(); it.hasNext(); ) { String name = (String)it.next(); Object version = map.get(name); sb.append(getPackageString(name, version, linkSuffix)); } return sb.toString(); } } boolean isSystemPackage(String name) { for(Iterator it = systemPackageSet.iterator(); it.hasNext();) { String prefix = (String)it.next(); if(name.startsWith(prefix)) { return true; } } return false; } String replace(String src, String a, String b) { return Util.replace(src, a, b == null ? "" : b); } /** * Comparator that sorts file objects based on their file name. */ class FileNameComparator implements Comparator { public int compare(Object o1, Object o2) { File f1 = (File) o1; File f2 = (File) o2; return f1.getName().compareTo(f2.getName()); } public boolean equals(Object obj) { return this==obj; } } /** * Comparator that sorts BundleInfo objects based on their file name. */ class BundleInfoComparator implements Comparator { public int compare(Object o1, Object o2) { BundleInfo info1 = (BundleInfo) o1; BundleInfo info2 = (BundleInfo) o2; return info1.file.getName().compareTo(info2.file.getName()); } public boolean equals(Object obj) { return this==obj; } } } knopflerfish-osgi-2.3.3/knopflerfish.org/ant/src/org/knopflerfish/ant/taskdefs/bundle/Util.java0000644000175000017500000003314111252437456032652 0ustar twernertwerner/* * Copyright (c) 2003-2009, KNOPFLERFISH project * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * - Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * - 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. * * - Neither the name of the KNOPFLERFISH project nor the names of its * contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS 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 * COPYRIGHT OWNER OR 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. */ package org.knopflerfish.ant.taskdefs.bundle; import java.net.*; import java.io.*; import java.util.*; /** * Misc static utility code. */ public class Util { public static byte [] loadURL(URL url) throws IOException { int bufSize = 1024 * 2; byte [] buf = new byte[bufSize]; ByteArrayOutputStream bout = new ByteArrayOutputStream(); BufferedInputStream in = new BufferedInputStream(url.openStream()); int n; while ((n = in.read(buf)) > 0) { bout.write(buf, 0, n); } try { in.close(); } catch (Exception ignored) { } return bout.toByteArray(); } public static String loadFile(String fname) throws IOException { byte[] bytes = loadURL(new URL("file:" + fname)); return new String(bytes); } /** * Load entire contents of a file or URL into a string. */ public static String load(String fileOrURL) throws IOException { try { URL url = new URL(fileOrURL); return new String(loadURL(url)); } catch (Exception e) { return loadFile(fileOrURL); } } /** * Create a Set from a comma-separated string. */ public static Set makeSetFromStringList(String s) { Set set = new HashSet(); String[] sa = Util.splitwords(s, ",", '"'); for(int i = 0; i < sa.length; i++) { set.add(sa[i]); } return set; } public static String getRelativePath(File fromFile, File toFile) { File fromDir = fromFile.isDirectory() ? fromFile : fromFile.getParentFile(); File toDir = toFile.isDirectory() ? toFile : toFile.getParentFile(); File dir = fromDir; String relPath = ""; while(dir != null && !dir.equals(toDir)) { relPath += "../"; dir = dir.getParentFile(); } if(dir == null) { throw new RuntimeException(toFile + " is not in parent of " + fromFile); } return relPath + toFile.toString(); } // String manipulation functions below by Erik Wistrand /** * Replace all occurences of a substring with another string. * *

* If no replacements are needed, the methods returns the original string. *

* * @param s Source string which will be scanned and modified. * If null, return null * @param v1 String to be replaced with v2. * If null, return original string. * @param v2 String replacing v1. * If null, return original string. * @return Modified string. */ public static String replace(final String s, final String v1, final String v2) { if(s == null || v1 == null || v2 == null || v1.length() == 0 || v1.equals(v2)) { return s; } int ix = 0; int v1Len = v1.length(); int n = 0; while(-1 != (ix = s.indexOf(v1, ix))) { n++; ix += v1Len; } if(n == 0) { return s; } int start = 0; int v2Len = v2.length(); char[] r = new char[s.length() + n * (v2Len - v1Len)]; int rPos = 0; while(-1 != (ix = s.indexOf(v1, start))) { while(start < ix) r[rPos++] = s.charAt(start++); for(int j = 0; j < v2Len; j++) { r[rPos++] = v2.charAt(j); } start += v1Len; } ix = s.length(); while(start < ix) r[rPos++] = s.charAt(start++); return new String(r); } /** * Split a string into words separated by whitespace * SPACE | TAB | NEWLINE | CR * Citation chars '"' may be used to group words * with embedded whitespace. *

*/ public static String [] splitwords(String s) { return splitwords(s, " \t\n\r", '"'); } /** * Split a string into words separated by whitespace. * Citation chars '"' may be used to group words with embedded * whitespace. * * @param s String to split. * @param whiteSpace whitespace to use for splitting. Any of the * characters in the whiteSpace string are considered * whitespace between words and will be removed * from the result. * @param citchar citation char used for enclosing words containing * whitespace */ public static String [] splitwords(String s, String whiteSpace, char citchar) { boolean bCit = false; // true when inside citation chars. Vector v = new Vector(); // (String) individual words after splitting StringBuffer buf = null; int i = 0; while(i < s.length()) { char c = s.charAt(i); if(bCit || whiteSpace.indexOf(c) == -1) { // Build up word until we breaks on // either a citation char or whitespace if(c == citchar) { bCit = !bCit; } else { if(buf == null) { buf = new StringBuffer(); } buf.append(c); } i++; } else { // found whitespace or end of citation, append word if we have one if(buf != null) { v.addElement(buf.toString()); buf = null; } // and skip whitespace so we start clean on a word or citation char while((i < s.length()) && (-1 != whiteSpace.indexOf(s.charAt(i)))) { i++; } } } // Add possible remaining word if(buf != null) { v.addElement(buf.toString()); } // Copy back into an array String [] r = new String[v.size()]; v.copyInto(r); return r; } static void writeStringToFile(File outFile, String s) throws IOException { FileWriter writer = null; try { outFile.getParentFile().mkdirs(); writer = new FileWriter(outFile); writer.write(s, 0, s.length()); // System.out.println("wrote " + outFile); } finally { try { writer.close(); } catch (Exception ignored) { } } } /** * Parse strings of format: * * ENTRY (, ENTRY)* * ENTRY = key (; key)* (; PARAM)* * PARAM = attribute '=' value * PARAM = directive ':=' value * * @param a Attribute being parsed * @param s String to parse * @param single If true, only allow one key per ENTRY * @param unique Only allow unique parameters for each ENTRY. * @param single_entry If true, only allow one ENTRY is allowed. * @return Iterator(Map(param -> value)) or null if input string is null. * @exception IllegalArgumentException If syntax error in input string. */ public static Iterator parseEntries(String a, String s, boolean single, boolean unique, boolean single_entry) { ArrayList result = new ArrayList(); if (s != null) { AttributeTokenizer at = new AttributeTokenizer(s); do { ArrayList keys = new ArrayList(); HashMap params = new HashMap(); Set directives = new TreeSet(); params.put("$directives", directives); // $ is not allowed in // param names... String key = at.getKey(); if (key == null) { throw new IllegalArgumentException ("Definition, " + a + ", expected key at: " + at.getRest() +". Key values are terminated by a ';' or a ',' and may not " +"contain ':', '='."); } if (!single) { keys.add(key); while ((key = at.getKey()) != null) { keys.add(key); } } String param; while ((param = at.getParam()) != null) { List old = (List)params.get(param); boolean is_directive = at.isDirective(); if (old != null && unique) { throw new IllegalArgumentException("Definition, " + a + ", duplicate " + (is_directive ? "directive" : "attribute") + ": " + param); } String value = at.getValue(); if (value == null) { throw new IllegalArgumentException("Definition, " + a + ", expected value at: " + at.getRest()); } if (is_directive) { // NYI Handle directives and check them // This method has become very ugly, please rewrite. directives.add(param); } if (unique) { params.put(param, value); } else { if (old == null) { old = new ArrayList(); params.put(param, old); } old.add(value); } } if (at.getEntryEnd()) { if (single) { params.put("$key", key); } else { params.put("$keys", keys); } result.add(params); } else { throw new IllegalArgumentException("Definition, " + a + ", expected end of entry at: " + at.getRest()); } if (single_entry && !at.getEnd()) { throw new IllegalArgumentException("Definition, " + a + ", expected end of single entry at: " + at.getRest()); } } while (!at.getEnd()); } return result.iterator(); } } /** * Class for tokenize an attribute string. */ class AttributeTokenizer { String s; int length; int pos = 0; AttributeTokenizer(String input) { s = input; length = s.length(); } String getWord() { skipWhite(); boolean backslash = false; boolean quote = false; StringBuffer val = new StringBuffer(); int end = 0; loop: for (; pos < length; pos++) { if (backslash) { backslash = false; val.append(s.charAt(pos)); } else { char c = s.charAt(pos); switch (c) { case '"': quote = !quote; end = val.length(); break; case '\\': backslash = true; break; case ',': case ':': case ';': case '=': if (!quote) { break loop; } // Fall through default: val.append(c); if (!Character.isWhitespace(c)) { end = val.length(); } break; } } } if (quote || backslash || end == 0) { return null; } char [] res = new char [end]; val.getChars(0, end, res, 0); return new String(res); } String getKey() { if (pos >= length) { return null; } int save = pos; if (s.charAt(pos) == ';') { pos++; } String res = getWord(); if (res != null) { if (pos == length) { return res; } char c = s.charAt(pos); if (c == ';' || c == ',') { return res; } } pos = save; return null; } String getParam() { if (pos == length || s.charAt(pos) != ';') { return null; } int save = pos++; String res = getWord(); if (res != null) { if (pos < length && s.charAt(pos) == '=') { return res; } if (pos + 1 < length && s.charAt(pos) == ':' && s.charAt(pos+1) == '=') { return res; } } pos = save; return null; } boolean isDirective() { if (pos + 1 < length && s.charAt(pos) == ':') { pos++; return true; } else { return false; } } String getValue() { if (s.charAt(pos) != '=') { return null; } int save = pos++; skipWhite(); String val = getWord(); if (val == null) { pos = save; return null; } return val; } boolean getEntryEnd() { int save = pos; skipWhite(); if (pos == length) { return true; } else if (s.charAt(pos) == ',') { pos++; return true; } else { pos = save; return false; } } boolean getEnd() { int save = pos; skipWhite(); if (pos == length) { return true; } else { pos = save; return false; } } String getRest() { String res = s.substring(pos).trim(); return res.length() == 0 ? "" : res; } private void skipWhite() { for (; pos < length; pos++) { if (!Character.isWhitespace(s.charAt(pos))) { break; } } } } ././@LongLink0000000000000000000000000000014700000000000011567 Lustar rootrootknopflerfish-osgi-2.3.3/knopflerfish.org/ant/src/org/knopflerfish/ant/taskdefs/bundle/OSGiPackage.javaknopflerfish-osgi-2.3.3/knopflerfish.org/ant/src/org/knopflerfish/ant/taskdefs/bundle/OSGiPackage.ja0000644000175000017500000000425611252437456033470 0ustar twernertwerner/* * Copyright (c) 2005, KNOPFLERFISH project * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * - Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * - 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. * * - Neither the name of the KNOPFLERFISH project nor the names of its * contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS 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 * COPYRIGHT OWNER OR 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. */ package org.knopflerfish.ant.taskdefs.bundle; /** * @author Kaspar Weilenmann <kaspar@weilenmann.se> */ public class OSGiPackage { // private fields private String name = null; private String version = null; private String prefix = null; // public methods public String getName() { return name; } public void setName(String name) { this.name = name; } public String getVersion() { return version; } public void setVersion(String version) { this.version = version; } public String getPrefix() { return prefix; } public void setPrefix(String prefix) { this.prefix = prefix; } } // OSGiPackage ././@LongLink0000000000000000000000000000015200000000000011563 Lustar rootrootknopflerfish-osgi-2.3.3/knopflerfish.org/ant/src/org/knopflerfish/ant/taskdefs/bundle/BundleInfoTask.javaknopflerfish-osgi-2.3.3/knopflerfish.org/ant/src/org/knopflerfish/ant/taskdefs/bundle/BundleInfoTask0000644000175000017500000014300611252437456033667 0ustar twernertwerner/* * Copyright (c) 2003-2009, KNOPFLERFISH project * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * - Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * - 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. * * - Neither the name of the KNOPFLERFISH project nor the names of its * contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS 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 * COPYRIGHT OWNER OR 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. */ package org.knopflerfish.ant.taskdefs.bundle; import java.io.BufferedReader; import java.io.File; import java.io.FileReader; import java.io.InputStream; import java.util.Arrays; import java.util.Enumeration; import java.util.HashMap; import java.util.Iterator; import java.util.Map; import java.util.Set; import java.util.TreeSet; import java.util.Vector; import java.util.jar.JarFile; import java.util.zip.ZipEntry; import org.apache.bcel.classfile.ClassParser; import org.apache.bcel.classfile.Code; import org.apache.bcel.classfile.ConstantClass; import org.apache.bcel.classfile.ConstantPool; import org.apache.bcel.classfile.DescendingVisitor; import org.apache.bcel.classfile.EmptyVisitor; import org.apache.bcel.classfile.Field; import org.apache.bcel.classfile.JavaClass; import org.apache.bcel.classfile.LocalVariable; import org.apache.bcel.classfile.Method; import org.apache.bcel.classfile.Utility; import org.apache.bcel.generic.BasicType; import org.apache.bcel.generic.ConstantPoolGen; import org.apache.bcel.generic.InvokeInstruction; import org.apache.bcel.generic.InstructionHandle; import org.apache.bcel.generic.InstructionList; import org.apache.bcel.generic.Instruction; import org.apache.bcel.generic.Type; import org.apache.tools.ant.BuildException; import org.apache.tools.ant.DirectoryScanner; import org.apache.tools.ant.Project; import org.apache.tools.ant.Task; import org.apache.tools.ant.types.FileSet; import org.apache.tools.ant.util.FileUtils; import org.apache.tools.ant.util.StringUtils; import org.osgi.framework.Version; /** * Task that analyzes a set of java sources or class files, and lists all * imported and defined packages. Also tries to find any class implementing * org.osgi.framework.BundleActivator. * *
    *
  • Class files *

    * Java class files are analyzed using the BCEL lib available from * http://jakarta.apache.org/bcel. *
    * Note: Scanning only applies * to the listed files - a complete closure of all referenced classes is * not done. *

    * *
  • Source code *

    * Java source code is analyzed using very simple line-based scanning of * files.
    * Note: Source code analysis does not attempt to find any * BundleActivator *

    * *
  • Jar files *

    * Jar file analysis is not yet implemented *

    * *
* *

Parameters

* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
AttributeDescriptionRequired
importsName of property that will receive a comma-separated list * of all used packages. *

* If set to empty string, no property will be set. *

*

* Note: Some default packages are always added. These * defaults can be set using the defaultimports parameter. *

*
No.
Default value is ""
exportsName of property that will receive a comma-separated * list of all defined packages. *

* If set to empty string, no property will be set. *

*
No.
Default value is ""
activator * Name of property that will receive name of class which implements * org.osgi.framework.BundleActivator *

* If set to empty string, no property will be set. *

*

* If set to non-empty, and multiple activators are found, or * an activator not equal to any previous content in the named property * is found - a warning will be logged. *

*
No.
Default value is ""
stdimports * * Comma-separated list of package name prefixes for referenced * packages that shall not be included in the Import-Package * manifest attribute. * *

Example of packages to list in this attribute are *

    *
  • non-standard packages obtained via boot-delegation, *
  • packages exported by a required bundle, *
  • packages referenced to by code in nested jar-files that * are never used. *
* * The default value, "java.", is added to any given list * since packages starting with "java.*" shall never be * imported. They are allways made available to the bundle by * delegation to the parent classloader. * *
* No.
* Default value is "java." *
defaultimports * Comma-separated list of packages that will be unconditionally * added to the derived set of packages that the bundle needs to * import. * * No.
* Default value is "" *
extraimports * Comma-separated list of package names that must be present * in the import list even though they are not explicitly * referenced from the bundles code. E.g., packages from which * all classes are loaded using reflection. * * No.
* Default value is "" *
importsOnly * If set to true then do not update Export-Package * manifest header. * No.
Default value is "false".
implicitImports * Flag for adding all exported packages to the import list. *

* If set to "true", the task will add all packages mentioned in * the property named by exports to the list of * imported packages in the property named by imports. * This emulates the implicit import behaviour present in OSG R1-3. *

*
* No.
* Default value is "true" *
serviceComponent * The value of the Service-Component manifest header. *

* If set to non-empty, leave the value of the activator * property untouched and do not complain if there are no class * that implements BundleActivator in the bundle. *

*
No.
Default value is ""
fragmentHost * The value of the Fragment-Host manifest header. *

* If set to non-empty (i.e., this is a fragment bundle), leave * the value of the activator property untouched and do not * complain if there are no class that implements * BundleActivator in the bundle. *

*
No.
Default value is ""
manifestVersion * The value of the Bundle-ManifestVersion manifest header. *

* If set to "2" and the uses attribute is also * true then a "uses" directive is computed and added * to each package in the Export-Package header generated by * this task. *

*
No.
Default value is "1" (pre OSGi R4 bundle).
uses * * If set to true then add / update uses * directive in the value of the Export-Package manifest header. *

* Note that uses-directives are not added for pre OSGi * R4 bundle. That is for bundle with manifestVersion * less than "2". *

*
No.
Default value is "true".
checkMinimumEE * Flag for testing for the Minum Execution Environment *

* If set to "true", the task will check if all used classes * is in the set of the Minimum Execution Environment. *

*
* No.
* Default value is "false" *
checkSMFEE * Flag for testing for the SMF Execution Environment *

* If set to "true", the task will check if all used classes * is in the set of the SMF profile Execution Environment. *

*
* No.
* Default value is "false" *
checkFoundationEE * Flag for testing for the Foundation Execution Environment *

* If set to "true", the task will check if all used classes * is in the set of the OSGi Foundation Execution Environment. *

*
* No.
* Default value is "false" *
failOnExports * If an error is detected in the given export package header * and this attibute is set to true then a build * failure is trigger. * * No.
* Default value is "true" *
failOnImports * If an error is detected in the given import package header * and this attibute is set to true then a build * failure is trigger. * * No.
* Default value is "true" *
failOnActivator * If an error is detected in the given bundle activator header * and this attibute is set to true then a build * failure is trigger. * * No.
* Default value is "true" *
* *

Parameters specified as nested elements

*

fileset

* * (required)
*

* All files must be specified as a fileset. Unsupported file types * are ignored. *

* *

Examples

* *

Check all imports and activator in implementation classes

* *

* This example assumes all implemention classes are in the package * test.impl.* *

* *
 *  <bundleinfo  activator = "bmfa.Bundle-Activator"
 *               imports   = "impl.import.package">
 *   <fileset dir="classes" includes="test/impl/*"/>
 *  </bundleinfo>
 *  <echo message="imports   = ${impl.import.package}"/>
 *  <echo message="activator = ${bmfa.Bundle-Activator}"/>
 * 
* * *

Check all imports and exports in API classes

* *

* This example assumes all API classes are in the package * test.* *

* *
 *  <bundleinfo  exports  = "api.export.package"
 *               imports  = "api.import.package">
 *   <fileset dir="classes" includes="test/*"/>
 *  </bundleinfo>
 *  <echo message="imports  = ${api.import.package}"/>
 *  <echo message="exports  = ${api.export.package}"/>
 * 
* */ public class BundleInfoTask extends Task { private Vector filesets = new Vector(); private FileUtils fileUtils; private String importsProperty = ""; private String exportsProperty = ""; private String activatorProperty = ""; private String mainProperty = ""; private String serviceComponent = ""; private String fragmentHost = ""; private Version manifestVersion = new Version("1"); private boolean bUses = true; private Set stdImports = new TreeSet(); private boolean bDebug = false; private boolean bPrintClasses = false; private boolean bCheckFoundationEE = false; private boolean bCheckMinimumEE = false; private boolean bCheckSMFEE = false; private boolean bImplicitImports = true; private boolean bSetActivator = true; private boolean failOnExports = true; private boolean failOnImports = true; private boolean failOnActivator = true; private boolean bImportsOnly = false; /** The set of packages that are provided by the inlcuded classes. */ private Set providedSet = new TreeSet(); /** The set of packages that are referenced by the inlcuded classes. */ private Set referencedSet = new TreeSet(); /** The sub set of the included classes that implements BundleActivator. */ private Set activatorSet = new TreeSet(); /** * The set of packages referenced by the included classes but not * provided by them. */ private Set importSet = new TreeSet(); /** * A set of packages used by the included classes but not * referenced from them. */ private Set extraImportSet = new TreeSet(); /** * The set of classes that are refrenced from the included classes. */ private Set classSet = new TreeSet(); /** * The set of included classes. */ private Set ownClasses = new TreeSet(); /** * A mapping from package name of included classes to a set of * package names that the classes in the key package references. */ private Map packageUsingMap = new HashMap(); public BundleInfoTask() { fileUtils = FileUtils.newFileUtils(); setDefaultImports(""); setStdImports("java."); } /** * Set property receiving list of imported packages. */ public void setImports(String s) { this.importsProperty = s; } public void setPrintClasses(String s) { this.bPrintClasses = "true".equals(s); } public void setCheckFoundationEE(String s) { this.bCheckFoundationEE = "true".equals(s); } public void setCheckMinimumEE(String s) { this.bCheckMinimumEE = "true".equals(s); } public void setCheckSMFEE(String s) { this.bCheckSMFEE = "true".equals(s); } public void setFailOnExports(boolean b) { this.failOnExports = b; } public void setFailOnImports(boolean b) { this.failOnImports = b; } public void setFailOnActivator(boolean b) { this.failOnActivator = b; } public void setImplicitImports(String s) { this.bImplicitImports = "true".equals(s); } /** * Set default import set. * * @param packageList Comma-separated list of package names. */ public void setDefaultImports(String packageList) { importSet.clear(); if (null!=packageList) { packageList = packageList.trim(); if (00) { Vector v = StringUtils.split(packageList,','); for (Iterator it = v.iterator(); it.hasNext(); ) { extraImportSet.add(((String)it.next()).trim()); } } } } /** * Set property receiving list of exported packages. */ public void setExports(String propName) { this.exportsProperty = propName; } /** * Set property receiving any BundleActivator class. */ public void setActivator(String propName) { this.activatorProperty = propName; } /** * Set name value of the Service-Component manifest header. */ public void setServiceComponent(String serviceComponent) { this.serviceComponent = serviceComponent; if (!BundleManifestTask.isPropertyValueEmpty(this.serviceComponent)) { bSetActivator = false; } } /** * Set value of the Fragment-Host manifest header. */ public void setFragmentHost(String fragmentHost) { this.fragmentHost = fragmentHost; if (!BundleManifestTask.isPropertyValueEmpty(this.fragmentHost)) { bSetActivator = false; } } /** * Set value of the Bundle-ManifestVersion manifest header. */ public void setManifestVersion(String manifestVersion) { this.manifestVersion = new Version(manifestVersion); } /** * Shall uses directives be added to the Export-Package header or not. */ public void setUses(boolean uses) { this.bUses = uses; } /** * Set property receiving any Main class. *

* Not yet implemented. *

*/ public void setMain(String propName) { this.mainProperty = propName; } /** * Set set of packages always imported. * * @param packageList Comma-separated list of package names. */ public void setStdImports(String packageList) { stdImports.clear(); stdImports.add("java."); Vector v = StringUtils.split(packageList,','); for (Iterator it = v.iterator(); it.hasNext(); ) { stdImports.add(((String)it.next()).trim()); } } public void addFileset(FileSet set) { filesets.addElement(set); } /** * Shall uses directives be added to the Export-Package header or not. */ public void setImportsOnly(boolean importsOnly) { this.bImportsOnly = importsOnly; } // Implements Task // // Scan all files in fileset and delegate to analyze() // then write back values to properties. public void execute() throws BuildException { if (filesets.size() == 0) { throw new BuildException("No fileset specified", getLocation()); } for (int i = 0; i < filesets.size(); i++) { FileSet fs = (FileSet) filesets.elementAt(i); DirectoryScanner ds = fs.getDirectoryScanner(project); File fromDir = fs.getDir(project); String[] srcFiles = ds.getIncludedFiles(); String[] srcDirs = ds.getIncludedDirectories(); for (int j = 0; j < srcFiles.length ; j++) { analyze(new File(fromDir, srcFiles[j])); } for (int j = 0; j < srcDirs.length ; j++) { analyze(new File(fromDir, srcDirs[j])); } }// Scan done // created importSet from referencedSet for (Iterator refIt=referencedSet.iterator(); refIt.hasNext(); ) { final String refPkg = (String) refIt.next(); // only packages defined outside this set of files if(!providedSet.contains(refPkg)) { // ...and only add non-std packages if(!isStdImport(refPkg)) { log(" " +refPkg +" added ; un-provided non-standard package.", Project.MSG_DEBUG); importSet.add(refPkg); } else { log(" " +refPkg +" skiped; standard import.", Project.MSG_DEBUG); } } else { log(" " +refPkg +" skiped; package provided.", Project.MSG_DEBUG); } } final TreeSet unprovidedExtraImportSet = new TreeSet(extraImportSet); unprovidedExtraImportSet.removeAll(providedSet); importSet.addAll(unprovidedExtraImportSet); // The sub-set of the provided packages that export final Set providedExportSet = getProvidedExportSet(); // The set of packages that will be mentioned in the // Export-Package or the Import-Package header. final Set allImpExpPkgs = new TreeSet(providedExportSet); allImpExpPkgs.addAll(importSet); // Clean up the usingPackageMap; remove all stdimports, any self // reference, ensure that it only contains imported or exported packages. for (Iterator usingMapEntryIt=packageUsingMap.entrySet().iterator(); usingMapEntryIt.hasNext(); ) { final Map.Entry entry = (Map.Entry) usingMapEntryIt.next(); final Set usedSet = (Set) entry.getValue(); usedSet.remove((String) entry.getKey()); for (Iterator usedIt=usedSet.iterator(); usedIt.hasNext(); ) { final String usedPkg = (String) usedIt.next(); if (isStdImport(usedPkg)) usedIt.remove(); } usedSet.retainAll(allImpExpPkgs); } // Data collection done - write back properties final Project proj = getProject(); if(!"".equals(exportsProperty)) { String exportsVal = proj.getProperty(exportsProperty); if (BundleManifestTask.isPropertyValueEmpty(exportsVal)) { if (!bImportsOnly) { if (0==providedSet.size()) { proj.setProperty(exportsProperty, BundleManifestTask.BUNDLE_EMPTY_STRING); log("No packages exported, leaving \"" +exportsProperty +"\" empty.", Project.MSG_VERBOSE); } else { exportsVal = buildExportPackagesValue(); log("Setting \"" +exportsProperty +"\" to \""+exportsVal +"\"", Project.MSG_VERBOSE); proj.setProperty(exportsProperty, exportsVal); } } } else { // Export-Package given; check that they are provided. final String newExportsVal = validateExportPackagesValue(exportsVal); log("Updating \"" +exportsProperty +"\" to \""+newExportsVal +"\"", Project.MSG_VERBOSE); proj.setProperty(exportsProperty, newExportsVal); } } if(!"".equals(importsProperty)) { String importsVal = proj.getProperty(importsProperty); if (BundleManifestTask.isPropertyValueEmpty(importsVal)) { // No Import-Package given; use derived value. log("importSet.size()="+importSet.size(),Project.MSG_VERBOSE); if (0==importSet.size()) { log("No packages to import, leaving \"" +importsProperty +"\" empty.", Project.MSG_VERBOSE); proj.setProperty(importsProperty, BundleManifestTask.BUNDLE_EMPTY_STRING); } else { importsVal = toString(importSet, ","); log("Setting \"" +importsProperty +"\" to \""+importsVal +"\"", Project.MSG_VERBOSE); proj.setProperty(importsProperty, importsVal); } } else { // Import-Package given; check that all derived packages are // present and that there are no duplicated packages. final TreeSet givenImportSet = new TreeSet(); final Iterator impIt = Util.parseEntries("import.package",importsVal, true, true, false ); while (impIt.hasNext()) { final Map impEntry = (Map) impIt.next(); final String pkgName = (String) impEntry.get("$key"); if (!givenImportSet.add( pkgName )) { final String msg = "The package '" +pkgName +"' is mentioned twice in the given 'Import-Package' manifest " +"header: '" +importsVal +"'."; log(msg, Project.MSG_ERR); throw new BuildException(msg, getLocation()); } } givenImportSet.removeAll(providedSet); final TreeSet missingImports = new TreeSet(importSet); missingImports.removeAll(givenImportSet); if (0 0) { System.out.println("Missing " + missing.size() + " classes from "+ profileName +" profile"); } else { System.out.println("Passes " +profileName +" EE"); } for(Iterator it = missing.iterator(); it.hasNext();) { final String s = (String)it.next(); System.out.println("Not in " +profileName +": " + s); } } private boolean doUses() { return bUses && manifestVersion.compareTo(new Version("1")) > 0; } /** * The sub-set of the provided packages that are exported. */ private Set getProvidedExportSet() { final Set res = new TreeSet(); if(!"".equals(exportsProperty)) { final String exportsVal = getProject().getProperty(exportsProperty); if (!BundleManifestTask.isPropertyValueEmpty(exportsVal)) { final Iterator expIt = Util.parseEntries("export.package", exportsVal, true, true, false ); while (expIt.hasNext()) { final Map expEntry = (Map) expIt.next(); final String pkgName = (String) expEntry.get("$key"); if (providedSet.contains(pkgName)) { res.add(pkgName); } } } } else { res.addAll(providedSet); } return res; } /** * Return the value of the ExportPackage based on the analyzis. */ protected String buildExportPackagesValue() { final String sep = ","; final StringBuffer sb = new StringBuffer(); final boolean addUses = doUses(); for(Iterator it = providedSet.iterator(); it.hasNext(); ) { final String name = (String)it.next(); sb.append(name); if (addUses) { final Set usesPkgs = (Set) packageUsingMap.get(name); if (0analyzeClass, analyzeJava etc */ protected void analyze(File file) throws BuildException { if(file.getName().endsWith(".class")) { analyzeClass(file); } else if(file.getName().endsWith(".jar")) { analyzeJar(file); } else if(file.getName().endsWith(".java")) { analyzeJava(file); } else { // Just ignore all other files } } protected void addProvidedPackage(String name) { if(name == null || "".equals(name)) { return; } log(" Provides package: " + name, Project.MSG_DEBUG); providedSet.add(name); } protected void addActivator(String s) { activatorSet.add(s); } /** * Add a type's package name to the list of referenced packages. * * @param usingPackage The package that the class referencing * t belongs to. * @param t Type of an object. */ protected void addReferencedType(String usingPackage, Type t) { if(t instanceof BasicType) { log(" " +t +" skiped; basic", Project.MSG_DEBUG); } else { addReferencedClass(usingPackage, t.toString()); } } /** * Add package names of all types in ts to the list of * referenced packages. * * @param usingPackage The package that the class referencing * ts belongs to. * @param ts Array with Type objects. */ protected void addReferencedType(String usingPackage, Type[] ts) { for (int i = ts.length-1; i>-1; i-- ) { addReferencedType(usingPackage, ts[i]); } } /** * Add data for a referenced class. * * @param usingPackage * The package that the class referencing * className belongs to. * @param className Name of the referenced class. */ protected void addReferencedClass(String usingPackage, String className) { if(className == null) { return; } final String packageName = packageName(className); if("".equals(packageName)) { log(" " +className +" skipped; no package name", Project.MSG_DEBUG); return; } classSet.add(className); referencedSet.add(packageName); if (null!=usingPackage) { Set usingSet = (Set) packageUsingMap.get(usingPackage); if (null==usingSet) { usingSet = new TreeSet(); packageUsingMap.put(usingPackage, usingSet); } usingSet.add(packageName); } } protected boolean isImported(String className) { for(Iterator it = importSet.iterator(); it.hasNext(); ) { final String pkg = (String)it.next(); if(className.startsWith(pkg)) { final String rest = className.substring(pkg.length() + 1); if(-1 == rest.indexOf(".")) { return true; } } } return false; } /** * Check if package is included in the prefix list of packages that * does not need to be in the Import-Package list. * * @return true if name is prefixed with any of the elements in * stdImports set, false otherwise. */ protected boolean isStdImport(String name) { for(Iterator it = stdImports.iterator(); it.hasNext();) { final String s = (String)it.next(); if(name.startsWith(s)) { return true; } } return false; } protected void analyzeJar(File file) throws BuildException { log("Analyze jar file " + file.getAbsolutePath(), Project.MSG_VERBOSE); try { final JarFile jarFile = new JarFile(file); for (Enumeration entries = jarFile.entries(); entries.hasMoreElements(); ) { final ZipEntry ze = (ZipEntry) entries.nextElement(); final String fileName = ze.getName(); if (fileName.endsWith(".class")) { log("Analyze jar class file " + fileName, Project.MSG_VERBOSE); final InputStream is = jarFile.getInputStream(ze); analyzeClass( new ClassParser(is, fileName ) ); } } } catch (Exception e) { e.printStackTrace(); throw new BuildException("Failed to analyze class-file " + file + ", exception=" + e, getLocation()); } } protected void analyzeClass(File file) throws BuildException { log("Analyze class file " + file.getAbsolutePath(), Project.MSG_VERBOSE); try { analyzeClass( new ClassParser(file.getAbsolutePath()) ); } catch (Exception e) { e.printStackTrace(); throw new BuildException("Failed to analyze class-file " + file + ", exception=" + e, getLocation()); } } protected void analyzeClass(ClassParser parser) throws Exception { final JavaClass clazz = parser.parse(); final ConstantPool constant_pool = clazz.getConstantPool(); final ConstantPoolGen constant_poolGen = new ConstantPoolGen(constant_pool); final String clazzPackage = clazz.getPackageName(); ownClasses.add(clazz.getClassName()); addProvidedPackage(clazzPackage); // Scan all implemented interfaces to find // candidates for the activator AND to find // all referenced packages. final String[] interfaces = clazz.getInterfaceNames(); for(int i = 0; i < interfaces.length; i++) { if("org.osgi.framework.BundleActivator".equals(interfaces[i])) { addActivator(clazz.getClassName()); break; } } /** * Use a descending visitor to find all classes that the given * clazz refers to and add them to the set of imported classes. */ DescendingVisitor v = new DescendingVisitor(clazz, new EmptyVisitor() { /** * Keep track of the signatures visited to avoid processing * them more than once. The same signature may apply to * many methods or fields. */ boolean[] visitedSignatures = new boolean[constant_pool.getLength()]; /** * Add the class that the given ConstantClass object * represents to the set of imported classes. * * @param obj The ConstantClass object */ public void visitConstantClass( ConstantClass obj ) { log(" visit constant class " +obj, Project.MSG_DEBUG); String referencedClass = obj.getBytes(constant_pool); referencedClass = referencedClass.charAt(0) == '[' ? Utility.signatureToString(referencedClass, false) : Utility.compactClassName(referencedClass, false); addReferencedClass(clazzPackage, referencedClass); } /** * Add the class used as types for the given field. * This is necessary since if no method is applied to an * object valued field there will be no ConstantClass object * in the ConstantPool for the class that is the type of the * field. * * @param obj A Field object */ public void visitField( Field obj ) { if (!visitedSignatures[obj.getSignatureIndex()]) { log(" visit field " +obj, Project.MSG_DEBUG); visitedSignatures[obj.getSignatureIndex()] = true; final String signature = obj.getSignature(); final Type type = Type.getType(signature); addReferencedType(clazzPackage, type); } } /** * Add all classes used as types for a local variable in the * class we are analyzing. This is necessary since if no * method is applied to an object valued local variable * there will be no ConstantClass object in the ConstantPool * for the class that is the type of the local variable. * * @param obj A LocalVariable object */ public void visitLocalVariable( LocalVariable obj ) { if (!visitedSignatures[obj.getSignatureIndex()]) { log(" visit local variable " +obj, Project.MSG_DEBUG); visitedSignatures[obj.getSignatureIndex()] = true; final String signature = obj.getSignature(); final Type type = Type.getType(signature); addReferencedType(clazzPackage, type); } } /** * Add all classes mentioned in the signature of the given * method. This is necessary since if no method is applied * to a parameter (return type) there will be no * ConstantClass object in the ConstantPool for the class * that is the type of that parameter (return type). * * @param obj A Method object */ public void visitMethod( Method obj ) { if (!visitedSignatures[obj.getSignatureIndex()]) { log(" visit method " +obj, Project.MSG_DEBUG); visitedSignatures[obj.getSignatureIndex()] = true; final String signature = obj.getSignature(); final Type returnType = Type.getReturnType(signature); final Type[] argTypes = Type.getArgumentTypes(signature); addReferencedType(clazzPackage, returnType); addReferencedType(clazzPackage, argTypes); } } /** * Look for packages for types in signatures of methods * invoked from code in the class. * * This typically finds packages from arguments in calls to a * superclass method in the current class where no local * variable (or field) was used for intermediate storage of * the parameter. * * @param obj The Code object to visit */ public void visitCode( Code obj ) { final InstructionList il = new InstructionList(obj.getCode()); for (InstructionHandle ih=il.getStart(); ih!=null; ih=ih.getNext()) { final Instruction inst = ih.getInstruction(); if (inst instanceof InvokeInstruction) { final InvokeInstruction ii = (InvokeInstruction) inst; log(" " +ii.toString(constant_pool), Project.MSG_DEBUG); // These signatures have no index in the constant pool // thus no check/update in visitedSignatures[]. final String signature = ii.getSignature(constant_poolGen); final Type returnType = Type.getReturnType(signature); final Type[] argTypes = Type.getArgumentTypes(signature); addReferencedType(clazzPackage, returnType); addReferencedType(clazzPackage, argTypes); } } } } ); // Run the scanner on the loaded class v.visit(); } /** * Analyze java source file by reading line by line and looking * for keywords such as "import", "package". * *

* Note: This code does not attempt to find any class implementing * BundleActivator */ protected void analyzeJava(File file) throws BuildException { if(bDebug) { System.out.println("Analyze java file " + file.getAbsolutePath()); } BufferedReader reader = null; try { String packageName = null; String line; int lineNo = 0; reader = new BufferedReader(new FileReader(file)); while(null != (line = reader.readLine())) { lineNo++; line = line.replace(';', ' ').replace('\t', ' ').trim(); if(line.startsWith("package")) { final Vector v = StringUtils.split(line, ' '); if(v.size() > 1 && "package".equals(v.elementAt(0))) { packageName = (String)v.elementAt(1); addProvidedPackage(packageName); } } if(line.startsWith("import")) { final Vector v = StringUtils.split(line, ' '); if(v.size() > 1 && "import".equals(v.elementAt(0))) { final String name = (String)v.elementAt(1); addReferencedClass(packageName, name); } } } } catch (Exception e) { throw new BuildException("Failed to scan " + file + ", err=" + e, getLocation()); } finally { if(reader != null) { try { reader.close(); } catch (Exception ignored) { } } } } /** * Get package name of class string representation. */ static String packageName(String s) { s = s.trim(); int ix = s.lastIndexOf('.'); if(ix != -1) { s = s.substring(0, ix); } else { s = ""; } return s; } /** * Convert Set elements to a string. * * @param separator String to use as sperator between elements. */ static protected String toString(Set set, String separator) { final StringBuffer sb = new StringBuffer(); for(Iterator it = set.iterator(); it.hasNext(); ) { final String name = (String)it.next(); sb.append(name); if(it.hasNext()) { sb.append(separator); } } return sb.toString(); } } ././@LongLink0000000000000000000000000000015000000000000011561 Lustar rootrootknopflerfish-osgi-2.3.3/knopflerfish.org/ant/src/org/knopflerfish/ant/taskdefs/bundle/MakeHTMLTask.javaknopflerfish-osgi-2.3.3/knopflerfish.org/ant/src/org/knopflerfish/ant/taskdefs/bundle/MakeHTMLTask.j0000644000175000017500000003676511252437456033451 0ustar twernertwerner/* * Copyright (c) 2003-2009, KNOPFLERFISH project * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following * conditions are met: * * - Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * - 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. * * - Neither the name of the KNOPFLERFISH project nor the names of its * contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS 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 * COPYRIGHT OWNER OR 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. */ package org.knopflerfish.ant.taskdefs.bundle; import java.io.File; import java.io.IOException; import java.text.SimpleDateFormat; import java.util.ArrayList; import java.util.Date; import java.util.HashMap; import java.util.Iterator; import java.util.Locale; import java.util.Map.Entry; import org.apache.tools.ant.BuildException; import org.apache.tools.ant.DirectoryScanner; import org.apache.tools.ant.Project; import org.apache.tools.ant.Task; import org.apache.tools.ant.types.FileSet; import org.apache.tools.ant.util.FileUtils; /** *

* This task is used when building distributions of Knopflerfish. * If you don't intend to create a new distribution type of * Knopflerfish then you're in the wrong place. *

* *

* Task that creates web sites given a template and a source file. * Currently used to create the htdocs directory in the KF dist. * It does this by simply replacing certain text strings with * others. For more information on which text strings this is * please check the source code. *

* *

* Here is a outline of how to use the task and a description * of different parameters and used system properties. *

* *

* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
AttributeDescriptionRequired
* outdir * * What dir to put the actual the generated file * * Yes *
* tofile * * The releative path to where the generated file should be * copied. That is the actual location of the generated file * will be outdir/tofile * * Yes *
* template * * The file which describes what the page should look like * * Yes *
* title * * The page's title * * No, default is "" *
* description * * The page's description * * No, default is "" *
* disable * * Allows you to disable certain links. This attribute is very ad hoc. * It will use the properties htdocs.link.disabled.class * and htdocs.link.enabled.class. The task will then use the * values of these properties to generate the file. * * No *
*

* Note: instead of using the attributes fromfile and * tofile one can use filesets. It will simply run through * and perform the task on all given files. *

* */ public class MakeHTMLTask extends Task { private final static String TIMESTAMP = new SimpleDateFormat("EE MMMM d yyyy, HH:mm:ss", Locale.ENGLISH).format(new Date()); private String lib_suffix = ""; private String api_suffix = "_api"; private String impl_suffix = ""; private String all_suffix = "_all"; private String projectName = ""; private boolean do_manpage = false; /** * The source file */ private String fromFile; /** * Target directory, where everything will end up */ private File outdir; /** * The relative path to the target file from output dir */ private File toFile; /** * File's title */ private String title; /** * Description */ private String description; /** * Template file */ private File template; /** * Bundle list */ private String bundleList; private ArrayList filesets = new ArrayList(); private String disable; public void setFromfile(String s) { fromFile = s; } public void setTofile(String s) { toFile = new File(s); } public void setTitle(String title) { this.title = title; } public void setDescription(String description) { this.description = description; } public void setOutdir(String s) { outdir = new File(s); } public void setTemplate(String template) { this.template = new File(template); } public void setBundleList(String bundleList) { this.bundleList = bundleList; } public void setManstyle(String manstyle) { this.do_manpage = true; } public void setDisable(String disabled) { this.disable = disabled; } public void addFileset(FileSet fs) { filesets.add(fs); } public void execute() { Project proj = getProject(); this.projectName = proj.getName(); if (template == null) throw new BuildException("template must be set"); if (title == null) title = ""; if (description == null) description = ""; if (filesets.isEmpty() && fromFile == null && toFile == null) { throw new BuildException("Need to specify tofile and fromfile or give a fileset"); } // Set suffixes impl_suffix = proj.getProperty("impl.suffix"); api_suffix = proj.getProperty("api.suffix"); lib_suffix = proj.getProperty("lib.suffix"); all_suffix = proj.getProperty("all.suffix"); if (filesets.isEmpty()) { // log("Project base is: " + getProject().getBaseDir()); // log("Attempting to transform: " + fromFile); if (!FileUtils.isAbsolutePath(fromFile)) { fromFile = getProject().getBaseDir() + File.separator + fromFile; } transform(fromFile, toFile.toString()); } else { if (fromFile != null) throw new BuildException("Can not specify fromfile when using filesets"); if (toFile != null) throw new BuildException("Can not specify tofile when using filesets"); for (Iterator iter = filesets.iterator(); iter.hasNext(); ) { FileSet fs = (FileSet) iter.next(); DirectoryScanner ds = fs.getDirectoryScanner(getProject()); String[] files = ds.getIncludedFiles(); for (int i = 0; i < files.length; i++) { transform(new File(fs.getDir(getProject()), files[i]).getAbsolutePath(), files[i]); } } } } private void transform(String fromFile, String toFile) { if (fromFile == null) throw new BuildException("fromfile must be set"); if (toFile == null) throw new BuildException("tofile must be set"); try { Project proj = getProject(); File tmp = new File(outdir, toFile).getParentFile(); if (!tmp.exists()) { if (tmp.exists() || !tmp.mkdirs()) { throw new IOException("Could not create " + tmp); } } tmp = new File(toFile); String pathToRoot = "."; while ((tmp = tmp.getParentFile()) != null) { pathToRoot = pathToRoot + "/.."; } String content = Util.loadFile(template.toString()); content = Util.replace(content, "$(LINKS)", links()); content = Util.replace(content, "$(MAIN)", Util.loadFile(fromFile)); content = Util.replace(content, "$(TITLE)", title); content = Util.replace(content, "$(DESC)", description); content = Util.replace(content, "$(TSTAMP)", TIMESTAMP); content = Util.replace(content, "$(USER)", System.getProperty("user.name")); content = Util.replace(content, "$(VERSION)", proj.getProperty("version")); content = Util.replace(content, "$(BASE_VERSION)", proj.getProperty("base_version")); content = Util.replace(content, "$(DISTNAME)", proj.getProperty("distname")); content = Util.replace(content, "$(DISTRIB_NAME)", proj.getProperty("distrib.name")); content = Util.replace(content, "$(RELEASE_NAME)", proj.getProperty("release.name")); content = Util.replace(content, "$(MESSAGE)", proj.getProperty("release")); content = Util.replace(content, "$(BUNDLE_LIST)", bundleList); content = Util.replace(content, "$(ROOT)", pathToRoot); content = Util.replace(content, "$(JAVADOC)", proj.getProperty("JAVADOC")); content = Util.replace(content, "$(CLASS_NAVIGATION)", proj.getProperty("css_navigation_enabled")); content = Util.replace(content, "$(SVN_REPO_URL)", proj.getProperty("svn.repo.url")); content = Util.replace(content, "$(SVN_TAG)",proj.getProperty("svn.tag")); // Used for bundle_doc generation if (do_manpage) { content = Util.replace(content, "$(BUNDLE_NAME)", this.projectName); content = Util.replace(content, "$(BUNDLE_VERSION)", proj.getProperty("bmfa.Bundle-Version")); // Create links to generated jardoc for this bundle StringBuffer sbuf = new StringBuffer(); generateJardocPath(sbuf, "do_build_lib", lib_suffix); generateJardocPath(sbuf, "do_build_api", api_suffix); generateJardocPath(sbuf, "do_build_all", all_suffix); generateJardocPath(sbuf, "do_build_impl", impl_suffix); content = Util.replace(content, "$(BUNDLE_JARDOCS)", sbuf.toString()); String epkgs = proj.getProperty("bmfa.Export-Package"); if ("[bundle.emptystring]".equals(epkgs)) { epkgs = ""; } epkgs = Util.replace(epkgs, ",", "
"); content = Util.replace(content, "$(BUNDLE_EXPORT_PACKAGE)", epkgs); // Replce H1-H3 headers to man page style, if manpage style content = Util.replace(content, "

"); } else if (type.equals("link")) { String name = proj.getProperty(LINK_NAME + i); String url = proj.getProperty(LINK_URL + i); if (name == null) { throw new BuildException("Name not set for htdocs.link.url." + i); } String cssClass = null; if (disable != null && disable.equals(id)) { cssClass = getProject().getProperty(CSS_CLASS_DISABLED); } else { cssClass = getProject().getProperty(CSS_CLASS_ENABLED); } buf.append("" + name + "
\n"); } else { throw new BuildException("Do not recognize type " + type); } } return buf.toString(); } // Returns a bool for s Project prop. If null => false private boolean getBoolProperty(String prop) { if (prop == null) return false; Boolean b = Boolean.valueOf(getProject().getProperty(prop)); return b.booleanValue(); } private void generateJardocPath(StringBuffer sbuf, String prop, String suffix) { if (getBoolProperty(prop)) { sbuf.append(""); sbuf.append(this.projectName); sbuf.append(suffix); sbuf.append("
\n"); } } } knopflerfish-osgi-2.3.3/knopflerfish.org/ant/src/org/knopflerfish/ant/taskdefs/bundle/Bundle.java0000644000175000017500000007400511252437456033152 0ustar twernertwerner/* * Copyright (c) 2005-2009, KNOPFLERFISH project * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * - Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * - 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. * * - Neither the name of the KNOPFLERFISH project nor the names of its * contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS 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 * COPYRIGHT OWNER OR 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. */ package org.knopflerfish.ant.taskdefs.bundle; import java.io.File; import java.io.IOException; import java.util.ArrayList; import java.util.Enumeration; import java.util.HashMap; import java.util.HashSet; import java.util.Iterator; import java.util.List; import java.util.Map; import java.util.Set; import java.util.TreeSet; import java.util.zip.ZipEntry; import java.util.zip.ZipFile; import org.apache.bcel.classfile.ClassParser; import org.apache.bcel.classfile.Code; import org.apache.bcel.classfile.ConstantClass; import org.apache.bcel.classfile.ConstantPool; import org.apache.bcel.classfile.DescendingVisitor; import org.apache.bcel.classfile.EmptyVisitor; import org.apache.bcel.classfile.Field; import org.apache.bcel.classfile.JavaClass; import org.apache.bcel.classfile.LocalVariable; import org.apache.bcel.classfile.Method; import org.apache.bcel.classfile.Utility; import org.apache.bcel.generic.BasicType; import org.apache.bcel.generic.ConstantPoolGen; import org.apache.bcel.generic.InvokeInstruction; import org.apache.bcel.generic.InstructionHandle; import org.apache.bcel.generic.InstructionList; import org.apache.bcel.generic.Instruction; import org.apache.bcel.generic.Type; import org.apache.tools.ant.BuildException; import org.apache.tools.ant.DirectoryScanner; import org.apache.tools.ant.FileScanner; import org.apache.tools.ant.Project; import org.apache.tools.ant.taskdefs.Jar; import org.apache.tools.ant.taskdefs.Manifest; import org.apache.tools.ant.taskdefs.ManifestException; import org.apache.tools.ant.types.FileSet; import org.apache.tools.ant.types.ZipFileSet; //import org.apache.tools.zip.ZipFile; /** *

* An extension of the * Jar task that * builds an OSGi bundle. It can generate the Bundle-Activator, * Bundle-ClassPath and Import-Package manifest headers based on the content * specified in the task. *

* *

* Note: This task depends on the * Apache Jakarta BCEL library, * not included in the Ant distribution. *

* *

Parameters

* * * * * * * * * * * * * * * * * * * * * *
AttributeDescriptionRequired
fileThe bundle file to create.Yes
activator * The bundle activator class name. If set to "none" no Bundle-Activator * manifest header will be generated. If set to "auto" the bundle task * will try to find an activator in the included class files. * No, default is "auto"
packageanalysis * Analyzes the class files of the bundle and the contents of the * exportpackage and importpackage nested elements. *
    *
  • none – no analysis is performed.
  • *
  • warn – a warning will be displayed for each referenced * package not found in the bundle or the importpackage nested * elements.
  • *
  • auto – each referenced package not found in the bundle or * the importpackage nested elements will be added to the * Import-Package manifest header. Packages exported by the bundle will * be added to the Import-Package manifest header with the version as * specified in the exportpackage nested element.
  • *
*
No, default is "warn"
* *

Nested elements

* *

classes

*

* The nested classes element specifies a * ZipFileSet. * The prefix attribute will be added to the Bundle-ClassPath manifest * header. The classes specified by the file set will be included in the class * analysis. *

* *

lib

*

* The nested lib element specifies a * ZipFileSet. * The locations of all files in the file set will be added to the * Bundle-ClassPath manifest header. All files of this file set must be either * zip or jar files. The classes available in the zip or jar files will be * included in the class analysis. *

* *

exportpackage

*

* The nested exportpackage element specifies the name and * specification version of a package to add to the Export-Package manifest * header. If package analysis is not turned off, a warning will be issued if * the specified package cannot be found in the bundle. *

* *

importpackage

*

* The nested importpackage element specifies the name and * specification version of a package to add to the Import-Package manifest * header. *

* *

standardpackage

*

* The nested standardpackage element specifies the name or prefix * of a package that should be excluded from the package analysis. It can * be used to avoid importing packages that are available in the underlying * runtime environment. *

* *

Implicit fileset

*

* The implicit fileset is specified by the baseDir attribute of the * bundle task and the nested include and exclude elements. *

*

* The implicit fileset of the bundle task will be included in the * class analysis and in the Bundle-ClassPath manifest header if needed. *

* *

Examples

*
 * <bundle activator="auto"
 *         packageanalysis="auto"
 *         file="out/${ant.project.name}.jar">
 *
 *   <standardpackage name="javax.imageio"/>
 *
 *   <exportpackage name="se.weilenmann.bundle.test" version="1.0"/>
 *
 *   <manifest>
 *     <attribute name="Bundle-Name" value="testbundle"/>
 *     <attribute name="Bundle-Version" value="1.0"/>
 *     <attribute name="Bundle-Vendor" value="Kaspar Weilenmann"/>
 *   </manifest>
 *
 *   <classes dir="out/classes">
 *     <include name="se/weilenmann/bundle/test/**"/>
 *   </classes>
 *   <classes dir="out/classes" prefix="util">
 *     <include name="se/weilenmann/util/**"/>
 *   </classes>
 *   <classes src="osgi/jars/log/log_api.jar" prefix="log_api">
 *     <include name="**/*.class"/>
 *   </classes>
 *
 *   <lib dir="osgi/jars/cm" includes="cm_api.jar" prefix="osgi"/>
 *   <lib dir="lib/commons" includes="commons-logging.jar" prefix="commons"/>
 *
 * </bundle>
 * 
*

Creates a bundle with the following manifest:

*

 * Manifest-Version: 1.0
 * Ant-Version: Apache Ant 1.6.2
 * Created-By: 1.4.2_02-b03 (Sun Microsystems Inc.)
 * Bundle-Name: testbundle
 * Bundle-Version: 1.0
 * Bundle-Vendor: Kaspar Weilenmann
 * Bundle-Activator: se.weilenmann.bundle.test.Activator
 * Bundle-ClassPath: .,util,log_api,osgi/cm_api.jar,commons/commons-loggi
 * ng.jar
 * Import-Package: se.weilenmann.bundle.test;specification-version=1.0,or
 * g.osgi.framework
 * Export-Package: se.weilenmann.bundle.test;specification-version=1.0
 * 
* * @author Kaspar Weilenmann */ public class Bundle extends Jar { // private fields private static final String BUNDLE_CLASS_PATH_KEY = "Bundle-ClassPath"; private static final String BUNDLE_ACTIVATOR_KEY = "Bundle-Activator"; private static final String IMPORT_PACKAGE_KEY = "Import-Package"; private static final String EXPORT_PACKAGE_KEY = "Export-Package"; private static final String ACTIVATOR_NONE = "none"; private static final String ACTIVATOR_AUTO = "auto"; private static final String PACKAGE_ANALYSIS_NONE = "none"; private static final String PACKAGE_ANALYSIS_WARN = "warn"; private static final String PACKAGE_ANALYSIS_AUTO = "auto"; private String activator = ACTIVATOR_AUTO; private String packageAnalysis = PACKAGE_ANALYSIS_WARN; private Map importPackage = new HashMap(); private Map exportPackage = new HashMap(); private List libs = new ArrayList(); private List classes = new ArrayList(); private File baseDir = null; private List zipgroups = new ArrayList(); private List srcFilesets = new ArrayList(); private Manifest generatedManifest = new Manifest(); private Set activatorClasses = new HashSet(); private Set availablePackages = new HashSet(); private Set referencedPackages = new HashSet(); private Set standardPackagePrefixes = new HashSet(); { standardPackagePrefixes.add("java."); } /** * The set of classes that are refrenced from the included classes. * May be used to check execution environment, see {@link BundleInfo}. */ private Set classSet = new TreeSet(); /** * A mapping from package name of included classes to a set of * package names that the classes in the key package references. */ private Map packageUsingMap = new HashMap(); // private methods private void analyze() { if (activator == ACTIVATOR_AUTO || packageAnalysis != PACKAGE_ANALYSIS_NONE) { addZipGroups(); addImplicitFileset(); for (Iterator i = srcFilesets.iterator(); i.hasNext();) { FileSet fileset = (FileSet) i.next(); File srcFile = getZipFile(fileset); if (srcFile == null) { File filesetBaseDir = fileset.getDir(getProject()); DirectoryScanner ds = fileset.getDirectoryScanner(getProject()); String[] files = ds.getIncludedFiles(); for (int j = 0; j < files.length; j++) { String fileName = files[j]; if (fileName.endsWith(".class")) { File file = new File(filesetBaseDir, fileName); try { analyzeClass(new ClassParser(file.getAbsolutePath())); } catch (IOException ioe) { throw new BuildException ("Failed to parse class file: " +file.getAbsolutePath(), ioe); } } } } else { try { ZipFile zipFile = new ZipFile(srcFile); DirectoryScanner ds = fileset.getDirectoryScanner(getProject()); String[] entries = ds.getIncludedFiles(); for (int kk = 0; kkt belongs to. * @param t Type of an object. */ protected void addReferencedType(String usingPackage, Type t) { if(t instanceof BasicType) { log(" " +t +" skiped; basic", Project.MSG_DEBUG); } else { addReferencedClass(usingPackage, t.toString()); } } /** * Add package names of all types in ts to the list of * referenced packages. * * @param usingPackage The package that the class referencing * ts belongs to. * @param ts Array with Type objects. */ protected void addReferencedType(String usingPackage, Type[] ts) { for (int i = ts.length-1; i>-1; i-- ) { addReferencedType(usingPackage, ts[i]); } } /** * Add data for a referenced class. * * @param usingPackage * The package that the class referencing * className belongs to. * @param className Name of the referenced class. */ protected void addReferencedClass(String usingPackage, String className) { if(className == null) { return; } String packageName = packageName(className); if("".equals(packageName)) { log(" " +className +" skipped; no package name", Project.MSG_DEBUG); return; } classSet.add(className); referencedPackages.add(packageName); if (null!=usingPackage) { Set usingSet = (Set) packageUsingMap.get(usingPackage); if (null==usingSet) { usingSet = new TreeSet(); packageUsingMap.put(usingPackage, usingSet); } usingSet.add(packageName); } } private void analyzeClass(ClassParser parser) throws IOException { final JavaClass javaClass = parser.parse(); final String javaPackage = javaClass.getPackageName(); final ConstantPool constant_pool = javaClass.getConstantPool(); final ConstantPoolGen constant_poolGen = new ConstantPoolGen(constant_pool); availablePackages.add(javaClass.getPackageName()); final String[] interfaces = javaClass.getInterfaceNames(); for (int i = 0; i < interfaces.length; i++) { if("org.osgi.framework.BundleActivator".equals(interfaces[i])) { activatorClasses.add(javaClass.getClassName()); break; } } /** * Use a descending visitor to find all classes that the given * clazz refers to and add them to the set of imported classes. */ DescendingVisitor v = new DescendingVisitor(javaClass, new EmptyVisitor() { /** * Keep track of the signatures visited to avoid processing * them more than once. The same signature may apply to * many methods or fields. */ boolean[] visitedSignatures = new boolean[constant_pool.getLength()]; /** * Add the class that the given ConstantClass object * represents to the set of imported classes. * * @param obj The ConstantClass object */ public void visitConstantClass( ConstantClass obj ) { log(" visit constant class " +obj, Project.MSG_DEBUG); String referencedClass = obj.getBytes(constant_pool); referencedClass = referencedClass.charAt(0) == '[' ? Utility.signatureToString(referencedClass, false) : Utility.compactClassName(referencedClass, false); addReferencedClass(javaPackage,referencedClass); } /** * Add the class used as types for the given field. * This is necessary since if no method is applied to an * object valued field there will be no ConstantClass object * in the ConstantPool for the class that is the type of the * field. * * @param obj A Field object */ public void visitField( Field obj ) { if (!visitedSignatures[obj.getSignatureIndex()]) { log(" visit field " +obj, Project.MSG_DEBUG); visitedSignatures[obj.getSignatureIndex()] = true; final String signature = obj.getSignature(); final Type type = Type.getType(signature); addReferencedType(javaPackage, type); } } /** * Add all classes used as types for a local variable in the * class we are analyzing. This is necessary since if no * method is applied to an object valued local variable * there will be no ConstantClass object in the ConstantPool * for the class that is the type of the local variable. * * @param obj A LocalVariable object */ public void visitLocalVariable( LocalVariable obj ) { if (!visitedSignatures[obj.getSignatureIndex()]) { log(" visit local variable " +obj, Project.MSG_DEBUG); visitedSignatures[obj.getSignatureIndex()] = true; final String signature = obj.getSignature(); final Type type = Type.getType(signature); addReferencedType(javaPackage, type); } } /** * Add all classes mentioned in the signature of the given * method. This is necessary since if no method is applied * to a parameter (return type) there will be no * ConstantClass object in the ConstantPool for the class * that is the type of that parameter (return type). * * @param obj A Method object */ public void visitMethod( Method obj ) { if (!visitedSignatures[obj.getSignatureIndex()]) { log(" visit method " +obj, Project.MSG_DEBUG); visitedSignatures[obj.getSignatureIndex()] = true; final String signature = obj.getSignature(); final Type returnType = Type.getReturnType(signature); final Type[] argTypes = Type.getArgumentTypes(signature); addReferencedType(javaPackage, returnType); addReferencedType(javaPackage, argTypes); } } /** * Look for packages for types in signatures of methods * invoked from code in the class. * * This typically finds packages from arguments in calls to a * superclass method in the current class where no local * variable (or field) was used for intermediate storage of * the parameter. * * @param obj The Code object to visit */ public void visitCode( Code obj ) { final InstructionList il = new InstructionList(obj.getCode()); for (InstructionHandle ih=il.getStart(); ih!=null; ih=ih.getNext()) { final Instruction inst = ih.getInstruction(); if (inst instanceof InvokeInstruction) { final InvokeInstruction ii = (InvokeInstruction) inst; log(" " +ii.toString(constant_pool), Project.MSG_DEBUG); // These signatures have no index in the constant pool // thus no check/update in visitedSignatures[]. final String signature = ii.getSignature(constant_poolGen); final Type returnType = Type.getReturnType(signature); final Type[] argTypes = Type.getArgumentTypes(signature); addReferencedType(javaPackage, returnType); addReferencedType(javaPackage, argTypes); } } } } ); // Run the scanner on the loaded class v.visit(); } private boolean isStandardPackage(String packageName) { for (Iterator i = standardPackagePrefixes.iterator(); i.hasNext();) { final String prefix = (String) i.next(); if (packageName.startsWith(prefix)) { return true; } } return false; } private void handleActivator() throws ManifestException { if (activator == ACTIVATOR_NONE) { log("No BundleActivator set", Project.MSG_DEBUG); } else if (activator == ACTIVATOR_AUTO) { switch (activatorClasses.size()) { case 0: { log("No class implementing BundleActivator found", Project.MSG_INFO); break; } case 1: { activator = (String) activatorClasses.iterator().next(); break; } default: { log("More than one class implementing BundleActivator found:", Project.MSG_WARN); for (Iterator i = activatorClasses.iterator(); i.hasNext();) { String activator = (String) i.next(); log(" " + activator, Project.MSG_WARN); } break; } } } if (activator != ACTIVATOR_NONE && activator != ACTIVATOR_AUTO) { log("Bundle-Activator: " + activator, Project.MSG_INFO); generatedManifest.addConfiguredAttribute(createAttribute(BUNDLE_ACTIVATOR_KEY, activator)); } } private void handleClassPath() throws ManifestException { final StringBuffer value = new StringBuffer(); boolean rootIncluded = false; if (baseDir != null || classes.size() == 0) { value.append(".,"); rootIncluded = true; } Iterator i = classes.iterator(); while (i.hasNext()) { final ZipFileSet zipFileSet = (ZipFileSet) i.next(); final String prefix = zipFileSet.getPrefix(getProject()); if (prefix.length() > 0) { value.append(prefix); value.append(','); } else if (!rootIncluded) { value.append(".,"); rootIncluded = true; } } i = libs.iterator(); while (i.hasNext()) { final ZipFileSet fileset = (ZipFileSet) i.next(); if (fileset.getSrc(getProject()) == null) { final DirectoryScanner ds = fileset.getDirectoryScanner(getProject()); final String[] files = ds.getIncludedFiles(); if (files.length != 0) { zipgroups.add(fileset); final String prefix = fixPrefix(fileset.getPrefix(getProject())); for (int j = 0; j < files.length; j++) { value.append(prefix.replace('\\', '/')); value.append(files[j].replace('\\', '/')); value.append(','); } } } } if (value.length() > 2) { generatedManifest.addConfiguredAttribute(createAttribute(BUNDLE_CLASS_PATH_KEY, value.substring(0, value.length() - 1))); } } private static String fixPrefix(String prefix) { if (prefix.length() > 0) { final char c = prefix.charAt(prefix.length() - 1); if (c != '/' && c != '\\') { prefix = prefix + "/"; } } return prefix; } private void addPackageHeader(String headerName, Map packageMap) throws ManifestException { final Iterator i = packageMap.entrySet().iterator(); if (i.hasNext()) { final StringBuffer valueBuffer = new StringBuffer(); while (i.hasNext()) { Map.Entry entry = (Map.Entry) i.next(); final String name = (String) entry.getKey(); final String version = (String) entry.getValue(); valueBuffer.append(name); if (version != null) { valueBuffer.append(";specification-version="); valueBuffer.append(version); } valueBuffer.append(','); } valueBuffer.setLength(valueBuffer.length() - 1); final String value = valueBuffer.toString(); generatedManifest.addConfiguredAttribute(createAttribute(headerName, value)); log(headerName + ": " + value, Project.MSG_INFO); } } private static Manifest.Attribute createAttribute(String name, String value) { final Manifest.Attribute attribute = new Manifest.Attribute(); attribute.setName(name); attribute.setValue(value); return attribute; } // public methods public void setActivator(String activator) { if (ACTIVATOR_NONE.equalsIgnoreCase(activator)) { this.activator = ACTIVATOR_NONE; } else if (ACTIVATOR_AUTO.equalsIgnoreCase(activator)) { this.activator = ACTIVATOR_AUTO; } else { this.activator = activator; } } public void setPackageAnalysis(String packageAnalysis) { packageAnalysis = packageAnalysis.trim().toLowerCase(); if (PACKAGE_ANALYSIS_NONE.equals(packageAnalysis)) { this.packageAnalysis = PACKAGE_ANALYSIS_NONE; } else if (PACKAGE_ANALYSIS_WARN.equals(packageAnalysis)) { this.packageAnalysis = PACKAGE_ANALYSIS_WARN; } else if (PACKAGE_ANALYSIS_AUTO.equals(packageAnalysis)) { this.packageAnalysis = PACKAGE_ANALYSIS_AUTO; } else { throw new BuildException("Illegal value: " + packageAnalysis); } } public void addConfiguredStandardPackage(OSGiPackage osgiPackage) { final String name = osgiPackage.getName(); final String prefix = osgiPackage.getPrefix(); if (name != null && prefix == null) { availablePackages.add(name); } else if (prefix != null && name == null) { standardPackagePrefixes.add(prefix); } else { throw new BuildException("StandardPackage must have exactly one of the name and prefix attributes defined"); } } public void addConfiguredImportPackage(OSGiPackage osgiPackage) { final String name = osgiPackage.getName(); if (name == null) { throw new BuildException("ImportPackage must have a name"); } else if (osgiPackage.getPrefix() != null) { throw new BuildException("ImportPackage must not have a prefix attribute"); } else { importPackage.put(name, osgiPackage.getVersion()); } } public void addConfiguredExportPackage(OSGiPackage osgiPackage) { final String name = osgiPackage.getName(); if (name == null) { throw new BuildException("ExportPackage must have a name"); } else if (osgiPackage.getPrefix() != null) { throw new BuildException("ExportPackage must not have a prefix attribute"); } else { exportPackage.put(name, osgiPackage.getVersion()); } } public void addConfiguredLib(ZipFileSet fileset) { // TODO: handle refid if (fileset.getSrc(getProject()) == null) { addFileset(fileset); libs.add(fileset); } else { addClasses(fileset); } } public void addClasses(ZipFileSet fileset) { super.addZipfileset(fileset); srcFilesets.add(fileset); classes.add(fileset); } // extends Jar public void execute() { try { handleClassPath(); analyze(); handleActivator(); addPackageHeader(IMPORT_PACKAGE_KEY, importPackage); addPackageHeader(EXPORT_PACKAGE_KEY, exportPackage); // TODO: better merge may be needed, currently overwrites pre-existing headers addConfiguredManifest(generatedManifest); } catch (ManifestException me) { throw new BuildException("Error merging manifest headers", me); } super.execute(); } public void setBasedir(File baseDir) { super.setBasedir(baseDir); this.baseDir = baseDir; } public void addZipGroupFileset(FileSet fileset) { super.addZipGroupFileset(fileset); zipgroups.add(fileset); } public void addZipfileset(ZipFileSet fileset) { super.addZipfileset(fileset); } } // Bundle ././@LongLink0000000000000000000000000000015700000000000011570 Lustar rootrootknopflerfish-osgi-2.3.3/knopflerfish.org/ant/src/org/knopflerfish/ant/taskdefs/bundle/BundleClasspathTask.javaknopflerfish-osgi-2.3.3/knopflerfish.org/ant/src/org/knopflerfish/ant/taskdefs/bundle/BundleClasspat0000644000175000017500000001640311252437456033723 0ustar twernertwerner/* * Copyright (c) 2006-2008, KNOPFLERFISH project * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * - Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * - 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. * * - Neither the name of the KNOPFLERFISH project nor the names of its * contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS 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 * COPYRIGHT OWNER OR 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. */ package org.knopflerfish.ant.taskdefs.bundle; import java.io.File; import java.util.StringTokenizer; import org.apache.tools.ant.BuildException; import org.apache.tools.ant.Project; import org.apache.tools.ant.Task; import org.apache.tools.ant.types.FileSet; /** * Task that translates the value of the OSGi specified manifest * header Bundle-Classpath into either a file set or pattern * suitable for use as the includes attribute in a file set that will * find all classes and jars that the framework may use given the * specified Bundle-Classpath manifest attribute. * *

Parameters

* * * * * * * * * * * * * * * * * * * * * * * * * * * *
AttributeDescriptionRequired
BundleClasspathThe bundle class path to convert into an includes * pattern. *

* If unset, set to empty string, or set to the special empty * value [bundle.emptystring] the default bundle * classpath, "." will be used. *

*

* Note: The current value of this property will be overwritten * by the derived pattern. *

*
No.
Default value is "."
propertyNameName of property that will receive the resulting * pattern. * Yes.
No default value.
dirThe directory to use as root directory in the * created fileset. * Yes.
No default value.
filesetIdId of a file set with include patterns based on * the given BundleClasspath and base directory given * by dir. If dir is not given or * non-existing then an empty file set is created. * No.
No default value.
* *

Examples

* The table below shows how different bundle class path entries are * translated int patterns. * * * * * * * * *
EntryPattern
.**/*.class
rxtxrxtx/**/*.class
/rxtxrxtx/**/*.class
required.jarrequired.jar
xx/required.jarxx/required.jar
/xx/required.jarxx/required.jar
*/ public class BundleClasspathTask extends Task { private File dir; private String filesetId; private String bundleClasspath = "."; private String propertyName; public BundleClasspathTask() { } /** * Set bundle class path to create a pattern for. */ public void setBundleClasspath(String s) { this.bundleClasspath = (BundleManifestTask.BUNDLE_EMPTY_STRING.equals(s)) ? "." : s; log("bundleClasspath="+bundleClasspath, Project.MSG_DEBUG); } /** * Set property receiving the bundle class path pattern. */ public void setPropertyName(String s) { this.propertyName = s; log("propertyName="+propertyName, Project.MSG_DEBUG); } /** * Set property receiving the file set root directory. */ public void setDir(File f) { this.dir = f; log("dir="+dir, Project.MSG_DEBUG); } /** * Set property receiving the file set id. */ public void setFilesetId(String s) { this.filesetId = s; log("filesetId="+filesetId, Project.MSG_DEBUG); } // Implements Task // public void execute() throws BuildException { if ( (null==propertyName || 0==propertyName.length()) && (null==filesetId || 0==filesetId.length()) ) { throw new BuildException ("Either propertyName or filesetId must be given."); } if (null!=filesetId && dir==null) { throw new BuildException ("dir is required when filesetId is given."); } if (null==bundleClasspath || 0==bundleClasspath.length() ) bundleClasspath = "."; StringBuffer sb = new StringBuffer(100); // Convert path entries to patterns. StringTokenizer st = new StringTokenizer(bundleClasspath, ","); while (st.hasMoreTokens()) { String entry = st.nextToken().trim(); if (".".equals(entry)) { sb.append("**/*.class"); } else if (entry.endsWith(".jar")) { if (entry.startsWith("/")) entry = entry.substring(1); sb.append(entry); } else { if (entry.startsWith("/")) entry = entry.substring(1); sb.append(entry + "/**/*.class"); } if (st.hasMoreTokens()) sb.append(","); } Project proj = getProject(); // Conversion done - write back properties if (null!=propertyName) { proj.setProperty(propertyName, sb.toString()); log("Converted \"" +bundleClasspath +"\" to pattern \"" +sb.toString() +"\"", Project.MSG_VERBOSE); } if (null!=filesetId) { FileSet fileSet = new FileSet(); fileSet.setProject(proj); if (dir.exists()) { fileSet.setDir(dir); fileSet.setIncludes(sb.toString()); } else { log("Bundle class path root dir '" +dir +"' does not exist, returning empty file set.", Project.MSG_DEBUG); fileSet.setDir(new File(".")); fileSet.setExcludes("**/*"); } proj.addReference(filesetId, fileSet); log("Converted bundle class path \"" +bundleClasspath +"\" to file set with id '" +filesetId +"' and files \"" +fileSet +"\"", Project.MSG_VERBOSE); } } } ././@LongLink0000000000000000000000000000015100000000000011562 Lustar rootrootknopflerfish-osgi-2.3.3/knopflerfish.org/ant/src/org/knopflerfish/ant/taskdefs/bundle/BundleLocator.javaknopflerfish-osgi-2.3.3/knopflerfish.org/ant/src/org/knopflerfish/ant/taskdefs/bundle/BundleLocator.0000644000175000017500000007031211252437456033631 0ustar twernertwerner/* * Copyright (c) 2008-2009, KNOPFLERFISH project * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * - Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * - 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. * * - Neither the name of the KNOPFLERFISH project nor the names of its * contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS 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 * COPYRIGHT OWNER OR 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. */ package org.knopflerfish.ant.taskdefs.bundle; import java.io.File; import java.io.FileOutputStream; import java.io.IOException; import java.io.OutputStream; import java.util.ArrayList; import java.util.HashMap; import java.util.Iterator; import java.util.List; import java.util.Map; import java.util.Properties; import java.util.StringTokenizer; import java.util.TreeSet; import java.util.Vector; import java.util.jar.Attributes; import java.util.jar.JarFile; import java.util.jar.Manifest; import org.osgi.framework.Version; import org.apache.tools.ant.BuildException; import org.apache.tools.ant.DirectoryScanner; import org.apache.tools.ant.Project; import org.apache.tools.ant.Task; import org.apache.tools.ant.types.FileSet; import org.apache.tools.ant.types.Path; import org.apache.tools.ant.types.PatternSet; import org.apache.tools.ant.types.Reference; import org.apache.tools.ant.types.Resource; //import org.apache.tools.ant.types.resources.FileResource; import org.apache.tools.ant.util.FileUtils; /** * Determines a sub-set of bundles from a given file set. The * resulting set of bundles will only contain the highest version of * each bundle in the original file set. The resulting set of bundles * may then be used in several ways. * *

* * An OSGi version spec used below is a string on the format * Major.Minor.Micro.Qualifier * where major, minor and micro are integers, and all parts of the * version except major are optional. See {@link * org.osgi.framework.Version#Version(java.lang.String) org.osgi.framework.Version} * for details. The version formatting used by Maven 2 is also * recognized, i.e., a '‑' between the micro and qualifier * fields: * Major.Minor.MicroQualifier. * *

* * Given a partial bundle name and a file set with bundles, this task * may be used to select the bundle with the highest version number * and name that matches. E.g., * *

 *   <bundle_locator bundleName="http" property="http.path">
 *     <fileset dir="${jars.dir}">
 *       <include name="**/*.jar"/>
 *     </fileset>
 *   </bundle_locator>
 * 
* * will set the project property http.path to the absolute * path of the highest version of the bundle named http * within the given file set. * *

* * The bundle locator task can also iterate over a path and replace * all non-existing file resources in it that either has a name * ending with -N.N.N.jar or that is the symbolic name of a * bundle with the corresponding bundle with the highest version of * the matching bundle from the given file set. Non-existing path * entries that does not end in .jar or .zip that * does not match a symbolic bundle name will trigger a build error if * failOnMissingBundles is set to true. The same * applies to path entries ending with -N.N.N.jar that does * not yield a match. * *

 *   <bundle_locator classPathRef="bundle.path"
 *                   newClassPathId="bundle.path.Expanded"
 *                   failOnMissingBundles="true">
 *     <fileset dir="${jars.dir}">
 *       <include name="**/*.jar"/>
 *     </fileset>
 *   </bundle_locator>
 * 
* * this will build a new path added to the project with the id * bundle.path.Expanded. The new path will be a copy of the * original, bundle.path, but with all path elements with a * name ending in -N.N.N.jar replaced with the corresponding * match or removed if no match was found. * *

* * Another usage of the bundle locator task is to ensure that only the * highest version of a bundle is matched by a certain pattern set. * *

 *   <bundle_locator patternSetId="my.ps.exact">
 *     <fileset dir="${jars.dir}">
 *       <patternset refid="my.ps"/>
 *     </fileset>
 *   </bundle_locator>
 * 
* * Here the original pattern set my.ps is used to find * bundles in the directory jars.dir, if more than one * version of a bundle matches then only the one with the highest * version will be selected. A new pattern set based on the matches is * created and saved in the project under the name * my.ps.exact. This pattern set will contain one include * pattern for each matching bundle. The value of the include pattern * is the relative path of that bundle (relative to the root directory * of the file set that the matching bundle originates from). * *

* * Finally this task may also be used to create a properties file * suitable for using as a replacement filter that will replace bundle * names on the form @name-N.N.N.jar@ or bundle symbolic * names on the form @bundleSymbolicName@ with the relative * path within the given file set of the bundle with the given name * and the highest version. * *

 *   <bundle_locator replacefilterfile="my.filter">
 *     <fileset dir="${jars.dir}">
 *       <patternset refid="my.ps"/>
 *     </fileset>
 *   </bundle_locator>
 * 
* * *

Parameters

* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
AttributeDescriptionRequired
bundleName * The name of the bundle to look for. There are several ways to * specify the bundle name. *
    *
  • If the bundle to locate is named like * name‑OSGi version spec.jar, then * the value of the bundleName-attribute may be * specified as name. *
  • The symbolic name of the bundle. *
* * A property with name given by the value of the attribute * property with the location (absolute path) of the bundle * as value is added to the project. * *
No. No default value.
bundleNames * * A comma separated list of bundle names to look for. There are * several ways to specify the bundle name. *
    *
  • If a bundle to locate is named like * name‑OSGi version spec.jar, then * the value of the bundleName-attribute may be * specified as name. *
  • The symbolic name of the bundle. *
* * The absolute path of the matching bundle will be stored in a * project property named bap.bundleName. * *

* * If the attribute property is set its value will be used * as prefix for the property names in stead of the default * bap. * *

No. No default value.
property * The name of a project property to be assigned the location of * the matching bundle. * Yes when bundleName is specified.
* No default value.
classPathRef * The reference name (id) of a path-structure to transform. * No. No default value.
newClassPathId * The transformed path-structure will be added to the current * project using this name (id). * Yes when classPathRef is specified.
* No default value.
patternSetId * Create a pattern set from the set of bundles that are selected * by the nested file set(s) and add it to the project using this * name (id). * No. No default value.
failOnMissingBundles * * If an entry with the file with name * bundleName-N.N.N.jar is found on the * classpath to transform and there is no matching bundle in the * file set then a build failure is triggered if this attribute is * set to true. Same applies if the given * bundleName or one of the given bundleNames * does not yield a match. * * No.
Defaults to true.
extendedReplaceFilter * * If set to true then the replace filter generated by * the replacefilter attribute will be extended with the * following set of replacements for each matching bundle. * * * * * * * * * * * * * * * *
KeyValue
* @bundleName‑N.N.N.name@
* @Bundle‑SymbolicName.name@ *
* * The bundle symbolic name from the manifest. For bundles * with manifest version 1 (i.e., pre OSGi R4 bundles) the * bundle name. * *
* @bundleName‑N.N.N.version@
* @Bundle‑SymbolicName.version@ *
* * The bundle version from the manifest. * *
* @bundleName‑N.N.N.location@
* @Bundle‑SymbolicName.location@ *
* * The absolute path of the bundle. * *
* *
No.
Defaults to false.
replacefilterfile * * Creates a property file suitable for use as the * replacefilterfile argument in the replace-task. The * generated file will contain two entries for each matching * bundle. * * * * * * * *
KeyValue
* @bundleName‑N.N.N.jar@
* @Bundle‑SymbolicName.jar@ *
* * The relative path to the bundle from the root-directory * of the file set that the matching bundle ordinates from. * *
* *
No.
No default value.
* *

Parameters specified as nested elements

*

fileset

* * (required)
*

* The jar files to match against must be specified as a fileset. *

* */ public class BundleLocator extends Task { private final static String PROPS_PREFIX = "bap."; private final Vector filesets = new Vector(); private final FileUtils fileUtils; private String bundleName = null; private String bundleNames = null; private String property = null; private Reference classPathRef = null; private String newClassPathId = null; private String patternSetId = null; private boolean failOnMissingBundles = true; private File replacefilterfile = null; private boolean extendedReplaceFilter= false; /** * A list with all BundeInfo-objects that has been created in the * order that they are specified through the included file sets. */ final private List allBis = new ArrayList(); /** * Mapping from bundle symbolic name to the BundleInfo object of the * bundle within the file set with the highest version. */ final private Map bsnMap = new HashMap(); /** * Mapping that for bundles named like bundleName-N.N.N.jar * maos from the bundleName part to the BundleInfo object * of the bundle within the file set with the highest version. */ final private Map bundleMap = new HashMap(); public BundleLocator() { fileUtils = FileUtils.newFileUtils(); } public void setProperty(String s) { this.property = s; } public void setBundleName(String s) { this.bundleName = s; } public void setBundleNames(String s) { this.bundleNames = s; } public void addFileset(FileSet set) { filesets.addElement(set); } public void setClassPathRef(Reference r) { classPathRef = r; } public void setNewClassPathId(String s) { newClassPathId = s; } public void setPatternSetId(String s) { patternSetId = s; } public void setFailOnMissingBundles(boolean b) { failOnMissingBundles = b; } public void setExtendedReplaceFilter(boolean b) { extendedReplaceFilter = b; } public void setReplacefilterfile(File f) { replacefilterfile = f; } // Implements Task public void execute() throws BuildException { if (filesets.size() == 0) { throw new BuildException("No fileset specified"); } analyze(); if (null!=bundleName) { setProperty(); } if (null!=bundleNames) { setProperties(); } if (classPathRef!=null && newClassPathId!=null) { transformPath(); } if (patternSetId!=null) { createPatternSet(); } if (null!=replacefilterfile) { writeReplaceFilterFile(); } } /** * Holder of the value in the bundle version map. */ static class BundleInfo { /** The short bundle name. I.e., the name to the left of the last '-'.*/ public String name; /** The bundle file name without path.*/ public String fileName; /** The bundle symbolic name.*/ public String bsn; /** The bundles version. I.e., the part to the right of the last '-'.*/ public Version version; /** The relative path from the root of the file set holding the bundle.*/ public String relPath; /** The absolute path of the bundle. */ public File file; public String toString() { return "BundleInfo[fileName=" +fileName +", name=" +name +", Bundle-SymbolicName=" +bsn +", version=" +version +", relPath=" +relPath +", absPath=" +file.getAbsolutePath() +"]"; } } private String encodeBundleName(final String bundleName) { String name = bundleName; if (null!=name) { name = name.replace(':', '.'); name = name.replace(' ', '_'); } return name; } /** * Format the OSGi version as Maven 2 does in versioned file names. */ private String toMavenVersion(final Version version) { final StringBuffer sb = new StringBuffer(40); sb.append(String.valueOf(version.getMajor())).append("."); sb.append(String.valueOf(version.getMinor())).append("."); sb.append(String.valueOf(version.getMicro())); final String qualifier = version.getQualifier(); if (0Bundle-SymbolicName attribute is missing use the * Bundle-Name but replace all ':' with '.' and all ' ' * with '_' in the returned value. * * @param attributes The main attributes from the bundle's manifest. */ private String getBundleSymbolicName(final Attributes attributes) { String name = attributes.getValue("Bundle-SymbolicName"); if (null==name) { name = attributes.getValue("Bundle-Name"); } return encodeBundleName(name); } /** * Get the bundle version from the manifest. * * @param attributes The main attributes from the bundle's manifest. */ private Version getBundleVersion(final File file, final Attributes attributes) throws NumberFormatException { String versionS = attributes.getValue("Bundle-Version"); if (null==versionS) { versionS = "0.0.0"; } try { return new Version(versionS); } catch (NumberFormatException nfe) { log("Invalid bundle version '" +versionS +"' found in " +file +": "+nfe, Project.MSG_ERR); throw nfe; } } /** * Create a BundleInfo-object for the given file if it is a bundle. */ private BundleInfo createBundleInfo(final File rootDir, final String relPath) throws Exception { final File file = new File(rootDir, relPath); final String fileName = file.getName(); BundleInfo bi = null; if(file.getName().endsWith(".jar")) { log( "Processing candidate " +file, Project.MSG_DEBUG); String bundleName = null; Version nameVersion = null; int ix = fileName.lastIndexOf('-'); if (00) { map.put(key, bi); log("Found better version of '" +key +"'.", Project.MSG_DEBUG); } } /** * Traverses the given file sets, identify files that are bundles * and add them to the bundle info maps. */ private void analyze() { try { for (int i = 0; i < filesets.size(); i++) { final FileSet fs = (FileSet) filesets.elementAt(i); final File projDir = fs.getDir(project); if (!projDir.exists()) { log("Skipping nested file set rooted at '" +projDir +"' since that directory does not exist.", Project.MSG_WARN); continue; } else { log( "Processing file set rooted at " +projDir, Project.MSG_DEBUG); } final DirectoryScanner ds = fs.getDirectoryScanner(project); final String[] srcFiles = ds.getIncludedFiles(); final String[] srcDirs = ds.getIncludedDirectories(); for (int j = 0; j < srcFiles.length ; j++) { final BundleInfo bi = createBundleInfo(projDir, srcFiles[j]); if (null!=bi) { allBis.add(bi); updateMap(bundleMap, bi.name, bi); updateMap(bsnMap, bi.bsn, bi); } } } } catch (Exception e) { e.printStackTrace(); throw new BuildException("Failed locate bundle: " + e, e); } } private void setProperty(final String bn, final String propName) { log("Searching for a bundle with name '" +bn +"'.", Project.MSG_DEBUG); BundleInfo bi = (BundleInfo) bundleMap.get(bn); if (null==bi) bi = (BundleInfo) bsnMap.get(encodeBundleName(bn)); if (bi!=null) { project.setProperty(propName, bi.file.getAbsolutePath()); log(propName +" = " +bi.file, Project.MSG_VERBOSE); } else { final int logLevel = failOnMissingBundles ? Project.MSG_ERR : Project.MSG_INFO; log("No bundle with name '" +bn +"' found.", logLevel); TreeSet knownNames = new TreeSet(bundleMap.keySet()); knownNames.addAll(bsnMap.keySet()); log("Known bundles names: " +knownNames, logLevel); if (failOnMissingBundles) { throw new BuildException("No bundle with name '" +bn+"' found."); } } } private void setProperty() { if (null!=property) { setProperty(bundleName, property); } else { throw new BuildException ("The attribute 'bundleName' requires 'property'"); } } private void setProperties() { final String prefix = null==property ? PROPS_PREFIX : property; final StringTokenizer st = new StringTokenizer(bundleNames, ","); while (st.hasMoreTokens()) { final String bn = st.nextToken().trim(); setProperty(bn, prefix +bn); } } private void transformPath() { final Path newPath = new Path(project); log("Updating bundle paths in class path reference '" +classPathRef.getRefId() +"'.", Project.MSG_DEBUG); String[] pathElements = null; try { final Path path = (Path) classPathRef.getReferencedObject(); pathElements = path.list(); } catch (BuildException e) { // Unsatisfied ref in the given path; can not expand. // Make the new path a reference to the old one. log("Unresolvable reference in '" +classPathRef.getRefId() +"' can not expand bundle names in it.", Project.MSG_WARN); newPath.setRefid(classPathRef); } if (null!=pathElements) { for (int i=0; i " +filePath, Project.MSG_VERBOSE); } else if (doTransformPathElement) { final int logLevel = failOnMissingBundles ? Project.MSG_ERR : Project.MSG_INFO; log("No match for '" +fileName +"' when expanding the path named '" +classPathRef.getRefId() +"'.", logLevel); TreeSet knownNames = new TreeSet(bundleMap.keySet()); knownNames.addAll(bsnMap.keySet()); log("Known bundles names: " +knownNames, logLevel); if (failOnMissingBundles) { throw new BuildException ("No bundle with name like '" +fileName+"' found."); } } } if (!added) { newPath.setPath(pathElement.getAbsolutePath()); } } log(newClassPathId +" = " +newPath, Project.MSG_VERBOSE); } project.addReference(newClassPathId, newPath); } // end of transform path structure. private void createPatternSet() { final PatternSet patternSet = new PatternSet(); log("Creating a patternset for the bundles with id='" +patternSetId +"'.", Project.MSG_DEBUG); for (Iterator it=allBis.iterator(); it.hasNext();) { BundleInfo bi = (BundleInfo) it.next(); patternSet.setIncludes(bi.relPath); log("Adding includes '" +bi.relPath +"'.", Project.MSG_DEBUG); } project.addReference(patternSetId, patternSet); } // end of create pattern set for bundles private void writeReplaceFilterFile() { final Properties props = new Properties(); for (Iterator it = allBis.iterator(); it.hasNext();) { final BundleInfo bi = (BundleInfo) it.next(); //Note: since the path is an URL we must ensure that '/' is used. final String relPath = bi.relPath.replace('\\','/'); props.put("@" +bi.bsn +".jar@", relPath); if (null!=bi.name) { props.put("@" +bi.name +"-N.N.N.jar@", relPath); } if (extendedReplaceFilter) { addExtendedProps(props, bi); } } OutputStream out = null; try { out= new FileOutputStream(replacefilterfile); props.store(out, "Bundle Version Expansion Mapping"); } catch (IOException ioe) { log("Failed to write replacefilterfile, "+replacefilterfile +", reason: "+ioe, Project.MSG_ERR); throw new BuildException("Failed to write replacefilterfile",ioe); } finally { if (null!=out) { try { out.close(); } catch (IOException _ioe) {} log("Created: "+replacefilterfile, Project.MSG_VERBOSE); } } } private void addExtendedProps(final Properties props, final BundleInfo bi) { if (null!=bi.name) { final String prefix = "@" +bi.name +"-N.N.N."; props.put(prefix +"location@", bi.file.getAbsolutePath()); if (null!=bi.bsn) props.put(prefix +"name@", bi.bsn); if (null!=bi.version) props.put(prefix +"version@",bi.version.toString()); } if (null!=bi.bsn) { props.put("@" +bi.bsn +".location@", bi.file.getAbsolutePath()); props.put("@" +bi.bsn +".name@", bi.bsn); props.put("@" +bi.bsn +".version@", bi.version.toString()); } } } ././@LongLink0000000000000000000000000000015000000000000011561 Lustar rootrootknopflerfish-osgi-2.3.3/knopflerfish.org/ant/src/org/knopflerfish/ant/taskdefs/bundle/VersionRange.javaknopflerfish-osgi-2.3.3/knopflerfish.org/ant/src/org/knopflerfish/ant/taskdefs/bundle/VersionRange.j0000644000175000017500000000741111252437456033650 0ustar twernertwerner/* * Copyright (c) 2008-2008, KNOPFLERFISH project * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * - Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * - 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. * * - Neither the name of the KNOPFLERFISH project nor the names of its * contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS 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 * COPYRIGHT OWNER OR 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. */ package org.knopflerfish.ant.taskdefs.bundle; import org.osgi.framework.Version; public class VersionRange { Version lowerBound; Version upperBound; boolean lowerBoundInclusive; boolean upperBoundInclusive; public VersionRange() { this(null); } public VersionRange(String s) { if (s==null) s = "0"; s = s.trim(); char c = s.charAt(0); if ('['==c) { lowerBoundInclusive = true; s = s.substring(1); } else if ('('==c) { lowerBoundInclusive = false; s = s.substring(1); } else { lowerBoundInclusive = true; } c = s.charAt(s.length()-1); if (']'==c) { upperBoundInclusive = true; s = s.substring(0,s.length()-1); } else if (')'==c) { upperBoundInclusive = false; s = s.substring(0,s.length()-1); } else { upperBoundInclusive = false; } int splitPos = s.indexOf(","); if (-1==splitPos) { lowerBound = new Version(s); upperBound = null; // Infinity } else { lowerBound = new Version(s.substring(0,splitPos).trim()); upperBound = new Version(s.substring(splitPos+1,s.length()).trim()); } } /** * Check if the specified version is conatined in this version * range. * @param ver The version to check. * @return true if the specified version is in this range, * false otherwise. */ public boolean contains(Version ver) { boolean res = false; if (null==upperBound) { res = lowerBound.compareTo(ver) <= 0; } else { if (lowerBoundInclusive) { res = lowerBound.compareTo(ver)<=0; } else { res = lowerBound.compareTo(ver)<0; } if (upperBoundInclusive) { res &= ver.compareTo(upperBound)<=0; } else { res &= ver.compareTo(upperBound)<0; } } return res; } public String toString() { StringBuffer sb = new StringBuffer(); if (null==upperBound) { sb.append(lowerBound.toString()); } else { sb.append(lowerBoundInclusive ? '[' : '(') .append(lowerBound.toString()) .append(',') .append(upperBound.toString()) .append(upperBoundInclusive ? ']' : ')'); } return sb.toString(); } } ././@LongLink0000000000000000000000000000016300000000000011565 Lustar rootrootknopflerfish-osgi-2.3.3/knopflerfish.org/ant/src/org/knopflerfish/ant/taskdefs/bundle/BundleJavadocHelperTask.javaknopflerfish-osgi-2.3.3/knopflerfish.org/ant/src/org/knopflerfish/ant/taskdefs/bundle/BundleJavadocH0000644000175000017500000002077111252437456033633 0ustar twernertwerner/* * Copyright (c) 2008-2009, KNOPFLERFISH project * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * - Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * - 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. * * - Neither the name of the KNOPFLERFISH project nor the names of its * contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS 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 * COPYRIGHT OWNER OR 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. */ package org.knopflerfish.ant.taskdefs.bundle; import java.io.BufferedReader; import java.io.File; import java.io.FileNotFoundException; import java.io.FileReader; import java.io.IOException; import java.util.Iterator; import java.util.Map; import java.util.Set; import java.util.StringTokenizer; import java.util.StringTokenizer; import java.util.TreeSet; import org.apache.tools.ant.BuildException; import org.apache.tools.ant.Project; import org.apache.tools.ant.Task; import org.apache.tools.ant.types.Path; /** * Task that helps building arguments to javadoc. * * Loads source paths from a file removes dupliocates and adds them to * a path structure. * * Loads export package definitions from a file removes duplicates and * osgi specific annotation, then adds them to a comma separated string. * *

Parameters

* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
AttributeDescriptionRequired
srcRootsFileThe file to read source tree root directories from. * No.
No default value.
srcPropertyNameName of property that the resulting * java source roots are appended to. * No.
No default value.
srcPathIdId of a path like structure to append the source * root dirs to. The structure is created if needed. * No.
No default value.
exportPkgsFileThe file to read export package definitions from. * No.
No default value.
pkgPropertyNameName of property that the resulting * java package list is appended to. * No.
No default value.
* *

Examples

*/ public class BundleJavadocHelperTask extends Task { private File exportPkgsFile; private String pkgPropertyName; private File srcRootsFile; private String srcPropertyName; private String srcPathId; public BundleJavadocHelperTask() { } /** * Set property receiving the file to load export package definitions from. */ public void setExportPkgsFile(File f) { this.exportPkgsFile = f; log("exportPkgsFile="+exportPkgsFile, Project.MSG_INFO); } /** * Set property receiving the bundle class path pattern. */ public void setPkgPropertyName(String s) { if (s!=null && 0==s.length() ) { this.pkgPropertyName = null; } else { this.pkgPropertyName = s; } log("pkgPropertyName=" +this.pkgPropertyName, Project.MSG_INFO); } /** * Set property receiving the file to load source root directory * names from. */ public void setSrcRootsFile(File f) { this.srcRootsFile = f; log("srcRootsFile="+srcRootsFile, Project.MSG_DEBUG); } /** * Set property receiving the comma separated string with source * root directories. */ public void setSrcPropertyName(String s) { if (s!=null && 0==s.length()) { this.srcPropertyName = null; } else { this.srcPropertyName = s; } log("srcPropertyName="+srcPropertyName, Project.MSG_DEBUG); } /** * Set id of path like structure receiving to add source root * directories to. */ public void setSrcPathId(String s) { if (s!=null && 0==s.length() ) { this.srcPathId = null; } else { this.srcPathId = s; } log("srcPathId=" +this.srcPathId, Project.MSG_DEBUG); } // Implements Task // public void execute() throws BuildException { if (null==exportPkgsFile && null!=pkgPropertyName ) { throw new BuildException ("exportPkgsFile must be set when pkgPropertyName is set."); } if (null==srcRootsFile && (null!=srcPropertyName || null!=srcPathId)) { throw new BuildException ("srcRootsFile must be set when srcPropertyName or srcPathId is set."); } try { processSrcRootsFile(); processExportPkgsFile(); } catch (Exception e) { throw new BuildException(e); } } private void processSrcRootsFile() throws FileNotFoundException, IOException { if (null==srcRootsFile) return; BufferedReader in = new BufferedReader(new FileReader(srcRootsFile)); Set srcRoots = new TreeSet(); String line = in.readLine(); while (null!=line) { srcRoots.add(line.trim()); line = in.readLine(); } Project proj = getProject(); if (null!=srcPropertyName) { String sourcepath = proj.getProperty(srcPropertyName); if (null==sourcepath) sourcepath = ""; StringBuffer sb = new StringBuffer(sourcepath.length() +50*srcRoots.size()); sb.append(sourcepath); for (Iterator it = srcRoots.iterator(); it.hasNext(); ) { if (sb.length()>0) sb.append(","); sb.append(it.next()); } proj.setProperty(srcPropertyName, sb.toString()); } if (null!=srcPathId) { Path path = new Path(proj); for (Iterator it = srcRoots.iterator(); it.hasNext(); ) { path.setLocation(new File( (String) it.next() )); } log("Created path: "+path,Project.MSG_DEBUG); Path oldPath = (Path) proj.getReference(srcPathId); if (null!=oldPath) { oldPath.add(path); log(srcPathId +" after extension: "+oldPath, Project.MSG_VERBOSE); } else { proj.addReference(srcPathId, path); log("Created \"" +srcPathId +"\": "+path, Project.MSG_VERBOSE); } } } private void processExportPkgsFile() throws FileNotFoundException, IOException { if (null==exportPkgsFile) return; BufferedReader in = new BufferedReader(new FileReader(exportPkgsFile)); Set pkgs = new TreeSet(); String line = in.readLine(); while (null!=line) { if (!BundleManifestTask.BUNDLE_EMPTY_STRING.equals(line)) { Iterator expIt = Util.parseEntries ("export.package", line.trim(), true, true, false ); while (expIt.hasNext()) { Map expEntry = (Map) expIt.next(); String exPkg = (String) expEntry.get("$key"); pkgs.add(exPkg); } } line = in.readLine(); } Project proj = getProject(); if (null!=pkgPropertyName) { String packagenames = proj.getProperty(pkgPropertyName); if (null==packagenames) packagenames = ""; StringBuffer sb = new StringBuffer(packagenames.length() +50*pkgs.size()); sb.append(packagenames); for (Iterator it =pkgs.iterator(); it.hasNext(); ) { if (sb.length()>0) sb.append(","); sb.append(it.next()); } proj.setProperty(pkgPropertyName, sb.toString()); log("Setting property '" +pkgPropertyName +"' -> " +sb.toString(), Project.MSG_VERBOSE); } } } knopflerfish-osgi-2.3.3/knopflerfish.org/ant/src/org/knopflerfish/ant/taskdefs/bundle/EE.java0000644000175000017500000011444511252437456032235 0ustar twernertwerner/* * Copyright (c) 2003, KNOPFLERFISH project * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * - Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * - 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. * * - Neither the name of the KNOPFLERFISH project nor the names of its * contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS 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 * COPYRIGHT OWNER OR 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. */ package org.knopflerfish.ant.taskdefs.bundle; import java.util.Hashtable; /** * Utility class with static methods for checking classes with * the standard OSGi profiles. See r3.book.pdf for details. */ public class EE { final static String[] EE_MINIMUM = { "java.io.BufferedInputStream", "java.io.FilterInputStream", "java.io.InputStream", "java.io.IOException", "java.io.Serializable", "java.io.PrintStream", "java.io.FilterOutputStream", "java.io.OutputStream", "java.io.PrintWriter", "java.io.Writer", "java.io.UnsupportedEncodingException", "java.io.BufferedOutputStream", "java.io.BufferedReader", "java.io.Reader", "java.io.BufferedWriter", "java.io.ByteArrayInputStream", "java.io.ByteArrayOutputStream", "java.io.CharConversionException", "java.io.DataInput", "java.io.DataInputStream", "java.io.DataOutput", "java.io.DataOutputStream", "java.io.EOFException", "java.io.Externalizable", "java.io.ObjectInput", "java.io.ObjectOutput", "java.io.File", "java.io.FileDescriptor", "java.io.SyncFailedException", "java.io.FileInputStream", "java.io.FileNotFoundException", "java.io.FileOutputStream", "java.io.FilePermission", "java.io.FileReader", "java.io.InputStreamReader", "java.io.FileWriter", "java.io.OutputStreamWriter", "java.io.InterruptedIOException", "java.io.InvalidClassException", "java.io.ObjectStreamException", "java.io.InvalidObjectException", "java.io.NotActiveException", "java.io.NotSerializableException", "java.io.ObjectInputStream$GetField", "java.io.ObjectInputStream", "java.io.ObjectStreamConstants", "java.io.StreamCorruptedException", "java.io.ObjectStreamClass", "java.io.OptionalDataException", "java.io.ObjectInputValidation", "java.io.SerializablePermission", "java.io.ObjectStreamField", "java.io.ObjectOutputStream$PutField", "java.io.ObjectOutputStream", "java.io.PushbackInputStream", "java.io.RandomAccessFile", "java.io.StringReader", "java.io.StringWriter", "java.io.UTFDataFormatException", "java.io.WriteAbortedException", "java.lang.ref.PhantomReference", "java.lang.ref.Reference", "java.lang.ref.ReferenceQueue", "java.lang.ref.SoftReference", "java.lang.ref.WeakReference", "java.lang.reflect.Constructor", "java.lang.reflect.AccessibleObject", "java.lang.reflect.Member", "java.lang.reflect.Field", "java.lang.reflect.Method", "java.lang.reflect.InvocationTargetException", "java.lang.reflect.Array", "java.lang.reflect.InvocationHandler", "java.lang.reflect.Modifier", "java.lang.reflect.Proxy", "java.lang.reflect.ReflectPermission", "java.lang.reflect.UndeclaredThrowableException", "java.lang.Object", "java.lang.Exception", "java.lang.Throwable", "java.lang.CloneNotSupportedException", "java.lang.Class", "java.lang.String", "java.lang.Comparable", "java.lang.InterruptedException", "java.lang.ClassNotFoundException", "java.lang.ClassLoader", "java.lang.NoSuchMethodException", "java.lang.SecurityException", "java.lang.RuntimeException", "java.lang.NoSuchFieldException", "java.lang.IllegalAccessException", "java.lang.InstantiationException", "java.lang.ClassFormatError", "java.lang.LinkageError", "java.lang.Error", "java.lang.IllegalArgumentException", "java.lang.StringBuffer", "java.lang.AbstractMethodError", "java.lang.IncompatibleClassChangeError", "java.lang.ArithmeticException", "java.lang.ArrayIndexOutOfBoundsException", "java.lang.IndexOutOfBoundsException", "java.lang.ArrayStoreException", "java.lang.Boolean", "java.lang.Byte", "java.lang.Number", "java.lang.NumberFormatException", "java.lang.Character", "java.lang.ClassCastException", "java.lang.ClassCircularityError", "java.lang.Cloneable", "java.lang.Double", "java.lang.ExceptionInInitializerError", "java.lang.Float", "java.lang.IllegalAccessError", "java.lang.IllegalMonitorStateException", "java.lang.IllegalStateException", "java.lang.IllegalThreadStateException", "java.lang.InstantiationError", "java.lang.Integer", "java.lang.InternalError", "java.lang.VirtualMachineError", "java.lang.Long", "java.lang.Math", "java.lang.NegativeArraySizeException", "java.lang.NoClassDefFoundError", "java.lang.NoSuchFieldError", "java.lang.NoSuchMethodError", "java.lang.NullPointerException", "java.lang.OutOfMemoryError", "java.lang.Process", "java.lang.Runnable", "java.lang.Runtime", "java.lang.RuntimePermission", "java.lang.SecurityManager", "java.lang.Thread", "java.lang.ThreadGroup", "java.lang.Short", "java.lang.System", "java.lang.Void", "java.lang.StackOverflowError", "java.lang.StringIndexOutOfBoundsException", "java.lang.ThreadDeath", "java.lang.UnknownError", "java.lang.UnsatisfiedLinkError", "java.lang.UnsupportedOperationException", "java.lang.VerifyError", "java.net.URL", "java.net.URLStreamHandlerFactory", "java.net.MalformedURLException", "java.net.URLStreamHandler", "java.net.URLConnection", "java.net.InetAddress", "java.net.FileNameMap", "java.net.ContentHandlerFactory", "java.net.UnknownHostException", "java.net.ContentHandler", "java.net.Authenticator", "java.net.PasswordAuthentication", "java.net.BindException", "java.net.SocketException", "java.net.ConnectException", "java.net.DatagramPacket", "java.net.DatagramSocket", "java.net.DatagramSocketImpl", "java.net.SocketOptions", "java.net.HttpURLConnection", "java.net.ProtocolException", "java.net.JarURLConnection", "java.net.MulticastSocket", "java.net.NetPermission", "java.net.NoRouteToHostException", "java.net.ServerSocket", "java.net.Socket", "java.net.SocketImpl", "java.net.SocketImplFactory", "java.net.SocketPermission", "java.net.URLDecoder", "java.net.URLEncoder", "java.net.UnknownServiceException", "java.security.cert.Certificate", "java.security.ProtectionDomain", "java.security.CodeSource", "java.security.PermissionCollection", "java.security.Permission", "java.security.BasicPermission", "java.security.AccessControlContext", "java.security.AccessControlException", "java.security.AccessController", "java.security.PrivilegedAction", "java.security.PrivilegedExceptionAction", "java.security.PrivilegedActionException", "java.security.AllPermission", "java.security.Permissions", "java.security.Policy", "java.security.Principal", "java.security.Security", "java.security.SecurityPermission", "java.security.UnresolvedPermission", "java.util.zip.CRC32", "java.util.zip.Checksum", "java.util.zip.DataFormatException", "java.util.zip.Inflater", "java.util.zip.InflaterInputStream", "java.util.zip.ZipConstants", "java.util.zip.ZipEntry", "java.util.zip.ZipException", "java.util.zip.ZipFile", "java.util.zip.ZipInputStream", "java.util.Comparator", "java.util.Enumeration", "java.util.Properties", "java.util.Hashtable", "java.util.Dictionary", "java.util.Map$Entry", "java.util.Map", "java.util.Set", "java.util.Collection", "java.util.Iterator", "java.util.AbstractCollection", "java.util.AbstractList", "java.util.List", "java.util.ListIterator", "java.util.AbstractMap", "java.util.AbstractSequentialList", "java.util.AbstractSet", "java.util.ArrayList", "java.util.Arrays", "java.util.Calendar", "java.util.TimeZone", "java.util.Date", "java.util.Collections", "java.util.Random", "java.util.SortedMap", "java.util.SortedSet", "java.util.ConcurrentModificationException", "java.util.EventListener", "java.util.EventObject", "java.util.GregorianCalendar", "java.util.ListResourceBundle", "java.util.ResourceBundle", "java.util.MissingResourceException", "java.util.Locale", "java.util.NoSuchElementException", "java.util.PropertyPermission", "java.util.PropertyResourceBundle", "java.util.SimpleTimeZone", "java.util.StringTokenizer", "java.util.Vector", "java.util.WeakHashMap", }; final static String[] EE_FOUNDATION = { "java.io.BufferedInputStream", "java.io.FilterInputStream", "java.io.InputStream", "java.io.IOException", "java.io.Serializable", "java.io.PrintStream", "java.io.FilterOutputStream", "java.io.OutputStream", "java.io.PrintWriter", "java.io.Writer", "java.io.UnsupportedEncodingException", "java.io.ObjectStreamException", "java.io.BufferedOutputStream", "java.io.BufferedReader", "java.io.Reader", "java.io.BufferedWriter", "java.io.ByteArrayInputStream", "java.io.ByteArrayOutputStream", "java.io.CharArrayReader", "java.io.CharArrayWriter", "java.io.CharConversionException", "java.io.DataInput", "java.io.DataInputStream", "java.io.DataOutput", "java.io.DataOutputStream", "java.io.EOFException", "java.io.Externalizable", "java.io.ObjectInput", "java.io.ObjectOutput", "java.io.File", "java.io.FilenameFilter", "java.io.FileFilter", "java.io.FileDescriptor", "java.io.SyncFailedException", "java.io.FileInputStream", "java.io.FileNotFoundException", "java.io.FileOutputStream", "java.io.FilePermission", "java.io.FileReader", "java.io.InputStreamReader", "java.io.FileWriter", "java.io.OutputStreamWriter", "java.io.FilterReader", "java.io.FilterWriter", "java.io.InterruptedIOException", "java.io.InvalidClassException", "java.io.InvalidObjectException", "java.io.LineNumberReader", "java.io.NotActiveException", "java.io.NotSerializableException", "java.io.ObjectInputStream$GetField", "java.io.ObjectInputStream", "java.io.ObjectStreamConstants", "java.io.StreamCorruptedException", "java.io.ObjectStreamClass", "java.io.OptionalDataException", "java.io.ObjectInputValidation", "java.io.SerializablePermission", "java.io.ObjectStreamField", "java.io.ObjectOutputStream", "java.io.ObjectOutputStream$PutField", "java.io.PipedInputStream", "java.io.PipedOutputStream", "java.io.PipedReader", "java.io.PipedWriter", "java.io.PushbackInputStream", "java.io.PushbackReader", "java.io.RandomAccessFile", "java.io.SequenceInputStream", "java.io.StreamTokenizer", "java.io.StringReader", "java.io.StringWriter", "java.io.UTFDataFormatException", "java.io.WriteAbortedException", "java.lang.ref.PhantomReference", "java.lang.ref.Reference", "java.lang.ref.ReferenceQueue", "java.lang.ref.SoftReference", "java.lang.ref.WeakReference", "java.lang.reflect.Constructor", "java.lang.reflect.AccessibleObject", "java.lang.reflect.Member", "java.lang.reflect.Field", "java.lang.reflect.Method", "java.lang.reflect.InvocationTargetException", "java.lang.reflect.Array", "java.lang.reflect.InvocationHandler", "java.lang.reflect.Modifier", "java.lang.reflect.Proxy", "java.lang.reflect.ReflectPermission", "java.lang.reflect.UndeclaredThrowableException", "java.lang.Object", "java.lang.Exception", "java.lang.Throwable", "java.lang.CloneNotSupportedException", "java.lang.Class", "java.lang.String", "java.lang.Comparable", "java.lang.InterruptedException", "java.lang.ClassNotFoundException", "java.lang.ClassLoader", "java.lang.NoSuchMethodException", "java.lang.SecurityException", "java.lang.RuntimeException", "java.lang.NoSuchFieldException", "java.lang.IllegalAccessException", "java.lang.InstantiationException", "java.lang.Package", "java.lang.StringBuffer", "java.lang.Cloneable", "java.lang.ClassFormatError", "java.lang.LinkageError", "java.lang.Error", "java.lang.IllegalArgumentException", "java.lang.NumberFormatException", "java.lang.AbstractMethodError", "java.lang.IncompatibleClassChangeError", "java.lang.ArithmeticException", "java.lang.ArrayIndexOutOfBoundsException", "java.lang.IndexOutOfBoundsException", "java.lang.ArrayStoreException", "java.lang.Boolean", "java.lang.Byte", "java.lang.Number", "java.lang.Character$Subset", "java.lang.Character$UnicodeBlock", "java.lang.Character", "java.lang.ClassCastException", "java.lang.ClassCircularityError", "java.lang.Compiler", "java.lang.Double", "java.lang.ExceptionInInitializerError", "java.lang.Float", "java.lang.IllegalAccessError", "java.lang.IllegalMonitorStateException", "java.lang.IllegalStateException", "java.lang.IllegalThreadStateException", "java.lang.InheritableThreadLocal", "java.lang.ThreadLocal", "java.lang.InstantiationError", "java.lang.Integer", "java.lang.InternalError", "java.lang.VirtualMachineError", "java.lang.Long", "java.lang.Math", "java.lang.NegativeArraySizeException", "java.lang.NoClassDefFoundError", "java.lang.Process", "java.lang.NoSuchFieldError", "java.lang.NoSuchMethodError", "java.lang.NullPointerException", "java.lang.OutOfMemoryError", "java.lang.Runnable", "java.lang.Runtime", "java.lang.Thread", "java.lang.ThreadGroup", "java.lang.RuntimePermission", "java.lang.SecurityManager", "java.lang.Short", "java.lang.StackOverflowError", "java.lang.StrictMath", "java.lang.StringIndexOutOfBoundsException", "java.lang.System", "java.lang.ThreadDeath", "java.lang.UnknownError", "java.lang.UnsatisfiedLinkError", "java.lang.UnsupportedClassVersionError", "java.lang.UnsupportedOperationException", "java.lang.VerifyError", "java.lang.Void", "java.math.BigInteger", "java.net.URL", "java.net.URLStreamHandlerFactory", "java.net.MalformedURLException", "java.net.URLStreamHandler", "java.net.URLConnection", "java.net.InetAddress", "java.net.FileNameMap", "java.net.ContentHandlerFactory", "java.net.UnknownHostException", "java.net.ContentHandler", "java.net.Authenticator", "java.net.PasswordAuthentication", "java.net.BindException", "java.net.SocketException", "java.net.ConnectException", "java.net.DatagramPacket", "java.net.DatagramSocket", "java.net.DatagramSocketImplFactory", "java.net.DatagramSocketImpl", "java.net.SocketOptions", "java.net.HttpURLConnection", "java.net.ProtocolException", "java.net.JarURLConnection", "java.net.MulticastSocket", "java.net.NetPermission", "java.net.NoRouteToHostException", "java.net.ServerSocket", "java.net.Socket", "java.net.SocketImpl", "java.net.SocketImplFactory", "java.net.SocketPermission", "java.net.URLClassLoader", "java.net.URLDecoder", "java.net.URLEncoder", "java.net.UnknownServiceException", "java.security.acl.Acl", "java.security.acl.Owner", "java.security.acl.AclEntry", "java.security.acl.NotOwnerException", "java.security.acl.Permission", "java.security.acl.LastOwnerException", "java.security.acl.AclNotFoundException", "java.security.acl.Group", "java.security.cert.Certificate$CertificateRep", "java.security.cert.Certificate", "java.security.cert.CertificateEncodingException", "java.security.cert.CertificateException", "java.security.cert.CRL", "java.security.cert.CRLException", "java.security.cert.CertificateExpiredException", "java.security.cert.CertificateFactory", "java.security.cert.CertificateFactorySpi", "java.security.cert.CertificateNotYetValidException", "java.security.cert.CertificateParsingException", "java.security.cert.X509CRL", "java.security.cert.X509Extension", "java.security.cert.X509CRLEntry", "java.security.cert.X509Certificate", "java.security.interfaces.DSAKey", "java.security.interfaces.DSAParams", "java.security.interfaces.DSAKeyPairGenerator", "java.security.interfaces.DSAPrivateKey", "java.security.interfaces.DSAPublicKey", "java.security.interfaces.RSAKey", "java.security.interfaces.RSAPrivateCrtKey", "java.security.interfaces.RSAPrivateKey", "java.security.interfaces.RSAPublicKey", "java.security.spec.AlgorithmParameterSpec", "java.security.spec.InvalidParameterSpecException", "java.security.spec.KeySpec", "java.security.spec.InvalidKeySpecException", "java.security.spec.DSAParameterSpec", "java.security.spec.DSAPrivateKeySpec", "java.security.spec.DSAPublicKeySpec", "java.security.spec.EncodedKeySpec", "java.security.spec.PKCS8EncodedKeySpec", "java.security.spec.RSAKeyGenParameterSpec", "java.security.spec.RSAPrivateCrtKeySpec", "java.security.spec.RSAPrivateKeySpec", "java.security.spec.RSAPublicKeySpec", "java.security.spec.X509EncodedKeySpec", "java.security.ProtectionDomain", "java.security.CodeSource", "java.security.PermissionCollection", "java.security.Permission", "java.security.Guard", "java.security.GeneralSecurityException", "java.security.PublicKey", "java.security.Key", "java.security.NoSuchAlgorithmException", "java.security.InvalidKeyException", "java.security.KeyException", "java.security.NoSuchProviderException", "java.security.SignatureException", "java.security.BasicPermission", "java.security.SecureClassLoader", "java.security.AccessControlContext", "java.security.DomainCombiner", "java.security.AccessControlException", "java.security.AccessController", "java.security.PrivilegedAction", "java.security.PrivilegedExceptionAction", "java.security.PrivilegedActionException", "java.security.AlgorithmParameterGenerator", "java.security.AlgorithmParameterGeneratorSpi", "java.security.AlgorithmParameters", "java.security.AlgorithmParametersSpi", "java.security.Provider", "java.security.SecureRandom", "java.security.SecureRandomSpi", "java.security.InvalidAlgorithmParameterException", "java.security.AllPermission", "java.security.Certificate", "java.security.Principal", "java.security.DigestException", "java.security.DigestInputStream", "java.security.MessageDigest", "java.security.MessageDigestSpi", "java.security.DigestOutputStream", "java.security.GuardedObject", "java.security.Identity", "java.security.IdentityScope", "java.security.KeyManagementException", "java.security.InvalidParameterException", "java.security.KeyFactory", "java.security.KeyFactorySpi", "java.security.PrivateKey", "java.security.KeyPair", "java.security.KeyPairGenerator", "java.security.KeyPairGeneratorSpi", "java.security.KeyStore", "java.security.KeyStoreSpi", "java.security.KeyStoreException", "java.security.UnrecoverableKeyException", "java.security.Permissions", "java.security.Policy", "java.security.ProviderException", "java.security.Security", "java.security.SecurityPermission", "java.security.Signature", "java.security.SignatureSpi", "java.security.SignedObject", "java.security.Signer", "java.security.UnresolvedPermission", "java.text.resources.BreakIteratorRules", "java.text.resources.BreakIteratorRules_th", "java.text.Annotation", "java.text.AttributedCharacterIterator$Attribute", "java.text.AttributedCharacterIterator", "java.text.CharacterIterator", "java.text.AttributedString", "java.text.BreakIterator", "java.text.ChoiceFormat", "java.text.NumberFormat", "java.text.Format", "java.text.FieldPosition", "java.text.ParsePosition", "java.text.ParseException", "java.text.CollationElementIterator", "java.text.RuleBasedCollator", "java.text.Collator", "java.text.CollationKey", "java.text.DateFormat", "java.text.DateFormatSymbols", "java.text.DecimalFormat", "java.text.DecimalFormatSymbols", "java.text.MessageFormat", "java.text.SimpleDateFormat", "java.text.StringCharacterIterator", "java.util.jar.Attributes$Name", "java.util.jar.Attributes", "java.util.jar.JarEntry", "java.util.jar.Manifest", "java.util.jar.JarFile", "java.util.jar.JarException", "java.util.jar.JarInputStream", "java.util.jar.JarOutputStream", "java.util.zip.ZipEntry", "java.util.zip.ZipConstants", "java.util.zip.ZipFile", "java.util.zip.ZipException", "java.util.zip.ZipInputStream", "java.util.zip.InflaterInputStream", "java.util.zip.Inflater", "java.util.zip.DataFormatException", "java.util.zip.ZipOutputStream", "java.util.zip.DeflaterOutputStream", "java.util.zip.Deflater", "java.util.zip.Adler32", "java.util.zip.Checksum", "java.util.zip.CRC32", "java.util.zip.CheckedInputStream", "java.util.zip.CheckedOutputStream", "java.util.zip.GZIPInputStream", "java.util.zip.GZIPOutputStream", "java.util.Locale", "java.util.Comparator", "java.util.Enumeration", "java.util.MissingResourceException", "java.util.Properties", "java.util.Hashtable", "java.util.Dictionary", "java.util.Map$Entry", "java.util.Map", "java.util.Set", "java.util.Collection", "java.util.Iterator", "java.util.Random", "java.util.Date", "java.util.Calendar", "java.util.TimeZone", "java.util.ListResourceBundle", "java.util.ResourceBundle", "java.util.AbstractCollection", "java.util.AbstractList", "java.util.List", "java.util.ListIterator", "java.util.AbstractMap", "java.util.AbstractSequentialList", "java.util.AbstractSet", "java.util.ArrayList", "java.util.Arrays", "java.util.BitSet", "java.util.Collections", "java.util.SortedMap", "java.util.SortedSet", "java.util.ConcurrentModificationException", "java.util.EmptyStackException", "java.util.EventListener", "java.util.EventObject", "java.util.GregorianCalendar", "java.util.HashMap", "java.util.HashSet", "java.util.LinkedList", "java.util.NoSuchElementException", "java.util.Observable", "java.util.Observer", "java.util.PropertyPermission", "java.util.PropertyResourceBundle", "java.util.SimpleTimeZone", "java.util.Stack", "java.util.Vector", "java.util.StringTokenizer", "java.util.Timer", "java.util.TimerTask", "java.util.TooManyListenersException", "java.util.TreeMap", "java.util.TreeSet", "java.util.WeakHashMap", "javax.microedition.io.Connection", "javax.microedition.io.ConnectionNotFoundException", "javax.microedition.io.Connector", "javax.microedition.io.ContentConnection", "javax.microedition.io.StreamConnection", "javax.microedition.io.InputConnection", "javax.microedition.io.OutputConnection", "javax.microedition.io.Datagram", "javax.microedition.io.DatagramConnection", "javax.microedition.io.HttpConnection", "javax.microedition.io.StreamConnectionNotifier", }; final static String[] EE_SMF = { "java.io.BufferedInputStream", "java.io.BufferedOutputStream", "java.io.BufferedReader", "java.io.BufferedWriter$1", "java.io.BufferedWriter", "java.io.ByteArrayInputStream", "java.io.ByteArrayOutputStream", "java.io.CharConversionException", "java.io.DataInput", "java.io.DataInputStream", "java.io.DataOutput", "java.io.DataOutputStream", "java.io.EmulatedFields$ObjectSlot", "java.io.EmulatedFields", "java.io.EmulatedFieldsForDumping", "java.io.EmulatedFieldsForLoading", "java.io.EOFException", "java.io.Externalizable", "java.io.File$1", "java.io.File$2", "java.io.File", "java.io.FileDescriptor", "java.io.FileInputStream", "java.io.FileNotFoundException", "java.io.FileOutputStream", "java.io.FilePermission$1", "java.io.FilePermission", "java.io.FilePermissionCollection", "java.io.FileReader", "java.io.FileWriter", "java.io.FilterInputStream", "java.io.FilterOutputStream", "java.io.InputStream", "java.io.InputStreamReader$1", "java.io.InputStreamReader", "java.io.InterruptedIOException", "java.io.InvalidClassException", "java.io.InvalidObjectException", "java.io.IOException", "java.io.NotActiveException", "java.io.NotSerializableException", "java.io.ObjectInput", "java.io.ObjectInputStream$1", "java.io.ObjectInputStream$2", "java.io.ObjectInputStream$GetField", "java.io.ObjectInputStream$InputValidationDesc", "java.io.ObjectInputStream", "java.io.ObjectInputValidation", "java.io.ObjectOutput", "java.io.ObjectOutputStream$1", "java.io.ObjectOutputStream$2", "java.io.ObjectOutputStream$PutField", "java.io.ObjectOutputStream", "java.io.ObjectStreamClass$1", "java.io.ObjectStreamClass$2", "java.io.ObjectStreamClass$3", "java.io.ObjectStreamClass$4", "java.io.ObjectStreamClass$5", "java.io.ObjectStreamClass$6", "java.io.ObjectStreamClass", "java.io.ObjectStreamConstants", "java.io.ObjectStreamException", "java.io.ObjectStreamField$1", "java.io.ObjectStreamField", "java.io.OptionalDataException", "java.io.OutputStream", "java.io.OutputStreamWriter$1", "java.io.OutputStreamWriter", "java.io.PrintStream$1", "java.io.PrintStream", "java.io.PrintWriter$1", "java.io.PrintWriter", "java.io.PushbackInputStream", "java.io.RandomAccessFile", "java.io.Reader", "java.io.Serializable", "java.io.SerializablePermission", "java.io.StreamCorruptedException", "java.io.StringReader", "java.io.StringWriter", "java.io.SyncFailedException", "java.io.UnsupportedEncodingException", "java.io.UTFDataFormatException", "java.io.WriteAbortedException", "java.io.Writer", "java.lang.AbstractMethodError", "java.lang.ArithmeticException", "java.lang.ArrayIndexOutOfBoundsException", "java.lang.ArrayStoreException", "java.lang.Boolean", "java.lang.Byte", "java.lang.Character", "java.lang.Class", "java.lang.ClassCastException", "java.lang.ClassCircularityError", "java.lang.ClassFormatError", "java.lang.ClassLoader$1", "java.lang.ClassLoader$2", "java.lang.ClassLoader", "java.lang.ClassNotFoundException", "java.lang.Cloneable", "java.lang.CloneNotSupportedException", "java.lang.Comparable", "java.lang.Double", "java.lang.Error", "java.lang.Exception", "java.lang.ExceptionInInitializerError", "java.lang.Float", "java.lang.IllegalAccessError", "java.lang.IllegalAccessException", "java.lang.IllegalArgumentException", "java.lang.IllegalMonitorStateException", "java.lang.IllegalStateException", "java.lang.IllegalThreadStateException", "java.lang.IncompatibleClassChangeError", "java.lang.IndexOutOfBoundsException", "java.lang.InstantiationError", "java.lang.InstantiationException", "java.lang.Integer", "java.lang.InternalError", "java.lang.InterruptedException", "java.lang.LinkageError", "java.lang.Long", "java.lang.Math", "java.lang.NegativeArraySizeException", "java.lang.NoClassDefFoundError", "java.lang.NoSuchFieldError", "java.lang.NoSuchFieldException", "java.lang.NoSuchMethodError", "java.lang.NoSuchMethodException", "java.lang.NullPointerException", "java.lang.Number", "java.lang.NumberFormatException", "java.lang.Object", "java.lang.OutOfMemoryError", "java.lang.Process", "java.lang.ref.PhantomReference", "java.lang.ref.Reference", "java.lang.ref.ReferenceQueue", "java.lang.ref.SoftReference", "java.lang.ref.WeakReference", "java.lang.reflect.AccessibleObject", "java.lang.reflect.Array", "java.lang.reflect.Constructor", "java.lang.reflect.Field", "java.lang.reflect.InvocationHandler", "java.lang.reflect.InvocationTargetException", "java.lang.reflect.Member", "java.lang.reflect.Method", "java.lang.reflect.Modifier", "java.lang.reflect.Proxy", "java.lang.reflect.ReflectPermission", "java.lang.reflect.UndeclaredThrowableException", "java.lang.Runnable", "java.lang.Runtime", "java.lang.RuntimeException", "java.lang.RuntimePermission", "java.lang.SecurityException", "java.lang.SecurityManager$1", "java.lang.SecurityManager$2", "java.lang.SecurityManager", "java.lang.Short", "java.lang.StackOverflowError", "java.lang.StackTraceElement", "java.lang.String$CaseInsensitiveComparator", "java.lang.String", "java.lang.StringBuffer", "java.lang.StringIndexOutOfBoundsException", "java.lang.System", "java.lang.Thread", "java.lang.ThreadDeath", "java.lang.ThreadGroup", "java.lang.Throwable", "java.lang.UnknownError", "java.lang.UnsatisfiedLinkError", "java.lang.UnsupportedOperationException", "java.lang.VerifyError", "java.lang.VirtualMachineError", "java.lang.Void", "java.net.Authenticator", "java.net.BindException", "java.net.ConnectException", "java.net.ContentHandler", "java.net.ContentHandlerFactory", "java.net.DatagramPacket", "java.net.DatagramSocket$1", "java.net.DatagramSocket", "java.net.DatagramSocketImpl", "java.net.FileNameMap", "java.net.HttpURLConnection", "java.net.InetAddress$1", "java.net.InetAddress$Cache", "java.net.InetAddress$CacheElement", "java.net.InetAddress", "java.net.JarURLConnection", "java.net.MalformedURLException", "java.net.MulticastSocket", "java.net.NetPermission", "java.net.NoRouteToHostException", "java.net.PasswordAuthentication", "java.net.PlainDatagramSocketImpl$1", "java.net.PlainDatagramSocketImpl", "java.net.PlainSocketImpl$1", "java.net.PlainSocketImpl$2", "java.net.PlainSocketImpl$3", "java.net.PlainSocketImpl", "java.net.ProtocolException", "java.net.ServerSocket", "java.net.Socket", "java.net.SocketException", "java.net.SocketImpl", "java.net.SocketImplFactory", "java.net.SocketInputStream", "java.net.SocketOptions", "java.net.SocketOutputStream", "java.net.SocketPermission", "java.net.SocketPermissionCollection", "java.net.Socks4Message", "java.net.UnknownHostException", "java.net.UnknownServiceException", "java.net.URL$1", "java.net.URL", "java.net.URLConnection$1", "java.net.URLConnection$2", "java.net.URLConnection$DefaultContentHandler", "java.net.URLConnection", "java.net.URLDecoder", "java.net.URLEncoder", "java.net.URLStreamHandler", "java.net.URLStreamHandlerFactory", "java.security.AccessControlContext", "java.security.AccessControlException", "java.security.AccessController", "java.security.AllPermission", "java.security.AllPermissionCollection", "java.security.BasicPermission", "java.security.BasicPermissionCollection", "java.security.cert.Certificate", "java.security.CodeSource", "java.security.Permission", "java.security.PermissionCollection$1", "java.security.PermissionCollection", "java.security.Permissions$PermissionsEnumeration", "java.security.Permissions", "java.security.PermissionsHash", "java.security.Policy", "java.security.Principal", "java.security.PrivilegedAction", "java.security.PrivilegedActionException", "java.security.PrivilegedExceptionAction", "java.security.ProtectionDomain$1", "java.security.ProtectionDomain", "java.security.Security", "java.security.SecurityPermission", "java.security.UnresolvedPermission", "java.security.UnresolvedPermissionCollection$1", "java.security.UnresolvedPermissionCollection", "java.util.AbstractCollection", "java.util.AbstractList$FullListIterator", "java.util.AbstractList$SimpleListIterator", "java.util.AbstractList$SubList$SubListIterator", "java.util.AbstractList$SubList", "java.util.AbstractList", "java.util.AbstractMap$1", "java.util.AbstractMap$2", "java.util.AbstractMap$3", "java.util.AbstractMap$4", "java.util.AbstractMap", "java.util.AbstractSequentialList", "java.util.AbstractSet", "java.util.ArrayList", "java.util.Arrays$ArrayList", "java.util.Arrays", "java.util.Calendar", "java.util.Collection", "java.util.Collections$1", "java.util.Collections$2", "java.util.Collections$3", "java.util.Collections$4", "java.util.Collections$5", "java.util.Collections$6", "java.util.Collections$7", "java.util.Collections$8", "java.util.Collections$9", "java.util.Collections$CopiesList", "java.util.Collections$EmptyList", "java.util.Collections$EmptyMap", "java.util.Collections$EmptySet", "java.util.Collections$ReverseComparator", "java.util.Collections$SingletonList", "java.util.Collections$SingletonMap", "java.util.Collections$SingletonSet", "java.util.Collections$SynchronizedCollection", "java.util.Collections$SynchronizedList", "java.util.Collections$SynchronizedMap", "java.util.Collections$SynchronizedSet", "java.util.Collections$SynchronizedSortedMap", "java.util.Collections$SynchronizedSortedSet", "java.util.Collections$UnmodifiableCollection", "java.util.Collections$UnmodifiableList", "java.util.Collections$UnmodifiableMap$UnmodifiableEntrySet$UnmodifiableEntry", "java.util.Collections$UnmodifiableMap$UnmodifiableEntrySet", "java.util.Collections$UnmodifiableMap", "java.util.Collections$UnmodifiableSet", "java.util.Collections$UnmodifiableSortedMap", "java.util.Collections$UnmodifiableSortedSet", "java.util.Collections", "java.util.Comparator", "java.util.ConcurrentModificationException", "java.util.Date", "java.util.Dictionary", "java.util.Enumeration", "java.util.EventListener", "java.util.EventObject", "java.util.GregorianCalendar", "java.util.HashMapEntry", "java.util.Hashtable$1", "java.util.Hashtable$2", "java.util.Hashtable$3", "java.util.Hashtable$4", "java.util.Hashtable$5", "java.util.Hashtable$6", "java.util.Hashtable$EmptyEnumerator", "java.util.Hashtable$HashEnumerator", "java.util.Hashtable$HashIterator", "java.util.Hashtable", "java.util.Iterator", "java.util.List", "java.util.ListIterator", "java.util.ListResourceBundle$1", "java.util.ListResourceBundle", "java.util.Locale$1", "java.util.Locale", "java.util.Map$Entry", "java.util.Map", "java.util.MapEntry$Type", "java.util.MapEntry", "java.util.MissingResourceException", "java.util.NoSuchElementException", "java.util.Properties$1", "java.util.Properties", "java.util.PropertyPermission", "java.util.PropertyPermissionCollection", "java.util.PropertyResourceBundle$1", "java.util.PropertyResourceBundle", "java.util.Random", "java.util.ResourceBundle$1", "java.util.ResourceBundle$MissingBundle", "java.util.ResourceBundle", "java.util.Set", "java.util.SimpleTimeZone", "java.util.SortedMap", "java.util.SortedSet", "java.util.StringTokenizer", "java.util.TimeZone$1", "java.util.TimeZone", "java.util.TimeZones", "java.util.Vector$1", "java.util.Vector", "java.util.WeakHashMap$1", "java.util.WeakHashMap$HashIterator", "java.util.WeakHashMap$KeyEntry", "java.util.WeakHashMap$WeakHashMapEntry", "java.util.WeakHashMap", "java.util.zip.Checksum", "java.util.zip.CRC32", "java.util.zip.DataFormatException", "java.util.zip.Inflater", "java.util.zip.InflaterInputStream", "java.util.zip.ZipConstants", "java.util.zip.ZipEntry", "java.util.zip.ZipException", "java.util.zip.ZipFile$ZFEnum", "java.util.zip.ZipFile", "java.util.zip.ZipInputStream", }; static Hashtable foundationMap = new Hashtable(); static Hashtable minimumMap = new Hashtable(); static Hashtable smfMap = new Hashtable(); /** * Check if a class is allowed by the "Foundation" profile. */ public static boolean isFoundation(String className) { return foundationMap.containsKey(className); } /** * Check if a class is allowed by the "Mimimum" profile. */ public static boolean isMinimum(String className) { return minimumMap.containsKey(className); } /** * Check if a class is allowed by the "Mimimum" profile. */ public static boolean isSMF(String className) { return smfMap.containsKey(className); } static { for(int i = 0; i < EE_FOUNDATION.length; i++) { foundationMap.put(EE_FOUNDATION[i], ""); } for(int i = 0; i < EE_MINIMUM.length; i++) { minimumMap.put(EE_MINIMUM[i], ""); } for(int i = 0; i < EE_SMF.length; i++) { smfMap.put(EE_SMF[i], ""); } } } ././@LongLink0000000000000000000000000000015600000000000011567 Lustar rootrootknopflerfish-osgi-2.3.3/knopflerfish.org/ant/src/org/knopflerfish/ant/taskdefs/bundle/BundleManifestTask.javaknopflerfish-osgi-2.3.3/knopflerfish.org/ant/src/org/knopflerfish/ant/taskdefs/bundle/BundleManifest0000644000175000017500000007171111252437456033722 0ustar twernertwerner/* * Copyright (c) 2003-2006, KNOPFLERFISH project * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * - Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * - 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. * * - Neither the name of the KNOPFLERFISH project nor the names of its * contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS 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 * COPYRIGHT OWNER OR 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. */ package org.knopflerfish.ant.taskdefs.bundle; import java.io.File; import java.io.FileInputStream; import java.io.InputStreamReader; import java.io.FileOutputStream; import java.io.OutputStreamWriter; import java.io.IOException; import java.io.PrintWriter; import java.util.Enumeration; import java.util.Hashtable; import java.util.StringTokenizer; import java.util.Vector; import org.apache.tools.ant.BuildException; import org.apache.tools.ant.Project; import org.apache.tools.ant.Task; import org.apache.tools.ant.taskdefs.Manifest; import org.apache.tools.ant.taskdefs.ManifestException; import org.apache.tools.ant.types.EnumeratedAttribute; /** * Extension of the standard Manifest task. *

* This task builds a manifest file from three different sources: *

    *
  1. A template manifest file. *
  2. Project properties with given prefix. *
  3. Nested attribute and section data. *
* It may also be used to create properties (with a given prefix) for * each main section attribute in the template manifest file. * *

Parameters

* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
AttributeDescriptionRequired
filethe manifest-file to create. * Yes if "attributePropertyPrefix" is empty, otherwise No.
encoding * The encoding used to read the existing manifest when updating.No, defaults to UTF-8 encoding.
mode * One of "update", "replace", "template" and "templateOnly" * default is "replace". *

* The "mode" determines which sources to use when creating the * resulting manifest: *

*
replace
Use properties and nested data. *
update
Use template, properties and nested data. *
template
Use template and nested data. *
templateOnly
Use template. *
*
No.
templateFilethe template mainfest file to load.No.
attributePropertyPrefixIf set and a template file is given but no file * to write to export all attributes * from the main section of the template file as * properties. *

* If set and mode is one of "update", "replace" * then create main section attributes for all * project properties that starts with the prefix. *

* If set and "file" is given then export all attributes * written to the main section as properties. *

* The name of property that mapps to a main * section attribute is the value of * "attributePropertyPrefix" followed by the * attribute name. The value is the attribute value. *

No.
kindThe kind of bundle that the manifest is for. *

* If given this string will be appended to the * following manifest attributes of the main section: *

    *
  • Bundle-Name *
  • Bundle-SymbolicName *
  • Bundle-UUID *
  • Bundle-Description *
  • Bundle-Category (only for kind="api"). *
* All main section manifest attribute starting * with "kind-" will be replaced with a main section * attribute without the prefix. E.g., if kind="api" * and there is an attribute named "api-Export-Package" * then it will be renamed to "Export-Package", overriding * any previous definition of "Export-Package". *
No.
mainAttributesToSkipComma separated list with names of main section * attributes to weed out when writing the * manifest file. * No.
verboseIf set to "true" then log the name of the * bundle activator together with the imported * and exported packagesNo.
* *

Nested elements

* *

attribute

*

One attribute for the manifest file. Those attributes that are * not nested into a section will be added to the "Main" section.

* * * * * * * * * * * * * * * * *
AttributeDescriptionRequired
namethe name of the attribute.Yes
valuethe value of the attribute.Yes
* * *

section

*

A manifest section - you can nest attribute elements into sections.

* * * * * * * * * * * * *
AttributeDescriptionRequired
namethe name of the section.No, if omitted it will be assumed * to be the main section.
* *

Examples

* *

Build bundle manifest for the impl jar

* *
 *  <bundlemanifest mode="template"
 *                  kind="impl"
 *                  mainAttributesToSkip="Export-Package"
 *                  attributePropertyPrefix="bmfa."
 *                  templateFile="bundle.manifest"
 *                  verbose="true"
 *                  file="${outdir}/impl.mf">
 *     <attribute name="Build-Date"       value="${bundle.date}"/>
 *     <attribute name="Built-From"       value="${proj.dir}"/>
 *   </bundlemanifest>
 * 
* * *

Create properties for main section attributes in the template * manifest file

* *
 *   <bundlemanifest mode="template"
 *                   attributePropertyPrefix = "bmfa."
 *                   templateFile="bundle.manifest">
 *   </bundlemanifest>
 * 
* */ public class BundleManifestTask extends Task { /** * Default constructor. */ public BundleManifestTask() { super(); mode = new Mode(); mode.setValue("replace"); } /** * Helper class for bundle manifest's mode attribute. */ public static class Mode extends EnumeratedAttribute { /** * Get Allowed values for the mode attribute. * * @return a String array of the allowed values. */ public String[] getValues() { return new String[] {"update", "replace", "template", "templateOnly"}; } } /** * The mode with which the manifest file is written */ private Mode mode; /** * The encoding of the manifest template file. */ private String encoding; /** * Comma separated list of names of attributes that must not be * present in the main section of the resulting manifest. */ private String mainAttributesToSkip; /** * The kind of bundle to generate manifest for. * If given this string will be appended to the following manifest * attributes of the main section: *
    *
  • Bundle-Name *
  • Bundle-SymbolicName *
  • Bundle-UUID *
*/ private String bundleKind; /** * Prefix of project properties to add main section attributes for. * * For each property in the project with a name that starts with this * prefix a manifest attribute in the main section will be created. * The attribute name will be the property name without the prefix * and the attribute value will be the property value. */ private String attributePropertyPrefix; /** * The manifest template file. */ private File manifestTemplateFile; /** * The manifest file to create. */ private File manifestFile; /** * Holds explicit manifest data given in the build file. */ private Manifest manifestNested = new Manifest(); /** * The encoding to use for reading in the manifest template file. * Default encoding is UTF-8. * * @param encoding the manifest template file encoding. */ public void setEncoding(String encoding) { this.encoding = encoding; } /** * The name of the template manifest file. * * @param f the template manifest file to load. */ public void setTemplateFile(File f) { manifestTemplateFile = f; } /** * The name of the manifest file to create. * * @param f the manifest file to write. */ public void setFile(File f) { manifestFile = f; } /** * Which sources to use when creating the resulting manifest. *
*
replace
Use properties and nested data. *
update
Use template, properties and nested data. *
template
Use template and nested data. *
templateOnly
Use template. *
* @param m the mode value one of - update, * replace, template and * templateOnly. */ public void setMode(Mode m) { mode = m; } /** * Comma separated list of attributes to skip from the main section. * @param s main section attributes to skip from out put. */ public void setMainAttributesToSkip(String s) { mainAttributesToSkip = s.trim(); } /** * Bundle kind, will be appended to some of the bundle specific * attributes in the main section. * @param s the kind of bundle that we are writing a manifest file for. */ public void setKind(String s) { bundleKind = s.trim(); } /** * If set to true the bundle activator, export package and import * package list in the written manifest will be printed on the * console. */ private boolean verbose = false; /** * Set the verbosity of this task. * If set to true the bundle activator, export package and import * package list in the written manifest will be printed on the * console. * @param b verbose or not. */ public void setVerbose(boolean b) { verbose = b; } private void doVerbose(Manifest mf) { if (verbose) { Manifest.Section ms = mf.getMainSection(); doVerbose( ms, "Bundle-Activator", "activator"); doVerbose( ms, "Export-Package", "exports"); doVerbose( ms, "Import-Package", "imports"); } } private void doVerbose(Manifest.Section ms, String attrName, String heading) { Manifest.Attribute ma = ms.getAttribute(attrName); if (null!=ma) { String val = ma.getValue(); if (!isPropertyValueEmpty(val)) { log( heading +" = "+val, Project.MSG_INFO); } } } /** * Set the prefix of project properties to add main section * attributes for. * * For each property in the project with a name that starts with this * prefix a manifest attribute in the main section will be created. * The attribute name will be the property name without the prefix * and the attribute value will be the property value. * * @param s the property names prefix to check for. */ public void setAttributePropertyPrefix( String s) { attributePropertyPrefix = s; } /** * If attributePropertyPrefix is set then iterate over * all properties and add attributes to the main section of * the given manifest for those properties that starts with the prefix. * * The name of the attribute will be the property name without the * prefix and the value will be the property value. * * @param mf The manifest to add the property based attributes to. */ private void addAttributesFromProperties(Manifest mf) { if (null!=attributePropertyPrefix) { int prefixLength = attributePropertyPrefix.length(); Project project = getProject(); Manifest.Section mainS = mf.getMainSection(); Hashtable properties = project.getProperties(); for (Enumeration pe = properties.keys(); pe.hasMoreElements();) { String key = (String) pe.nextElement(); if (key.startsWith(attributePropertyPrefix)) { String attrName = key.substring(prefixLength); String attrValue = (String) properties.get(key); if(!BUNDLE_EMPTY_STRING.equals(attrValue)) { Manifest.Attribute attr = mainS.getAttribute(attrName); if (null!=attr) { throw new BuildException ( "Can not add main section attribute for property '" +key+"' with value '"+attrValue+"' since a " +"main section attribute with that name exists: '" +attr.getName() +": "+attr.getValue() +"'.", getLocation()); } try { attr = new Manifest.Attribute(attrName, attrValue); mf.addConfiguredAttribute(attr); log("from propety '" +attrName +": "+attrValue+"'.", Project.MSG_VERBOSE); } catch (ManifestException me) { throw new BuildException ( "Failed to add main section attribute for property '" +key+"' with value '"+attrValue+"'.\n"+me.getMessage(), me, getLocation()); } } } } } } /** * We must ensure that the case used in attribute names when they * are mapped to properties by * updatePropertiesFromMainSectionAttributeValues() are * the same as the one used in the build files, i.e., the one used * in the OSGi specification. If not it may happen that a we get two * propreties defined for the same attribute (with different cases) * if this happens there will be an error when adding back the * properties to the generated manifest. Thus we need a list of all * OSGi specified attribute names in the case used in the * specification. */ private static final String[] osgiAttrNames = new String[]{ "Application-Icon", "Bundle-APIVendor", "Bundle-Activator", "Bundle-Category", "Bundle-Classpath", "Bundle-Config", "Bundle-ContactAddress", "Bundle-Copyright", "Bundle-Description", "Bundle-DocURL", "Bundle-Localization", "Bundle-ManifestVersion", "Bundle-Name", "Bundle-NativeCode", "Bundle-RequiredExecutionEnvironment", "Bundle-SubversionURL", "Bundle-SymbolicName", "Bundle-UUID", "Bundle-UpdateLocation", "Bundle-Vendor", "Bundle-Version", "DynamicImport-Package", "Export-Package", "Export-Service", "Fragment-Host", "Import-Package", "Import-Service", "Require-Bundle", "Service-Component", }; /** * Mapping from attribute key, all lowercase, to attribute name * with case according to the OSGi specification. */ private static final Hashtable osgiAttrNamesMap = new Hashtable(); static { for (int i=0; iattributePropertyPrefix is set then iterate over * all attributes in the main section and set the value for * corresponding property to the value of that attribute. * * The name of the attribute will be the property name without the * prefix and the value will be the property value. */ private void updatePropertiesFromMainSectionAttributeValues(Manifest mf) { if (null!=attributePropertyPrefix) { int prefixLength = attributePropertyPrefix.length(); Project project = getProject(); Manifest.Section mainS = mf.getMainSection(); for (Enumeration ae = mainS.getAttributeKeys(); ae.hasMoreElements();) { String key = (String) ae.nextElement(); Manifest.Attribute attr = mainS.getAttribute(key); // Ensure that the default case is used for OSGi specified attributes String propKey = attributePropertyPrefix + (osgiAttrNamesMap.containsKey(key) ? osgiAttrNamesMap.get(key) : attr.getName() ); String propVal = attr.getValue(); log("setting '" +propKey +"'='"+propVal+"'.", Project.MSG_VERBOSE); project.setProperty(propKey,propVal); } } } /** * Replace all main section attributes that starts with the * specified prefix with an attribute without that prefix, * overriding any old definition. * @param mf The manifest to update * @param prefix The prefix to match on. */ private void overrideAttributes(Manifest mf, String prefix) { if (null!=prefix && 0null, the empty string * or the special value BundleManifestTask.BUNDLE_EMPTY_STRING. * * @param pval The property value to check. * @return true if the value is empty. */ static protected boolean isPropertyValueEmpty( String pval ) { return null==pval || "".equals(pval) || BUNDLE_EMPTY_STRING.equals(pval); } /** * Add an attribute to the main section of the manifest. * Attributes with the value BUNDLE_EMPTY_STRING are not added. * * @param attribute the attribute to be added. * * @exception ManifestException if the attribute is not valid. */ public void addConfiguredAttribute(Manifest.Attribute attribute) throws ManifestException { if(BUNDLE_EMPTY_STRING.equals(attribute.getValue())) { return; } manifestNested.addConfiguredAttribute(attribute); } /** * Ensure that the named main section attribute ends with the * specified suffix. * @param mf The manifest object to work with. * @param attrName The name of the attribute to check / update. * @param suffix The required suffix. */ private void ensureAttrEndsWith(Manifest mf, String attrName, String suffix){ Manifest.Attribute attr = mf.getMainSection().getAttribute(attrName); if (null!=attr && !attr.getValue().endsWith(suffix)) attr.setValue( attr.getValue() +suffix ); } /** * Ensure that the named main section attribute have the given * value. * @param mf The manifest object to work with. * @param attrName The name of the attribute to check / update. * @param value The required attribute value. */ private void ensureAttrValue(Manifest mf, String attrName, String value){ Manifest.Attribute ma = mf.getMainSection().getAttribute(attrName); if (null==ma) { ma = new Manifest.Attribute(attrName,value); try { mf.getMainSection().addConfiguredAttribute(ma); } catch (ManifestException me) { throw new BuildException("ensureAttrValue("+attrName+"," +value +") failed.", me, getLocation()); } } else { ma.setValue(value); } } /** * Create or update the Manifest when used as a task. * * @throws BuildException if the manifest cannot be written. */ public void execute() throws BuildException { if (mode.getValue().equals("update") && manifestTemplateFile==null) { throw new BuildException("the template file attribute is required" +" when mode is \"update\""); } if (mode.getValue().startsWith("template") && manifestTemplateFile==null) { throw new BuildException("the template file attribute is required" +" when mode is \"" +mode.getValue() +"\""); } Manifest manifestProps = new Manifest(); if (!mode.getValue().equals("templateOnly")) { addAttributesFromProperties(manifestProps); } Manifest manifestToWrite = Manifest.getDefaultManifest(); Manifest manifestTemplate = null; if (null!=manifestTemplateFile && manifestTemplateFile.exists()) { FileInputStream is = null; InputStreamReader ir = null; try { is = new FileInputStream(manifestTemplateFile); if (encoding == null) { ir = new InputStreamReader(is, "UTF-8"); } else { ir = new InputStreamReader(is, encoding); } manifestTemplate = new Manifest(ir); } catch (ManifestException me) { throw new BuildException("Template manifest " + manifestTemplateFile + " is invalid", me, getLocation()); } catch (IOException ioe) { throw new BuildException("Failed to read " + manifestTemplateFile, ioe, getLocation()); } finally { if (ir != null) { try { ir.close(); } catch (IOException e) { // ignore } } } } try { if (mode.getValue().equals("update")) { // resutling manifest based on data from // template file + manifest properties + nested data if (manifestTemplate != null) { manifestToWrite.merge(manifestTemplate); } manifestToWrite.merge(manifestProps); manifestToWrite.merge(manifestNested); log("Creating bundle manifets based on '" +manifestTemplateFile +"' merged with data from" +" manifest properties and nested elements.", manifestFile==null ? Project.MSG_DEBUG: Project.MSG_VERBOSE); } if (mode.getValue().equals("replace")) { // resutling manifest based on propeties and nested data manifestToWrite.merge(manifestProps); manifestToWrite.merge(manifestNested); log("Creating bundle manifets based on data from" +" properties and nested elements.", manifestFile==null ? Project.MSG_DEBUG: Project.MSG_VERBOSE); } if (mode.getValue().startsWith("template")) { // resutling manifest based on template and nested data. if (manifestTemplate != null) { manifestToWrite.merge(manifestTemplate); } if (!mode.getValue().equals("templateOnly")) { manifestToWrite.merge(manifestNested); log("Creating bundle manifets based on '" +manifestTemplateFile +"' and nested elements.", manifestFile==null ? Project.MSG_DEBUG: Project.MSG_VERBOSE); } else { log("Creating bundle manifets based on '" +manifestTemplateFile +"'.", manifestFile==null ? Project.MSG_DEBUG: Project.MSG_VERBOSE); } } } catch (ManifestException me) { throw new BuildException("Manifest is invalid", me, getLocation()); } if (null!=mainAttributesToSkip && 0 knopflerfish-osgi-2.3.3/knopflerfish.org/ant/build_example.xml0000644000175000017500000000731011252437456024516 0ustar twernertwerner knopflerfish-osgi-2.3.3/knopflerfish.org/ant/html_template/0000755000175000017500000000000011252437454024016 5ustar twernertwernerknopflerfish-osgi-2.3.3/knopflerfish.org/ant/html_template/bundle_header.html0000644000175000017500000000223511252437454027467 0ustar twernertwerner knopflerfish-osgi-2.3.3/knopflerfish.org/ant/html_template/bundledoc_ext.html0000644000175000017500000000046011252437454027523 0ustar twernertwerner Knopflerfish - Bundle Documentation $(MAIN) knopflerfish-osgi-2.3.3/knopflerfish.org/ant/html_template/bundle_index.html0000644000175000017500000000110411252437454027340 0ustar twernertwerner Knopflerfish - Bundle Jar Documentation knopflerfish-osgi-2.3.3/knopflerfish.org/ant/html_template/bundledoc.html0000644000175000017500000000120211252437454026636 0ustar twernertwerner Bundle User Documentation - $(BUNDLE_NAME):$(BUNDLE_VERSION)
Bundle: $(BUNDLE_NAME)
Version $(BUNDLE_VERSION)
$(MAIN)

Jar docs

$(BUNDLE_JARDOCS)

Exported Packages

$(BUNDLE_EXPORT_PACKAGE)
knopflerfish-osgi-2.3.3/knopflerfish.org/ant/html_template/bundle_info.html0000644000175000017500000000276111252437454027176 0ustar twernertwerner Bundle info: ${FILE}

${FILE}

download (${FILEINFO})

${MF.UNHANDLED}
OSGi manifest attributes
Bundle-Name ${Bundle-Name}
Bundle-Description ${Bundle-Description}
Bundle-Version ${Bundle-Version}
Bundle-Vendor ${Bundle-Vendor}
Bundle-Activator ${Bundle-Activator}
Bundle-DocURL ${Bundle-DocURL}
Bundle-ContactAddress ${Bundle-ContactAddress}
Bundle-Classpath ${Bundle-Classpath}
Export-Package ${Export-Package}
Import-Package ${Import-Package}
Export-Service ${Export-Service}
Import-Service ${Import-Service}
Other manifest attributes

Depends on

${depends.list}

Other bundles depending on this bundle

${depending.list}

Bundle source

${sources.list} knopflerfish-osgi-2.3.3/knopflerfish.org/ant/html_template/bundle_main.html0000644000175000017500000000123111252437454027156 0ustar twernertwerner Bundles

Bundle Jar Documentation

This section contains information on all bundle jar files included in this distribution of Knopflerfish.

Select the bundles from the bundle list to the left to view detailed bundle information, including manifest headers, bundle dependencies and derived javadoc links based on imported and exported packages.

${unresolved.list}

Bundle Jars Listing

${bundle.list}

knopflerfish-osgi-2.3.3/knopflerfish.org/ant/html_template/style.css0000644000175000017500000000574211252437454025700 0ustar twernertwernerBODY { font-family: Verdana, Arial, Helvetica, sans-serif; font-size:11px; color:000000; text-align:left; font-weight:normal; background:#fff; } TD { font-family: Verdana, Arial, Helvetica, sans-serif; text-align:left; vertical-align:top; font-size:11px; } TD A { color:000000; text-decoration:none font-size:11px; } .mfheader { font-family: Verdana, Arial, Helvetica, sans-serif; text-align:left; vertical-align:top; font-size:11px; font-weight:bold; background: #805362; color: #fff; padding-top: 2px; padding-bottom: 2px; } TH { font-family: Verdana, Arial, Helvetica, sans-serif; font-size:11px; color:000000; text-align:left; vertical-align:top; font-weight:bold } TD A { color:000000; text-decoration:none font-size:11px; } PRE { font-family: Courier New, Courier; font-size:11px; color:000000; text-align:left; font-weight:normal; } H1 { font-family: Verdana, Arial, Helvetica, sans-serif; font-size:19px; font-weight:bold; background: #dddddd; } H3 { font-family: Verdana, Arial, Helvetica, sans-serif; font-size:13px; font-weight:bold; background: #805362; color: #fff; padding: 2px 0px 2px 3px; } H4 { font-family: Verdana, Arial, Helvetica, sans-serif; font-size:11px; font-weight:bold; background: #805362; color: #fff; padding: 2px 0px 2px 3px; } H5 { font-family: Verdana, Arial, Helvetica, sans-serif; font-size:9px; font-weight:bold; background: #805362; color: #fff; padding: 2px 0px 2px 3px; } H6 { font-family: Verdana, Arial, Helvetica, sans-serif; font-size:7px; font-weight:bold } TD.menu { color: #ffffff; font-size:9px; font-weight:bold; text-align:left; } A.top { float: right; text-decoration: none; font-weight: bold; } A, A:visited, A:selected, A:active { color:000000; text-decoration: none; font-weight: bold; } A:hover { text-decoration: underline; } li.A:visited, li.A:selected, li.A:active { text-decoration: none; font-weight: bold; } li.A:hover { text-decoration: underline; } .small { font-size:9px; } .medium { font-size:13px; } .big { font-size:17px; } .ghosted { color: #888888; } .framed { border-type: solid; border-top: 1px solid; border-left: 1px solid; border-bottom: 1px solid; border-right: 1px solid; background:#eeeeee; border-color:#000000; padding-left: 2; padding-top: 2; padding-bottom: 2; padding-right: 2; text-decoration:none; font-size: 11px; } .boxed { border-type: solid; border-top: 1px solid; border-left: 1px solid; border-bottom: 1px solid; border-right: 1px solid; background:#E7DBAD; border-color:#000000; padding-left: 2; padding-top: 1; padding-bottom: 2; padding-right: 2; text-decoration:none; float: left; } dt { font-weight:bold; margin-bottom: 5px; } dd { margin-bottom: 5px; } knopflerfish-osgi-2.3.3/knopflerfish.org/ant/html_template/bundle_list.html0000644000175000017500000000177611252437454027223 0ustar twernertwerner ${bundle.list.header} Knopflerfish Documentation
Bundle Jar Documentation
Bundle Packages

${bundle.list}

knopflerfish-osgi-2.3.3/knopflerfish.org/ant/html_template/package_list.html0000644000175000017500000000123511252437454027333 0ustar twernertwerner
${package.list}
PackageProvider(s)

knopflerfish-osgi-2.3.3/knopflerfish.org/ant/docbuild_include.xml0000644000175000017500000000333711252437456025201 0ustar twernertwerner knopflerfish-osgi-2.3.3/knopflerfish.org/ant/xargs.xml0000644000175000017500000000300111252437456023021 0ustar twernertwerner knopflerfish-osgi-2.3.3/knopflerfish.org/ant/console_interactions.xml0000644000175000017500000001612511252437456026134 0ustar twernertwerner ogin: ${console.user} assword: ${console.pwd} ${cmd} knopflerfish-osgi-2.3.3/knopflerfish.org/docs/0000755000175000017500000000000011400541206021307 5ustar twernertwernerknopflerfish-osgi-2.3.3/knopflerfish.org/docs/desktop.html0000644000175000017500000002075211252440212023654 0ustar twernertwerner Desktop

The Knopflerfish Desktop

The Knopflerfish OSGi Desktop displays a graphical overview of the OSGi framework. Most common operations as install, start, stop and update can be performed on bundles using the desktop. Additionally, bundle and service detail information is shown, and an experimental "Save deploy archive" is included.

The desktop is a standard OSGi bundle, using Swing. The desktop is primarily designed to manage a locally running framework, but can be used to control a remote framework, using the optional SOAP bundles. Consult the description of how to activate the "Remote framework..." menu item.

Additionally, the HTTP console or the Telnet console bundle can always be used for remote control. Both are available in the KF bundle repository.

The desktop can be customized using plugin services, see SwingBundleDisplayer for details.

The Desktop bundle can be found in

  knopflerfish/osgi/bundles/desktop

When started, it creates a window with four main areas:

Toolbar
The top toolbar provides quick access to common operations as start/stop/update bundles.
Bundle view
The center bundle view area display all installed bundles and their states. By clicking on bundles in this are, detail information is displayed in the Bundle detail area Four different views a supported internally (new can be installed):
  • Icons - each bundle is displayed as an icon.
  • Details - each bundle is displayed as a table row.
  • Spin - each bundle is displayed in a really cool graphics view.
  • Time line - each bundle event is displayed in a zoomable time line view.
Bundle detail area
The rightmost bundle detail area shows detailed information on selected bundles such as:
  • manifest
  • bundle closure
  • imported/exported services
  • imported/exported packages
  • bundle logs.
New detail pages can be installed run-time using plug-ins.
Framework console
The bottom console area allows interaction with the text console. This console acts exactly as the consoltty bundle, but does not require a shell or DOS window to run.

Icon view

To view the installed bundles as icons, select
View -> Large Icons
Bundle which has a BundleActivator
Active bundle
"Library" bundle which has no BundleActivator

Bundles can be selected by clicking.

Detail list view

To view the installed bundles as a detailed list, select
View -> Details

Bundles can be selected by clicking.

Detail spin view

To view the installed bundles as graphics, select
View -> Spin

Dependencies between bundles and services are shown as connecting lines. Not how the console bundle depends on three other bundles in the image above.

Bundles can be selected by clicking.

Detail spin view

To view the installed bundles as a time line, select
View -> Time line

Each bundle has a horizontal line, with bundle events marked for each bundle

Bundles can be selected by clicking.

knopflerfish-osgi-2.3.3/knopflerfish.org/docs/jars/0000755000175000017500000000000011252440162022252 5ustar twernertwernerknopflerfish-osgi-2.3.3/knopflerfish.org/docs/jars/remotefw/0000755000175000017500000000000011252440162024102 5ustar twernertwernerknopflerfish-osgi-2.3.3/knopflerfish.org/docs/jars/remotefw/remotefw_api-2.0.0.html0000644000175000017500000000552611252440162030114 0ustar twernertwerner Bundle info: remotefw_api-2.0.0.jar

remotefw_api-2.0.0.jar

download (1552 bytes)

OSGi manifest attributes
Bundle-Name RemoteFW-API
Bundle-Description Remote Framework (API)
Bundle-Version 2.0.0
Bundle-Vendor Knopflerfish
Bundle-Activator
Bundle-DocURL https://www.knopflerfish.org/svn/knopflerfish.org/trunk/osgi/bundles_opt/remotefw/readme.txt
Bundle-ContactAddress http://www.knopflerfish.org
Bundle-Classpath .
Export-Package org.knopflerfish.service.remotefw 0.0.0
Import-Package org.osgi.framework 0.0.0
Export-Service
Import-Service
Other manifest attributes
Bundle-UUID org.knopflerfish:remotefw:2.0.0:api
Build-Date Fri September 11 2009, 14:18:58
Bundle-ManifestVersion 2
Built-From /home/ekolin/work/kf/svn/knopflerfish.org-2.3.3/osgi/bundles/remotefw
Bundle-SymbolicName org.knopflerfish.bundle.remotefw-API
Bundle-Category API
Bundle-SubversionURL https://www.knopflerfish.org/svn/

Depends on

frameworkorg.osgi.framework

Other bundles depending on this bundle

desktop-2.3.11org.knopflerfish.service.remotefw
desktop_all-2.3.11org.knopflerfish.service.remotefw

Bundle source

org/knopflerfish/service/remotefw/RemoteFramework.java
knopflerfish-osgi-2.3.3/knopflerfish.org/docs/jars/remotefw/remotefw_api-2.0.0/0000755000175000017500000000000011252440154027217 5ustar twernertwernerknopflerfish-osgi-2.3.3/knopflerfish.org/docs/jars/remotefw/remotefw_api-2.0.0/src/0000755000175000017500000000000011252440154030006 5ustar twernertwernerknopflerfish-osgi-2.3.3/knopflerfish.org/docs/jars/remotefw/remotefw_api-2.0.0/src/org/0000755000175000017500000000000011252440154030575 5ustar twernertwerner././@LongLink0000000000000000000000000000014500000000000011565 Lustar rootrootknopflerfish-osgi-2.3.3/knopflerfish.org/docs/jars/remotefw/remotefw_api-2.0.0/src/org/knopflerfish/knopflerfish-osgi-2.3.3/knopflerfish.org/docs/jars/remotefw/remotefw_api-2.0.0/src/org/knopflerfish/0000755000175000017500000000000011252440154033267 5ustar twernertwerner././@LongLink0000000000000000000000000000015500000000000011566 Lustar rootrootknopflerfish-osgi-2.3.3/knopflerfish.org/docs/jars/remotefw/remotefw_api-2.0.0/src/org/knopflerfish/service/knopflerfish-osgi-2.3.3/knopflerfish.org/docs/jars/remotefw/remotefw_api-2.0.0/src/org/knopflerfish/0000755000175000017500000000000011252440154033267 5ustar twernertwerner././@LongLink0000000000000000000000000000016600000000000011570 Lustar rootrootknopflerfish-osgi-2.3.3/knopflerfish.org/docs/jars/remotefw/remotefw_api-2.0.0/src/org/knopflerfish/service/remotefw/knopflerfish-osgi-2.3.3/knopflerfish.org/docs/jars/remotefw/remotefw_api-2.0.0/src/org/knopflerfish/0000755000175000017500000000000011252440154033267 5ustar twernertwerner././@LongLink0000000000000000000000000000021200000000000011560 Lustar rootrootknopflerfish-osgi-2.3.3/knopflerfish.org/docs/jars/remotefw/remotefw_api-2.0.0/src/org/knopflerfish/service/remotefw/RemoteFramework.javaknopflerfish-osgi-2.3.3/knopflerfish.org/docs/jars/remotefw/remotefw_api-2.0.0/src/org/knopflerfish/0000644000175000017500000000455611252440154033303 0ustar twernertwernerpackage org.knopflerfish.service.remotefw; import org.osgi.framework.*; import java.util.Map; /** * Service interface for remote framework connections. * *

* By connecting to a remote framework, a client gets access * to a BundleContext representing the entire remote * platform. This BundleContext can be used as a normal context, * installing/starting/stopping bundles, adding listeners, getting * service references etc. *

* *

* Some service instances * as StartLevel and PackageAdmin may also be remotely accessible * via the context. For services not remotely accessible, properties * are still available (such as service id, object class array etc) *

* *

* Registering service instances are not * likely to be supported. Some differences in bundle and service * event sematics may also be present, since eventing may be handled * with some delay. *

* *

* Currently, the only known implementation is by using SOAP access * to the remote framework. See *

 *  osgi/bundles_opt/soap/readme.txt
 * 
* for more information. *

*/ public interface RemoteFramework { /** * Connect to a remote framework. * *

* The host string is implementation specific, but the SOAP * implementation uses the form http://[host]:[port] *

*

* If the connection fails, a RuntimeException is thrown. *

* * @return Context representing the remote framework. * * @throws RuntimeException if the connection fails */ public BundleContext connect(String host); /** * Disconnect from a previously connected framework. * * @param bc Context representing the remote framework. If the * context is not previously returned from connect, * do nothing. */ public void disconnect(BundleContext bc); /** * Get system properties from a remote framework. * * @param bc Context representing the remote framework. Must be * a context previously returned from connect * * @return Map of key/value (String/String) pairs representing * all system properties on the remote framework. * * @throws IllegalArgumentException if bc is not a context returned * from connect */ public Map getSystemProperties(BundleContext bc); } knopflerfish-osgi-2.3.3/knopflerfish.org/docs/jars/sslj2sp/0000755000175000017500000000000011252440162023652 5ustar twernertwernerknopflerfish-osgi-2.3.3/knopflerfish.org/docs/jars/sslj2sp/sslj2sp-2.0.0.html0000644000175000017500000000764011252440162026602 0ustar twernertwerner Bundle info: sslj2sp-2.0.0.jar

sslj2sp-2.0.0.jar

download (17159 bytes)

OSGi manifest attributes
Bundle-Name sslj2sp-IMPL
Bundle-Description SSL Provider using the J2 security architecture. (IMPL)
Bundle-Version 2.0.0
Bundle-Vendor Knopflerfish/Oscar
Bundle-Activator org.knopflerfish.bundle.ssl.j2sp.Activator
Bundle-DocURL https://www.knopflerfish.org/svn/knopflerfish.org/trunk/osgi/bundles/sslj2sp/readme.txt
Bundle-ContactAddress http://www.knopflerfish.org
Bundle-Classpath .
Export-Package
Import-Package javax.net.ssl 0.0.0
org.osgi.framework 0.0.0
org.osgi.service.cm 0.0.0
org.osgi.service.log 0.0.0
Export-Service
Import-Service
Other manifest attributes
Bundle-UUID org.knopflerfish:sslj2sp:2.0.0:impl
Build-Date Fri September 11 2009, 14:17:03
Bundle-ManifestVersion 2
Built-From /home/ekolin/work/kf/svn/knopflerfish.org-2.3.3/osgi/bundles/sslj2sp
Bundle-SymbolicName org.knopflerfish.bundle.sslj2sp-IMPL
Bundle-Category service
Bundle-SubversionURL https://www.knopflerfish.org/svn/

Depends on

frameworkorg.osgi.framework
cm_all-2.0.1org.osgi.service.cm
cm_api-2.0.1org.osgi.service.cm
desktop_all-2.3.11org.osgi.service.cm, org.osgi.service.log
desktop_api-2.3.11org.osgi.service.cm, org.osgi.service.log
log_all-2.0.2org.osgi.service.log
log_api-2.0.2org.osgi.service.log

Other bundles depending on this bundle

None found

Bundle source

org/knopflerfish/bundle/ssl/j2sp/Activator.java
org/knopflerfish/bundle/ssl/j2sp/ConstsIf.java
org/knopflerfish/bundle/ssl/j2sp/SslServiceFactory.java
org/knopflerfish/bundle/ssl/j2sp/SslServiceWrapper.java
knopflerfish-osgi-2.3.3/knopflerfish.org/docs/jars/sslj2sp/sslj2sp-2.0.0/0000755000175000017500000000000011252440154025706 5ustar twernertwernerknopflerfish-osgi-2.3.3/knopflerfish.org/docs/jars/sslj2sp/sslj2sp-2.0.0/src/0000755000175000017500000000000011252440154026475 5ustar twernertwernerknopflerfish-osgi-2.3.3/knopflerfish.org/docs/jars/sslj2sp/sslj2sp-2.0.0/src/org/0000755000175000017500000000000011252440154027264 5ustar twernertwernerknopflerfish-osgi-2.3.3/knopflerfish.org/docs/jars/sslj2sp/sslj2sp-2.0.0/src/org/knopflerfish/0000755000175000017500000000000011252440154031756 5ustar twernertwerner././@LongLink0000000000000000000000000000014600000000000011566 Lustar rootrootknopflerfish-osgi-2.3.3/knopflerfish.org/docs/jars/sslj2sp/sslj2sp-2.0.0/src/org/knopflerfish/bundle/knopflerfish-osgi-2.3.3/knopflerfish.org/docs/jars/sslj2sp/sslj2sp-2.0.0/src/org/knopflerfish/bundle0000755000175000017500000000000011252440154033150 5ustar twernertwerner././@LongLink0000000000000000000000000000015200000000000011563 Lustar rootrootknopflerfish-osgi-2.3.3/knopflerfish.org/docs/jars/sslj2sp/sslj2sp-2.0.0/src/org/knopflerfish/bundle/ssl/knopflerfish-osgi-2.3.3/knopflerfish.org/docs/jars/sslj2sp/sslj2sp-2.0.0/src/org/knopflerfish/bundle0000755000175000017500000000000011252440154033150 5ustar twernertwerner././@LongLink0000000000000000000000000000015700000000000011570 Lustar rootrootknopflerfish-osgi-2.3.3/knopflerfish.org/docs/jars/sslj2sp/sslj2sp-2.0.0/src/org/knopflerfish/bundle/ssl/j2sp/knopflerfish-osgi-2.3.3/knopflerfish.org/docs/jars/sslj2sp/sslj2sp-2.0.0/src/org/knopflerfish/bundle0000755000175000017500000000000011252440154033150 5ustar twernertwerner././@LongLink0000000000000000000000000000020500000000000011562 Lustar rootrootknopflerfish-osgi-2.3.3/knopflerfish.org/docs/jars/sslj2sp/sslj2sp-2.0.0/src/org/knopflerfish/bundle/ssl/j2sp/SslServiceWrapper.javaknopflerfish-osgi-2.3.3/knopflerfish.org/docs/jars/sslj2sp/sslj2sp-2.0.0/src/org/knopflerfish/bundle0000644000175000017500000002323111252440154033153 0ustar twernertwerner/* * Copyright (c) 2003, KNOPFLERFISH project * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following * conditions are met: * * - Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * - 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. * * - Neither the name of the KNOPFLERFISH project nor the names of its * contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS 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 * COPYRIGHT OWNER OR 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. */ package org.knopflerfish.bundle.ssl.j2sp; import java.io.ByteArrayInputStream; import java.io.FileInputStream; import java.io.InputStream; import java.security.KeyManagementException; import java.security.KeyStore; import java.security.KeyStoreException; import java.security.NoSuchAlgorithmException; import java.util.Dictionary; import java.util.Hashtable; import javax.net.ssl.KeyManagerFactory; import javax.net.ssl.SSLContext; import javax.net.ssl.SSLServerSocketFactory; import org.knopflerfish.service.log.LogRef; import org.osgi.framework.BundleContext; import org.osgi.framework.Constants; import org.osgi.framework.ServiceRegistration; import org.osgi.service.cm.ConfigurationException; /** * This Wrapper class manages basically a sinle SslServerSocketFactory * object which will be registered as a service. * It includes keeping track of the object itself, the registration and * to update, delete and create this registration based on calls to * the update method. * */ public class SslServiceWrapper { protected final static String DEFAULT_SERVICE_PID = "org.knopflerfish.bundle.ssl.j2sp.DEFAULT"; private final static String KEYSTOREPASS_KEY = "keystorepass"; private final static String KEYSTORE_KEY = "keystore"; private final static String DEFAULT_KEYSTORE_VALUE = "/resources/defaultkeys"; private final static String DEFAULT_PASSPHR_VALUE = "defaultpass"; private Dictionary m_config; private BundleContext m_bc; private LogRef m_log; private ServiceRegistration m_reg; /** * @param m_bc * @param m_log */ protected SslServiceWrapper(BundleContext bc, LogRef log) { m_bc = bc; m_log = log; } /** * @param config The latest properties to be used by this service, also used when registering framework. * If this is null, will tell this object to do cleanup! * @throws ConfigurationException */ protected void update (Dictionary config) throws ConfigurationException { //typically, if we have an m_config, and the passed in config is not //different, no reason to always recreate and reregister the same service. //TODO: later. For now, just always undo it m_config = config; //First, delete the old registration. if (m_reg != null) { m_reg.unregister(); m_reg = null; } //Stop here in case of cleanup if (m_config == null) { return; } // create new SSLServerSocketFactory!!! boolean isDefaultConfig = DEFAULT_SERVICE_PID.equals(m_config.get("service.pid")); // Step 1: context SSLContext context = null; try { context = SSLContext.getInstance(ConstsIf.PROT_TLS_V1); } catch (NoSuchAlgorithmException e) { throw new ConfigurationException( "", "creating SSLContext: ERROR no such algorithm"); } //Step 2: obtain a key store instance, type is fixed KeyStore myKeys; try { myKeys = KeyStore.getInstance(ConstsIf.KS_TYPE_JKS); } catch (KeyStoreException e1) { throw new ConfigurationException( "", "creating SSLContext: ERROR no such algorithm"); } InputStream is = null; char[] keyPassPhrase = null; if (!isDefaultConfig) { //Step 3:obtain password phrase for a keystore try { keyPassPhrase = ((String) m_config.get(KEYSTOREPASS_KEY)).toCharArray(); } catch (Exception epass) {} //Step 4:obtain input stream for a key store // - if the config admin set it to type byte[], assume it is a keystore itself // - else if it is of type string try to interpret this string as an (absolute) path // to a file // - else assume that this is a incomplete configruation we got from the CM Admin, // use the default keystore // from CM as byte[] ? if ((keyPassPhrase != null) && (is == null)) { try { is = new ByteArrayInputStream((byte[]) m_config.get(KEYSTORE_KEY)); } catch (Exception eb) {} } //from CM as a file pointer ? if ((keyPassPhrase != null) && (is == null)) { try { is = new FileInputStream((String) m_config.get(KEYSTORE_KEY)); } catch (Exception ef) {} } if ((is == null) && m_log.doWarn()) { m_log.warn("using default, config is invalid: " + m_config.get("service.pid")); } } // Step 3 & 4 executed now if config is bad or we just use the default config if (is == null) { try { keyPassPhrase = DEFAULT_PASSPHR_VALUE.toCharArray(); is = getClass().getResourceAsStream(DEFAULT_KEYSTORE_VALUE); } catch (Exception edef) { } } // Step 5: load keys into keystore try { myKeys.load(is, keyPassPhrase); } catch (Exception eload) { throw new ConfigurationException( KEYSTORE_KEY + "," + KEYSTOREPASS_KEY, "ERROR loading keys !, passphrase " + String.valueOf(keyPassPhrase)); } //Step 6: create and initialize KeyManagerFactory KeyManagerFactory kmf; try { kmf = KeyManagerFactory.getInstance(ConstsIf.KM_TYPE_SUN); } catch (NoSuchAlgorithmException e4) { throw new ConfigurationException( "", "creating KeyManagerFactory: ERROR no such algorithm"); } try { kmf.init(myKeys, keyPassPhrase); } catch (Exception e5) { throw new ConfigurationException( "", "initing kmf: " + e5.getMessage()); } //Step 7: initialize context with the key manager factory try { context.init(kmf.getKeyManagers(), null, null); } catch (KeyManagementException e6) { throw new ConfigurationException( "", "initing SSLContext: " + e6.getMessage()); } //Step 8: create SSL Server Socket Factory SSLServerSocketFactory ssl = null; try { ssl = context.getServerSocketFactory(); } catch (Exception e7) { throw new ConfigurationException( "", "creating SSLServerSocketFactory object: " + e7.getMessage()); } m_reg = m_bc.registerService(SSLServerSocketFactory.class.getName(), ssl, m_config); } protected static Dictionary getDefaultConfig() { Hashtable properties = new Hashtable(); properties.put(Constants.SERVICE_VENDOR, "knopflerfish"); properties.put(Constants.BUNDLE_NAME, "SSL Java2 Security Provider"); properties.put(Constants.BUNDLE_DESCRIPTION, "The default SSL Server Socket factory."); properties.put(Constants.SERVICE_PID, SslServiceWrapper.DEFAULT_SERVICE_PID); properties.put(KEYSTOREPASS_KEY, DEFAULT_PASSPHR_VALUE); properties.put(KEYSTORE_KEY, DEFAULT_KEYSTORE_VALUE); return properties; } } ././@LongLink0000000000000000000000000000020500000000000011562 Lustar rootrootknopflerfish-osgi-2.3.3/knopflerfish.org/docs/jars/sslj2sp/sslj2sp-2.0.0/src/org/knopflerfish/bundle/ssl/j2sp/SslServiceFactory.javaknopflerfish-osgi-2.3.3/knopflerfish.org/docs/jars/sslj2sp/sslj2sp-2.0.0/src/org/knopflerfish/bundle0000644000175000017500000001107311252440154033154 0ustar twernertwerner/* * Copyright (c) 2003, KNOPFLERFISH project * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following * conditions are met: * * - Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * - 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. * * - Neither the name of the KNOPFLERFISH project nor the names of its * contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS 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 * COPYRIGHT OWNER OR 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. */ package org.knopflerfish.bundle.ssl.j2sp; import java.util.Dictionary; import java.util.Enumeration; import java.util.Hashtable; import org.knopflerfish.service.log.LogRef; import org.osgi.framework.BundleContext; import org.osgi.service.cm.ConfigurationException; import org.osgi.service.cm.ManagedServiceFactory; /** * This class is based on the class HttpServerFactory from Knopflerfish's * HTTP Service bundle. * The ManagedServiceFactory approach has been chosen over the managed * Service Approach / using a proxy * - to prevent multiple registrations of the same object with default parameters * - to possibly allow several different J2 based SslFactories within the same * framework. * Can be argued if this is really necessary. */ public class SslServiceFactory implements ManagedServiceFactory { protected final static String PID = "org.knopflerfish.bundle.ssl.j2sp"; private final BundleContext m_bc; private final LogRef m_log; private final Object m_updateLock = new Object(); private final Dictionary m_services = new Hashtable(); public SslServiceFactory(BundleContext bc, LogRef log) { m_bc = bc; m_log = log; } public String getName() { return "SSL Java2 Service Provider"; } // public methods public void destroy() { Enumeration e = m_services.keys(); while (e.hasMoreElements()) deleted((String) e.nextElement()); } public void updated(String pid, Dictionary configuration) throws ConfigurationException { synchronized(m_updateLock) { if(m_log.doDebug()) m_log.debug("Updated pid=" + pid); if(!PID.equals(pid) && (null != m_services.get(PID))) { if(m_log.doDebug()) m_log.debug("Overriding default instance with new pid " + pid); deleted(PID); } SslServiceWrapper service = (SslServiceWrapper) m_services.get(pid); if (service == null) { if(m_log.doDebug()) m_log.debug("create pid=" + pid); service = new SslServiceWrapper(m_bc, m_log); m_services.put(pid, service); } service.update(configuration); } } /* (non-Javadoc) * @see org.osgi.service.cm.ManagedServiceFactory#deleted(java.lang.String) */ public void deleted(String pid) { SslServiceWrapper service = (SslServiceWrapper) m_services.get(pid); if (service != null) { if(m_log.doDebug()) m_log.debug("delete pid=" + pid); try { service.update(null); } catch (ConfigurationException e) {} } } } ././@LongLink0000000000000000000000000000017500000000000011570 Lustar rootrootknopflerfish-osgi-2.3.3/knopflerfish.org/docs/jars/sslj2sp/sslj2sp-2.0.0/src/org/knopflerfish/bundle/ssl/j2sp/Activator.javaknopflerfish-osgi-2.3.3/knopflerfish.org/docs/jars/sslj2sp/sslj2sp-2.0.0/src/org/knopflerfish/bundle0000644000175000017500000001272511252440154033161 0ustar twernertwerner/* * Copyright (c) 2003, KNOPFLERFISH project * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following * conditions are met: * * - Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * - 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. * * - Neither the name of the KNOPFLERFISH project nor the names of its * contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS 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 * COPYRIGHT OWNER OR 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. */ package org.knopflerfish.bundle.ssl.j2sp; //import org.knopflerfish.bundle.util.LogClient; import java.util.Dictionary; import java.util.Hashtable; import org.knopflerfish.service.log.LogRef; import org.osgi.framework.*; import org.osgi.service.cm.*; /** * Standard bundle activator, which registers a managed service factory * @see SslServiceFactory. * Based on the HTTP Service design, this class is also in charge of * triggering the creation of a default SslServerSocketFactory if nothing * else is present. */ public class Activator implements org.osgi.framework.BundleActivator { //public final LogClient m_log = new LogClient(); protected LogRef m_log; private BundleContext m_bc; ServiceRegistration m_reg; SslServiceFactory m_factory; /** * */ public Activator() { super(); } /* (non-Javadoc) * @see org.osgi.framework.BundleActivator#start(org.osgi.framework.BundleContext) */ public void start(BundleContext bc) throws Exception { m_bc = bc; m_log = new LogRef(m_bc); m_factory = new SslServiceFactory(m_bc, m_log); Dictionary parameters = new Hashtable(); parameters.put("service.pid", SslServiceFactory.PID); m_reg = bc.registerService(ManagedServiceFactory.class.getName(), m_factory, parameters); ServiceReference adminRef = null; try { ConfigurationAdmin admin = null; Configuration[] configs = null; try { adminRef = bc.getServiceReference(ConfigurationAdmin.class.getName()); // Potential start order problem! if(adminRef != null) { admin = (ConfigurationAdmin) bc.getService(adminRef); String filter = "(&(service.m_factoryPid=" + SslServiceFactory.PID + ")" + "(|(service.bundleLocation=" + bc.getBundle().getLocation() + ")" + "(service.bundleLocation=NULL)" + "(!(service.bundleLocation=*))))"; configs = admin.listConfigurations(filter); } } catch (Exception e) { if (m_log.doDebug()) m_log.debug("Exception when trying to get CM", e); } if (admin == null) { if (m_log.doInfo()) m_log.info("No CM present, using default configuration"); m_factory.updated(SslServiceWrapper.DEFAULT_SERVICE_PID, SslServiceWrapper.getDefaultConfig()); } else { if (configs == null || configs.length == 0) { if (m_log.doInfo()) m_log.info("No configuration present, creating default configuration"); m_factory.updated(SslServiceFactory.PID, SslServiceWrapper.getDefaultConfig()); } } } catch (ConfigurationException ce) { m_log.error("Configuration error", ce); } finally { if (adminRef != null) { m_bc.ungetService(adminRef); } } } /* (non-Javadoc) * @see org.osgi.framework.BundleActivator#stop(org.osgi.framework.BundleContext) */ public void stop(BundleContext arg0) throws Exception { if (m_reg != null) { m_reg.unregister(); } if (m_factory != null) { m_factory.destroy(); } m_log.close(); m_log = null; } } ././@LongLink0000000000000000000000000000017400000000000011567 Lustar rootrootknopflerfish-osgi-2.3.3/knopflerfish.org/docs/jars/sslj2sp/sslj2sp-2.0.0/src/org/knopflerfish/bundle/ssl/j2sp/ConstsIf.javaknopflerfish-osgi-2.3.3/knopflerfish.org/docs/jars/sslj2sp/sslj2sp-2.0.0/src/org/knopflerfish/bundle0000644000175000017500000000430611252440154033155 0ustar twernertwerner/* * Copyright (c) 2003, KNOPFLERFISH project * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following * conditions are met: * * - Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * - 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. * * - Neither the name of the KNOPFLERFISH project nor the names of its * contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS 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 * COPYRIGHT OWNER OR 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. */ package org.knopflerfish.bundle.ssl.j2sp; /** * This class is a collection of well known constants. * @see "JavaTM Secure Socket Extension (JSSE) * Reference Guide for the Java 2 SDK, Standard Edition, v1.4.2" * Appendix A * */ public interface ConstsIf { //SSL protocol types public final String PROT_SSL_V3 = "SSLv3"; public final String PROT_TLS_V1 = "TLSv1"; //Keystore Types public final String KS_TYPE_JKS = "JKS"; public final String KS_TYPE_PKC12 = "PKC12"; //Keymanager Types public final String KM_TYPE_SUN = "SunX509"; } knopflerfish-osgi-2.3.3/knopflerfish.org/docs/jars/list.html0000644000175000017500000001451111252440162024115 0ustar twernertwerner

Knopflerfish OSGi 2.3.3 Bundles

Knopflerfish Documentation
Bundle Jar Documentation
Bundle Packages

knopflerfish-osgi-2.3.3/knopflerfish.org/docs/jars/crimson/0000755000175000017500000000000011252440156023727 5ustar twernertwernerknopflerfish-osgi-2.3.3/knopflerfish.org/docs/jars/crimson/crimson-2.0.1/0000755000175000017500000000000011252440154026033 5ustar twernertwernerknopflerfish-osgi-2.3.3/knopflerfish.org/docs/jars/crimson/crimson-2.0.1/src/0000755000175000017500000000000011252440154026622 5ustar twernertwernerknopflerfish-osgi-2.3.3/knopflerfish.org/docs/jars/crimson/crimson-2.0.1/src/javax/0000755000175000017500000000000011252440154027733 5ustar twernertwernerknopflerfish-osgi-2.3.3/knopflerfish.org/docs/jars/crimson/crimson-2.0.1/src/javax/xml/0000755000175000017500000000000011252440154030533 5ustar twernertwernerknopflerfish-osgi-2.3.3/knopflerfish.org/docs/jars/crimson/crimson-2.0.1/src/javax/xml/parsers/0000755000175000017500000000000011252440154032212 5ustar twernertwerner././@LongLink0000000000000000000000000000016200000000000011564 Lustar rootrootknopflerfish-osgi-2.3.3/knopflerfish.org/docs/jars/crimson/crimson-2.0.1/src/javax/xml/parsers/FactoryFinder.javaknopflerfish-osgi-2.3.3/knopflerfish.org/docs/jars/crimson/crimson-2.0.1/src/javax/xml/parsers/Facto0000644000175000017500000002521511252440154033176 0ustar twernertwerner// Modified to work with an OSGi bundle-classloader. /* * The Apache Software License, Version 1.1 * * * Copyright (c) 2001 The Apache Software Foundation. All rights * reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in * the documentation and/or other materials provided with the * distribution. * * 3. The end-user documentation included with the redistribution, * if any, must include the following acknowledgment: * "This product includes software developed by the * Apache Software Foundation (http://www.apache.org/)." * Alternately, this acknowledgment may appear in the software itself, * if and wherever such third-party acknowledgments normally appear. * * 4. The name "Apache Software Foundation" must not be used to endorse or * promote products derived from this software without prior written * permission. For written permission, please contact apache@apache.org. * * 5. Products derived from this software may not be called "Apache", * nor may "Apache" appear in their name, without prior written * permission of the Apache Software Foundation. * * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION 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. * ==================================================================== * * This software consists of voluntary contributions made by many * individuals on behalf of the Apache Software Foundation and was * originally based on software copyright (c) 1999-2001, Sun Microsystems, * Inc., http://www.sun.com. For more information on the Apache Software * Foundation, please see . */ package javax.xml.parsers; import java.io.InputStream; import java.io.IOException; import java.io.File; import java.io.FileInputStream; import java.util.Properties; import java.io.BufferedReader; import java.io.InputStreamReader; /** * This class is duplicated for each JAXP subpackage so keep it in * sync. It is package private. * * This code is designed to implement the JAXP 1.1 spec pluggability * feature and is designed to run on JDK version 1.1 and later including * JVMs that perform early linking like the Microsoft JVM in IE 5. Note * however that it must be compiled on a JDK version 1.2 or later system * since it calls Thread#getContextClassLoader(). The code also runs both * as part of an unbundled jar file and when bundled as part of the JDK. */ class FactoryFinder { /** Temp debug code - this will be removed after we test everything */ private static boolean debug = false; static { // Use try/catch block to support applets try { debug = System.getProperty("jaxp.debug") != null; } catch (Exception x) { } } private static void debugPrintln(String msg) { if (debug) { System.err.println("JAXP: " + msg); } } /** * Figure out which ClassLoader to use. For JDK 1.2 and later use the * context ClassLoader if possible. Note: we defer linking the class * that calls an API only in JDK 1.2 until runtime so that we can catch * LinkageError so that this code will run in older non-Sun JVMs such * as the Microsoft JVM in IE. */ private static ClassLoader findClassLoader() throws ConfigurationError { ClassLoader classLoader; try { // Construct the name of the concrete class to instantiate Class clazz = Class.forName(FactoryFinder.class.getName() + "$ClassLoaderFinderConcrete"); ClassLoaderFinder clf = (ClassLoaderFinder) clazz.newInstance(); classLoader = clf.getContextClassLoader(); } catch (LinkageError le) { // Assume that we are running JDK 1.1, use the current ClassLoader classLoader = FactoryFinder.class.getClassLoader(); } catch (ClassNotFoundException x) { // This case should not normally happen. MS IE can throw this // instead of a LinkageError the second time Class.forName() is // called so assume that we are running JDK 1.1 and use the // current ClassLoader classLoader = FactoryFinder.class.getClassLoader(); } catch (Exception x) { // Something abnormal happened so throw an error throw new ConfigurationError(x.toString(), x); } return classLoader; } /** * Create an instance of a class using the specified ClassLoader */ private static Object newInstance(String className, ClassLoader classLoader) throws ConfigurationError { debugPrintln("newInstance of '" + className +"', cl="+classLoader); try { Class spiClass; if (classLoader == null) { ClassLoader myCL = FactoryFinder.class.getClassLoader(); spiClass = myCL.loadClass(className); } else { spiClass = classLoader.loadClass(className); } return spiClass.newInstance(); } catch (ClassNotFoundException x) { // If context loader failed, try the current classloader. if (null!=classLoader) { return newInstance(className,null); } throw new ConfigurationError( "Provider " + className + " not found", x); } catch (Exception x) { throw new ConfigurationError( "Provider " + className + " could not be instantiated: " + x, x); } } /** * Finds the implementation Class object in the specified order. Main * entry point. * @return Class object of factory, never null * * @param factoryId Name of the factory to find, same as * a property name * @param fallbackClassName Implementation class name, if nothing else * is found. Use null to mean no fallback. * * Package private so this code can be shared. */ static Object find(String factoryId, String fallbackClassName) throws ConfigurationError { ClassLoader classLoader = findClassLoader(); // Use the system property first try { String systemProp = System.getProperty( factoryId ); if( systemProp!=null) { debugPrintln("found system property" + systemProp); return newInstance(systemProp, classLoader); } } catch (SecurityException se) { } // try to read from $java.home/lib/xml.properties try { String javah=System.getProperty( "java.home" ); String configFile = javah + File.separator + "lib" + File.separator + "jaxp.properties"; File f=new File( configFile ); if( f.exists()) { Properties props=new Properties(); props.load( new FileInputStream(f)); String factoryClassName = props.getProperty(factoryId); debugPrintln("found java.home property " + factoryClassName); return newInstance(factoryClassName, classLoader); } } catch(Exception ex ) { if( debug ) ex.printStackTrace(); } String serviceId = "META-INF/services/" + factoryId; // try to find services in CLASSPATH try { InputStream is=null; // GIve priority to the context-classloader if (classLoader != null) { is=classLoader.getResourceAsStream( serviceId ); } if (is == null) { ClassLoader myCL = FactoryFinder.class.getClassLoader(); debugPrintln("asking " +myCL +" for "+serviceId); is=myCL.getResourceAsStream( serviceId ); } if( is!=null ) { debugPrintln("found " + serviceId); BufferedReader rd = new BufferedReader(new InputStreamReader(is, "UTF-8")); String factoryClassName = rd.readLine(); rd.close(); if (factoryClassName != null && ! "".equals(factoryClassName)) { debugPrintln("loaded from services: " + factoryClassName); return newInstance(factoryClassName, classLoader); } } } catch( Exception ex ) { if( debug ) ex.printStackTrace(); } if (fallbackClassName == null) { throw new ConfigurationError( "Provider for " + factoryId + " cannot be found", null); } debugPrintln("loading from fallback value: " + fallbackClassName); return newInstance(fallbackClassName, classLoader); } static class ConfigurationError extends Error { private Exception exception; /** * Construct a new instance with the specified detail string and * exception. */ ConfigurationError(String msg, Exception x) { super(msg); this.exception = x; } Exception getException() { return exception; } } /* * The following nested classes allow getContextClassLoader() to be * called only on JDK 1.2 and yet run in older JDK 1.1 JVMs */ private static abstract class ClassLoaderFinder { abstract ClassLoader getContextClassLoader(); } static class ClassLoaderFinderConcrete extends ClassLoaderFinder { ClassLoader getContextClassLoader() { return Thread.currentThread().getContextClassLoader(); } } } knopflerfish-osgi-2.3.3/knopflerfish.org/docs/jars/crimson/crimson-2.0.1/src/org/0000755000175000017500000000000011252440154027411 5ustar twernertwernerknopflerfish-osgi-2.3.3/knopflerfish.org/docs/jars/crimson/crimson-2.0.1/src/org/osgi/0000755000175000017500000000000011252440154030352 5ustar twernertwernerknopflerfish-osgi-2.3.3/knopflerfish.org/docs/jars/crimson/crimson-2.0.1/src/org/osgi/util/0000755000175000017500000000000011252440154031327 5ustar twernertwernerknopflerfish-osgi-2.3.3/knopflerfish.org/docs/jars/crimson/crimson-2.0.1/src/org/osgi/util/xml/0000755000175000017500000000000011252440154032127 5ustar twernertwerner././@LongLink0000000000000000000000000000016700000000000011571 Lustar rootrootknopflerfish-osgi-2.3.3/knopflerfish.org/docs/jars/crimson/crimson-2.0.1/src/org/osgi/util/xml/XMLParserActivator.javaknopflerfish-osgi-2.3.3/knopflerfish.org/docs/jars/crimson/crimson-2.0.1/src/org/osgi/util/xml/XMLPa0000644000175000017500000004642311252440154033004 0ustar twernertwerner/* * $Header: /cvshome/build/org.osgi.util.xml/src/org/osgi/util/xml/XMLParserActivator.java,v 1.10 2006/06/21 17:41:20 hargrave Exp $ * * Copyright (c) OSGi Alliance (2002, 2006). All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.osgi.util.xml; import java.io.*; import java.net.URL; import java.util.*; import javax.xml.parsers.*; import org.osgi.framework.*; /** * A BundleActivator class that allows any JAXP compliant XML Parser to register * itself as an OSGi parser service. * * Multiple JAXP compliant parsers can concurrently register by using this * BundleActivator class. Bundles who wish to use an XML parser can then use the * framework's service registry to locate available XML Parsers with the desired * characteristics such as validating and namespace-aware. * *

* The services that this bundle activator enables a bundle to provide are: *

    *
  • javax.xml.parsers.SAXParserFactory({@link #SAXFACTORYNAME}) *
  • javax.xml.parsers.DocumentBuilderFactory( * {@link #DOMFACTORYNAME}) *
* *

* The algorithm to find the implementations of the abstract parsers is derived * from the JAR file specifications, specifically the Services API. *

* An XMLParserActivator assumes that it can find the class file names of the * factory classes in the following files: *

    *
  • /META-INF/services/javax.xml.parsers.SAXParserFactory is * a file contained in a jar available to the runtime which contains the * implementation class name(s) of the SAXParserFactory. *
  • /META-INF/services/javax.xml.parsers.DocumentBuilderFactory * is a file contained in a jar available to the runtime which contains the * implementation class name(s) of the DocumentBuilderFactory *
*

* If either of the files does not exist, XMLParserActivator * assumes that the parser does not support that parser type. * *

* XMLParserActivator attempts to instantiate both the * SAXParserFactory and the DocumentBuilderFactory. * It registers each factory with the framework along with service properties: *

    *
  • {@link #PARSER_VALIDATING}- indicates if this factory supports * validating parsers. It's value is a Boolean. *
  • {@link #PARSER_NAMESPACEAWARE}- indicates if this factory supports * namespace aware parsers It's value is a Boolean. *
*

* Individual parser implementations may have additional features, properties, * or attributes which could be used to select a parser with a filter. These can * be added by extending this class and overriding the * setSAXProperties and setDOMProperties methods. */ public class XMLParserActivator implements BundleActivator, ServiceFactory { /** Context of this bundle */ private BundleContext context; /** * Filename containing the SAX Parser Factory Class name. Also used as the * basis for the SERVICE_PID registration property. */ public static final String SAXFACTORYNAME = "javax.xml.parsers.SAXParserFactory"; /** * Filename containing the DOM Parser Factory Class name. Also used as the * basis for the SERVICE_PID registration property. */ public static final String DOMFACTORYNAME = "javax.xml.parsers.DocumentBuilderFactory"; /** Path to the factory class name files */ private static final String PARSERCLASSFILEPATH = "/META-INF/services/"; /** Fully qualified path name of SAX Parser Factory Class Name file */ public static final String SAXCLASSFILE = PARSERCLASSFILEPATH + SAXFACTORYNAME; /** Fully qualified path name of DOM Parser Factory Class Name file */ public static final String DOMCLASSFILE = PARSERCLASSFILEPATH + DOMFACTORYNAME; /** SAX Factory Service Description */ private static final String SAXFACTORYDESCRIPTION = "A JAXP Compliant SAX Parser"; /** DOM Factory Service Description */ private static final String DOMFACTORYDESCRIPTION = "A JAXP Compliant DOM Parser"; /** * Service property specifying if factory is configured to support * validating parsers. The value is of type Boolean. */ public static final String PARSER_VALIDATING = "parser.validating"; /** * Service property specifying if factory is configured to support namespace * aware parsers. The value is of type Boolean. */ public static final String PARSER_NAMESPACEAWARE = "parser.namespaceAware"; /** * Key for parser factory name property - this must be saved in the parsers * properties hashtable so that the parser factory can be instantiated from * a ServiceReference */ private static final String FACTORYNAMEKEY = "parser.factoryname"; /** * Called when this bundle is started so the Framework can perform the * bundle-specific activities necessary to start this bundle. This method * can be used to register services or to allocate any resources that this * bundle needs. * *

* This method must complete and return to its caller in a timely manner. * *

* This method attempts to register a SAX and DOM parser with the * Framework's service registry. * * @param context The execution context of the bundle being started. * @throws java.lang.Exception If this method throws an exception, this * bundle is marked as stopped and the Framework will remove this * bundle's listeners, unregister all services registered by this * bundle, and release all services used by this bundle. * @see Bundle#start */ public void start(BundleContext context) throws Exception { this.context = context; Bundle parserBundle = context.getBundle(); try { // check for sax parsers registerSAXParsers(getParserFactoryClassNames(parserBundle .getResource(SAXCLASSFILE))); // check for dom parsers registerDOMParsers(getParserFactoryClassNames(parserBundle .getResource(DOMCLASSFILE))); } catch (IOException ioe) { // if there were any IO errors accessing the resource files // containing the class names ioe.printStackTrace(); throw new FactoryConfigurationError(ioe); } } /** *

* This method has nothing to do as all active service registrations will * automatically get unregistered when the bundle stops. * * @param context The execution context of the bundle being stopped. * @throws java.lang.Exception If this method throws an exception, the * bundle is still marked as stopped, and the Framework will remove * the bundle's listeners, unregister all services registered by the * bundle, and release all services used by the bundle. * @see Bundle#stop */ public void stop(BundleContext context) throws Exception { } /** * Given the URL for a file, reads and returns the parser class names. There * may be multiple classes specified in this file, one per line. There may * also be comment lines in the file, which begin with "#". * * @param parserUrl The URL of the service file containing the parser class * names * @return A vector of strings containing the parser class names or null if * parserUrl is null * @throws IOException if there is a problem reading the URL input stream */ private Vector getParserFactoryClassNames(URL parserUrl) throws IOException { Vector v = new Vector(1); if (parserUrl != null) { String parserFactoryClassName = null; InputStream is = parserUrl.openStream(); BufferedReader br = new BufferedReader(new InputStreamReader(is)); while (true) { parserFactoryClassName = br.readLine(); if (parserFactoryClassName == null) { break; // end of file reached } String pfcName = parserFactoryClassName.trim(); if (pfcName.length() == 0) { continue; // blank line } int commentIdx = pfcName.indexOf("#"); if (commentIdx == 0) { // comment line continue; } else if (commentIdx < 0) { // no comment on this line v.addElement(pfcName); } else { v.addElement(pfcName.substring(0, commentIdx).trim()); } } return v; } else { return null; } } /** * Register SAX Parser Factory Services with the framework. * * @param parserFactoryClassNames - a Vector of * String objects containing the names of the parser * Factory Classes * @throws FactoryConfigurationError if thrown from getFactory */ private void registerSAXParsers(Vector parserFactoryClassNames) throws FactoryConfigurationError { if (parserFactoryClassNames != null) { Enumeration e = parserFactoryClassNames.elements(); int index = 0; while (e.hasMoreElements()) { String parserFactoryClassName = (String) e.nextElement(); // create a sax parser factory just to get it's default // properties. It will never be used since // this class will operate as a service factory and give each // service requestor it's own SaxParserFactory SAXParserFactory factory = (SAXParserFactory) getFactory(parserFactoryClassName); Hashtable properties = new Hashtable(7); // figure out the default properties of the parser setDefaultSAXProperties(factory, properties, index); // store the parser factory class name in the properties so that // it can be retrieved when getService is called // to return a parser factory properties.put(FACTORYNAMEKEY, parserFactoryClassName); // release the factory factory = null; // register the factory as a service context.registerService(SAXFACTORYNAME, this, properties); index++; } } } /** *

* Set the SAX Parser Service Properties. By default, the following * properties are set: *