Semi-replying to myself:

From this code:


public class FOMParserOptions
  extends AbstractParserOptions {

  protected void initFactory() {
    factory = new FOMFactory();
  }
...
}

It seems like I have to pass some options to the parse method, otherwise default options will always give me a FOMFactory, regardless of what system properties I set.

Is that correct?

        Ugo

On Oct 9, 2006, at 2:19 PM, Ugo Cei wrote:

Folks,

I'm trying to extend the stock Abdera factory to perform some tricks (more on this later). This is what I'm doing:

        System.setProperty("org.apache.abdera.factory.Factory",
                           "org.apache.abdera.ext.MyFactory");
InputStream in = this.getClass().getResourceAsStream("/ simple.xml");
        Parser parser = Abdera.getNewParser();
        Document<Feed> doc = parser.parse(in);

And here's my Factory class:


public class MyFactory extends FOMFactory {

private static final Log logger = LogFactory.getLog (MyFactory.class);

    public MyFactory() {
        super();
        logger.debug("<init>");
    }

    public MyFactory(Abdera abdera) {
        super(abdera);
        logger.debug("<init>(" + abdera + ")");
    }

    @Override
protected OMElement createElement(QName qname, OMContainer parent, FOMBuilder builder) {
        logger.debug("createElement(" + qname + ")");
OMElement element = super.createElement(qname, parent, builder);
        return element;
    }

    @Override
protected OMElement createElement(QName qname, OMContainer parent, OMFactory factory, Object objecttype) {
        logger.debug("createElement(" + qname + ")");
OMElement element = super.createElement(qname, parent, factory, objecttype);
        return element;
    }

}

As you can see I'm basically delegating everything back to the parent class, apart from some logging.

I would expect my overridden createElement methods to be called, but they are not. I get the logging output from the MyFactory (Abdera abdera) constructor, but nothing else.

Any hints?

        Ugo



--
Ugo Cei
Blog: http://agylen.com/
Open Source Zone: http://oszone.org/
Evil or Not?: http://evilornot.info/
Company: http://www.sourcesense.com/



Reply via email to