I like this breakup! Expanding on this, how about splitting the
ClasspathModuleProvider into a XmlModuleProvider and a
ClasspathXmlModuleProvider:

class XmlModuleProvider implements ModuleProvider {
  XmlModuleProvider(Resource resource) {...}
  XmlModuleProvider(List resources) {...}
  List getModuleDescriptors() {...}
}

ClasspathXmlModule would just be responsible for iterating over a
classpath (using a ClassResolver) and delegate to XmlModuleProvider
for parsing.

--knut

On Mon, 06 Sep 2004 22:38:53 +0200, Achim Huegen <[EMAIL PROTECTED]> wrote:
> I think a refactoring does make a lot of sense here.
> IMO RegistryBuilder knows too much about finding module descriptors and
> about their format.
> The search for "META-INF/hivemodule.xml" and the xml-processing should be
> shifted
> to specialized classes.
> I could imagine these responsibilities:
> 
> // Providers supply a list of ModuleDescriptors to the registryBuilder
> public interface ModuleProvider {
>    public List getModuleDescriptors(ErrorHandler errorHandler,
> RegistryAssembly assembly);
> }
> 
> // RegistryBuilder accepts a list of ModuleProviders in constructRegistry
> public class RegistryBuilder
> {
>    public constructRegistry( List providers ) {
>      // calls getModuleDescriptors() on all providers
>      // and adds them by calling processModule
>    }
> }
> 
> // Provider that searches for XML-Descriptors in classpath
> // default path is "META-INF/hivemodule.xml" (configurable)
> // Logic from RegistryBuilder#processModules and processModulesResources
> // is moved over here
> public class ClasspathModuleProvider implements ModuleProvider
> {
>    public ClasspathModuleProvider(ClassResolver resolver, String
> resourcePath)
>    public List getModuleDescriptors(ErrorHandler errorHandler,
> RegistryAssembly assembly);
> }
> 
> This would allow the easy implementation of additional providers, which
> read modules from a database, jndi, or just work on an array of filenames:
> For example the implementation of
> HiveMindTestcase#buildFrameworkRegistry(String[] files)
> could look like this:
> {
>    ModuleProvider provider = new FileListModuleProvider( files );
>    return builder.constructRegistry(provider);
> }
> 
> Achim Huegen
>

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to