You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-dev@axis.apache.org by Glen Daniels <gl...@thoughtcraft.com> on 2009/05/19 06:08:40 UTC

[axis2] AxisConfiguration.getService() and inactive services

Hi y'all:

So I'm cleaning up a little code and javadoc, and happened to come across
AxisConfiguration.getService()... which *throws an Exception* if you ask for
an inactive service.

...which is why we have a second method called "getServiceForActivation()"
that simply avoids the check and the exception.

Does this make sense?  Why?

--Glen

Re: [axis2] AxisConfiguration.getService() and inactive services

Posted by Deepal jayasinghe <de...@gmail.com>.
Hi Glen,
> Throwing an exception to do this is (IMHO) bad code.  It's expensive, slower,
> non-intuitive (what would you expect "getService()" to do?) and just plain
> annoying for people calling this method.
>   
Well inactive service treat as same as  service is not there in the
system. So I do not see a big problem of throwing the exception (other
than it is costly). You will get the same exception if the service is
not deployed in the system or service is inactive. IMO, throwing the
exception is consistent, since we do the same thing for the operation,
module etc..
> getService(name) should return the AxisService matching the name if there is
> one, period, end of story, just like all the other accessors like it do.
>   
No there should be a difference between active and inactive service. So
it should throw exception (or null) if the service is not there or inactive.
> If you don't want the dispatch code to call "isActive()" on the resulting
> service (which IMHO isn't that egregious), a getActiveService(name) utility
> method would be fine, which would simply return null if there was a service
> by the specified name that was inactive.  No exceptions necessary.
>   
I like your idea, but my belief is we should not change those methods
now, since it is everywhere, may be we can introduce new methods.
> Thoughts?
>
> --Glen
>
> P.S.  This is all not to mention that "getServiceForActivation()" is a
> terrible name for a method that simply returns you a service.
>   
I know, I should have changed that to getInactiveService or something.

Deepal

Re: [axis2] AxisConfiguration.getService() and inactive services

Posted by Glen Daniels <gl...@thoughtcraft.com>.
Hi Deepal:

Deepal jayasinghe wrote:
> Yes, there is a difference. One method is for management other method is
> for dispatching.
> So at the runtime when a message receive we call getService, and if we
> want to activate, inactivate we call other method.

Throwing an exception to do this is (IMHO) bad code.  It's expensive, slower,
non-intuitive (what would you expect "getService()" to do?) and just plain
annoying for people calling this method.

getService(name) should return the AxisService matching the name if there is
one, period, end of story, just like all the other accessors like it do.

If you don't want the dispatch code to call "isActive()" on the resulting
service (which IMHO isn't that egregious), a getActiveService(name) utility
method would be fine, which would simply return null if there was a service
by the specified name that was inactive.  No exceptions necessary.

Thoughts?

--Glen

P.S.  This is all not to mention that "getServiceForActivation()" is a
terrible name for a method that simply returns you a service.

> Deepal
>> Hi y'all:
>>
>> So I'm cleaning up a little code and javadoc, and happened to come across
>> AxisConfiguration.getService()... which *throws an Exception* if you ask for
>> an inactive service.
>>
>> ...which is why we have a second method called "getServiceForActivation()"
>> that simply avoids the check and the exception.
>>
>> Does this make sense?  Why?
>>
>> --Glen
>>
>>   
> 
> 

Re: [axis2] AxisConfiguration.getService() and inactive services

Posted by Deepal jayasinghe <de...@gmail.com>.
Yes, there is a difference. One method is for management other method is
for dispatching.
So at the runtime when a message receive we call getService, and if we
want to activate, inactivate we call other method.

So please do not remove the method.

Deepal
> Hi y'all:
>
> So I'm cleaning up a little code and javadoc, and happened to come across
> AxisConfiguration.getService()... which *throws an Exception* if you ask for
> an inactive service.
>
> ...which is why we have a second method called "getServiceForActivation()"
> that simply avoids the check and the exception.
>
> Does this make sense?  Why?
>
> --Glen
>
>   


-- 
Thank you!


http://blogs.deepal.org
http://deepal.org