/** * Creates <CODE>ObjectConverter</CODE>. * @param annotatedClasses Annotated class mapping against jcr primary node types. * @param ignoreDuplicates Flag whether duplicate mapping for a node type is ignored or not. If it is false, it throws <CODE>IllegalArgumentException</CODE> on duplicate mappings. * @return the ObjectConverter for these<code>annotatedClasses</code> * @throws IllegalArgumentException when two annotatedClasses have the same {@link Node#jcrType()} and <code>ignoreDuplicates</code> is false */ @SuppressWarnings("unchecked") public static ObjectConverter createObjectConverter(final Collection<Class<? extends HippoBean>> annotatedClasses, boolean ignoreDuplicates) throws IllegalArgumentException { return createObjectConverter(annotatedClasses, (Class<? extends HippoBean> []) DEFAULT_BUILT_IN_MAPPING_CLASSES, DEFAULT_FALLBACK_NODE_TYPES, ignoreDuplicates); }
/** * Creates <CODE>ObjectConverter</CODE>, with ignoreDuplicates = false, which means that when there are two annotated beans with the same * value for {@link Node#jcrType()}, an IllegalArgumentException is thrown. * @param annotatedClasses Annotated class mapping against jcr primary node types. * @return the ObjectConverter for these<code>annotatedClasses</code> * @throws IllegalArgumentException when two annotatedClasses have the same {@link Node#jcrType()} */ public static ObjectConverter createObjectConverter(final Collection<Class<? extends HippoBean>> annotatedClasses) throws IllegalArgumentException { return createObjectConverter(annotatedClasses, false); }
@Override protected ObjectConverter createInstance() throws Exception { List<Class<? extends HippoBean>> annotatedClasses = null; if (annotatedClassesResourcePath == null && servletContext != null) { annotatedClassesResourcePath = servletContext.getInitParameter(annotatedClassesInitParam); } if (annotatedClassesResourcePath != null) { try { annotatedClasses = ObjectConverterUtils.getAnnotatedClasses(classpathResourceScanner, StringUtils.split(annotatedClassesResourcePath, ", \t\r\n")); } catch (Exception e) { throw new IllegalStateException(e); } } if (annotatedClasses != null) { return ObjectConverterUtils.createObjectConverter(annotatedClasses); } return null; }
public ObjectConverter getObjectConverter() { if (objectConverter == null) { synchronized (this) { if (objectConverter == null) { if (!HstServices.isAvailable()) { throw new IllegalStateException("HST Services are not available."); } ClasspathResourceScanner classpathResourceScanner = HstServices.getComponentManager().getComponent(ClasspathResourceScanner.class.getName()); List<Class<? extends HippoBean>> annotatedClasses = getAnnotatedClasses(classpathResourceScanner); objectConverter = ObjectConverterUtils.createObjectConverter(annotatedClasses); } } } return objectConverter; }