From: <sha...@us...> - 2011-01-29 18:40:48
|
Revision: 13689 http://exist.svn.sourceforge.net/exist/?rev=13689&view=rev Author: shabanovd Date: 2011-01-29 18:40:42 +0000 (Sat, 29 Jan 2011) Log Message: ----------- [ignore] get the type of a generic class at runtime is nightmare, so resolver method should be send to constructor Modified Paths: -------------- trunk/eXist/src/org/exist/config/ReferenceImpl.java Modified: trunk/eXist/src/org/exist/config/ReferenceImpl.java =================================================================== --- trunk/eXist/src/org/exist/config/ReferenceImpl.java 2011-01-29 18:34:16 UTC (rev 13688) +++ trunk/eXist/src/org/exist/config/ReferenceImpl.java 2011-01-29 18:40:42 UTC (rev 13689) @@ -29,28 +29,34 @@ * @author <a href="mailto:sha...@gm...">Dmitriy Shabanov</a> * */ -public class ReferenceImpl<R, O> implements Reference<R, O> { +public class ReferenceImpl<R, O extends Configurable> implements Reference<R, O>, Configurable { - R resolver; - String name; + private R resolver; + private String methodName; + private String name; + private O cached = null; - public ReferenceImpl(R resolver, String name) { + public ReferenceImpl(R resolver, String methodName, String name) { this.resolver = resolver; + this.methodName = methodName; this.name = name; } - O cached = null; - + public ReferenceImpl(R resolver, O cached) { + this.resolver = resolver; + this.methodName = null; + this.name = null; + this.cached = cached; + } + + @SuppressWarnings("unchecked") @Override public O resolve() { if (cached == null) { - String methodName = "get"+cached.getClass().getName(); - methodName = methodName.toLowerCase(); - Class<? extends Object> clazz = resolver.getClass(); for (Method method : clazz.getMethods()) { - if (method.getName().toLowerCase().equals(methodName) + if (method.getName().equals(methodName) && method.getParameterTypes().length == 1 && method.getParameterTypes()[0].getName().equals("java.lang.String") ) @@ -72,4 +78,20 @@ public R resolver() { return resolver; } + + @Override + public boolean isConfigured() { + O obj = resolve(); + if (obj == null) return false; + + return obj.isConfigured(); + } + + @Override + public Configuration getConfiguration() { + O obj = resolve(); + if (obj == null) return null; + + return obj.getConfiguration(); + } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |