我需要编写一个代码来调用'transferControl'例程并从收件箱中读取信息。我在java中调用'transferControl'方法的代码是什么?请帮助我新的java
public class WhatNext
{
//
// this method is invoked by the business logic to determine the
// NextStep and set it in the receipient's Inbox. There is a suggested
// InBox layout design in this code
//
public static void transferControl ( String requestId,
String businessTransactionId,
String transactionStepId,
String selector,
String requesterId)
{
InStorDB theDB = new InStorDB(); // "connect" to the DB
NextStep next = theDB.getNextStep(businessTransactionId,
transactionStepId,
selector);
//
// these 'columns' provide information on the next step to be taken
//
String nextTranId = next.nextBusinessTransactionId;
String nextStepId = next.nextBusinessStepId;
//
// which is then used to obtain the next initiation environment
//
CurrentStep current = theDB.getCurrentStep(nextTranId,
nextStepId);
//
// then used to set up the InBox fields of the recepient
// "to be coded"
//
// and stored in Inbox database
// "to be coded"
}
}
答案 0 :(得分:2)
由于Method transferControl是静态的,您可以调用下面的方法
WhatNext.transferControl(parameters);
答案 1 :(得分:0)
简单地:
WhatNext.transferControl(all parameters);
答案 2 :(得分:0)
有可能的方法,我提出两种方式:
由于transferControl方法是静态的,意味着此方法不在各种对象之间共享,因此JVM将视为类级别对象,因此您可以直接调用此方法,即
WhatNext.transferControl("requestId", "businessTransactionId",
"transactionStepId", "selector", "requesterId"); // values are dummy.
在第二种方法中,您可以使用反射invoke
方法(不推荐),即..
Class[] paramTypes = new Class[5];
paramTypes[0] = String.class;
paramTypes[1] = String.class;
paramTypes[2] = String.class;
paramTypes[3] = String.class;
paramTypes[4] = String.class;
Class<?> c = Class.forName("com.ankush.WhatNext");
Method methodCall = c.getDeclaredMethod("transferControl", paramTypes);
Object[] obj = {"requestId", "businessTransactionId",
"transactionStepId", "selector", "requesterId"};// values are dummy.
methodCall.invoke(null, obj);