/** * Return the proxy type for this model * @param <T> the proxy type * @return the class object for this proxy type */ public <T extends ConfigBeanProxy> Class<T> getProxyType() { if (targetTypeClass == null) { targetTypeClass = (Class<T>) classLoaderHolder.loadClass(targetTypeName); } return targetTypeClass; }
@Override public Class<?> run() { return delegate.loadClass(className); }
/** * Returns the list of sub-elements supported by a ConfigBean * @return array of classes reprensenting the sub elements of a particular * @throws ClassNotFoundException for severe errors with the model associated * with the passed config bean. */ public static Class<?>[] getSubElementsTypes(ConfigBean bean) throws ClassNotFoundException { List<Class<?>> subTypes = new ArrayList<Class<?>>(); for (ConfigModel.Property element : bean.model.elements.values()) { if (!element.isLeaf()) { ConfigModel elementModel = ((ConfigModel.Node) element).model; Class<?> subType = elementModel.classLoaderHolder.loadClass(elementModel.targetTypeName); subTypes.add(subType); } else { if (element.isCollection()) { subTypes.add(List.class); } } } return subTypes.toArray(new Class[subTypes.size()]); }
public static Class<? extends ConfigBeanProxy> getElementTypeByName(ConfigBeanProxy parent, String elementName) throws ClassNotFoundException { final Dom parentDom = Dom.unwrap(parent); DomDocument document = parentDom.document; ConfigModel.Property a = parentDom.model.elements.get(elementName); if (a!=null) { if (a.isLeaf()) { // dochez : I am not too sure, but that should be a String @Element return null; } else { ConfigModel childModel = ((ConfigModel.Node) a).model; return (Class<? extends ConfigBeanProxy>) childModel.classLoaderHolder.loadClass(childModel.targetTypeName); } } // global lookup ConfigModel model = document.getModelByElementName(elementName); if (model!=null) { return (Class<? extends ConfigBeanProxy>) model.classLoaderHolder.loadClass(model.targetTypeName); } return null; }
/** * probably a bit slow, calculates all the @Configured interfaces subclassing, useful * to find all possible subclasses of a type. * * @throws ClassNotFoundException */ private void initXRef() throws ClassNotFoundException { // force initialization of all the config models. for (ServiceHandle<?> i : habitat.getAllServiceHandles(ConfigInjector.class)) { buildModel((ActiveDescriptor<? extends ConfigInjector>) i.getActiveDescriptor()); } for (ConfigModel cm : models.values()) { Class targetType = cm.classLoaderHolder.loadClass(cm.targetTypeName); do { Class[] intfs = targetType.getInterfaces(); for (Class intf : intfs) { if (intf.isAnnotationPresent(Configured.class)) { addXRef(intf, cm); } } targetType = targetType.getSuperclass(); } while (targetType!=null); } }
final Class<?> targetClass = parent.model.classLoaderHolder.loadClass(elementModel.targetTypeName); if (targetClass.isAssignableFrom(childType)) { element = e;
final Class<?> tempClass = elementModel.classLoaderHolder.loadClass(elementModel.targetTypeName); if ( tempClass.isAssignableFrom( childType ) ) { element = e;
/** * Return the proxy type for this model * @param <T> the proxy type * @return the class object for this proxy type */ public <T extends ConfigBeanProxy> Class<T> getProxyType() { if (targetTypeClass == null) { targetTypeClass = (Class<T>) classLoaderHolder.loadClass(targetTypeName); } return targetTypeClass; }
/** * Return the proxy type for this model * @param <T> the proxy type * @return the class object for this proxy type */ public <T extends ConfigBeanProxy> Class<T> getProxyType() { if (targetTypeClass == null) { targetTypeClass = (Class<T>) classLoaderHolder.loadClass(targetTypeName); } return targetTypeClass; }
@Override public Class<?> run() { return delegate.loadClass(className); }
/** * Returns the list of sub-elements supported by a ConfigBean * @return array of classes reprensenting the sub elements of a particular * @throws ClassNotFoundException for severe errors with the model associated * with the passed config bean. */ public static Class<?>[] getSubElementsTypes(ConfigBean bean) throws ClassNotFoundException { List<Class<?>> subTypes = new ArrayList<Class<?>>(); for (ConfigModel.Property element : bean.model.elements.values()) { if (!element.isLeaf()) { ConfigModel elementModel = ((ConfigModel.Node) element).model; Class<?> subType = elementModel.classLoaderHolder.loadClass(elementModel.targetTypeName); subTypes.add(subType); } else { if (element.isCollection()) { subTypes.add(List.class); } } } return subTypes.toArray(new Class[subTypes.size()]); }
public static Class<? extends ConfigBeanProxy> getElementTypeByName(ConfigBeanProxy parent, String elementName) throws ClassNotFoundException { final Dom parentDom = Dom.unwrap(parent); DomDocument document = parentDom.document; ConfigModel.Property a = parentDom.model.elements.get(elementName); if (a!=null) { if (a.isLeaf()) { // dochez : I am not too sure, but that should be a String @Element return null; } else { ConfigModel childModel = ((ConfigModel.Node) a).model; return (Class<? extends ConfigBeanProxy>) childModel.classLoaderHolder.loadClass(childModel.targetTypeName); } } // global lookup ConfigModel model = document.getModelByElementName(elementName); if (model!=null) { return (Class<? extends ConfigBeanProxy>) model.classLoaderHolder.loadClass(model.targetTypeName); } return null; }
public static Class<? extends ConfigBeanProxy> getElementTypeByName(ConfigBeanProxy parent, String elementName) throws ClassNotFoundException { final Dom parentDom = Dom.unwrap(parent); DomDocument document = parentDom.document; ConfigModel.Property a = parentDom.model.elements.get(elementName); if (a!=null) { if (a.isLeaf()) { // dochez : I am not too sure, but that should be a String @Element return null; } else { ConfigModel childModel = ((ConfigModel.Node) a).model; return (Class<? extends ConfigBeanProxy>) childModel.classLoaderHolder.loadClass(childModel.targetTypeName); } } // global lookup ConfigModel model = document.getModelByElementName(elementName); if (model!=null) { return (Class<? extends ConfigBeanProxy>) model.classLoaderHolder.loadClass(model.targetTypeName); } return null; }
protected Class<?> loadClass(String type) throws ClassNotFoundException { HK2Loader loader = myself.getLoader(); if (loader == null) { return getClass().getClassLoader().loadClass(type); } try { return loader.loadClass(type); } catch (MultiException me) { for (Throwable th : me.getErrors()) { if (th instanceof ClassNotFoundException) { throw (ClassNotFoundException) th; } } throw new ClassNotFoundException(me.getMessage()); } }
private Class<?> loadClass(final String cname) throws ClassNotFoundException { List<ActiveDescriptor<?>> descriptors; // non-services are not known by HK2 if ("com.oracle.cloudlogic.accountmanager.cli.AccountAwareJobImpl".equals(cname)) { descriptors = getDescriptors("com.oracle.cloudlogic.accountmanager.cli.AccountAwareJobCreator"); } else { descriptors = getDescriptors(cname); } if (descriptors.size() > 0) { try { return descriptors.get(0).getLoader().loadClass(cname); } catch (MultiException ex) { throw ex; } } else { throw new ClassNotFoundException(cname); } }
/** * probably a bit slow, calculates all the @Configured interfaces subclassing, useful * to find all possible subclasses of a type. * * @throws ClassNotFoundException */ private void initXRef() throws ClassNotFoundException { // force initialization of all the config models. for (ServiceHandle<?> i : habitat.getAllServiceHandles(ConfigInjector.class)) { buildModel((ActiveDescriptor<? extends ConfigInjector>) i.getActiveDescriptor()); } for (ConfigModel cm : models.values()) { Class targetType = cm.classLoaderHolder.loadClass(cm.targetTypeName); do { Class[] intfs = targetType.getInterfaces(); for (Class intf : intfs) { if (intf.isAnnotationPresent(Configured.class)) { addXRef(intf, cm); } } targetType = targetType.getSuperclass(); } while (targetType!=null); } }
private Class<?> loadClass(Descriptor descriptor, Injectee injectee) { if (descriptor == null) throw new IllegalArgumentException(); HK2Loader loader = descriptor.getLoader(); if (loader == null) { return Utilities.loadClass(descriptor.getImplementation(), injectee); } Class<?> retVal; try { retVal = loader.loadClass(descriptor.getImplementation()); } catch (MultiException me) { me.addError(new IllegalStateException("Could not load descriptor " + descriptor)); throw me; } catch (Throwable th) { MultiException me = new MultiException(th); me.addError(new IllegalStateException("Could not load descriptor " + descriptor)); throw me; } return retVal; }
private Class<?> loadClass(Descriptor descriptor, Injectee injectee) { if (descriptor == null) throw new IllegalArgumentException(); HK2Loader loader = descriptor.getLoader(); if (loader == null) { return Utilities.loadClass(descriptor.getImplementation(), injectee); } Class<?> retVal; try { retVal = loader.loadClass(descriptor.getImplementation()); } catch (MultiException me) { me.addError(new IllegalStateException("Could not load descriptor " + descriptor)); throw me; } catch (Throwable th) { MultiException me = new MultiException(th); me.addError(new IllegalStateException("Could not load descriptor " + descriptor)); throw me; } return retVal; }
private Class<?> loadClass(Descriptor descriptor, Injectee injectee) { if (descriptor == null) throw new IllegalArgumentException(); HK2Loader loader = descriptor.getLoader(); if (loader == null) { return Utilities.loadClass(descriptor.getImplementation(), injectee); } Class<?> retVal; try { retVal = loader.loadClass(descriptor.getImplementation()); } catch (MultiException me) { me.addError(new IllegalStateException("Could not load descriptor " + descriptor)); throw me; } catch (Throwable th) { MultiException me = new MultiException(th); me.addError(new IllegalStateException("Could not load descriptor " + descriptor)); throw me; } return retVal; }
private Class<?> loadClass(Descriptor descriptor, Injectee injectee) { if (descriptor == null) throw new IllegalArgumentException(); HK2Loader loader = descriptor.getLoader(); if (loader == null) { return Utilities.loadClass(descriptor.getImplementation(), injectee); } Class<?> retVal; try { retVal = loader.loadClass(descriptor.getImplementation()); } catch (MultiException me) { me.addError(new IllegalStateException("Could not load descriptor " + descriptor)); throw me; } catch (Throwable th) { MultiException me = new MultiException(th); me.addError(new IllegalStateException("Could not load descriptor " + descriptor)); throw me; } return retVal; }