You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@ant.apache.org by Matt Bishop <ma...@bea.com> on 2002/10/13 20:41:00 UTC
Project.toXML() ?
Is there any code available to dump a Project object out to XML? I am not concerned with preserving comments, whitespace, etc. from the load, just want to emit the Project tree.
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
Re: Project.toXML() ?
Posted by Costin Manolache <cm...@yahoo.com>.
David Jencks wrote:
>> > Saving changes in your mbeans is IMO best handled by using a jmx and
>> > modelmbean implementation that implements persistence. Writing out
>> > something like the original xml config file is more or less
>> disasterous:
>> > after trying it in jboss 2.2 we will never go back.
>>
>> I'll have to disagree with this :-)
>
> Well, did you experience the incredible confusion of this system?
I've seen and tried few systems - some worse than others.
Using JMX to intercept the config changes was one of the solutions
I tried - but as I said, I don't think it's the right solution.
JMX is far from a good API for data persistence ( JNDI has
defects, but it was at least designed for directories and data).
And JMX is hard to make work in a 'passive' mode ( i.e. without
runtime objects ).
BTW, I think this discussion would be better on tomcat-dev than ant.
> JMX persistence is not a way to instantiate new mbeans. You still need a
> "deployment" step. I'm fairly happy with the current jboss mbean
> deployment system, based on multiple xml files with the possibility of xsl
> transformations. I find this orders of magnitudes more powerful than
> anything I have seen done with jndi (admittedly, not a lot).
Jboss deployment is not bad, but I don't think it's perfect either.
About XSL transformations and XML config files - I would rather see
the config get away from beeing tied to XML. ( and I would like
to see ant working without having to have an xml file around ).
> -You don't want to overwrite the original source file -- it's a source
> file. Therefore you have to write the copy somewhere else. Now you have
I actually want to change the original source when making a change.
( and by source I am also thinking LDAP directory or registry )
> -Most mbeans have a lot of attributes that come with default values which
> may not be specified explicitly in the deployment descriptor. Unless they
> are model mbeans with carefully configured default values, you can't
> really detect that the values are defaults, so you have to write all the
> attribute
> values to storage. This can result in unreadably longer files.
That's one of the big problems. Quite easy to work around even with
JMX by using 2 layers. In ant you have the
UnknownElement/RuntimeConfigurable, with JMX you can have the model mbean
wrapper - and those can store _only_ original config data and what
gets changed.
This way you don't ask the bean directly for config, but you ask the
mbean for what it stored. The system works pretty well - and you can
even preserve ${properties}.
> The solution I'm working towards for jboss when using the timestamp based
> auto-redeploy is to model the originally deployed xml deployment
> descriptors as mbeans, including something like a modification timestamp.
> These mbeans and the timestamp will be persisted through jmx. When the
> server shuts down and wakes up again it can tell by comparing timestamps
> from the mbean and the actual file if the descriptor has changed, and
> redeploy the mbeans from the file if necessary.
As I said, I have no problem with overriding or changing the original
source. That makes a lot of sense if you consider non-file sources
like directories.
> I _really_ don't understand this. Maybe I am biased from having worked
> with the jboss xml based mbean deployment descriptors for so long, but I
> find both them and working directly with mbean attributes much more
> powerful than jndi.
There are 2 different APIs with different goals. JMX is great when you
change runtime objects. JNDI is great when you work with a ( possibly
multi-source/federated ) hierarchical data storage.
> Anyway, I am very glad to see interest in jmx in the ant community.
I don't know about the whole community, but at least I am very interested
in 'embeded ant' and using it via APIs. And JMX is a perfect fit
for the ant internal model.
I don't think we can expect ant to depend on jmx, but to wrap it
would be quite easy. I'm trying to extend the TaskAdapter to be
able to wrap MBeans, so both ways should work ( ant tasks used as
mbeans, and mbeans used inside ant as tasks ).
( I'm not sugesting any of this will get into 'main' ant anytime
soon - just that it will be possible using hooks )
Costin
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
Re: Project.toXML() ?
Posted by David Jencks <da...@directvinternet.com>.
On 2002.10.13 20:53:36 -0400 Costin Manolache wrote:
> David Jencks wrote:
>
> > Saving changes in your mbeans is IMO best handled by using a jmx and
> > modelmbean implementation that implements persistence. Writing out
> > something like the original xml config file is more or less
> disasterous:
> > after trying it in jboss 2.2 we will never go back.
>
> I'll have to disagree with this :-)
Well, did you experience the incredible confusion of this system?
>
> I agree that (runtime) changes should be done via a JMX, but
> JMX is (IMO) a pretty bad persistence API, and I don't thing
> that configuration should be restricted to runtime ( in
> JMX-handles-persistence you do need the MBeans instantiated and
> in a certain state - it works very well for modifying a running
> server, but sometimes it's a bit of foreced solution if you
> want to modify passive config ).
JMX persistence is not a way to instantiate new mbeans. You still need a
"deployment" step. I'm fairly happy with the current jboss mbean
deployment system, based on multiple xml files with the possibility of xsl
transformations. I find this orders of magnitudes more powerful than
anything I have seen done with jndi (admittedly, not a lot).
A couple of the problems with writing out an imitation of an original xml
deployment configuration as a means of persistence:
-You don't want to overwrite the original source file -- it's a source
file. Therefore you have to write the copy somewhere else. Now you have 2
versions of the file. When restarting, how do you decide which copy gets
priority if they disagree?
-Most mbeans have a lot of attributes that come with default values which
may not be specified explicitly in the deployment descriptor. Unless they
are model mbeans with carefully configured default values, you can't really
detect that the values are defaults, so you have to write all the attribute
values to storage. This can result in unreadably longer files.
The solution I'm working towards for jboss when using the timestamp based
auto-redeploy is to model the originally deployed xml deployment
descriptors as mbeans, including something like a modification timestamp.
These mbeans and the timestamp will be persisted through jmx. When the
server shuts down and wakes up again it can tell by comparing timestamps
from the mbean and the actual file if the descriptor has changed, and
redeploy the mbeans from the file if necessary.
>
> I agree that 'original xml' can't be completely preserved, and comments
> and some other structures are hard.
>
> At least the solution that we are trying ( or at least I'm trying )for
> tomcat5 is a 2-layer, with config handled by JNDI and runtime changes
> handled by JMX. It should be possible to change the port of tomcat using
> a simple ant task ( and without starting tomcat ) - and that shouldn't
> destroy the comments or the rest of the config structure.
>
> I think that also maps well for ant ( at least when used 'embeded',
> for standalone ant it's not an issue ).
>
> > Perhaps studying these related problems will lead an ant developer to
> > consider my proposal that much of the infrastructure and many of the
> > infrastructure problems of ant could be eliminated by making ant into a
> > bunch of mbeans running in an mbean server.
>
> I don't have any doubt about this. Ant is already formed of tasks that
> are perfectly fit for a model ( or dynamic ) MBean wrapper, same
> for Target and Project.
>
> I don't think the MBeans should be very tight ( at least for now ), but
> wrapping ant and using tasks/targets/projects via JMX is certainly
> desirable ( and quite easy to do with the current ant and minimal changes
> ).
> Right now I'm more interested on exposing ant internals via JNDI,
> since I thing the API is a bit more powerfull and easy to use and fits
> better ( things like ant:env/properties/foo or ant:env/ref/bar ).
I _really_ don't understand this. Maybe I am biased from having worked
with the jboss xml based mbean deployment descriptors for so long, but I
find both them and working directly with mbean attributes much more
powerful than jndi.
Anyway, I am very glad to see interest in jmx in the ant community.
thanks
david jencks
>
> Costin
>
>
>
> --
> To unsubscribe, e-mail: <ma...@jakarta.apache.org>
> For additional commands, e-mail: <ma...@jakarta.apache.org>
>
>
>
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
Re: Project.toXML() ?
Posted by Costin Manolache <cm...@yahoo.com>.
David Jencks wrote:
> Saving changes in your mbeans is IMO best handled by using a jmx and
> modelmbean implementation that implements persistence. Writing out
> something like the original xml config file is more or less disasterous:
> after trying it in jboss 2.2 we will never go back.
I'll have to disagree with this :-)
I agree that (runtime) changes should be done via a JMX, but
JMX is (IMO) a pretty bad persistence API, and I don't thing
that configuration should be restricted to runtime ( in
JMX-handles-persistence you do need the MBeans instantiated and
in a certain state - it works very well for modifying a running
server, but sometimes it's a bit of foreced solution if you
want to modify passive config ).
I agree that 'original xml' can't be completely preserved, and comments
and some other structures are hard.
At least the solution that we are trying ( or at least I'm trying )for
tomcat5 is a 2-layer, with config handled by JNDI and runtime changes
handled by JMX. It should be possible to change the port of tomcat using
a simple ant task ( and without starting tomcat ) - and that shouldn't
destroy the comments or the rest of the config structure.
I think that also maps well for ant ( at least when used 'embeded',
for standalone ant it's not an issue ).
> Perhaps studying these related problems will lead an ant developer to
> consider my proposal that much of the infrastructure and many of the
> infrastructure problems of ant could be eliminated by making ant into a
> bunch of mbeans running in an mbean server.
I don't have any doubt about this. Ant is already formed of tasks that
are perfectly fit for a model ( or dynamic ) MBean wrapper, same
for Target and Project.
I don't think the MBeans should be very tight ( at least for now ), but
wrapping ant and using tasks/targets/projects via JMX is certainly
desirable ( and quite easy to do with the current ant and minimal changes ).
Right now I'm more interested on exposing ant internals via JNDI,
since I thing the API is a bit more powerfull and easy to use and fits
better ( things like ant:env/properties/foo or ant:env/ref/bar ).
Costin
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
Re: Project.toXML() ?
Posted by David Jencks <da...@directvinternet.com>.
On 2002.10.13 18:26:12 -0400 Costin Manolache wrote:
> Matt Bishop wrote:
>
> > Is there any code available to dump a Project object out to XML? I am
> not
> > concerned with preserving comments, whitespace, etc. from the load,
> just
> > want to emit the Project tree.
>
> Not yet - AFAIK.
>
> In general, it is not possible using the current model - the document is
> read using SAX and most tasks are created on the fly. In order to
> get the XML you would need how to reconstruct the xml from beans. That
> requires getters on all beans and knowledge on what is 'real' data
> and what is just runtime getter.
>
> One thing that seems possible is to use
> UnknownElement/RuntimeConfigurable
> on all tasks ( right now they are used only in special cases, when the
> type is not known at parsing time ). I have the code working fine
> ( i.e. most projects I work on and gump seem fine ). Using this it would
> be possible to reconstruct the xml form.
>
> Another aproach that would also preserve the comments is to use a
> ProjectHelper that is based on DOM.
>
> I'm not sure why would you want that - since you could just read
> the original document. It is only interesting when you create the
> Project at runtime, using API calls, or when you use some tool to
> dynamically change the project ( edit properties, etc ).
>
> ( I'm very interested in those use-cases, not only in ant but also
> on tomcat - where the server.xml must be saved to reflect changes
> made via JMX )
Saving changes in your mbeans is IMO best handled by using a jmx and
modelmbean implementation that implements persistence. Writing out
something like the original xml config file is more or less disasterous:
after trying it in jboss 2.2 we will never go back.
Perhaps studying these related problems will lead an ant developer to
consider my proposal that much of the infrastructure and many of the
infrastructure problems of ant could be eliminated by making ant into a
bunch of mbeans running in an mbean server.
thanks
david jencks
>
> --
> Costin
>
>
>
> --
> To unsubscribe, e-mail: <ma...@jakarta.apache.org>
> For additional commands, e-mail: <ma...@jakarta.apache.org>
>
>
>
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
Re: Project.toXML() ?
Posted by Costin Manolache <cm...@yahoo.com>.
Matt Bishop wrote:
> Is there any code available to dump a Project object out to XML? I am not
> concerned with preserving comments, whitespace, etc. from the load, just
> want to emit the Project tree.
Not yet - AFAIK.
In general, it is not possible using the current model - the document is
read using SAX and most tasks are created on the fly. In order to
get the XML you would need how to reconstruct the xml from beans. That
requires getters on all beans and knowledge on what is 'real' data
and what is just runtime getter.
One thing that seems possible is to use UnknownElement/RuntimeConfigurable
on all tasks ( right now they are used only in special cases, when the
type is not known at parsing time ). I have the code working fine
( i.e. most projects I work on and gump seem fine ). Using this it would
be possible to reconstruct the xml form.
Another aproach that would also preserve the comments is to use a
ProjectHelper that is based on DOM.
I'm not sure why would you want that - since you could just read
the original document. It is only interesting when you create the
Project at runtime, using API calls, or when you use some tool to
dynamically change the project ( edit properties, etc ).
( I'm very interested in those use-cases, not only in ant but also
on tomcat - where the server.xml must be saved to reflect changes
made via JMX )
--
Costin
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
Re: Project.toXML() ?
Posted by Stefan Bodewig <bo...@apache.org>.
On Sun, 13 Oct 2002, Matt Bishop <ma...@bea.com> wrote:
> Is there any code available to dump a Project object out to XML?
Not within Ant's classes, but I think Antidote is able to do that, so
you may be able to get some inspiration from there.
Stefan
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>