Uploaded image for project: 'ModeShape'
  1. ModeShape
  2. MODE-1242

RepositoryFactory should accept JNDI URL to Repository instance (not just RepositoryEngine) instance

XMLWordPrintable

    • Workaround Exists
    • Hide

      When using the JndiRepositoryFactory, use the JCR 1.0 style of lookup.

      Or, if JCR 2.0 style of lookup is expected, create a new javax.naming.spi.ObjectFactory that is similar to JndiRepositoryFactory but that registers the *engine* in JNDI.

      Show
      When using the JndiRepositoryFactory, use the JCR 1.0 style of lookup. Or, if JCR 2.0 style of lookup is expected, create a new javax.naming.spi.ObjectFactory that is similar to JndiRepositoryFactory but that registers the * engine * in JNDI.

      JCR 1.0 suggested finding Repository instances in JNDI directly, using something like this:

      InitialContext initCtx = new InitialContext();
      Context envCtx = (Context) initCtx.lookup("java:comp/env");
      Repository repository = (Repository) envCtx.lookup("jcr/local");
      

      ModeShape's JndiRepositoryFactory can be used within web servers to deploy a ModeShape engine instance and register a particular Repository instance in JNDI.

      However, JCR 2.0 changed this and instead uses the ServiceLoader mechanism and introduced a RepositoryFactory interface that allowed a different way to find a Repository instance:

      Map<String, String> parameters = ...
      for (RepositoryFactory factory : ServiceLoader.load(RepositoryFactory.class)) {
          repository = factory.getRepository(parameters);
          if (repository != null) break;
      }
      

      where the parameters are implementation-dependent. ModeShape expects a single "org.modeshape.jcr.URL" parameter whose value is a URL of several forms. However, the only JNDI form expects the *ModeShape engine* to be found in JNDI, and thus this is not compatible with the JndiRepositoryFactory approach described above.

      Therefore, the RepositoryFactory should be changed to look for a JNDI URL that points directly to a Repository instance.

              rhauch Randall Hauch (Inactive)
              rhauch Randall Hauch (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

                Created:
                Updated:
                Resolved: