@Override public ComponentAdapter getAdapter(String id) throws Exception { return (ComponentAdapter) activator.getObject(id); }
@SuppressWarnings("unchecked") public <T> T getObject(Class<T> ifc, String name) throws Exception { return (T)getObject(ifc.getCanonicalName() + ":" + name); }
@SuppressWarnings("unchecked") public <T> T getObject(Class<T> ifc) throws Exception { return (T)getObject(ifc.getCanonicalName()); }
@Deprecated public <T> T loadModule(Class<? extends T> clazz) throws Exception { T out = (T) getActivator().getObject(clazz,""); if (out instanceof DesktopInject) ((DesktopInject) out).setDesktop(this); return out; }
ObjectFactory inst = getObject(factoryClazz.value()); if (inst != null) { out = inst.create(clazz,classes,objects);
@Override public <T, D extends T> T lookup(Class<T> ifc, Class<D> def) { try { if (activator == null) { if (parent != null) return parent.lookup(ifc, def); } else { if (parent != null && !activator.isInstance(ifc) && ( local == null || !local.contains(ifc.getCanonicalName()) ) ) return parent.lookup(ifc, def); } T ret = activator.getObject(ifc); if (ret != null) return ret; } catch (Exception e) { MApi.dirtyLog("info: fallback to default",ifc,def,e); } if (def == null) return null; try { return def.newInstance(); } catch (InstantiationException | IllegalAccessException e) { MApi.dirtyLog(ifc,e); } return null; }
ObjectFactory factory = getObject(defaultFactory.value()); return factory.create(orgClazz, null, null);
/** {@inheritDoc} */ @Override public boolean validate(LayoutElement element, DataConnector dataConnector, Object value) throws MException { String string = element.getConfig().getString("validator", null); if (string == null) return true; // MActivator a = validators; // if (a == null) a = element.getLayoutFactory().getActivator(); MActivator a = element.getLayoutFactory().getActivator(); String[] va = string.split(","); for (String v : va) { Validator validator; try { validator = (Validator) a.getObject(Validator.class,v); } catch (Exception e) { e.printStackTrace(); return false; } if (validator != null && !validator.validate(this,element,value)) return false; } return true; }
/** {@inheritDoc} */ @Override public void wizard(LayoutElement element) { // MActivator a = wizards; // if (a == null) a = element.getLayoutFactory().getActivator(); MActivator a = element.getLayoutFactory().getActivator(); Wizard wizard; try { // wizard = (Wizard) a.getObject(Wizard.class,element.getConfig().getString("wizard", null)); wizard = (Wizard) a.getObject(element.getConfig().getString("wizard", null)); } catch (Exception e) { e.printStackTrace(); return; } if (wizard != null) wizard.openWizard(this,element); }
/** {@inheritDoc} */ @Override public void action(FormAction action) { // MActivator a = wizards; // if (a == null) a = action.getParent().getLayoutFactory().getActivator(); MActivator a = action.getParent().getLayoutFactory().getActivator(); Action act; try { // act = (Action) a.getObject(Action.class,action.getConfig().getString("action", null)); act = (Action) a.getObject(action.getConfig().getString("action", null)); } catch (Exception e) { e.printStackTrace(); return; } if (act != null) act.doExecute(this,action); }
@Override public synchronized Dialect getDialect() { if (dialect == null) { // ResourceNode concon = config.getNode("connection"); String dialectName = config.getExtracted("dialect"); if (dialectName != null) { try { dialect = (Dialect)activator.getObject(dialectName); } catch (Exception e) { log().t(dialect,e); } } if (dialect == null) { dialectName = config.getExtracted("driver"); if (dialectName != null) { dialect = Dialect.findDialect(dialectName); } } log().i("found dialect",getName(), dialectName, dialect); } return dialect; }