You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by fmaylinch <fe...@gmail.com> on 2012/03/27 12:04:26 UTC

How to define a "private" service (a service only for another service)

Hello,

We've found that some times we would like to define a service that will only
be used from some specific services (for example, services inside the same
package).

Is there any way to do this in Tapestry? This way, the developer won't use
that "private" service from places where it is not supposed to be used.

We tried to declare its interface as "package-private" but it seems that
Tapestry can't find a package-private interface even when the module (where
the interface is binded) is inside the same package.

Thank you!

--
View this message in context: http://tapestry.1045711.n5.nabble.com/How-to-define-a-private-service-a-service-only-for-another-service-tp5597443p5597443.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: How to define a "private" service (a service only for another service)

Posted by Nicolas Barrera <nb...@gmail.com>.
Maybe you could use a custom annotation on the service... just like those
used for disambiguate services and make that anntotation only visible to
the service that needs the private service...

I 'm not really sure about this... in fact i haven't tested it and...  most
important i think this way of doing this seems quite hacky...

perhaps someone else got better invoice on this subject.


just throwing my ideas on the list...

Nicolás.-


On Tue, Mar 27, 2012 at 7:04 AM, fmaylinch <fe...@gmail.com> wrote:

> Hello,
>
> We've found that some times we would like to define a service that will
> only
> be used from some specific services (for example, services inside the same
> package).
>
> Is there any way to do this in Tapestry? This way, the developer won't use
> that "private" service from places where it is not supposed to be used.
>
> We tried to declare its interface as "package-private" but it seems that
> Tapestry can't find a package-private interface even when the module (where
> the interface is binded) is inside the same package.
>
> Thank you!
>
> --
> View this message in context:
> http://tapestry.1045711.n5.nabble.com/How-to-define-a-private-service-a-service-only-for-another-service-tp5597443p5597443.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: How to define a "private" service (a service only for another service)

Posted by fmaylinch <fe...@gmail.com>.
Denis Stepanov-2 wrote
> 
> It makes sense to have "private" services, would be nice to have services
> which will be only exposed to the services in the current module.
> 

That's a very good and concise way to describe the idea.
Thanks for your support! :)

--
View this message in context: http://tapestry.1045711.n5.nabble.com/How-to-define-a-private-service-a-service-only-for-another-service-tp5597443p5600151.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: How to define a "private" service (a service only for another service)

Posted by fmaylinch <fe...@gmail.com>.
Howard Lewis Ship wrote
> 
> In fact, in functional programming (such as Clojure) all data is
> "public" (but immutable) and most functions are also public.
> 

(Do you mean (making everything public) is the way to go) ?

;)


--
View this message in context: http://tapestry.1045711.n5.nabble.com/How-to-define-a-private-service-a-service-only-for-another-service-tp5597443p5610246.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: How to define a "private" service (a service only for another service)

Posted by Kalle Korhonen <ka...@gmail.com>.
I was too lazy/busy to write the same message but couldn't agree more.

Kalle


On Wed, Mar 28, 2012 at 2:03 PM, Howard Lewis Ship <hl...@gmail.com> wrote:
> HiveMind, the predecessor to Tapestry IoC, had private services &
> visibility. In my opinion, it caused more problems than it was worth.
>
> What I'm hearing is a basic lack of trust between one developer and
> another within your team. One possible solution there is to work on
> that, or better documentation about how your services are meant to be
> used.
>
> You can never make things simple by adding complexity. Adding privacy
> will increase complexity, and add whole new ambiguities ... such as
> who can see a service in order for it to be advised or decorated.
>
> In fact, I wish I had a time machine to tell myself that (there are a
> number of areas in Tapestry I would prefer to simplify).
>
> In terms of your initial problem, the special @Local annotation may be
> helpful, which limits an injection to just services defined within the
> same module as the service receiving the injection.
>
> On Wed, Mar 28, 2012 at 7:38 AM, fmaylinch <fe...@gmail.com> wrote:
>>
>> Nikla wrote
>>>
>>> I guess the suggested @ModulePrivate would be similar [to @Local] but
>>> controlling
>>> service exposure scope instead of lookup scope.
>>>
>>
>> Good idea!
>>
>> --
>> View this message in context: http://tapestry.1045711.n5.nabble.com/How-to-define-a-private-service-a-service-only-for-another-service-tp5597443p5600731.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
>>
>
>
>
> --
> 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
>

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


Re: How to define a "private" service (a service only for another service)

Posted by "Thiago H. de Paula Figueiredo" <th...@gmail.com>.
On Wed, 28 Mar 2012 18:03:39 -0300, Howard Lewis Ship <hl...@gmail.com>  
wrote:

> HiveMind, the predecessor to Tapestry IoC, had private services &
> visibility. In my opinion, it caused more problems than it was worth.
>
> What I'm hearing is a basic lack of trust between one developer and
> another within your team. One possible solution there is to work on
> that, or better documentation about how your services are meant to be
> used.
>
> You can never make things simple by adding complexity. Adding privacy
> will increase complexity, and add whole new ambiguities ... such as
> who can see a service in order for it to be advised or decorated.

Agreed. By the way, Tapestry itself has many services that aren't supposed  
to be used outside it. In other words, private services. The solution? Put  
them under org.apache.tapestry5.internal and have a big warning in the  
documentation about not using them.

-- 
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


Re: How to define a "private" service (a service only for another service)

Posted by Howard Lewis Ship <hl...@gmail.com>.
On Thu, Mar 29, 2012 at 1:12 AM, fmaylinch <fe...@gmail.com> wrote:
>
> Howard Lewis Ship wrote
>>
>> HiveMind, the predecessor to Tapestry IoC, had private services &
>> visibility. In my opinion, it caused more problems than it was worth.
>>
>> What I'm hearing is a basic lack of trust between one developer and
>> another within your team. One possible solution there is to work on
>> that, or better documentation about how your services are meant to be
>> used.
>>
>
> Although I don't know what problems you are talking about I am sure you have
> a good reason not to have private services. I like what I've seen about
> Tapestry so far so I trust you on that one.
>
> However, I don't think this is a question of lack of trust. Or if you want,
> yes, I don't trust my team, but I don't trust ME either! After all, many
> features of languages and frameworks are there because programming is
> difficult and error prone so we have to prevent us from making mistakes.
>
>
> Thiago H de Paula Figueiredo wrote
>>
>> Tapestry itself has many services that aren't supposed
>> to be used outside it. In other words, private services. The solution? Put
>> them under org.apache.tapestry5.internal and have a big warning in the
>> documentation about not using them.
>>
>
> When building out systems, why not declaring all classes, methods and
> properties as public and put a big warning in the documentation about which
> ones to use and which not to use?

Well, that would be Groovy then :-)

In fact, in functional programming (such as Clojure) all data is
"public" (but immutable) and most functions are also public.

>
> I don't agree with that. I'm not saying it would be better to hide those
> Tapestry services because I don't know the consequences. Until I know why, I
> must trust Howard when he says it is better this way. But I still think
> private services make sense.
>
> Thank you all for your comments!
>
> --
> View this message in context: http://tapestry.1045711.n5.nabble.com/How-to-define-a-private-service-a-service-only-for-another-service-tp5597443p5602960.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
>



-- 
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: How to define a "private" service (a service only for another service)

Posted by fmaylinch <fe...@gmail.com>.
Howard Lewis Ship wrote
> 
> HiveMind, the predecessor to Tapestry IoC, had private services &
> visibility. In my opinion, it caused more problems than it was worth.
> 
> What I'm hearing is a basic lack of trust between one developer and
> another within your team. One possible solution there is to work on
> that, or better documentation about how your services are meant to be
> used.
> 

Although I don't know what problems you are talking about I am sure you have
a good reason not to have private services. I like what I've seen about
Tapestry so far so I trust you on that one.

However, I don't think this is a question of lack of trust. Or if you want,
yes, I don't trust my team, but I don't trust ME either! After all, many
features of languages and frameworks are there because programming is
difficult and error prone so we have to prevent us from making mistakes.


Thiago H de Paula Figueiredo wrote
> 
> Tapestry itself has many services that aren't supposed  
> to be used outside it. In other words, private services. The solution? Put  
> them under org.apache.tapestry5.internal and have a big warning in the  
> documentation about not using them.
> 

When building out systems, why not declaring all classes, methods and
properties as public and put a big warning in the documentation about which
ones to use and which not to use?

I don't agree with that. I'm not saying it would be better to hide those
Tapestry services because I don't know the consequences. Until I know why, I
must trust Howard when he says it is better this way. But I still think
private services make sense.

Thank you all for your comments!

--
View this message in context: http://tapestry.1045711.n5.nabble.com/How-to-define-a-private-service-a-service-only-for-another-service-tp5597443p5602960.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: How to define a "private" service (a service only for another service)

