dev@glassfish.java.net

programmatic config changes

From: Justin Lee <Justin.Lee_at_Sun.COM>
Date: Fri, 20 Mar 2009 16:36:49 -0400

In my test, i'm trying to programmatically add/remove elements from the
schema. However, the following code snippet always results in an
exception complaining about not being in a transaction. Stepping
through the code I come to org/jvnet/hk2/config/ConfigBean.java:165
where I get an AbstractList in which all the mutators throw exceptions.
I don't seem to be to doing anything terribly different from, say,
DeleteHttpListener but perhaps there's some bootstrapping that I'm
missing. Can someone point me in the right direction here?

final HttpService service = habitat.getComponent(HttpService.class);
ConfigSupport.apply(new SingleConfigCode<HttpService>() {
    public Object run(HttpService param) throws PropertyVetoException,
TransactionFailure {
        service.getHttpListener().clear();
        return null;
    }
}, service);