Thread: [SrcML] new plugin handling and API structure
Status: Beta
Brought to you by:
crashchaos
From: Frank R. <fra...@in...> - 2005-04-20 17:47:41
|
This is a summary of the discussion we had about restructuring the API and turn it into a plugin architecture. Everyone please feel free to comment on these points and add your own ideas where they differ from the proposed changes. As these changes will heavily affect the applications it will be best to get them into CVS as soon as possible to reduce the affection for the other projects. It is also not viable to wait with the restructuring until the semester is over, as this would mean all projects would have to be adjusted again. The actual changes to applications should however not be too drastic. With the currently planned design the plugin loading code should be significantly shorter and as the current API will be the default API plugin there won't be any changes neccessary for the actual usage. - New plugin architecture In order for the planned API restructuring we need a more powerful plugin structure behind it. Therefore the config module will have to be extended and the existing plugins will have to be adjusted to the new plugin scheme. We want plugins to integrate as easily as possible, and therefore the current .srcml/plugin_type.xml files in which every plugin had to be manually registered for now should be replaced by a .srcml/plugins directory. The installation of a new plugin is then reduced to copying the plugin's .jar file into this directory. The content of a plugin's .jar file should be a plugin.xml file and additional .class files for the plugin's implemented methods. Optionally source files or other helpful files may be included of course. The responsibility of the rewritten config handler will be to check the .srcml/plugins directory for any .jar files and read out the plugin.xml file from each. Now these plugin.xml files will contain a fixed meta-data portion as well as additional tags important for the individual plugin. Here's the common parts every plugin will have to include in it's plugin.xml definition: <plugin name="plugin name" version="x.y.z" homepage="http://find.the.plugin.here" type="parser" classname="de.srcml.foo.Bar" > <authors> <!-- typical authors markup. might be best if similar to docbook --> </authors> <dependencies> <depends name="other plugin's name" version="minimum version of plugin"/> <depends name="yet another plugin" version="u.v.w"/> </dependencies> <!-- plugin specific information --> </plugin> Plugins for all platforms (for now this includes API, Parser and View platforms) will then be loaded through a single method in the de.srcml.config.PluginManager class. Here's a sample call to load the java parser plugin for the ParserPlatform: Plugin p = PluginManager.loadPlugin( "java", "0.1.0", PluginManager.TYPE_PARSER); And here's what the PluginManager class will do with such a call: 1) It checks its list of plugins (gained earlier from reading in all the plugin.xml files.. or maybe reading them now on demand to save some startup time) for a plugin of this type and name. It will then check if there is a plugin matching exactly the requested version number, otherwise the latest version is used. 2) Once the correct plugin is found the dependencies will be checked recursively. To this end a dependency tree is built and topologically sorted. 3) Walk the dependency tree from the plugin requiring no dependencies to the actually requested plugin. For each plugin the class given by the classname attribute in plugin.xml is instantiated. Although this instantiation is often unneccessary we will see later when discussing the API changes how this can be quite comfortable. It'll also behave the same all the time then, so it'll be easier to understand for other developers. Of course if anything fails (plugin not found, cyclic dependencies, etc) an exception will be thrown detailing the problem. - new API structure The monolithic API we have right now has a big flaw we have overseen so far. Assume someone writes a parser for a new language. This developer will provide the parser as a plugin to the ParserPlatform. However every new language will most probably require new tags. These tags should must be supported by the API. With a monolithic API this means that the developer has to contact us first, so we can introduce these tags into the API and they're available with the next release then. Obviously this is not going to work out. So the idea is to get away from a monolithic API towards a pure plugin based API. A parser developer can then provide the neccessary API classes through an additional API plugin without having to sync with the SrcML team first. The actual API code will then be reduced to that of an APIPlatform only responsible for loading the neccessary plugins. Right now when a SrcML document is loaded with the SAXParser the nodes of the resulting DOM tree are replaced by nodes which are instances of the API classes. This substitution process will be described as part of an API plugin. so apart from the above mentioned meta information such a plugin will have to provide the API part of a plugin.xml also contains a matching table like this: <match name="if" class="my.own.If"/> <match name="loop" class="my.own.Loop"/> Now with the dependencies it is also easy to extend the API functionality by means of a plugin. Suppose you have written an enhanced version of the If class providing more functionalities you want to use throughout several projects in your company you can simply extend your class from the existing one like this: package my.own.improved; public class If extends my.own.If { ... } And package it into a new plugin which apart from the mandatory meta-data only needs: <depends name="the previous plugin" version="x.y.z"/> [..] <match name="if" class="my.own.improved.If"/> Now we can take full advantage of the new PluginManager. First the dependency tree will be built. The first plugin will then be instantiated first and this means that the API will from now on match every 'if' tag with the my.own.If class. After that the new plugin will be instantiated replacing this match so that every 'if' tag is now represented in the DOM tree through my.own.improved.If . Once this is realized applications can use whichever version of the API they require. All that is needed is a single line in the beginning telling the SrcML framework what the application expects: Plugin p = PluginManager.loadPlugin( "my own improved API plugin", "0.0.3", PluginManager.TYPE_API); Ok.. thanks for reading that far :p Now how do we implement this causing the least troubles? I suggest first implementing the new PluginManager and switching the existing plugins over. That should be realizeable pretty fast, although it requires several changes to some of the existing apps. But as mentioned earlier these changes are better done now than in a time of even more apps existing. A second step would be switching the API into the APIPlatform then and refactoring the existing API into a plugin. And now feel free to comment on the above points. If nothing essentially new is added we will probably start implementing the PluginManager and present the above on our meeting next week. -- Raiser, Frank Student @ University of Ulm (www.uni-ulm.de) Flon's axiom: There does not now, nor will there ever, exist a programming language in which it is the least bit hard to write bad programs. (Lawrence Flon) |
From: Dennis W. <den...@in...> - 2005-04-20 20:53:39
|
On Wed, 20 Apr 2005 19:47:29 +0200 Frank Raiser <fra...@in...> wrote: > - New plugin architecture > We want plugins to integrate as easily as possible, and therefore the > current .srcml/plugin_type.xml files in which every plugin had to be > manually registered for now should be replaced by a .srcml/plugins > directory. The installation of a new plugin is then reduced to copying > the plugin's .jar file into this directory. Sounds like a good idea to me. > The content of a plugin's .jar file should be a plugin.xml file and > additional .class files for the plugin's implemented methods. > Optionally source files or other helpful files may be included of > course. The responsibility of the rewritten config handler will be to > check the .srcml/plugins directory for any .jar files and read out the > plugin.xml file from each. Now these plugin.xml files will contain a > fixed meta-data portion as well as additional tags important for the > individual plugin. Here's the common parts every plugin will have to > include in it's plugin.xml definition: > > <plugin > name="plugin name" > version="x.y.z" > homepage="http://find.the.plugin.here" Instead of this attribute I'd rather have a new tag for custom information and include a "homepage" tag in there. This can also include author information etc. and make it more extensible. > type="parser" > classname="de.srcml.foo.Bar" > > > <authors> > <!-- typical authors markup. might be best if similar to docbook > --> > </authors> See above > <dependencies> > <depends name="other plugin's name" version="minimum version of > plugin"/> <depends name="yet another plugin" version="u.v.w"/> > </dependencies> > <!-- plugin specific information --> > </plugin> > > Plugins for all platforms (for now this includes API, Parser and View > platforms) will then be loaded through a single method in the > de.srcml.config.PluginManager class. Here's a sample call to load the > java parser plugin for the ParserPlatform: > > Plugin p = PluginManager.loadPlugin( > "java", "0.1.0", PluginManager.TYPE_PARSER); > > And here's what the PluginManager class will do with such a call: > > 2) Once the correct plugin is found the dependencies will be checked > recursively. To this end a dependency tree is built and topologically > sorted. I'm still not sure if a plugin will have more than one dependency to other plugins. This is especially problematic because the only plugins I can imagine working parallel are filter plugins which do not require a stream if any kind and won't modify the underlying content. > - new API structure [...] > So the idea is to get away from a monolithic API towards a pure plugin > based API. A parser developer can then provide the neccessary API > classes through an additional API plugin without having to sync with > the SrcML team first. The actual API code will then be reduced to that > of an APIPlatform only responsible for loading the neccessary plugins. > Right now when a SrcML document is loaded with the SAXParser the nodes > of the resulting DOM tree are replaced by nodes which are instances of > the API classes. This substitution process will be described as part > of an API plugin. so apart from the above mentioned meta information > such a plugin will have to provide the API part of a plugin.xml also > contains a matching table like this: > > <match name="if" class="my.own.If"/> > <match name="loop" class="my.own.Loop"/> > > Now with the dependencies it is also easy to extend the API > functionality by means of a plugin. Suppose you have written an > enhanced version of the If class providing more functionalities you > want to use throughout several projects in your company you can simply > extend your class from the existing one like this: > > package my.own.improved; > public class If extends my.own.If { ... } > > And package it into a new plugin which apart from the mandatory > meta-data only needs: > > <depends name="the previous plugin" version="x.y.z"/> > [..] > <match name="if" class="my.own.improved.If"/> I've got a proposal: (I'll currently ignore the plugins) Why not make the matching table an extra file ? This would - besides the "match" tag - include one or several import tags: <import name="myBaseMatchTableFile" version="x.y.z"> Imports overwrite matching defined above them. This would remove the ambiguity problem, which plugins have, for match tables. Additionally developers can use this to - kind of - create a custom "view" of the underlying srcMl tree. You'd have to call SrcML.loadMatchTable(...) after loading the srcML file and before actually letting the system replace the nodes. > Now we can take full advantage of the new PluginManager. First the > dependency tree will be built. The first plugin will then be > instantiated first and this means that the API will from now on match > every 'if' tag with the my.own.If class. After that the new plugin > will be instantiated replacing this match so that every 'if' tag is > now represented in the DOM tree through my.own.improved.If . I think "plugins" differ a bit from the matching which seems to me more like a class bases structure (therefore the text above). > Once this is realized applications can use whichever version of the > API they require. All that is needed is a single line in the beginning > telling the SrcML framework what the application expects: > > Plugin p = PluginManager.loadPlugin( > "my own improved API plugin", "0.0.3", PluginManager.TYPE_API); Hmm I'm not even sure if the thing we were discussing about actually is a plugin. Of course a dynamic plugin structure might still be a good idea. - Dennis |
From: Frank R. <fra...@in...> - 2005-04-20 21:30:34
|
On Wed, Apr 20, 2005 at 10:55:01PM +0200, Dennis Waldherr wrote: > > <plugin > > name="plugin name" > > version="x.y.z" > > homepage="http://find.the.plugin.here" > Instead of this attribute I'd rather have a new tag for custom > information and include a "homepage" tag in there. This can also include > author information etc. and make it more extensible. > > > type="parser" > > classname="de.srcml.foo.Bar" > > > > > <authors> > > <!-- typical authors markup. might be best if similar to docbook > > --> > > </authors> > See above What kind of information are you thinking of there? I'd like to have the meta-data part of the config.xml to strictly adhere to a XML schema to have a common ground for plugins. > > 2) Once the correct plugin is found the dependencies will be checked > > recursively. To this end a dependency tree is built and topologically > > sorted. > I'm still not sure if a plugin will have more than one dependency to > other plugins. This is especially problematic because the only plugins I > can imagine working parallel are filter plugins which do not require a > stream if any kind and won't modify the underlying content. Yes a plugin will have more than one dependency. We already have that right now. Consider a view plugin which is supposed to output plain source code. Now we also need the PrintSelectionPlugin and the WhitespacePlugin for it to work. And of course we want to use our own Input and Output Plugins too. So there's already a whole bunch of possible plugin dependencies. It shouldn't be much of a problem though to treat this more generally and support a complete tree (and including a cycle test of course). So I don't really see a reason to restrict plugins to strictly depend on one other plugin only. Actually I think just about every bigger plugin will need several other plugins. Most plugins will make use of input or output plugins, they will require parts of the API and in case of extending another plugin they will also depend on that plugin. > I've got a proposal: > (I'll currently ignore the plugins) > Why not make the matching table an extra file ? > This would - besides the "match" tag - include one or several import > tags: > <import name="myBaseMatchTableFile" version="x.y.z"> > > Imports overwrite matching defined above them. This would remove the > ambiguity problem, which plugins have, for match tables. > Additionally developers can use this to - kind of - create a custom > "view" of the underlying srcMl tree. You'd have to call > SrcML.loadMatchTable(...) after loading the srcML file and before > actually letting the system replace the nodes. Just a remark here: srcML is a project from kent.edu. We agreed on using SrcML for our project to avoid too much confusion. What I really dislike about this approach though is the need to explicitly call a loadMatchTable _after_ loading the file. So either you load the file and there is no DOM tree created yet, then I consider this bad, as I only ever want to write one line to get the whole tree set up from the file. And if the tree is already created it would consist of dom4j DOM nodes and thus we would have different kinds of trees before and after the call to loadMatchTable(). This is a design inconsistency I'd like to avoid. I also don't see how the ambiguity is solved any different to the earlier proposal. If I understood you correctly the extra file will contain the import statements from several plugins in the same order as we would have gotten the plugin instantiations through the dependency tree. Or what happens in case of a plugin wanting to match 'if' to a class and another plugin wanting to match it to another class? Won't it end up being the same with the more specialized plugin overwriting the matching of the earlier plugin? As for the custom view I don't think I really want to have that dynamically available through a loadMatchTable() call. I'm not really fond of the idea that the DOM nodes are exchanged, as this also exchanges the semantics and available methods behind the nodes I can see that getting way too confusing. If you want a custom view you are getting just that by specifying the exact plugins you need for your view anyways. > > Now we can take full advantage of the new PluginManager. First the > > dependency tree will be built. The first plugin will then be > > instantiated first and this means that the API will from now on match > > every 'if' tag with the my.own.If class. After that the new plugin > > will be instantiated replacing this match so that every 'if' tag is > > now represented in the DOM tree through my.own.improved.If . > I think "plugins" differ a bit from the matching which seems to me more > like a class bases structure (therefore the text above). Indeed the matching part is a speciality of API plugins, but I try to think of this plugin instantiation as a general mean for plugins to set up their working space. If you think of something like Eclipse you could have a plugin do simple things like adding its icons or menu entries to the program at the time it gets loaded for example. Setting up the matching table is just the equivalent of what an API plugin is doing to prepare its use. > > Once this is realized applications can use whichever version of the > > API they require. All that is needed is a single line in the beginning > > telling the SrcML framework what the application expects: > > > > Plugin p = PluginManager.loadPlugin( > > "my own improved API plugin", "0.0.3", PluginManager.TYPE_API); > Hmm I'm not even sure if the thing we were discussing about actually is > a plugin. Of course a dynamic plugin structure might still be a good > idea. In case of developing a new plugin you don't need such a loadPlugin() statement of course, as it will already be loaded through the dependency mechanism. But once you are developing a normal application there is no automatic dependency checking and loading available. In that case the application itself will simply try to load the neccessary plugins once they're needed. This would even cut down on the size of published .class/.jar applications, as you don't even have to include the complete API. Correct me if I'm wrong there, but it should be possible to 'link' the application's .class files to the API java/class files and then run the application without those other class files being available (in the CLASSPATH). If this works loading the plugins through the application will at least provide us with proper error messages. If it doesn't we might have to think of another way of ensuring the enduser knows what plugin is missing. A simple traceback that class ThisOrThat wasn't found will not be sufficient of course. -- Raiser, Frank Student @ University of Ulm (www.uni-ulm.de) When you can flatten entire cities at a whim, a tendency towards quiet reflection and seeing-things-from-the-other-fellow's-point- of-view is seldom necessary. -- (Terry Pratchett, Small Gods) |
From: Dennis W. <den...@in...> - 2005-04-21 12:10:11
|
On Wed, 20 Apr 2005 23:30:03 +0200 Frank Raiser <fra...@in...> wrote: > What kind of information are you thinking of there? I'd like to have the > meta-data part of the config.xml to strictly adhere to a XML schema to have a > common ground for plugins. Information about author and homepage for example are not required for usual operation of a plugin because it is content meant to be read by humans. Therefore, instead of placing it at the root header element of the xml file a subelement would fit better. But this - I guess - is just matter of taste. > Yes a plugin will have more than one dependency. We already have that right > now. Consider a view plugin which is supposed to output plain source code. Now > we also need the PrintSelectionPlugin and the WhitespacePlugin for it to work. > And of course we want to use our own Input and Output Plugins too. So there's > already a whole bunch of possible plugin dependencies. > It shouldn't be much of a problem though to treat this more generally and > support a complete tree (and including a cycle test of course). So I don't > really see a reason to restrict plugins to strictly depend on one other > plugin only. > > Actually I think just about every bigger plugin will need several other > plugins. Most plugins will make use of input or output plugins, they will > require parts of the API and in case of extending another plugin they will > also depend on that plugin. I meant especially an API plugin. But while normal plugins will usually have more dependencies I'm not sure that there will be any topologic reorder at all. > Just a remark here: srcML is a project from kent.edu. We agreed on using SrcML > for our project to avoid too much confusion. I doubt it's really possible to avoid confusion much. > What I really dislike about this approach though is the need to explicitly > call a loadMatchTable _after_ loading the file. So either you load the file > and there is no DOM tree created yet, then I consider this bad, as I only ever > want to write one line to get the whole tree set up from the file. And if the > tree is already created it would consist of dom4j DOM nodes and thus we would > have different kinds of trees before and after the call to loadMatchTable(). > This is a design inconsistency I'd like to avoid. Since you save language type within a SrcML file you can load a default match table given by that name. There is no inconsistency because loading a match table would not change the already loaded tree. But I guess there's no need to further discuss this matter as we already did that personally. > I also don't see how the ambiguity is solved any different to the earlier > proposal. If I understood you correctly the extra file will contain the import > statements from several plugins in the same order as we would have gotten the > plugin instantiations through the dependency tree. Or what happens in case of > a plugin wanting to match 'if' to a class and another plugin wanting to match > it to another class? Won't it end up being the same with the more specialized > plugin overwriting the matching of the earlier plugin? Yes and therefore no ambiguity because the import order of the xml file would not have bee changed whereas the loading order of plugins is dynamic. > As for the custom view I don't think I really want to have that dynamically > available through a loadMatchTable() call. I'm not really fond of the idea > that the DOM nodes are exchanged, as this also exchanges the semantics and > available methods behind the nodes I can see that getting way too confusing. > If you want a custom view you are getting just that by specifying the exact > plugins you need for your view anyways. Yes, thinking of that a plugin would make more sense for it. > > > Now we can take full advantage of the new PluginManager. First the > > > dependency tree will be built. The first plugin will then be > > > instantiated first and this means that the API will from now on match > > > every 'if' tag with the my.own.If class. After that the new plugin > > > will be instantiated replacing this match so that every 'if' tag is > > > now represented in the DOM tree through my.own.improved.If . > > I think "plugins" differ a bit from the matching which seems to me more > > like a class bases structure (therefore the text above). > > Indeed the matching part is a speciality of API plugins, but I try to think of > this plugin instantiation as a general mean for plugins to set up their > working space. If you think of something like Eclipse you could have a plugin > do simple things like adding its icons or menu entries to the program at the > time it gets loaded for example. Setting up the matching table is just the > equivalent of what an API plugin is doing to prepare its use. My perspective doesn't require to change that. As we discussed those match tags will be placed in the plugin's xml file. The plugin would be still the same in both cases, it just would access it's configuration differently. > > > Once this is realized applications can use whichever version of the > > > API they require. All that is needed is a single line in the beginning > > > telling the SrcML framework what the application expects: > > > > > > Plugin p = PluginManager.loadPlugin( > > > "my own improved API plugin", "0.0.3", PluginManager.TYPE_API); > > Hmm I'm not even sure if the thing we were discussing about actually is > > a plugin. Of course a dynamic plugin structure might still be a good > > idea. > > In case of developing a new plugin you don't need such a loadPlugin() > statement of course, as it will already be loaded through the dependency > mechanism. As before I was especially talking about API plugins - because that was actually the whole instigator of this discussion. > But once you are developing a normal application there is no automatic > dependency checking and loading available. In that case the application itself > will simply try to load the neccessary plugins once they're needed. This would > even cut down on the size of published .class/.jar applications, as you don't > even have to include the complete API. Correct me if I'm wrong there, but it > should be possible to 'link' the application's .class files to the API > java/class files and then run the application without those other class files > being available (in the CLASSPATH). If this works loading the plugins through > the application will at least provide us with proper error messages. If it > doesn't we might have to think of another way of ensuring the enduser knows > what plugin is missing. A simple traceback that class ThisOrThat wasn't found > will not be sufficient of course. Yes, the ClassLoader will throw an error/exception when attempting to load the class. - Dennis |
From: Frank R. <fra...@in...> - 2005-04-21 15:43:29
|
On Thu, Apr 21, 2005 at 02:10:03PM +0200, Dennis Waldherr wrote: > On Wed, 20 Apr 2005 23:30:03 +0200 > Frank Raiser <fra...@in...> wrote: > > What kind of information are you thinking of there? I'd like to have the > > meta-data part of the config.xml to strictly adhere to a XML schema to have a > > common ground for plugins. > Information about author and homepage for example are not required for usual > operation of a plugin because it is content meant to be read by humans. > Therefore, instead of placing it at the root header element of the xml file > a subelement would fit better. > But this - I guess - is just matter of taste. This makes sense of course. So let's try to keep the operation specific meta-data within the plugin attributes and the parts most interesting to humans separated from that. So here's my current suggestion for the plugin.xml format which will be shared for all kinds of plugins: <!-- operational meta-data to create a unique identifier for this plugin, to describe the type and provide a Class as entry point --> <plugin name="some interesting name" version="x.y.z" type="parser" classname="foo.bar.Baz" > <!-- authors of the plugin --> <authorgroup> <author> <!-- author content as described by docbook DTD: http://www.docbook.org/tdg5/en/html/author.html --> </author> <author> ... </author> </authorgroup> <!-- accompanying webpage - optional --> <link linkend="http://get.my.plugin/here"/> <!-- dependencies on other plugins - optional --> <dependencies> <depends name="other plugin" version="x.y.z"/> <depends name="another plugin" version="u.v.w"/> </dependencies> <!-- plugin specific content --> </plugin> > I meant especially an API plugin. But while normal plugins will usually have > more dependencies I'm not sure that there will be any topologic reorder at all. While it might be true that for API plugins a topological sorting is unneccessary I still think they should be treated just like other plugins. Doing no topological reordering for API plugins creates a special case that developers will have to be aware of again. I'd sacrifice this little bit of runtime to sorting the dependency tree before I require developers to always remember these plugins will be an exception to the rule. > > Just a remark here: srcML is a project from kent.edu. We agreed on using SrcML > > for our project to avoid too much confusion. > I doubt it's really possible to avoid confusion much. Indeed. It's a rather pathetic try to at least reduce the amount of confusion :) > > What I really dislike about this approach though is the need to explicitly > > call a loadMatchTable _after_ loading the file. So either you load the file > > and there is no DOM tree created yet, then I consider this bad, as I only ever > > want to write one line to get the whole tree set up from the file. And if the > > tree is already created it would consist of dom4j DOM nodes and thus we would > > have different kinds of trees before and after the call to loadMatchTable(). > > This is a design inconsistency I'd like to avoid. > Since you save language type within a SrcML file you can load a default match > table given by that name. There is no inconsistency because loading a match table > would not change the already loaded tree. It's not getting inconsistent at runtime. I think the problem is that from my point of view it is preferrable to keep a once loaded tree fixed. I believe it will create too much confusion if your program decides at some point to simply replace the tree with new nodes which essentially means that at this point in the program the underlying API will be changed. > But I guess there's no need to further discuss this matter as we already did that > personally. Just to try summing it up for the other readers on this list it comes down to a matter of personal taste. The question right now is which way will we go for the actual implementation? I especially would like to hear other people's opinion about this too. > Yes and therefore no ambiguity because the import order of the xml file would > not have bee changed whereas the loading order of plugins is dynamic. Here we are at the point of either topologically sorting by plugin dependencies or demanding the developer to specify the plugin load order. Once more we have two different opinions here and it'd be interesting to get to hear from a few more people. There's also the option to mix both ideas. Let's say a plugin specifies two plugins it depends on. Both plugins provide a similar methodology which could cause ambiguity. While we could simply throw both of them into the dependency graph and basically ignore this ambiguity letting either plugin win we could honor the order these dependencies are listed in the plugin.xml by adding additional edges to the dependency graph. In this case it would mean adding an edge from the first plugin to the second to ensure the provided functionality of the second will get overwritten by whatever the first plugin provides. Therefore the plugin developer can specify the loading order dynamically. -- Raiser, Frank Student @ University of Ulm (www.uni-ulm.de) When you have eliminated the impossible, whatever remains, however improbable, must be the truth. ("Sherlock Holmes") |
From: Dennis W. <den...@in...> - 2005-04-21 17:08:18
|
On Thu, 21 Apr 2005 17:43:23 +0200 Frank Raiser <fra...@in...> wrote: [Plugin structure] Looks ok to me. > > > I meant especially an API plugin. But while normal plugins will > > usually have more dependencies I'm not sure that there will be any > > topologic reorder at all. > > While it might be true that for API plugins a topological sorting is > unneccessary I still think they should be treated just like other > plugins. Doing no topological reordering for API plugins creates a > special case that developers will have to be aware of again. I'd > sacrifice this little bit of runtime to sorting the dependency tree > before I require developers to always remember these plugins will be > an exception to the rule. I'm not worrying of runtime speed, I just want to make sure that it will be clear that the topologic sort will not change order of API plugins. > > Since you save language type within a SrcML file you can load a > > default match table given by that name. There is no inconsistency > > because loading a match table would not change the already loaded > > tree. > > It's not getting inconsistent at runtime. I think the problem is that > from my point of view it is preferrable to keep a once loaded tree > fixed. I believe it will create too much confusion if your program > decides at some point to simply replace the tree with new nodes which > essentially means that at this point in the program the underlying API > will be changed. Of course it would be confusion to iterate a transformation upon a tree. My intend was to allow for different APIs to be used for the first transformation from xml to API. If the API was fixed after loading one could not write a application which handles different languages - unless he restarts his own program or uses multiple java instances. > > But I guess there's no need to further discuss this matter as we > > already did that personally. > Just to try summing it up for the other readers on this list it comes > down to a matter of personal taste. The question right now is which > way will we go for the actual implementation? I especially would like > to hear other people's opinion about this too. That would be interesting. > There's also the option to mix both ideas. Let's say a plugin > specifies two plugins it depends on. Both plugins provide a similar > methodology which could cause ambiguity. While we could simply throw > both of them into the dependency graph and basically ignore this > ambiguity letting either plugin win we could honor the order these > dependencies are listed in the plugin.xml by adding additional edges > to the dependency graph. In this case it would mean adding an edge > from the first plugin to the second to ensure the provided > functionality of the second will get overwritten by whatever the first > plugin provides. Therefore the plugin developer can specify the > loading order dynamically. That should do the trick too of course. - Dennis |
From: Frank R. <fra...@in...> - 2005-04-21 17:40:06
|
On Thu, Apr 21, 2005 at 07:09:46PM +0200, Dennis Waldherr wrote: > I'm not worrying of runtime speed, I just want to make sure that it will > be clear that the topologic sort will not change order of API plugins. Now what is the 'order' of API plugins? Let's say we have a simple dependency on one other plugin. Then this dependency plugin will be the first to be loaded. Therefore its dependencies will recursively be loaded before the dependency plugin itself is loaded. The last one to load is the actual plugin we wanted to load. Now if we consider the possibility of influencing the order by the order in which the dependency plugins are listed in plugin.xml (by adding the corresponding edges to the dependency tree), the plugin developer basically has free choice over the first depth level of the tree. I don't know whether you really plan on giving a plugin developer the ability to define the order in which dependencies of dependencies are resolved? If not I think this approach should be pretty good for us already. > Of course it would be confusion to iterate a transformation upon a tree. > My intend was to allow for different APIs to be used for the first > transformation from xml to API. If the API was fixed after loading one > could not write a application which handles different languages - unless > he restarts his own program or uses multiple java instances. Ok. So we have been talking about two different things here. I never intended to enforce a program restart in order to load another document with another API. My idea was to prepare the match table just before the SrcML class is instantiated for a document. Then for another document there'd be a method to reset the match table and prepare a new one for the new document. So for me this match table is only important while instantiating the SrcML class and modifications to it do not affect existing DOM trees (which should remain unchanged to avoid confusion). So to sum it up from my point of view: - new document takes a new match table - only one match table per document -- Raiser, Frank Student @ University of Ulm (www.uni-ulm.de) Ever tried. Ever failed. No matter. Try again. Fail again. Fail better. (Samuel Beckett) |
From: Dennis W. <den...@in...> - 2005-04-21 17:52:19
|
On Thu, 21 Apr 2005 19:39:58 +0200 Frank Raiser <fra...@in...> wrote: > Now what is the 'order' of API plugins? > Let's say we have a simple dependency on one other plugin. Then this > dependency plugin will be the first to be loaded. Therefore its > dependencies will recursively be loaded before the dependency plugin > itself is loaded. The last one to load is the actual plugin we wanted > to load. Now if we consider the possibility of influencing the order > by the order in which the dependency plugins are listed in plugin.xml > (by adding the corresponding edges to the dependency tree), the plugin > developer basically has free choice over the first depth level of the > tree. I don't know whether you really plan on giving a plugin > developer the ability to define the order in which dependencies of > dependencies are resolved? If not I think this approach should be > pretty good for us already. Uhm... I actually was trying to say that this approach looks good. And the order by using this method is clear. A programer wouldn't care for order of the "super" plugin dependencies. Never thought that this would work out after all. > Ok. So we have been talking about two different things here. I never > intended to enforce a program restart in order to load another > document with another API. My idea was to prepare the match table just > before the SrcML class is instantiated for a document. Then for > another document there'd be a method to reset the match table and > prepare a new one for the new document. So for me this match table is > only important while instantiating the SrcML class and modifications > to it do not affect existing DOM trees (which should remain unchanged > to avoid confusion). So to sum it up from my point of view: > - new document takes a new match table > - only one match table per document That is actually what I meant. And if you check my old mail you see while I called a method after creation of SrcML the basic idea is the same no matter if you do it when instancing or setting it up after it is created. - Dennis |