/** * Return the components extension both by resolving the property of the current * project and from the commons extension. If it is available instead of * request the extension from the superclass it search it in the common * cache * * @return a not null components extension */ @SuppressWarnings("unchecked") private List<ComponentsBundle> getExtensionComponents(){ if (bundles == null || refreshBundles) { bundles = (List<ComponentsBundle>)ExtensionLoader.getSharedExtension(ComponentsBundle.class); //fallback if something in the cache goes wrong if (bundles == null) bundles = super.getExtensions(ComponentsBundle.class); // remove all duplicates Set<ComponentsBundle> components = new LinkedHashSet<ComponentsBundle>(bundles); bundles = new ArrayList<ComponentsBundle>(components); for (ComponentsBundle cb : bundles) { try { ComponentManager cm = cb.getComponentManager(ComponentsExtensionsRegistryFactory.MAP_COMPONENT_NAME); if (cm != null && cm instanceof ComponentsManager) ((ComponentsManager) cm).setDesignConverter(MapDesignConverter.getInstance()); } catch (Exception e) { } } refreshBundles = false; } return bundles; }
@Override @SuppressWarnings("unchecked") public <T> List<T> getExtensions(Class<T> extensionType) { if (ComponentsBundle.class.equals(extensionType)) { return Collections.singletonList((T)bundle); } return null; }
protected static void addComponentRules(JasperReportsContext jasperReportsContext, Digester digester) { digester.addFactoryCreate("*/componentElement", JRComponentElementFactory.class.getName()); digester.addSetNext("*/componentElement", "addElement", JRDesignElement.class.getName()); Collection<ComponentsBundle> components = ComponentsEnvironment.getInstance(jasperReportsContext).getBundles(); for (Iterator<ComponentsBundle> it = components.iterator(); it.hasNext();) { ComponentsBundle componentsBundle = it.next(); ComponentsXmlParser xmlParser = componentsBundle.getXmlParser(); digester.setRuleNamespaceURI(xmlParser.getNamespace()); XmlDigesterConfigurer configurer = xmlParser.getDigesterConfigurer(); if (configurer != null) { configurer.configureDigester(digester); } digester.setRuleNamespaceURI(xmlParser.getNamespace()); for (Iterator<String> namesIt = componentsBundle.getComponentNames().iterator(); namesIt.hasNext();) { String componentName = namesIt.next(); digester.addRule("*/componentElement/" + componentName, JRComponentRule.newInstance()); } } digester.setRuleNamespaceURI(JRXmlConstants.JASPERREPORTS_NAMESPACE); }
@Override @SuppressWarnings({ "rawtypes", "unchecked" }) public List getExtensions(Class extensionType) { if (ComponentsBundle.class.equals(extensionType)) { return Collections.singletonList(bundle); } if (GenericElementHandlerBundle.class.equals(extensionType)) { return Collections.singletonList(handler); } if (CustomComponentTransform.class.equals(extensionType)) { return transforms; } return null; }
@SuppressWarnings("unchecked") @Override public <T> List<T> getExtensions(Class<T> extensionType) { if (extensionType == ComponentsBundle.class) { return (List<T>) Collections.singletonList(COMPONENTS_BUNDLE); } if (extensionType == GenericElementHandlerBundle.class) { return (List<T>) Collections.singletonList(HANDLER_BUNDLE); } return null; }