/** * Returns a JSONComponent of the given type. * * @param <T> the JSONComponent type * @param componentClass the class to instantiate * @param context the WOContext to create within * @return an instance of the given JSONComponent */ @SuppressWarnings("unchecked") public static <T extends JSONComponent> T componentWithName(Class<T> componentClass, WOContext context) { T jsonComponent = (T) _NSUtilities.instantiateObject(componentClass, new Class[] { WOContext.class }, new Object[] { context }, true, false); return jsonComponent; }
private WOAssociation createAssociationForClass(Class clazz, String value, boolean isConstant) { return (WOAssociation) _NSUtilities.instantiateObject(clazz, new Class[] { Object.class, boolean.class }, new Object[] { value, Boolean.valueOf(isConstant) }, true, false); }
/** * Returns a JSONComponent of the given type. * * @param <T> the JSONComponent type * @param componentClassName the name of the class to instantiate * @param context the WOContext to create within * @return an instance of the given JSONComponent */ @SuppressWarnings("unchecked") public static <T extends JSONComponent> T componentWithName(String componentClassName, WOContext context) { Class<T> componentClass = _NSUtilities.classWithName(componentClassName); T jsonComponent = (T) _NSUtilities.instantiateObject(componentClass, new Class[] { WOContext.class }, new Object[] { context }, true, false); return jsonComponent; } }
public static void initialize() { String className = ERXProperties.stringForKeyWithDefault("er.corebusinesslogic.ERCAuditTrailClassName", ERCAuditTrailHandler.class.getName()); Class c = ERXPatcher.classForName(className); _handler = (ERCAuditTrailHandler) _NSUtilities.instantiateObject(c, new Class[]{}, new Object[]{}, true, false); NSSelector sel = ERXSelectorUtilities.notificationSelector("modelGroupDidLoad"); NSNotificationCenter.defaultCenter().addObserver(_handler, sel, ERXModelGroup.ModelGroupAddedNotification, null); }
/** * @param key the name of the index * @param indexDef the dictionary containing the index definition (usually deserialized from the indexModel file) */ private void addIndex(String key, NSDictionary indexDef) { // Classname for the class that will create the lucene index String className = (String) indexDef.objectForKey("index"); NSMutableDictionary dict = indexDef.mutableClone(); // If index store not defined, default to index named the dsame as the indexModel file in the indexRoot directory if(!dict.containsKey("store")) { try { dict.setObjectForKey(new File(indexRoot(), key).toURI().toURL().toString(), "store"); } catch (MalformedURLException e) { throw NSForwardException._runtimeExceptionForThrowable(e); } } // Create the class that will create the index. Defaults to ERAutoIndex ERIndex index; if (className != null) { Class c = ERXPatcher.classForName(className); index = (ERIndex) _NSUtilities.instantiateObject(c, new Class[] { String.class, NSDictionary.class }, new Object[] { key, dict }, true, false); } else { index = new ERAutoIndex(key, dict); } // Add the index addIndex(key, index); }
private EREntityStore _entityStoreForExternalName(String name, boolean transactional) { EREntityStore store = _entityStores.objectForKey(name); if (store == null) { store = (EREntityStore) _NSUtilities.instantiateObject(_entityStoreClazz, null, null, false, false); _entityStores.setObjectForKey(store, name); } if (transactional) { EREntityStore transactionStore = _transactionEntityStores.objectForKey(name); if (transactionStore == null) { transactionStore = store.transactionStore(); _transactionEntityStores.setObjectForKey(transactionStore, name); } store = transactionStore; } return store; }
JSONComponent component; if (JSONComponent.class.isAssignableFrom(componentClass)) { component = (JSONComponent) _NSUtilities.instantiateObject(componentClass, new Class[] { WOContext.class }, new Object[] { context }, true, false);