You are viewing a plain text version of this content. The canonical link for it is here.
Posted to fop-dev@xmlgraphics.apache.org by Jeremias Maerki <de...@greenmail.ch> on 2005/08/02 11:14:41 UTC
Re: API discussion (was: DO NOT REPLY [Bug 35939] New: - [PATCH] Port of 0.20.5 Driver.java class)
On 01.08.2005 18:31:35 Andreas L Delmelle wrote:
> On Aug 1, 2005, at 11:37, Manuel Mall wrote:
>
> > no argument from me against what you are proposing and also Joerg in
> > [1]. We
> > can still have a Driver.java for backwards compatibility for those who
> > want
> > to "plug and play" either in the product, or in a separate jar
> > (fop-compat.jar?), or just here in BugZilla.
>
> Well, I've thought about that as well --keeping the Driver FTM as a
> sort of 'deprecated proxy' that simply forwards the method-calls to the
> respective components in the new API, but...
> IMO this is not an absolute necessity. If we decide on discontinuing
> support for the 0.20.5 API, then we may as well do it now.
Right. People just don't like API changes and the path away from the
Driver class a big break.
> The main point is however, that with the current design, implementing
> such a proxy looks rather clumsy --this has absolutely nothing to do
> with your coding, but is a consequence of the merging of component and
> standalone app... Right now, the Driver would have to be wrapped around
> the main-class, which is something I do NOT like :-/
I doesn't have to. The Fop class is so light-weight (if you think the
main() method plus helpers away). You can easily reproduce that code if
a few lines in that proxy.
> The following may make little sense to you, but just in case there are
> others following this thread:
I VERY MUCH hope that there are!
> I feel that the class that will be used for running FOP from the
> command line should be an example in itself, in that it should use the
> component in the same way an embedding user would. Only difference is
> that the configuration will be created based on the command line
> parameters.
I'm not fully happy either, especially, after I put in the classloader
stuff. My proposal would be to do the same I did in Barcode4J: Let's
create a "cli" package with the whole command-line stuff in there. See:
http://cvs.sourceforge.net/viewcvs.py/barcode4j/barcode4j/src/java/org/krysalis/barcode4j/cli/
> Our CommandLineOptions class should build a Configuration which the
> main-class can then pass into the configure() method of the component.
> It really does not need to --or stronger: it shouldn't-- concern itself
> with initializing the OutputStream, for example.
>
> Roughly its tasks should be limited to:
> - tell the CommandLineOptions to construct a Configuration based on the
> parameters specified on the command line
> - tell the component to configure itself with that Configuration object
> - tell the component to go about its business (start() or run())
>
> That class should, if I estimate correctly, be about 50 lines of code.
> Right now, we have a main() method in the Fop class at line 300+, which
> seems fishy to say the least.
Yes, it's become too big to be of educational value.
As a side note: Keep in mind that I've written a general API which
easily handles calling FOP 0.20.5, FOP Trunk, JFOR, FOray and even Batik
for the conversion of XSL-FO or SVG to PDF, PS, Print etc. It is
designed to provide for the various XSL-FO implementations what JAXP is
for Xerces, Crimson, Xalan, SAXON etc. The only problem is that I still
don't have a name for it that doesn't produce any problems (JAFOP was too
close to FOP to potentially scare commercial implementors away and JAXG,
its current name, has been criticized by a Sun employee to be
potentially problematic because of the use of the "JAX" prefix.)
Jeremias Maerki
Re: API discussion
Posted by Jeremias Maerki <de...@greenmail.ch>.
On 03.08.2005 02:20:39 Andreas L Delmelle wrote:
> On Aug 2, 2005, at 11:14, Jeremias Maerki wrote:
> >
> > On 01.08.2005 18:31:35 Andreas L Delmelle wrote:
<snip/>
> > I'm not fully happy either, especially, after I put in the classloader
> > stuff. My proposal would be to do the same I did in Barcode4J: Let's
> > create a "cli" package with the whole command-line stuff in there. See:
> > http://cvs.sourceforge.net/viewcvs.py/barcode4j/barcode4j/src/java/
> > org/krysalis/barcode4j/cli/
>
> Funny, right before I read your reply and without having looked at
> Barcode4J, that was EXACTLY what I was thinking about. That way, it
> becomes possible to build a JAR without the CLI classes, for people
> that hardly ever use FOP from a console. Those that need only
> occasional runs via CLI need simply an additional jar on their
> classpath that contains only FOP's CLI classes. It's not that there are
> many, but still, for the purists this means that they don't need to
> contaminate their environment with those classes (that are not
> re-usable in other contexts: see Joerg's remark earlier on).
> Plus: separating the CLI means that we're more at liberty to add
> dependencies there without forcing our API-users to drag them in as
> well.
Uhm, you know how much space the CLI part currently takes up in fop.jar?
12KB out of 1400KB (two and a half files ATM). And the classes don't
even get loaded if fop.jar is used "embedded only". I can understand if
people want a stand-alone RTF library or if they want SVG support to be
optional, but this. Hmmmm.
> (Ideas? Still a wild one ATM, but Jakarta Commons' Launcher
> seemed interesting: IIC, it can be used to handle the tasks we now deal
> with in our startup scripts --which would mean that we have to maintain
> that stuff only in one place--, offers fine-grained control over the
> class-loading.)
This would add more complexity and an additional dependency, where the
dynamic class loading for the CLI is already solved with a few lines. I
don't see the benefit, sorry. I'd rather have a Win32 executable for
people who don't know a thing about Java. I was thinking about doing
this many times now.
> <snip />
> > As a side note: Keep in mind that I've written a general API which
> > easily handles calling FOP 0.20.5, FOP Trunk, JFOR, FOray and even
> > Batik
> > for the conversion of XSL-FO or SVG to PDF, PS, Print etc.
>
> Yes, I remember. Of course, that is one side: a matter of conforming to
> a set of interfaces.
> How we implement them and map the general API to our own is another.
So far, I was able to map all the FOP-specifics into the JAXG
implementation without polluting the interface itself. There might be a
few very special use cases that won't be supported but I don't think
that's a problem.
> One thing's for sure: such mapping will be much easier if our specific
> API is neatly designed, regardless of what the general interfaces look
> like.
Actually, handling FOP Trunk was very easy in JAXG already. There's only
the little flaw in the Fop constructor when you actually use a
custom-configured Renderer.
> I'm very much in favor of the idea, and my preference in that area is
> towards a *very* abstract and stringent general API, even if that would
> mean that for all of the above apps someone still needs to code
> API-to-API (specific-to-general) bridges. Evidently, there can be
> absolutely no references whatsoever to any of those particular
> applications in the general API --ideally it should be designed by
> someone who knows nothing about those particular apps' usage patterns,
> but who understands what a FO or SVG processor is/does (besides being
> very proficient in Java interface-design, of course :-))
I think I already managed to do all that. There will certainly be a few
details to attend to but I'm already using the API in all my code and
for almost everything.
> > It is designed to provide for the various XSL-FO implementations what
> > JAXP is
> > for Xerces, Crimson, Xalan, SAXON etc.
>
> After all, I'm currently wondering if Xalan or SAXON ever started out
> as an attempt to write an implementation for JAXP, or if their initial
> concern was to code a decent XSLT processor and they added the JAXP
> conformance further on. (I'd guess it lies more in the direction of the
> latter, but I'm not sure at all)
The latter was indeed the case.
> And, now that JAXP is mentioned: of course, it's beneficial to expose
> that API's functionality in our own --after all, it's *XSL*-FO--,
> however, we should probably allow a number of possibilities, ranging
> from:
> URL srcFileloc, URL xslFileloc, URL tgtFileloc --we could determine
> the output target from tgtFileloc's extension (in a lot of situations)
>
> over
> File srcFile, File xslFile, File tgtFile
>
> over users passing in their own InputSources, Transformers and
> OutputStreams,
You're talking about convenience methods, right? I'm sure we can provide
a small number of them for beginners, but maybe we should put them in a
special class (like EasyFop) as public static methods.
> or in the end maybe even
> Source src, Style style, Target tgt --where those three are our own
> independent interfaces, and user-developers can code their own
> customized implementations.
Please not! Source can be reused from JAXP as I have done in JAXG. Same
for Style where you can reuse JAXP interfaces and classes. Target is
another matter and it is exactly what JAXG provides (among a few other
things).
> As long as their objects know how to
> produce sensible answers to FOP's questions, it will render them as
> specified. This abstraction is more or less based on our Obj2PDF
> example, but precisely that example would become much much simpler.
> [Think of a Processor, without XML, XSLT or FO:
> Object-over-Object-to-Object]
That was Jakarta Commons Morphos. It failed. It was a nice idea, though,
but IMO entirely out of scope for FOP.
> I have a feeling that such an approach would greatly simplify the
> eventual idea of a pluggable Renderer framework --Target as a class
> that is able to return a component that conforms to our most basic
> Renderer interface. Setting it through a RENDER_TYPE constant will be
> for convenience only.
That's cool for hardcore developers and a PITA for beginners who'd
rather concat a command-line String to pass it to Fop's main method.
Cough. Besides JAXG already handles that. :-)
> Especially the simpler ones are important --for rookie Java
> developers--, since *ours* is the XML API, but the users-embedders'
> shouldn't necessarily be. If they're interested and clever enough, they
> will be driven towards learning more about SAX and JAXP anyway.
Do you touch your code when it already works? I think it is very
important that people who work with XML understand a little bit of JAXP
(especially TraX) and that's why I wrote the Example* classes in the
first place. The current API we have, though breaking compatibility with
0.20.5 and not really based on general consensus, is encouraging the use
of JAXP which IMO is a Good Thing.
> In
> which case they can refine their own particular usage pattern if they
> want/need to --and, who knows, ultimately maybe even help us out in
> adding enhancements (or at least discuss them here, and maybe inspire
> others :-)).
>
> > The only problem is that I still don't have a name for it that doesn't
> > produce any problems (JAFOP was too close to FOP to potentially scare
> > commercial implementors away and JAXG,
> > its current name, has been criticized by a Sun employee to be
> > potentially problematic because of the use of the "JAX" prefix.)
>
> Wouldn't worry about the name too much right now. I believe that the
> idea in itself is worthwhile enough. Some cool name is bound to turn up
> for it eventually.
I'm waiting for a cool name to pop up for half a year now. I even had a
help from a number of people. I should probably revisit all the
proposals I got. Anyway, looks like I really need to publish what I
currently have and if it's only to replace the old JAFOP on my website
which is really out of date now.
Jeremias Maerki
Re: API discussion (was: DO NOT REPLY [Bug 35939] New: - [PATCH] Port of 0.20.5 Driver.java class)
Posted by Andreas L Delmelle <a_...@pandora.be>.
On Aug 2, 2005, at 11:14, Jeremias Maerki wrote:
>
> On 01.08.2005 18:31:35 Andreas L Delmelle wrote:
>> ... Right now, the Driver would have to be wrapped around
>> the main-class, which is something I do NOT like :-/
>
> I doesn't have to. The Fop class is so light-weight (if you think the
> main() method plus helpers away). You can easily reproduce that code if
> a few lines in that proxy.
Yeah, seems I was jumping the gun a bit... After all, it's 300+ lines,
only if you count all comments and whitespace :-)
<snip />
> I'm not fully happy either, especially, after I put in the classloader
> stuff. My proposal would be to do the same I did in Barcode4J: Let's
> create a "cli" package with the whole command-line stuff in there. See:
> http://cvs.sourceforge.net/viewcvs.py/barcode4j/barcode4j/src/java/
> org/krysalis/barcode4j/cli/
Funny, right before I read your reply and without having looked at
Barcode4J, that was EXACTLY what I was thinking about. That way, it
becomes possible to build a JAR without the CLI classes, for people
that hardly ever use FOP from a console. Those that need only
occasional runs via CLI need simply an additional jar on their
classpath that contains only FOP's CLI classes. It's not that there are
many, but still, for the purists this means that they don't need to
contaminate their environment with those classes (that are not
re-usable in other contexts: see Joerg's remark earlier on).
Plus: separating the CLI means that we're more at liberty to add
dependencies there without forcing our API-users to drag them in as
well. (Ideas? Still a wild one ATM, but Jakarta Commons' Launcher
seemed interesting: IIC, it can be used to handle the tasks we now deal
with in our startup scripts --which would mean that we have to maintain
that stuff only in one place--, offers fine-grained control over the
class-loading.)
<snip />
> As a side note: Keep in mind that I've written a general API which
> easily handles calling FOP 0.20.5, FOP Trunk, JFOR, FOray and even
> Batik
> for the conversion of XSL-FO or SVG to PDF, PS, Print etc.
Yes, I remember. Of course, that is one side: a matter of conforming to
a set of interfaces.
How we implement them and map the general API to our own is another.
One thing's for sure: such mapping will be much easier if our specific
API is neatly designed, regardless of what the general interfaces look
like.
I'm very much in favor of the idea, and my preference in that area is
towards a *very* abstract and stringent general API, even if that would
mean that for all of the above apps someone still needs to code
API-to-API (specific-to-general) bridges. Evidently, there can be
absolutely no references whatsoever to any of those particular
applications in the general API --ideally it should be designed by
someone who knows nothing about those particular apps' usage patterns,
but who understands what a FO or SVG processor is/does (besides being
very proficient in Java interface-design, of course :-))
> It is designed to provide for the various XSL-FO implementations what
> JAXP is
> for Xerces, Crimson, Xalan, SAXON etc.
After all, I'm currently wondering if Xalan or SAXON ever started out
as an attempt to write an implementation for JAXP, or if their initial
concern was to code a decent XSLT processor and they added the JAXP
conformance further on. (I'd guess it lies more in the direction of the
latter, but I'm not sure at all)
And, now that JAXP is mentioned: of course, it's beneficial to expose
that API's functionality in our own --after all, it's *XSL*-FO--,
however, we should probably allow a number of possibilities, ranging
from:
URL srcFileloc, URL xslFileloc, URL tgtFileloc --we could determine
the output target from tgtFileloc's extension (in a lot of situations)
over
File srcFile, File xslFile, File tgtFile
over users passing in their own InputSources, Transformers and
OutputStreams, or in the end maybe even
Source src, Style style, Target tgt --where those three are our own
independent interfaces, and user-developers can code their own
customized implementations. As long as their objects know how to
produce sensible answers to FOP's questions, it will render them as
specified. This abstraction is more or less based on our Obj2PDF
example, but precisely that example would become much much simpler.
[Think of a Processor, without XML, XSLT or FO:
Object-over-Object-to-Object]
I have a feeling that such an approach would greatly simplify the
eventual idea of a pluggable Renderer framework --Target as a class
that is able to return a component that conforms to our most basic
Renderer interface. Setting it through a RENDER_TYPE constant will be
for convenience only.
Especially the simpler ones are important --for rookie Java
developers--, since *ours* is the XML API, but the users-embedders'
shouldn't necessarily be. If they're interested and clever enough, they
will be driven towards learning more about SAX and JAXP anyway. In
which case they can refine their own particular usage pattern if they
want/need to --and, who knows, ultimately maybe even help us out in
adding enhancements (or at least discuss them here, and maybe inspire
others :-)).
> The only problem is that I still don't have a name for it that doesn't
> produce any problems (JAFOP was too close to FOP to potentially scare
> commercial implementors away and JAXG,
> its current name, has been criticized by a Sun employee to be
> potentially problematic because of the use of the "JAX" prefix.)
Wouldn't worry about the name too much right now. I believe that the
idea in itself is worthwhile enough. Some cool name is bound to turn up
for it eventually.
Cheers,
Andreas