Results 1 to 7 of 7

Thread: locate subclasses of abstract class/interface

  1. #1
    Join Date
    Mar 2005
    Posts
    21

    Default locate subclasses of abstract class/interface

    I have following problem:
    I need to split application into two parts:
    core part and plugin parts, which will define plugin dependent parts of core objects. Core object should not reference any plugin parts.
    Only binding between mentioned parts should be done in the web.xml file, where the config files for the BeanFactory are defined.
    Core objects should be able to enumerate all plugin parts, which are present in the classpath(or in BeanFactory configuration)


    It is possible to this with Spring?
    Is there any possibility to find all subclasses of defined abstract class/interface in all config files ?

  2. #2
    Join Date
    Nov 2004
    Location
    Hilversum - The Netherlands
    Posts
    1,054

    Default Re: locate subclasses of abstract class/interface

    Quote Originally Posted by ferencvaros
    I have following problem:
    I need to split application into two parts:
    core part and plugin parts, which will define plugin dependent parts of core objects. Core object should not reference any plugin parts.
    Only binding between mentioned parts should be done in the web.xml file, where the config files for the BeanFactory are defined.
    Core objects should be able to enumerate all plugin parts, which are present in the classpath(or in BeanFactory configuration)
    Why do so difficult?

    Plugin example:
    Code:
    <bean	id="pluginManager"
    		class="PluginManager">
    	
    	<constructor-arg>
    		<list>
    			<bean class="HtmlPlugin"/>
    			<bean class="PdfPlugin"/>
    			<bean class="TextPlugin"/>
    		</list>
    	</constructor-arg>	
    </bean>
    It is possible to this with Spring?
    If it is possible in Java it is possible in Spring. Don`t let Spring drive your design.. You are in control of your design, so you decide how you want it.

    Is there any possibility to find all subclasses of defined abstract class/interface in all config files ?
    I don`t think you want this. I prefer to register me plugins myself and don`t want to scan the whole classpath. This allows greater control what to use and what not to use. Sometimes you don`t want something but does exist as a classfile.

  3. #3
    Join Date
    Mar 2005
    Posts
    21

    Default

    Problem with your approach is, that in your example you directly defined beans references, names and amount of beans. But if you want to extend application to the new plugin, you must edit the file in the core part and that's the problem.
    I need to locate all plugins (all defined plug-in subclasses of abstract core class) whithout directly referencing them in the core part.

  4. #4
    Join Date
    Mar 2005
    Posts
    21

    Default

    I found class BeanFactoryUtils which contains beansOfTypeIncludingAncestors() method. Maybe this will help.

  5. #5
    Join Date
    Nov 2004
    Location
    Hilversum - The Netherlands
    Posts
    1,054

    Default

    Quote Originally Posted by ferencvaros
    Problem with your approach is, that in your example you directly defined beans references, names and amount of beans. But if you want to extend application to the new plugin, you must edit the file in the core part and that's the problem.
    Hmm.. normally I don`t find this a problem. In the appcontext I create a concrete application with specific functionality.

    I need to locate all plugins (all defined plug-in subclasses of abstract core class) whithout directly referencing them in the core part.
    Hmm.. but how are you going to deal with unwanted plugins? You don`t have control. Is it not a lot easier that you register the plugins yourself?

    If you really want to seperate it, you could use multiple appcontext-files. One core file with no specific functionality. And one concrete part where you could locate the pluginmanager en register your plugins.

  6. #6
    Join Date
    Mar 2005
    Posts
    21

    Default

    control over registered plugins will be only via appcontext config-file entry in the web.xml file - each plugin will define its own appcontext config file

  7. #7
    Join Date
    Mar 2005
    Posts
    21

    Default

    now, it works.

    I defined bean pluginManager in the core part, then I defined bean factory postprocessor, which call method:
    Code:
    BeanFactoryUtils.beansOfTypeIncludingAncestors&#40;factory, AbstractNeNavigator.class&#41;
    and return value sets to the pluginManager as reference.

Similar Threads

  1. PerformanceMonitorInceptor
    By chenrici in forum AOP
    Replies: 15
    Last Post: May 18th, 2006, 04:28 PM
  2. AopCoinfigException is normal?
    By Donald in forum AOP
    Replies: 2
    Last Post: Sep 28th, 2005, 09:12 AM
  3. PerformanceMonitorInterceptor
    By tnist in forum AOP
    Replies: 3
    Last Post: Aug 24th, 2005, 01:39 PM
  4. Abstract classes and bean definitions
    By pepper in forum Web
    Replies: 1
    Last Post: Mar 9th, 2005, 12:23 PM
  5. Abstract Schema
    By oliverhutchison in forum AOP
    Replies: 1
    Last Post: Nov 1st, 2004, 03:01 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •