I can't find the JIRA issue. So here's my attempt.  Opinions, anyone?

A utility class with the following method that takes a SqlMapClientImpl and path to sqlmap file to add it into the current sqlmapclient:

public static void addMapFromResource(SqlMapClientImpl client, String resourcePath) throws NodeletException, IOException {
      Variables v = new Variables();
      v.errorCtx.setActivity("loading the SQL Map resource");
      v.errorCtx.setResource(resourcePath);
      v.client = client;
      v.delegate = v.client.getDelegate();
      v.typeHandlerFactory = v.delegate.getTypeHandlerFactory();
      v.currentStatements = new HashMap();

      SqlMapParser parser = new SqlMapParser(v);
      parser.parse(Resources.getResourceAsReader(resourcePath));

Iterator cacheNames = v.client.getDelegate().getCacheModelNames ();
      while(cacheNames.hasNext()) {
          String cacheName = (String) cacheNames.next();
CacheModel cacheModel = v.client.getDelegate ().getCacheModel(cacheName); Iterator statementNames = cacheModel.getFlushTriggerStatementNames();
          while(statementNames.hasNext()) {
              String statementName = (String) statementNames.next();
MappedStatement statement = (MappedStatement) v.currentStatements.get(statementName); if(statement!=null) statement.addExecuteListener (cacheModel);
          }
      }
  }


The Variables class inside BaseParser will need an additional variable:

public Map currentStatements; // NOT currentStatement, which already exist.

The SqlMapParser's statement nodelets will need the following line at the end of process(Node) method:

vars.currentStatements.put(vars.currentStatement.getId(), vars.currentStatement);


Am I missing anything? I haven't tried it yet, but will do as soon as I get some free time.

-richard


On Feb 23, 2006, at 4:45 AM, Niels Beekman wrote:

Hi,

This has been discussed several times now on this mailing list, the
short answer is no, the longer answer: it is already in JIRA, find the
issue and vote for it, or even better, contribute it yourself.

Grtz,

Niels

-----Original Message-----
From: Richard Lin [mailto:[EMAIL PROTECTED]
Sent: donderdag 23 februari 2006 4:56
To: [email protected]
Subject: Adding sqlmap at runtime

Is there anyway to add/load a sqlmap XML file at runtime instead of
including in the sqlmap-config file?

I'm working on a framework that needs to discover and load sqlmap
files dynamically from jars with classloader.


Reply via email to