You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by 9902468 <vi...@greenstreet.fi> on 2010/09/16 07:54:52 UTC

[T5] PropertyAccess and thread safety

Hi,

I just noticed that some creative soul has created static object populator
method in a project that I work in. This method is very handy, and is used
through out the system now :)

It uses T5 PropertyAccess service, but the static method doesn't receive it
as parameter - it is instantiated inside the method using new
PropertyAccessImpl();. The implementation has caches and I tried to move
propertyAccess to be private static final in the populator class. This
resulted really substantial performance improvment. (Nearly twice as fast
populations.)

Now the only question is: is the PropertyAccess service thread safe to use?
What about the ClassPropertyAdapter.set(object, string, object) and
ClassPropertyAdapter.get(object, string)?

 - Ville


-- 
View this message in context: http://tapestry.1045711.n5.nabble.com/T5-PropertyAccess-and-thread-safety-tp2841770p2841770.html
Sent from the Tapestry - User mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


Re: [T5] PropertyAccess and thread safety

Posted by 9902468 <vi...@greenstreet.fi>.
Thanks for the input!

I'll change it to be parameter to the method, so the code that uses the util
must provide the implementation. I can't inject it directly as it is not T5
managed bean.

 - Ville


Howard Lewis Ship wrote:
> 
> You should use the injected service.
> 
> It is thread safe.
> 
> In addition, there is  logic in place to notify it when class loaders
> change (i.e., when reloading a component or service-layer class), so
> that it can clear its caches. This prevents memory leaks (where the PA
> keeps a reference to a Class and therefore an otherwise unused
> ClassLoader).
> 
> On Thu, Sep 16, 2010 at 4:26 AM, Thiago H. de Paula Figueiredo
> <th...@gmail.com> wrote:
>> On Thu, 16 Sep 2010 02:54:52 -0300, 9902468
>> <vi...@greenstreet.fi>
>> wrote:
>>
>>> Hi,
>>
>> Hi!
>>
>>> It uses T5 PropertyAccess service, but the static method doesn't receive
>>> it as parameter - it is instantiated inside the method using new
>>> PropertyAccessImpl();.
>>
>> PropertyAccessImpl is in a internal package and there's no guarantee of
>> backward compatibility. You should not use it. While don't you just
>> inject
>> PropertyAccess through Tapestry-IoC?
>>
>>> Now the only question is: is the PropertyAccess service thread safe to
>>> use? What about the ClassPropertyAdapter.set(object, string, object) and
>>> ClassPropertyAdapter.get(object, string)?
>>
>> Looking at the sources, I can't see why it wouldn't be thread-safe. The
>> set
>> methods in PropertyAccessImpl and ClassPropertyAdapterImpl don't change
>> their state.
>>
>> --
>> Thiago H. de Paula Figueiredo
>> Independent Java, Apache Tapestry 5 and Hibernate consultant, developer,
>> and
>> instructor
>> Owner, Ars Machina Tecnologia da Informação Ltda.
>> http://www.arsmachina.com.br
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
>> For additional commands, e-mail: users-help@tapestry.apache.org
>>
>>
> 
> 
> 
> -- 
> Howard M. Lewis Ship
> 
> Creator of Apache Tapestry
> 
> The source for Tapestry training, mentoring and support. Contact me to
> learn how I can get you up and productive in Tapestry fast!
> 
> (971) 678-5210
> http://howardlewisship.com
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
> 
> 
> 
-- 
View this message in context: http://tapestry.1045711.n5.nabble.com/T5-PropertyAccess-and-thread-safety-tp2841770p2845036.html
Sent from the Tapestry - User mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


Re: [T5] PropertyAccess and thread safety

Posted by Howard Lewis Ship <hl...@gmail.com>.
You should use the injected service.

It is thread safe.

In addition, there is  logic in place to notify it when class loaders
change (i.e., when reloading a component or service-layer class), so
that it can clear its caches. This prevents memory leaks (where the PA
keeps a reference to a Class and therefore an otherwise unused
ClassLoader).

On Thu, Sep 16, 2010 at 4:26 AM, Thiago H. de Paula Figueiredo
<th...@gmail.com> wrote:
> On Thu, 16 Sep 2010 02:54:52 -0300, 9902468 <vi...@greenstreet.fi>
> wrote:
>
>> Hi,
>
> Hi!
>
>> It uses T5 PropertyAccess service, but the static method doesn't receive
>> it as parameter - it is instantiated inside the method using new
>> PropertyAccessImpl();.
>
> PropertyAccessImpl is in a internal package and there's no guarantee of
> backward compatibility. You should not use it. While don't you just inject
> PropertyAccess through Tapestry-IoC?
>
>> Now the only question is: is the PropertyAccess service thread safe to
>> use? What about the ClassPropertyAdapter.set(object, string, object) and
>> ClassPropertyAdapter.get(object, string)?
>
> Looking at the sources, I can't see why it wouldn't be thread-safe. The set
> methods in PropertyAccessImpl and ClassPropertyAdapterImpl don't change
> their state.
>
> --
> Thiago H. de Paula Figueiredo
> Independent Java, Apache Tapestry 5 and Hibernate consultant, developer, and
> instructor
> Owner, Ars Machina Tecnologia da Informação Ltda.
> http://www.arsmachina.com.br
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>



-- 
Howard M. Lewis Ship

Creator of Apache Tapestry

The source for Tapestry training, mentoring and support. Contact me to
learn how I can get you up and productive in Tapestry fast!

(971) 678-5210
http://howardlewisship.com

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


Re: [T5] PropertyAccess and thread safety

Posted by "Thiago H. de Paula Figueiredo" <th...@gmail.com>.
On Thu, 16 Sep 2010 02:54:52 -0300, 9902468  
<vi...@greenstreet.fi> wrote:

> Hi,

Hi!

> It uses T5 PropertyAccess service, but the static method doesn't receive  
> it as parameter - it is instantiated inside the method using new
> PropertyAccessImpl();.

PropertyAccessImpl is in a internal package and there's no guarantee of  
backward compatibility. You should not use it. While don't you just inject  
PropertyAccess through Tapestry-IoC?

> Now the only question is: is the PropertyAccess service thread safe to  
> use? What about the ClassPropertyAdapter.set(object, string, object) and
> ClassPropertyAdapter.get(object, string)?

Looking at the sources, I can't see why it wouldn't be thread-safe. The  
set methods in PropertyAccessImpl and ClassPropertyAdapterImpl don't  
change their state.

-- 
Thiago H. de Paula Figueiredo
Independent Java, Apache Tapestry 5 and Hibernate consultant, developer,  
and instructor
Owner, Ars Machina Tecnologia da Informação Ltda.
http://www.arsmachina.com.br

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org