Posted by Howard Lewis Ship <hl...@gmail.com>.
HiveMind, the predecessor to Tapestry IoC, had private services &
visibility. In my opinion, it caused more problems than it was worth.

What I'm hearing is a basic lack of trust between one developer and
another within your team. One possible solution there is to work on
that, or better documentation about how your services are meant to be
used.

You can never make things simple by adding complexity. Adding privacy
will increase complexity, and add whole new ambiguities ... such as
who can see a service in order for it to be advised or decorated.

In fact, I wish I had a time machine to tell myself that (there are a
number of areas in Tapestry I would prefer to simplify).

In terms of your initial problem, the special @Local annotation may be
helpful, which limits an injection to just services defined within the
same module as the service receiving the injection.

On Wed, Mar 28, 2012 at 7:38 AM, fmaylinch <fe...@gmail.com> wrote:
>
> Nikla wrote
>>
>> I guess the suggested @ModulePrivate would be similar [to @Local] but
>> controlling
>> service exposure scope instead of lookup scope.
>>
>
> Good idea!
>
> --
> View this message in context: http://tapestry.1045711.n5.nabble.com/How-to-define-a-private-service-a-service-only-for-another-service-tp5597443p5600731.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
>



-- 
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: How to define a "private" service (a service only for another service)

Posted by fmaylinch <fe...@gmail.com>.
Nikla wrote
> 
> I guess the suggested @ModulePrivate would be similar [to @Local] but
> controlling
> service exposure scope instead of lookup scope.
> 

Good idea!

--
View this message in context: http://tapestry.1045711.n5.nabble.com/How-to-define-a-private-service-a-service-only-for-another-service-tp5597443p5600731.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: How to define a "private" service (a service only for another service)

Posted by Nikla Ratinen <ni...@gmail.com>.
Hi,

>> [...] a list of additional classes to be treated as module classes,
>> exactly as if they were identified in the manifest. Despite the name,
>> there is no hierarchy of modules in Tapestry IoC.
>>
>

The documentation is perhaps not 100% accurate here. @Local can be used to
restrict service lookup scope to same module so there is already sorts of
hierarchy going on.

I guess the suggested @ModulePrivate would be similar but controlling
service exposure scope instead of lookup scope.

Cheers,
--Nikla


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


Re: How to define a "private" service (a service only for another service)

Posted by fmaylinch <fe...@gmail.com>.
Tapestry doc says that @SubModule specifies...



> [...] a list of additional classes to be treated as module classes,
> exactly as if they were identified in the manifest. Despite the name,
> there is no hierarchy of modules in Tapestry IoC.
> 

So services added to submodules would be visible as if they were added to
"normal" modules, wouldn't they?

--
View this message in context: http://tapestry.1045711.n5.nabble.com/How-to-define-a-private-service-a-service-only-for-another-service-tp5597443p5600325.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: How to define a "private" service (a service only for another service)

Posted by Lance Java <la...@googlemail.com>.
No, this "private" functionality does not exist. I was merely throwing the
idea around with Denis.

I think that denis is talking about implementing a new annotation
(@ModulePrivate or similar) which you could add to service definitions.
These services would then only be available within the SubModule and would
not be exposed outside the SubModule.

On Wednesday, 28 March 2012, fmaylinch <fe...@gmail.com> wrote:
>
> Lance Java wrote
>>
>> Nice idea, so I guess in this case you include a submodule with a public
>> and a private service including the private advice but only the public
>> service is added to the top level module
>>
>
> Do you mean using the @SubModule annotation?
> And you think services included in submodules won't be available to other
> modules?
> Can you give us an example on how to do what you suggest?
>
> Thanks!
>
> --
> View this message in context:
http://tapestry.1045711.n5.nabble.com/How-to-define-a-private-service-a-service-only-for-another-service-tp5597443p5600313.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: How to define a "private" service (a service only for another service)

Posted by fmaylinch <fe...@gmail.com>.
Lance Java wrote
> 
> Nice idea, so I guess in this case you include a submodule with a public
> and a private service including the private advice but only the public
> service is added to the top level module
> 

Do you mean using the @SubModule annotation?
And you think services included in submodules won't be available to other
modules?
Can you give us an example on how to do what you suggest?

Thanks!

--
View this message in context: http://tapestry.1045711.n5.nabble.com/How-to-define-a-private-service-a-service-only-for-another-service-tp5597443p5600313.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: How to define a "private" service (a service only for another service)

