[picocontainer-dev] RE: Desired behavior for Picocontainer and Static injection

"Michael Rimov" <[email protected]> Sat, 8 Jun 2013 23:46:32 -0700
Newsgroups gmane.comp.java.picocontainer.devel
Organization Centerline Computers, Inc.
Message-ID <[email protected]>
------=_NextPart_000_009C_01CE64A2.68C39210
Content-Type: text/plain;
	charset="us-ascii"
Content-Transfer-Encoding: 7bit

Paul,

 

Well, according to the TCK's comments, static member injection IS optional.
That said just to get this far means I have a significant portion of the
work done to make it 100% pass the tck, and I'm kind of with the mindset
that since we're this far, go for it for "buzzword compliance" even if we
don't recommend the use of static member injection.

 

I think I'll peel the logic out into separate injectors that are turned off
by default but still included in Adapting injection.  That way a person
could explicitly turn it on with:

 

pico.as(STATIC_INJECTION).addComponent(..);

 

but it would sit in a default "off" state.  This would also help with
keeping track of statics initialization on a  per-container basis.  If
somebody wants to share a class across multiple unconnected containers, only
the container with STATIC_INJECTION turned on for the component registration
would be initializing the statics.

 

 

 
-Mike

 

 

From: Paul Hammant [mailto:[email protected]] 
Sent: Friday, June 07, 2013 10:13 PM
To: Michael Rimov
Cc: dev
Subject: Re: Desired behavior for Picocontainer and Static injection

 

Mike,

 

I'm not really happy with JSR330's patronage of injection into class
variables.  If we had to say we're not going to do it, but we'll do
everything else from JSR 330 that's instance based, then I'd not be unhappy.

 

Can we do it in a separate class?  StaticEnabledPicoContainer (implements
MPC, has-a DPC) ?  Then it's a take it or leave it thing.

 

On Wed, Jun 5, 2013 at 12:04 AM, Michael Rimov <[email protected]>
wrote:

Ok, so this is the last thing on the todo list to get the TCK + all optional
tests running for JSR-330.

 

The TCK wants static initialization, but to keep track of things so that we
only inject statics one time.

 

To me that means we have to maintain some sort of state about what's been
initialized, but what scope?

 

Do we do it across all containers?  (ie a static variable inside default
picocontainer)  (for the record, my own personal opinion on this solution.
ick!)

 

Personally I'm of the opinion that we keep track of static initialization
once per container.  (via a Non static member variable, probably a
WeakHashSet. weak so it doesn't prevent classloaders from gc'ing a class?)  

 

If we have multiple containers (not in a parent-child way) referencing the
same class, then it would mean that a static variable will be initialized
multiple times, but personally I think this is an edge case behavior that we
can live with compared to having to have Static variables inside DPC.  

 

I suppose a complicated way would be to run a class enhancer to offload the
state information there. but that seems like a lot of work for what we would
call an recommended way of doing things.

 

Thoughts?

 

 
-Mike

 


------=_NextPart_000_009C_01CE64A2.68C39210
Content-Type: text/html;
	charset="us-ascii"
Content-Transfer-Encoding: quoted-printable

