在我的 Xpages 应用程序中,我有一个 java 类,我想在其中将 Document 设置为全局属性并在我的方法中重用。该文档代表一个 Notes 配置文档,我只想执行一次查找。不幸的是,它没有按预期工作。也许有人可以指导我正确的过程?
首先,我设置了一个托管 bean:
<managed-bean>
<managed-bean-name>emplDataMining</managed-bean-name>
<managed-bean-class>se.bank.employeeApp.utils.EmployeeDataMining</managed-bean-class>
<managed-bean-scope>view</managed-bean-scope>
</managed-bean>
我的课程包含几种将转到不同系统的方法。系统的所有 URL 都存储在 Notes 配置文档中,我只想加载一次并在这些方法中重复使用
public class EmployeeDataMining implements Serializable{
private static final long serialVersionUID = 1L;
private Document configuration;
//constructor class. not so very special, so I wont post it
public void getConfiguration(){
//setting up database and view
//only 1 document stored in the view so I can hard-code the reference
configuration = vw.getDocumentByKey("ConfigDocument", true);
//... rest of code e.g. setting up httpclient, JSONobj
}
public void collectDataFromSystemX(CloseableHttpClient httpclient, Employee employee, JSONObject JSONobj){
//I wont post all of my code
HttpPost httpPost = new HttpPost(this.configuration.getItemValueString("urlSystemX"));
//this.configuration is null :-?
//..rest of code
}
public void collectDataFromSystemY(CloseableHttpClient httpclient, Employee employee, JSONObject JSONobj){
//I wont post all of my code
HttpPost httpPost = new HttpPost(this.configuration.getItemValueString("urlSystemY"));
//this.configuration is null :-?
//..rest of code
}
}
我的代码是从 SSJS 发起的:
emplDataMining.getConfiguration();
emplDataMining.collectDataFromSystemX(//passing in the variables which are setup in getConfiguration method)
所以我主要担心的是配置文件 Document 没有正确设置或在方法之间交换。
有人能告诉我我忽略了什么吗?
天涯尽头无女友
相关分类