Posted by Lance Java <la...@googlemail.com>.
Nice idea, so I guess in this case you include a submodule with a public
and a private service including the private advice but only the public
service is added to the top level module

On Wednesday, 28 March 2012, Denis Stepanov <de...@gmail.com>
wrote:
> It makes sense to have "private" services, would be nice to have services
which will be only exposed to the services in the current module.
>
> Denis
>
> Mar 28, 2012 v 12:43 PM, Lance Java:
>
>> I have never done this myself but see here for instantiating a Tapestry
IOC
>> registry yourself
>> http://wiki.apache.org/tapestry/Tapestry5HowToIocOnly
>>
>> If you want the private registry to inherit the public registry I think
>> that you will need to use RegistryBuilder.add(ModuleDef)
>>
>>
http://tapestry.apache.org/tapestry5/apidocs/org/apache/tapestry5/ioc/RegistryBuilder.html#add%28org.apache.tapestry5.ioc.def.ModuleDef%29
>>
>> I am surprised that Tapestry does not eat it's own dogfood, I would have
>> thought that Registry would have implemented ModuleDef or that there was
at
>> least an adapter available.
>>
>>
http://tapestry.apache.org/tapestry5/apidocs/org/apache/tapestry5/ioc/def/ModuleDef.html
>>
>> You may need to write a RegistryModuleDef which does a job to the
>> SpringModuleDef
>>
http://tapestry.apache.org/tapestry5/apidocs/org/apache/tapestry5/internal/spring/SpringModuleDef.html
>>
>> On Wednesday, 28 March 2012, fmaylinch <fe...@gmail.com> wrote:
>>>
>>> Lance Java wrote
>>>>
>>>> Perhaps a solution is to setup a second, private Tapestry IOC registry
>> for
>>>> defining your private services. Your public service then looks up the
>>>> private service from the private registry instead of from the public
>>>> registry.
>>>>
>>>
>>> Interesting solution... any help on how to do that will be appreciated.
>>>
>>> Anyway, I think that this solution means there would be many private
>>> services together, and they will be available to services they don't
>> belong
>>> to. For example, if A1 needs A2 and B1 needs B2, your solution is to put
>> A1
>>> and B1 in the "public" default registry and A2 and B2 in another
"private"
>>> registry. But that way A1 could access B2 when that is not our
intention.
>>>
>>> But thank you! Maybe we could use that idea somehow. As I said, can you
>>> explain me how to do that or give me some ideas?
>>>
>>>
>>> --
>>> View this message in context:
>>
http://tapestry.1045711.n5.nabble.com/How-to-define-a-private-service-a-service-only-for-another-service-tp5597443p5600049.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
>>>
>>>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>

Re: How to define a "private" service (a service only for another service)

Posted by Denis Stepanov <de...@gmail.com>.
It makes sense to have "private" services, would be nice to have services which will be only exposed to the services in the current module.

Denis

Mar 28, 2012 v 12:43 PM, Lance Java:

> I have never done this myself but see here for instantiating a Tapestry IOC
> registry yourself
> http://wiki.apache.org/tapestry/Tapestry5HowToIocOnly
> 
> If you want the private registry to inherit the public registry I think
> that you will need to use RegistryBuilder.add(ModuleDef)
> 
> http://tapestry.apache.org/tapestry5/apidocs/org/apache/tapestry5/ioc/RegistryBuilder.html#add%28org.apache.tapestry5.ioc.def.ModuleDef%29
> 
> I am surprised that Tapestry does not eat it's own dogfood, I would have
> thought that Registry would have implemented ModuleDef or that there was at
> least an adapter available.
> 
> http://tapestry.apache.org/tapestry5/apidocs/org/apache/tapestry5/ioc/def/ModuleDef.html
> 
> You may need to write a RegistryModuleDef which does a job to the
> SpringModuleDef
> http://tapestry.apache.org/tapestry5/apidocs/org/apache/tapestry5/internal/spring/SpringModuleDef.html
> 
> On Wednesday, 28 March 2012, fmaylinch <fe...@gmail.com> wrote:
>> 
>> Lance Java wrote
>>> 
>>> Perhaps a solution is to setup a second, private Tapestry IOC registry
> for
>>> defining your private services. Your public service then looks up the
>>> private service from the private registry instead of from the public
>>> registry.
>>> 
>> 
>> Interesting solution... any help on how to do that will be appreciated.
>> 
>> Anyway, I think that this solution means there would be many private
>> services together, and they will be available to services they don't
> belong
>> to. For example, if A1 needs A2 and B1 needs B2, your solution is to put
> A1
>> and B1 in the "public" default registry and A2 and B2 in another "private"
>> registry. But that way A1 could access B2 when that is not our intention.
>> 
>> But thank you! Maybe we could use that idea somehow. As I said, can you
>> explain me how to do that or give me some ideas?
>> 
>> 
>> --
>> View this message in context:
> http://tapestry.1045711.n5.nabble.com/How-to-define-a-private-service-a-service-only-for-another-service-tp5597443p5600049.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
>> 
>> 


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


