[Seasar-user:12767] Re: findComponents 、findAllComponentsの使い方について
Koichi Kobayashi
[E-MAIL ADDRESS DELETED]
2008年 2月 6日 (水) 15:30:06 JST
$B>.NS(B (koichik) $B$G$9!%(B
Date: Wed, 6 Feb 2008 14:39:44 +0900
From: "Nobutaka Yamada" <[E-MAIL ADDRESS DELETED]>
To: [E-MAIL ADDRESS DELETED]
Subject: [Seasar-user:12764] findComponents $B!"(BfindAllComponents$B$N;H$$J}$K$D$$$F(B
> S2Container#findAllComponents(A00.class)$B$r;HMQ$7(B
> $B-!$H-#$N$_$rJV$9$3$H$,$G$-$^$9$+!)(B
$B$G$-$^$;$s!%(B
A00 $B$r<BAu$7$?%3%s%]!<%M%s%H$OA4$F(B (1 $B$b(B 2 $B$b(B 3 $B$b(B)
$B<hF@$5$l$^$9!%(B
> $B$b$7$/$OB>$K<jCJ$O$"$k$G$7$g$&$+!)(B
$B%-!<$r(B A00 $B$H$$$&%$%s%?%U%'!<%9$G$O$J$/!$(B
$B%/%i%9L>(B ($B%3%s%]!<%M%s%HL>(B) $B$K$9$k$3$H$O(B
$B$G$-$J$$$N$G$7$g$&$+!)(B
$B$=$l$,2DG=$J$i!$(B
$B!&I8=`%Q%C%1!<%8$H3HD%%Q%C%1!<%8$G(Bdicon $B$rJ,3d!%(B
$B!&3HD%%Q%C%1!<%8MQ$N(B dicon $B$GI8=`%Q%C%1!<%8MQ$N(B
dicon $B$r%$%s%/%k!<%I!%(B
$B!&(Bapp.dicon $BEy$G$O3HD%%Q%C%1!<%8MQ$N(B dicon $B$r(B
$B%$%s%/%k!<%I!%(B
$B!&%3%s%]!<%M%s%HL>$O%/%i%9$NC1=cL>$K$9$k!%(B
$B$H$9$k$3$H$G!$(BgetComponent("A01") $B$GI8=`%Q%C%1!<%8$N(B
A01 $B$r!$(BgetComponent("A02") $B$G3HD%%Q%C%1!<%8$N(B
A02 $B$r<hF@$9$k$3$H$,$G$-$^$9!%(B
$B%-!<$,%$%s%?%U%'!<%9$G$J$/$F$O$J$i$J$$$J$i!$(B
org.seasar.framework.container.util.Traversal $B$r(B
$B;H$C$F!$(B
final Map components = new HashMap();
Traversal.forEachComponent(container, new ComponentDefHandler() {
public Object processComponent(ComponentDef componentDef) {
Class clazz = componentDef.getComponentClass();
if (A00.class.isAssignableFrom(clazz)) {
String name = clazz.getSimpleName();
if (!components.containsKey(name)) {
components.put(name, componentDef.getComponent());
}
}
return null;
}
});
$B$N$h$&$K$9$l$P!$L\E*$rC#$9$k$3$H$,2DG=$+$H!%(B
# $B%3!<%I$O%a!<%i$N%(%G%#%?$G=q$$$?$@$1$J$N$G(B
# $B%3%s%Q%$%k$9$iDL$i$J$$$+$b$7$l$^$;$s$,!%(B
$B$3$N>l9g$b(B dicon $B%U%!%$%k$N9=@.$O>e$K=q$$$?$N$H(B
$BF1$8$h$&$K$9$kI,MW$,$"$j$^$9!%(B
--
<component name="koichik">
<property name="fullName">"Koichi Kobayashi"</property>
<property name="email">"[E-MAIL ADDRESS DELETED]"</property>
<property name="blog">"http://d.hatena.ne.jp/koichik"</property>
</component>
Seasar-user メーリングリストの案内