2010/2/1 Grégory Joseph <[email protected]>: > Why don't we use a different implementation and module for this instead ?
well, apart from a few method signatures there are no other differences, so it's just a matter of avoiding 2 separate modules built with two different versions of jackrabbit from the dev side (with the additional problem that we will have to change the actual multi-module build since we will have to build against 2 jackrabbit versions, but checking carefully to have the expected version of jackrabbit in the final war - if we add both providers). All of this for 2 modules which will only have a single "Provider" class. >From the user point of view this means be able to switch from jackrabbit 1.6 to 2 without any additional configuration, just by replacing the jackrabbit jars. A couple of methods called using reflection are IMHO a much cheaper way at this point, WDYT? fabrizio > > -g > > Begin forwarded message: > > From: [email protected] > Date: January 31, 2010 10:07:50 PM GMT+01:00 > To: [email protected] > Subject: [magnolia-svn] [31392] MAGNOLIA-2988 ntReg.getNodeTypeDef() has a > different return type in jackrabbit 2.0, so this causes a binary > incompatibility if we compile the provider class with jackrabbit 1 .6 > Reply-To: "Magnolia SVN-List" <[email protected]> > > Revision 31392 Author fgiust Date 2010-01-31 22:07:49 +0100 (Sun, 31 Jan > 2010) > > Log Message > > MAGNOLIA-2988 ntReg.getNodeTypeDef() has a different return type in > jackrabbit 2.0, so this causes a binary incompatibility if we compile the > provider class with jackrabbit 1.6 > > Modified Paths > > community/magnolia/trunk/magnolia-core/src/main/java/info/magnolia/jackrabbit/ProviderImpl.java > > Diff > > Modified: > community/magnolia/trunk/magnolia-core/src/main/java/info/magnolia/jackrabbit/ProviderImpl.java > (31391 => 31392) > > --- > community/magnolia/trunk/magnolia-core/src/main/java/info/magnolia/jackrabbit/ProviderImpl.java > 2010-01-31 > 18:15:13 UTC (rev 31391) > +++ > community/magnolia/trunk/magnolia-core/src/main/java/info/magnolia/jackrabbit/ProviderImpl.java > 2010-01-31 > 21:07:49 UTC (rev 31392) > @@ -73,6 +73,7 @@ > import java.io.FileNotFoundException; > import java.io.IOException; > import java.io.InputStream; > +import java.lang.reflect.InvocationTargetException; > import java.lang.reflect.Method; > import java.util.Hashtable; > import java.util.Iterator; > @@ -333,18 +334,45 @@ > } > > try { > - ntReg.getNodeTypeDef(ntname); > + > + // return value has changed in jackrabbit 2, we still > have to use reflection here > + // ntReg.getNodeTypeDef(ntname); > + > + Method method = > ntReg.getClass().getMethod("getNodeTypeDef", Name.class); > + method.invoke(ntReg, ntname); > } > - catch (NoSuchNodeTypeException nsne) { > - log.info("Registering nodetype {}", ntname); > //$NON-NLS-1$ > + catch (IllegalArgumentException e) > + { > + throw new RepositoryException(e.getMessage(), e); > + } > + catch (IllegalAccessException e) > + { > + throw new RepositoryException(e.getMessage(), e); > + } > + catch (SecurityException e) > + { > + throw new RepositoryException(e.getMessage(), e); > + } > + catch (NoSuchMethodException e) > + { > + throw new RepositoryException(e.getMessage(), e); > + } > + catch (InvocationTargetException ite) > + { > + if (ite.getTargetException() instanceof > NoSuchNodeTypeException) > + { > + log.info("Registering nodetype {}", ntname); > //$NON-NLS-1$ > > - try { > - // reflection for jackrabbit 1+2 compatibility > - getMethod(NodeTypeRegistry.class, > "registerNodeType").invoke(ntReg, new Object[]{def}); > + try > + { > + // reflection for jackrabbit 1+2 compatibility > + getMethod(NodeTypeRegistry.class, > "registerNodeType").invoke(ntReg, new Object[]{def }); > + } > + catch (Exception e) > + { > + throw new RepositoryException(e.getMessage(), > e); > + } > } > - catch (Exception e) { > - throw new RepositoryException(e.getMessage(), e); > - } > } > } > > > > ________________________________ > ---------------------------------------------------------------- > For list details see > http://www.magnolia-cms.com/home/community/mailing-lists.html > To unsubscribe, E-mail to: <[email protected]> > ---------------------------------------------------------------- > > > > ________________________________ > ---------------------------------------------------------------- > For list details see > http://www.magnolia-cms.com/home/community/mailing-lists.html > To unsubscribe, E-mail to: <[email protected]> > ---------------------------------------------------------------- > ---------------------------------------------------------------- For list details see http://www.magnolia-cms.com/home/community/mailing-lists.html To unsubscribe, E-mail to: <[email protected]> ----------------------------------------------------------------
