首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 其他教程 > 开源软件 >

ofbiz 之服务 实业api 积累

2012-08-09 
ofbiz 之服务 实体api 积累1:根据delegator 获取 LocalDispatcher ???? LocalDispatcher thisDispatcher

ofbiz 之服务 实体api 积累

1:根据delegator 获取 LocalDispatcher

???? LocalDispatcher thisDispatcher = GenericDispatcher.getLocalDispatcher(delegator.getDelegatorName(), delegator);

?

2:根据dispatcher 获取 DispatcherContext

??? DispatchContext?dctx ?=
??????? dispatcher.getDispatchContext();

?

3:获取一个GenericValue对象的所有字段

?? GenericDelegator delegator =? DelegatorFactory.getDelegator("default");??
?? GenericValue tmp? = delegator.makeValue("UserLogin");
?? String entityName = tmp.getEntityName();
?? ModelEntity entity = delegator.getModelEntity(entityName);
???List fieldNameList = entity.getAllFieldNames();

?

4:----

?? ServiceDispatcher sd = ServiceDispatcher.getInstance(dispatcherName, delegator);

??? LocalDispatcher dispatcher = sd.getLocalDispatcher(dispatcherName);

??? dispatcher = new GenericDispatcher(dispatcherName, delegator, readerURLs, loader, sd);

??? DispatchContext dc = new DispatchContext(name, readerURLs, loader, null);

5:ofbiz URL

??? URL formFileUrl = FlexibleLocation.resolveLocation(resourceName);

??? resourceName:component://common/widget/LookupForms.xml

??? formFileUrl:file:/E:/workspace/cpsp20110819/framework/common/widget/LookupForms.xml

?

?

?Set<String> groupNames = getModelGroupReader().getGroupNames(delegatorBaseName);
??????? for (String groupName: groupNames) {
??????????? GenericHelperInfo helperInfo = this.getGroupHelperInfo(groupName);
??????????? String helperBaseName = helperInfo.getHelperBaseName();

??????????? if (Debug.infoOn()) Debug.logInfo("Delegator "" + delegatorFullName + "" initializing helper "" +
??????????????????? helperBaseName + "" for entity group "" + groupName + "".", module);
??????????? if (UtilValidate.isNotEmpty(helperInfo.getHelperFullName())) {
??????????????? // pre-load field type defs, the return value is ignored
??????????????? ModelFieldTypeReader.getModelFieldTypeReader(helperBaseName);
??????????????? // get the helper and if configured, do the datasource check
??????????????? GenericHelper helper = GenericHelperFactory.getHelper(helperInfo);

??????????????? DatasourceInfo datasourceInfo = EntityConfigUtil.getDatasourceInfo(helperBaseName);
??????????????? if (datasourceInfo.checkOnStart) {
??????????????????? if (Debug.infoOn()) Debug.logInfo("Doing database check as requested in entityengine.xml with addMissing=" + datasourceInfo.addMissingOnStart, module);
??????????????????? try {
??????????????????????? helper.checkDataSource(this.getModelEntityMapByGroup(groupName), null, datasourceInfo.addMissingOnStart);
??????????????????? } catch (GenericEntityException e) {
??????????????????????? Debug.logWarning(e, e.getMessage(), module);
??????????????????? }
??????????????? }
??????????? }
??????? }

6: 获取所有实体名称

????Set<String> entitys = delegator.getModelReader().getEntityNames();
????entityArr =? delegator.getModelReader().getEntityNames().toArray(new String[entitys.size()]);

7:清除实体缓存

??? Cache entityCache = delegator.getCache();

??? entityCache.remove(entityName);

?

8 : xml 中取${}值

??????? FlexibleStringExpander fse = FlexibleStringExpander.getInstance(expression);
??????? return fse.expandString(context, timeZone, locale);

?

9: xml 获取多个 不同节点

??????? Set<String> nameSet = UtilMisc.toSet("set", "action","log");
??? ??? for (Element actionOrSetElementOrLog : UtilXml.childElementList(eca, nameSet)) {

?

10 : String 类型xml? 与 Map 互相转换

??????? XmlSerializer.deserialize

??????? XmlSerializer.serialize

11:类型转化类的加载

Iterator<ConverterLoader> converterLoaders = ServiceLoader.load(ConverterLoader.class, loader).iterator();

热点排行