Carsten Ziegeler wrote:

Sylvain Wallez wrote:


Carsten Ziegeler wrote:

Sorry, I should have missed something. What is the purpose of a service interface that just returns an object. Why isn't this object the component itself? Just like the current OM contains the request and response objects, and not proxy components that give us access to request and response.


The request and response objects are put into the OM hard coded. If we
want to have a more dynamic way, we need to "register" some factories
that are able to create objects and these objects are then stored in the OM.



Ah ok, I see. So the getObject() method is responsible of returning the object that is part of the object model, according to the current execution context.


So in essence, the get() method on object model, which can be a special subclass of HashMap would be:

Object get(Object name) {
   // call the regular Map get method
   Object result = super.get(name);
   if (result instanceof Module) {
       // Dereference the module
       return ((Module)result).get();
   } else {
       return result;
   }
}

If I understand you correctly you want to put the factories into the OM
directly - but than every request has the same starting object. And in
addition it might be that some objects are not available for each
request. For example a user objects is only available if the user has
logged in etc.
So, imho we need some dynamic factories.



Sorry, you lost me ;-)

If we consider that the object model is a Map of object factories (the Module interface) which returns objects created by factories rather than the factories themselves (as illustrated above), then the object model can be the same for every request. Each factory/module will then be responsible for returning null if it doesn't have a value in the current context.

IMO, this makes things really simple, as configuring the object model simply consists in creating a singleton Map that is filled with factories.

Sylvain

--
Sylvain Wallez                                  Anyware Technologies
http://www.apache.org/~sylvain           http://www.anyware-tech.com
{ XML, Java, Cocoon, OpenSource }*{ Training, Consulting, Projects }



Reply via email to