Carsten Ziegeler wrote:
<snip/> > I'm currently totally confused about the ECM code. If you look at the > lookup method and compare it with the hasComponent() method, I see > a big difference. > > The hasComponent() only tests if the handler for the role is available > and if not passes the request on to the parent CM. > The lookup method tests if it has a handler, if not uses the parent CM > and if the parent is not able to serve the request, the strange part > begins. It starts with: > if( null != m_roles ) > { > final String className = > m_roles.getDefaultClassNameForRole( role ); > ... > Why is this only in the lookup method, but not in the hasComponent()? The hasComponent() method is used to look up to see if an optional exists. The ECM assumes that if you did not specify the component in the configuration file, you did not want it. THerefore, the hasComponent() simply returns if the component exists in the system at present. The lookup() method is a bit more accomodating in that it doesn't want to leave you empty handed if it can help it. If you lookup() a role instead of checking if it exists first, the ECM assumes you _really_ want the component even if you didn't specify it in the config file. It looks at the RoleManager to see if it can provide a default implementation for you. If not, it still throws an exception. Subsequent calls for hasComponent() will return true for the specific role. There are two reasons for this approach: 1) hasComponent() should be side-effect free and quick 2) We need to have the option to not have a component loaded if we don't want it. In Cocoon, there are alot of defaults for components--but we don't always want the HSQL server loaded. We do always want a parser, but many times the default parser is just fine. Required components are just looked up, and a failure to find that component results in a failure for the component that tried to find it. Optional components are checked to see if they exist yet, and only looked up if they do. > > PS: It's not my best day today, so sorry if I ask dumb questions. Not dumb at all. -- "They that give up essential liberty to obtain a little temporary safety deserve neither liberty nor safety." - Benjamin Franklin -- To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>