use of org.apache.ofbiz.minilang.artifact.ArtifactInfoContext in project ofbiz-framework by apache.
the class SimpleMethod method getAllEntityNamesUsed.
@Deprecated
public Set<String> getAllEntityNamesUsed() throws MiniLangException {
ArtifactInfoContext aic = new ArtifactInfoContext();
gatherArtifactInfo(aic);
return aic.getEntityNames();
}
use of org.apache.ofbiz.minilang.artifact.ArtifactInfoContext in project ofbiz-framework by apache.
the class SimpleMethod method getAllServiceNamesCalled.
@Deprecated
public Set<String> getAllServiceNamesCalled() throws MiniLangException {
ArtifactInfoContext aic = new ArtifactInfoContext();
gatherArtifactInfo(aic);
return aic.getServiceNames();
}
use of org.apache.ofbiz.minilang.artifact.ArtifactInfoContext in project ofbiz-framework by apache.
the class ServiceArtifactInfo method populateUsedEntities.
protected void populateUsedEntities() throws GeneralException {
// populate entitiesUsedByThisService and for each the reverse-associate cache in the aif
if ("simple".equals(this.modelService.engineName)) {
// we can do something with this!
SimpleMethod simpleMethodToCall = null;
try {
simpleMethodToCall = SimpleMethod.getSimpleMethod(this.modelService.location, this.modelService.invoke, null);
} catch (MiniLangException e) {
Debug.logWarning("Error getting Simple-method [" + this.modelService.invoke + "] in [" + this.modelService.location + "] referenced in service [" + this.modelService.name + "]: " + e.toString(), module);
}
if (simpleMethodToCall == null) {
Debug.logWarning("Simple-method [" + this.modelService.invoke + "] in [" + this.modelService.location + "] referenced in service [" + this.modelService.name + "] not found", module);
return;
}
ArtifactInfoContext aic = new ArtifactInfoContext();
simpleMethodToCall.gatherArtifactInfo(aic);
populateEntitiesFromNameSet(aic.getEntityNames());
} else if ("java".equals(this.modelService.engineName)) {
String fullClassPathAndFile = UtilJavaParse.findRealPathAndFileForClass(this.modelService.location);
if (fullClassPathAndFile != null) {
String javaFile = null;
try {
javaFile = FileUtil.readTextFile(fullClassPathAndFile, true).toString();
} catch (FileNotFoundException e) {
Debug.logWarning("Error reading java file [" + fullClassPathAndFile + "] for service implementation: " + e.toString(), module);
return;
} catch (IOException e) {
Debug.logWarning("Error reading java file [" + fullClassPathAndFile + "] for service implementation: " + e.toString(), module);
return;
}
javaFile = UtilJavaParse.stripComments(javaFile);
int methodBlockStart = UtilJavaParse.findServiceMethodBlockStart(this.modelService.invoke, javaFile);
int methodBlockEnd = UtilJavaParse.findEndOfBlock(methodBlockStart, javaFile);
Set<String> allEntityNameSet = UtilJavaParse.findEntityUseInBlock(methodBlockStart, methodBlockEnd, javaFile);
populateEntitiesFromNameSet(allEntityNameSet);
}
} else if ("group".equals(this.modelService.engineName)) {
// nothing to do, there won't be entities referred to in these
}
}
use of org.apache.ofbiz.minilang.artifact.ArtifactInfoContext in project ofbiz-framework by apache.
the class ServiceArtifactInfo method populateCalledServices.
protected void populateCalledServices() throws GeneralException {
// populate servicesCalledByThisService and for each the reverse-associate cache in the aif
if ("simple".equals(this.modelService.engineName)) {
// we can do something with this!
SimpleMethod simpleMethodToCall = null;
try {
simpleMethodToCall = SimpleMethod.getSimpleMethod(this.modelService.location, this.modelService.invoke, null);
} catch (MiniLangException e) {
Debug.logWarning("Error getting Simple-method [" + this.modelService.invoke + "] in [" + this.modelService.location + "] referenced in service [" + this.modelService.name + "]: " + e.toString(), module);
}
if (simpleMethodToCall == null) {
Debug.logWarning("Simple-method [" + this.modelService.invoke + "] in [" + this.modelService.location + "] referenced in service [" + this.modelService.name + "] not found", module);
return;
}
ArtifactInfoContext aic = new ArtifactInfoContext();
simpleMethodToCall.gatherArtifactInfo(aic);
populateServicesFromNameSet(aic.getServiceNames());
} else if ("java".equals(this.modelService.engineName)) {
String fullClassPathAndFile = UtilJavaParse.findRealPathAndFileForClass(this.modelService.location);
if (fullClassPathAndFile != null) {
String javaFile = null;
try {
javaFile = FileUtil.readTextFile(fullClassPathAndFile, true).toString();
} catch (FileNotFoundException e) {
Debug.logWarning("Error reading java file [" + fullClassPathAndFile + "] for service implementation: " + e.toString(), module);
return;
} catch (IOException e) {
Debug.logWarning("Error reading java file [" + fullClassPathAndFile + "] for service implementation: " + e.toString(), module);
return;
}
javaFile = UtilJavaParse.stripComments(javaFile);
int methodBlockStart = UtilJavaParse.findServiceMethodBlockStart(this.modelService.invoke, javaFile);
int methodBlockEnd = UtilJavaParse.findEndOfBlock(methodBlockStart, javaFile);
Set<String> allServiceNameSet = UtilJavaParse.findServiceCallsInBlock(methodBlockStart, methodBlockEnd, javaFile);
populateServicesFromNameSet(allServiceNameSet);
}
} else if ("group".equals(this.modelService.engineName)) {
Set<String> allServiceNameSet = new HashSet<String>();
GroupModel groupModel = modelService.internalGroup;
if (groupModel == null) {
groupModel = ServiceGroupReader.getGroupModel(this.modelService.location);
}
if (groupModel != null) {
List<GroupServiceModel> groupServiceModels = groupModel.getServices();
for (GroupServiceModel groupServiceModel : groupServiceModels) {
allServiceNameSet.add(groupServiceModel.getName());
}
}
populateServicesFromNameSet(allServiceNameSet);
}
}
Aggregations