private void testReferencedClasses() { ICObjectHome home = null; try { home = (ICObjectHome) IDOLookup.getHome(ICObject.class); } catch (IDOLookupException ex) { log.severe("Could not find home of ICObject"); return; } // get the current classloader (it is the same that is used for "Class.forName()" ) ClassLoader currentClassLoader = getClass().getClassLoader(); try { SortedSet classNames = new TreeSet(); Collection allICObjects = home.findAll(); Iterator iterator = allICObjects.iterator(); while (iterator.hasNext()) { ICObject object = (ICObject) iterator.next(); String className = object.getClassName(); try { // delay initialization, we are not using the class here RefactorClassRegistry.forName(className, false, currentClassLoader); } catch (ClassNotFoundException ex) { // bad luck classNames.add(className); // go ahead } } Iterator classNameIterator = classNames.iterator(); while (classNameIterator.hasNext()) { String className = (String) classNameIterator.next(); log.warning("Class " + className + " could not be found but is referenced as ICObject"); } } catch (FinderException ex) { log.fine("Could not find any ICObjects"); } }
/* (non-Javadoc) * @see com.idega.builder.handler.ICPropertyHandler#getHandlerObject(java.lang.String, java.lang.String, com.idega.presentation.IWContext) */ public PresentationObject getHandlerObject( String name, String stringValue, IWContext iwc, boolean oldGenerationHandler, String instanceId, String method) { IBObjectChooser chooser = new IBObjectChooser(name); chooser.setToUseClassValue(true); try { if (stringValue != null && !stringValue.equals("")) { ICObjectHome home = (ICObjectHome) IDOLookup.getHome(ICObject.class); chooser.setSelectedObject(home.findByClassName(stringValue)); } } catch (IDOLookupException e) { e.printStackTrace(); } catch (NumberFormatException e) { e.printStackTrace(); } catch (FinderException e) { e.printStackTrace(); } return chooser; }