Re: How to define a "private" service (a service only for another service)

Posted by Lance Java <la...@googlemail.com>.
I have never done this myself but see here for instantiating a Tapestry IOC
registry yourself
http://wiki.apache.org/tapestry/Tapestry5HowToIocOnly

If you want the private registry to inherit the public registry I think
that you will need to use RegistryBuilder.add(ModuleDef)

http://tapestry.apache.org/tapestry5/apidocs/org/apache/tapestry5/ioc/RegistryBuilder.html#add%28org.apache.tapestry5.ioc.def.ModuleDef%29

I am surprised that Tapestry does not eat it's own dogfood, I would have
thought that Registry would have implemented ModuleDef or that there was at
least an adapter available.

http://tapestry.apache.org/tapestry5/apidocs/org/apache/tapestry5/ioc/def/ModuleDef.html

You may need to write a RegistryModuleDef which does a job to the
SpringModuleDef
http://tapestry.apache.org/tapestry5/apidocs/org/apache/tapestry5/internal/spring/SpringModuleDef.html

On Wednesday, 28 March 2012, fmaylinch <fe...@gmail.com> wrote:
>
> Lance Java wrote
>>
>> Perhaps a solution is to setup a second, private Tapestry IOC registry
for
>> defining your private services. Your public service then looks up the
>> private service from the private registry instead of from the public
>> registry.
>>
>
> Interesting solution... any help on how to do that will be appreciated.
>
> Anyway, I think that this solution means there would be many private
> services together, and they will be available to services they don't
belong
> to. For example, if A1 needs A2 and B1 needs B2, your solution is to put
A1
> and B1 in the "public" default registry and A2 and B2 in another "private"
> registry. But that way A1 could access B2 when that is not our intention.
>
> But thank you! Maybe we could use that idea somehow. As I said, can you
> explain me how to do that or give me some ideas?
>
>
> --
> View this message in context:
http://tapestry.1045711.n5.nabble.com/How-to-define-a-private-service-a-service-only-for-another-service-tp5597443p5600049.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: How to define a "private" service (a service only for another service)

Posted by fmaylinch <fe...@gmail.com>.
Lance Java wrote
> 
> Perhaps a solution is to setup a second, private Tapestry IOC registry for
> defining your private services. Your public service then looks up the
> private service from the private registry instead of from the public
> registry.
> 

Interesting solution... any help on how to do that will be appreciated.

Anyway, I think that this solution means there would be many private
services together, and they will be available to services they don't belong
to. For example, if A1 needs A2 and B1 needs B2, your solution is to put A1
and B1 in the "public" default registry and A2 and B2 in another "private"
registry. But that way A1 could access B2 when that is not our intention.

But thank you! Maybe we could use that idea somehow. As I said, can you
explain me how to do that or give me some ideas?


--
View this message in context: http://tapestry.1045711.n5.nabble.com/How-to-define-a-private-service-a-service-only-for-another-service-tp5597443p5600049.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: How to define a "private" service (a service only for another service)

Posted by Lance Java <la...@googlemail.com>.
You seem to be asking for contradictory things:
1. I don't want MyPrivateService to be available in the Tapestry registry
2. I want MyPrivateService available in the Tapestry registry so that I can
advise it

Perhaps a solution is to setup a second, private Tapestry IOC registry for
defining your private services. Your public service then looks up the
private service from the private registry instead of from the public
registry.

