commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From <>
Subject Re: [Hivemind] ServiceImplementationFactory - no Exception (?)
Date Wed, 17 Mar 2004 18:37:53 GMT
You are right.  I probably got a good proxy, but a null in 
a dependancy caused this.

Here are a few points:

1. I see HiveMind being much more dynamic and inline to 
the app than a deployed servlet.  This comparison was done 
as a reason for not throwing an exeption.

2. ** When I moved code from...

// Load up static config
MyClass.configure(arg1, arg2, arg3)
MyClass service = MyClass.getInstance();



(MyClass) service = (MyClass) registry.getService(....

My overall after debugging the error was "Hivemind makes 
it harder to unit test because there is this nasty buried 

3. Hivemind is, at its core, object creational (via 
creating services).  There are a bunch of things that can 
go wrong here.  If we want to encourage users to use 
HiveMind services with lots of small components, I see 
good expcetion handling being critical.

HiveMind is flexible, which has its price with runtime 

The statement...

} catch (Exception e) {
   // Bury it here

is quite brittle to the calling app.

*** $64000 Final question

Without an exception, and since my object was not null, 
how does the app know a problem was encountered??  log4j 
is great for humans viewing the log, but log4j is not a 
notification mechanism for the app, and does not affect 
control flow.

On Wed, 17 Mar 2004 14:26:12 +0100
  Christian Essl <> wrote:
>>But, if I'm a client and I call registry.getService() I 
>>absolutely want a
>>service or an exception! Otherwise I have to stick null 
>>checks in all 
>I agree. Actullay I was always expecting HiveMind to do 
>that. This is also more consistent, because if the module 
>or the ServiceExtensionPoint is not found an 
>ApplicationRuntimeException is thrown.
>But now I am a bit confused about where this null comes 
>from. As I see all ServiceModels - except of primitive - 
>always return a proxy, independent of what the factory 
>actually returns. And the primitive ServiceModel (and as 
>I think the other Models as well) uses 
>which does check for null and throws an 
>Maybe Benjamin you could tell how you got this null. So 
>that it could be reproduced on the current HiveMind from 
>the cvs. To me it looks like a bug. Or maybe you used an 
>ServiceImplementationFactory directly - Spring like?  Or 
>I just miss something.
>On Wed, 17 Mar 2004 01:34:28 -0500, Geoff Longman 
><> wrote:
>>Wait a sec. Sure log errors when the modules are parsed. 
>>That makes 
>>But, if I'm a client and I call registry.getService() I 
>>absolutely want a
>>service or an exception! Otherwise I have to stick null 
>>checks in all 
>>the place.
>>----- Original Message -----
>>From: "Harish Krishnaswamy" <>
>>To: "Jakarta Commons Developers List" 
>>Sent: Tuesday, March 16, 2004 10:34 PM
>>Subject: Re: [Hivemind] ServiceImplementationFactory - no 
>>Exception (?)
>>>Not throwing an exception is a conscious decision. 
>>>HiveMind is a
>>>microkernal to be thought of as a servlet container - it 
>>>loads all
>>>modules at startup and any problems with the descriptors 
>>>will be
>>>identified and logged at load time but will continue to 
>>>run. I can see
>>>an exception being thrown at load time when there is a 
>>>problem but
>>>certainly disagree with the idea of throwing exceptions 
>>>at runtime. If a
>>>service is not loaded properly you have two options - 
>>>don't care or fix
>>>it and reload it!
>>>Benjamin Tomasini wrote:
>>>>I have started to use Hivemind and have been successful 
>>>>in porting over
>>>>some existing work.  It is quite nice!  Very well thought 
>>>>out. Keeping
>>>>the service / proxy layer in place is cool.
>>>>One suggestion so far...
>>>>I had a case where my service object from 
>>>>Registry.getService came back
>>>>null.  One of the services used the BuilderFactory.  I 
>>>>was getting a
>>>>log4j ERROR message, but no exception was thrown to my 
>>>>app.  It was a
>>>>simple runtime error - a typo in a config file.
>>>>Looking further, I see that
>>>>the method
>>>>does not throw an exception or anything.
>>>>It seems that this prevents calling applications from 
>>>>knowing about
>>>>problems creating a service.  I could always check for 
>>>>null in the
>>>>service object, but this isn't quite right, IMO. 
>>>> Especially with the
>>>>lazy loading, I think burying any exception here is bad, 
>>>>especially for
>>>>apps that depend on a large number of services.
>>>>I would be willing to put some work into this and submit 
>>>>a patch if we
>>>>think we need some exception handling here.
>>>>To unsubscribe, e-mail: 
>>>>For additional commands, e-mail: 
>>>To unsubscribe, e-mail: 
>>>For additional commands, e-mail: 
>>To unsubscribe, e-mail: 
>>For additional commands, e-mail: 
>Christian Essl 
>To unsubscribe, e-mail: 
>For additional commands, e-mail: 

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message