2

I need to write a code to invoke the 'transferControl' routine and to read the information off the Inbox.. What would me my code in java invoking the 'transferControl' method? pls help im new in 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"

    }                             
         }
1
  • It's nice to see comments. Some of them would be even better as doc comments. Commented Aug 10, 2015 at 3:40

3 Answers 3

2

Since the Method transferControl is static, you can call the method like below

WhatNext.transferControl(parameters);
Sign up to request clarification or add additional context in comments.

Comments

0

simply:

WhatNext.transferControl(all parameters);

Comments

0

There are possible ways to do that, I am presenting 2 ways of so:

Since transferControl method is static that mean this method is NOT shared among various object, JVM will treat as a Class level Object hence you can call this method directly i.e.

WhatNext.transferControl("requestId", "businessTransactionId",
        "transactionStepId", "selector", "requesterId"); // values are dummy.

In the second approach you can use reflection to invoke the method(not recommended) i.e..

        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);

3 Comments

she is new in java @Ankush
@PiyushMittal I agree, but if we provide the ways to do that it will be helpful for her and defiantly she will learn quickly.
Thank you so much everyone!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.