On Wednesday, 28 March 2012, fmaylinch <fe...@gmail.com> wrote:
>
> Kalle Korhonen-2 wrote
>>
>> Well, you have multiple instances of the object that you are using a
>> "private service". If you needed to, the instances could use private
>> static variables to hold the state. It's typically not a good idea to
>> make a service stateful, but since you were asking about making a
>> private service (i.e. a single instance), I assumed you specifically
>> have a need for creating a singleton.
>>
>
> Sorry, I still don't get you... Can you write an example? Some simple
> pseudocode is fine. Thank you!
>
> We can't use the @Autobuild solution because we need to advise methods of
> this "private" service, so I suppose we need to "publish" the service (via
> "bind" or "build" method) so we can apply the advisor this way:
>
>        @Match({"MyPrivateService"})
>        public static void adviseTransactions(HibernateTransactionAdvisor
advisor,
> MethodAdviceReceiver receiver)
>        {
>                advisor.addTransactionCommitAdvice(receiver);
>        }
>
> I've been thinking about the whole idea of this "private" service and the
> reason we need it is because some service A uses methods from service B
but
> no other page or service should use B directly; everyone else should
perform
> operations through A. But methods inside B can't be moved to A because B
> methods must be advised.
>
> I think Tapestry could offer some solution to this situation, don't you
> think? (It's a suggestion)
>
> Thank you all for your help!
>
> --
> View this message in context:
http://tapestry.1045711.n5.nabble.com/How-to-define-a-private-service-a-service-only-for-another-service-tp5597443p5599854.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: How to define a "private" service (a service only for another service)

Posted by fmaylinch <fe...@gmail.com>.
Kalle Korhonen-2 wrote
> 
> Well, you have multiple instances of the object that you are using a
> "private service". If you needed to, the instances could use private
> static variables to hold the state. It's typically not a good idea to
> make a service stateful, but since you were asking about making a
> private service (i.e. a single instance), I assumed you specifically
> have a need for creating a singleton.
> 

Sorry, I still don't get you... Can you write an example? Some simple
pseudocode is fine. Thank you!

We can't use the @Autobuild solution because we need to advise methods of
this "private" service, so I suppose we need to "publish" the service (via
"bind" or "build" method) so we can apply the advisor this way:

	@Match({"MyPrivateService"})
	public static void adviseTransactions(HibernateTransactionAdvisor advisor,
MethodAdviceReceiver receiver)
	{
		advisor.addTransactionCommitAdvice(receiver);
	}

I've been thinking about the whole idea of this "private" service and the
reason we need it is because some service A uses methods from service B but
no other page or service should use B directly; everyone else should perform
operations through A. But methods inside B can't be moved to A because B
methods must be advised.

I think Tapestry could offer some solution to this situation, don't you
think? (It's a suggestion)

Thank you all for your help!

--
View this message in context: http://tapestry.1045711.n5.nabble.com/How-to-define-a-private-service-a-service-only-for-another-service-tp5597443p5599854.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: How to define a "private" service (a service only for another service)

Posted by Kalle Korhonen <ka...@gmail.com>.
On Tue, Mar 27, 2012 at 8:17 AM, fmaylinch <fe...@gmail.com> wrote:
>> Could you just inject an object with @Autobuild to your service? You'd
> Thank you! Maybe we could use that.
>> If you really needed, you could use static
>> protected or static package private operations to synchronize state.
> I don't understand what you mean here. Can you explain it?

Well, you have multiple instances of the object that you are using a
"private service". If you needed to, the instances could use private
static variables to hold the state. It's typically not a good idea to
make a service stateful, but since you were asking about making a
private service (i.e. a single instance), I assumed you specifically
have a need for creating a singleton.

Kalle

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


Re: How to define a "private" service (a service only for another service)

Posted by fmaylinch <fe...@gmail.com>.
Kalle Korhonen-2 wrote
> 
> Could you just inject an object with @Autobuild to your service? You'd
> get one per service it's used in but the object itself wouldn't be
> available as a service.
> 
Thank you! Maybe we could use that.


Kalle Korhonen-2 wrote
> 
> If you really needed, you could use static
> protected or static package private operations to synchronize state.
> 
I don't understand what you mean here. Can you explain it?

--
View this message in context: http://tapestry.1045711.n5.nabble.com/How-to-define-a-private-service-a-service-only-for-another-service-tp5597443p5598131.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: How to define a "private" service (a service only for another service)

Posted by Kalle Korhonen <ka...@gmail.com>.
On Tue, Mar 27, 2012 at 3:04 AM, fmaylinch <fe...@gmail.com> wrote:
> We've found that some times we would like to define a service that will only
> be used from some specific services (for example, services inside the same
> package).
> Is there any way to do this in Tapestry? This way, the developer won't use
> that "private" service from places where it is not supposed to be used.

Could you just inject an object with @Autobuild to your service? You'd
get one per service it's used in but the object itself wouldn't be
available as a service. If you really needed, you could use static
protected or static package private operations to synchronize state.

Kalle

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