[Mulgara-dev] ItqlInterpreter.isLocal problem

Life is hard, and then you die ronald at innovation.ch
Sun Oct 1 02:25:48 CDT 2006


The logic surrounding the 'isLocal' flag in ItqlInterpreter seems
wrong, and is causing some problems for us. I'm unsure of the original
intentions, and hence of the best fix, which is why I'm sending this
email before creating a patch.

The isLocal flag is used when a new session is needed:

    SessionFactoryFinder.newSessionFactory(serverURI, !isLocal);

However, it always contains the value of the previous URI, i.e. after
setting a new session the following is invoked:

    isLocal = session.isLocal();

This seems wrong: why would the local'ity of the previous server URI
necessarily have anything to do with the locality of a new server URI
being set?

Now, there are in fact two places where isLocal is being used. First
in updateSession(), as follows:

    serverURI = SessionFactoryFinder.findServerURI();

    SessionFactory sessionFactory =
        SessionFactoryFinder.newSessionFactory(serverURI, !isLocal);

Since findServerURI() always returns a local URI, it would seem to
make more sense to just use

        SessionFactoryFinder.newSessionFactory(serverURI, false);

The second case is in setServerURI(). Here I'm thinking the best
option would be to either A) add a isRemote or isLocal parameter to
the setServerURI() method, or B) to try to guess the value from the
hostname using something like

    String host = databaseURI.getHost();
    boolean isLocal =
        NetworkInterface.getByInetAddress(InetAddress.getByName(host)) != null;

Does this make any sense? Am I missing something?

FYI, the specific problem we're running into is that we're exporting
ItqlInterpreterBean via SOAP. Because isLocal defaults to false, and
because we're not running an RMI server (or registry) the calls all
fail (we're using "rmi://localhost/server" as the server URI).


  Cheers,

  Ronald



More information about the Mulgara-dev mailing list