<html xmlns:v=3D"urn:schemas-microsoft-com:vml" =
xmlns:o=3D"urn:schemas-microsoft-com:office:office" =
xmlns:w=3D"urn:schemas-microsoft-com:office:word" =
xmlns:m=3D"http://schemas.microsoft.com/office/2004/12/omml" =
xmlns=3D"http://www.w3.org/TR/REC-html40"><head><meta =
http-equiv=3DContent-Type content=3D"text/html; =
charset=3Dus-ascii"><meta name=3DGenerator content=3D"Microsoft Word 14 =
(filtered medium)"><style><!--
/* Font Definitions */
@font-face
	{font-family:"Cambria Math";
	panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
	{font-family:Calibri;
	panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
	{font-family:Tahoma;
	panose-1:2 11 6 4 3 5 4 4 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
	{margin:0in;
	margin-bottom:.0001pt;
	font-size:12.0pt;
	font-family:"Times New Roman","serif";}
a:link, span.MsoHyperlink
	{mso-style-priority:99;
	color:blue;
	text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
	{mso-style-priority:99;
	color:purple;
	text-decoration:underline;}
span.EmailStyle17
	{mso-style-type:personal-reply;
	font-family:"Calibri","sans-serif";
	color:#1F497D;}
.MsoChpDefault
	{mso-style-type:export-only;}
@page WordSection1
	{size:8.5in 11.0in;
	margin:1.0in 1.0in 1.0in 1.0in;}
div.WordSection1
	{page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext=3D"edit" spidmax=3D"1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext=3D"edit">
<o:idmap v:ext=3D"edit" data=3D"1" />
</o:shapelayout></xml><![endif]--></head><body lang=3DEN-US link=3Dblue =
vlink=3Dpurple><div class=3DWordSection1><p class=3DMsoNormal><span =
style=3D'font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497=
D'>Paul,<o:p></o:p></span></p><p class=3DMsoNormal><span =
style=3D'font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497=
D'><o:p>&nbsp;</o:p></span></p><p class=3DMsoNormal><span =
style=3D'font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497=
D'>Well, according to the TCK&#8217;s comments, static member injection =
IS optional.&nbsp; That said just to get this far means I have a =
significant portion of the work done to make it 100% pass the tck, and =
I&#8217;m kind of with the mindset that since we&#8217;re this far, go =
for it for &#8220;buzzword compliance&#8221; even if we don&#8217;t =
recommend the use of static member injection.<o:p></o:p></span></p><p =
class=3DMsoNormal><span =
style=3D'font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497=
D'><o:p>&nbsp;</o:p></span></p><p class=3DMsoNormal><span =
style=3D'font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497=
D'>I think I&#8217;ll peel the logic out into separate injectors that =
are turned off by default but still included in Adapting =
injection.&nbsp; That way a person could explicitly turn it on =
with:<o:p></o:p></span></p><p class=3DMsoNormal><span =
style=3D'font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497=
D'><o:p>&nbsp;</o:p></span></p><p class=3DMsoNormal><span =
style=3D'font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497=
D'>pico.as(STATIC_INJECTION).addComponent(&#8230;.);<o:p></o:p></span></p=
><p class=3DMsoNormal><span =
style=3D'font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497=
D'><o:p>&nbsp;</o:p></span></p><p class=3DMsoNormal><span =
style=3D'font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497=
D'>but it would sit in a default &#8220;off&#8221; state.&nbsp; This =
would also help with keeping track of statics initialization on a&nbsp; =
per-container basis.&nbsp; If somebody wants to share a class across =
multiple unconnected containers, only the container with =
STATIC_INJECTION turned on for the component registration would be =
initializing the statics.<o:p></o:p></span></p><p =
class=3DMsoNormal><span =
style=3D'font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497=
D'><o:p>&nbsp;</o:p></span></p><p class=3DMsoNormal><span =
style=3D'font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497=
D'><o:p>&nbsp;</o:p></span></p><p class=3DMsoNormal><span =
style=3D'font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497=
D'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbs=
p;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp=
;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&=
nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&n=
bsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nb=
sp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbs=
p;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp=
;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&=
nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&n=
bsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nb=
sp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbs=
p;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp=
;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&=
nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&n=
bsp; -Mike<o:p></o:p></span></p><p class=3DMsoNormal><span =
style=3D'font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497=
D'><o:p>&nbsp;</o:p></span></p><p class=3DMsoNormal><span =
style=3D'font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497=
D'><o:p>&nbsp;</o:p></span></p><p class=3DMsoNormal><b><span =
style=3D'font-size:10.0pt;font-family:"Tahoma","sans-serif"'>From:</span>=
</b><span style=3D'font-size:10.0pt;font-family:"Tahoma","sans-serif"'> =
Paul Hammant [mailto:[email protected]] <br><b>Sent:</b> Friday, June 07, =
2013 10:13 PM<br><b>To:</b> Michael Rimov<br><b>Cc:</b> =
dev<br><b>Subject:</b> Re: Desired behavior for Picocontainer and Static =
injection<o:p></o:p></span></p><p =
class=3DMsoNormal><o:p>&nbsp;</o:p></p><div><p class=3DMsoNormal><span =
style=3D'font-size:10.0pt;font-family:"Arial","sans-serif"'>Mike,</span><=
o:p></o:p></p><div><p class=3DMsoNormal><span =
style=3D'font-size:10.0pt;font-family:"Arial","sans-serif"'><o:p>&nbsp;</=
o:p></span></p></div><div><p class=3DMsoNormal><span =
style=3D'font-size:10.0pt;font-family:"Arial","sans-serif"'>I'm not =
really happy with JSR330's patronage of injection into class variables. =
&nbsp;If we had to say we're not going to do it, but we'll do everything =
else from JSR 330 that's instance based, then I'd not be =
unhappy.<o:p></o:p></span></p></div><div><p class=3DMsoNormal><span =
style=3D'font-size:10.0pt;font-family:"Arial","sans-serif"'><o:p>&nbsp;</=
o:p></span></p></div><div><p class=3DMsoNormal><span =
style=3D'font-size:10.0pt;font-family:"Arial","sans-serif"'>Can we do it =
in a separate class? &nbsp;StaticEnabledPicoContainer (implements MPC, =
has-a DPC) ? &nbsp;Then it's a take it or leave it =
thing.<o:p></o:p></span></p></div></div><div><p class=3DMsoNormal =
style=3D'margin-bottom:12.0pt'><o:p>&nbsp;</o:p></p><div><p =
class=3DMsoNormal>On Wed, Jun 5, 2013 at 12:04 AM, Michael Rimov &lt;<a =
href=3D"mailto:[email protected]" =
target=3D"_blank">[email protected]</a>&gt; =
wrote:<o:p></o:p></p><div><div><p class=3DMsoNormal =
style=3D'mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'>Ok, so this =
is the last thing on the todo list to get the TCK + all optional tests =
running for JSR-330.<o:p></o:p></p><p class=3DMsoNormal =
style=3D'mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'>&nbsp;<o:p><=
/o:p></p><p class=3DMsoNormal =
style=3D'mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'>The TCK =
wants static initialization, but to keep track of things so that we only =
inject statics one time.<o:p></o:p></p><p class=3DMsoNormal =
style=3D'mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'>&nbsp;<o:p><=
/o:p></p><p class=3DMsoNormal =
style=3D'mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'>To me that =
means we have to maintain some sort of state about what&#8217;s been =
initialized, but what scope?<o:p></o:p></p><p class=3DMsoNormal =
style=3D'mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'>&nbsp;<o:p><=
/o:p></p><p class=3DMsoNormal =
style=3D'mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'>Do we do it =
across all containers?&nbsp; (ie a static variable inside default =
picocontainer)&nbsp; (for the record, my own personal opinion on this =
solution&#8230; ick!)<o:p></o:p></p><p class=3DMsoNormal =
style=3D'mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'>&nbsp;<o:p><=
/o:p></p><p class=3DMsoNormal =
style=3D'mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'>Personally =
I&#8217;m of the opinion that we keep track of static initialization =
once per container.&nbsp; (via a Non static member variable, probably a =
WeakHashSet&#8230; weak so it doesn&#8217;t prevent classloaders from =
gc&#8217;ing a class?)&nbsp; <o:p></o:p></p><p class=3DMsoNormal =
style=3D'mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'>&nbsp;<o:p><=
/o:p></p><p class=3DMsoNormal =
style=3D'mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'>If we have =
multiple containers (not in a parent-child way) referencing the same =
class, then it would mean that a static variable will be initialized =
multiple times, but personally I think this is an edge case behavior =
that we can live with compared to having to have Static variables inside =
DPC.&nbsp; <o:p></o:p></p><p class=3DMsoNormal =
style=3D'mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'>&nbsp;<o:p><=
/o:p></p><p class=3DMsoNormal =
style=3D'mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'>I suppose a =
complicated way would be to run a class enhancer to offload the state =
information there&#8230; but that seems like a lot of work for what we =
would call an recommended way of doing things.<o:p></o:p></p><p =
class=3DMsoNormal =
style=3D'mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'>&nbsp;<o:p><=
/o:p></p><p class=3DMsoNormal =
style=3D'mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'>Thoughts?<o:=
p></o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