How to get caller object reference from a method

Hi,
I am working a already existing Java Swing project, now I got a problem, in a method I need to get the caller object reference otherwise, I can't succeed this operation. So please tell me a way how to get the caller object reference from a method. that method would be static or regular method anything will do for me.
Edited by: navaneeth.j on Jan 29, 2010 11:20 PM

navaneeth.j wrote:
Actually my doubt is, I have a method "addition" method, which is using by many classes so my requirement is in the addition method I want to write a code snippet which will identify and get the the caller object. Actually I tried Reflection.getcallerclass but there I am getting "CLASS" object not the actual object reference, but I want object reference.
Actually we have a huge project which is writen plain JAVA, so in this project the authors written the Database connection package for single database transaction. so now we are using this project source code for JSF application in this web application the DB package has serve based on the dynamic db connection parameters, so if we want to change this package fully means need to solve the dependency problem in hundreds of classes, so my point is if I can access the caller object in the DB package when ever it gets called by any class from any where of the project. So actually I liked Reflection.getcallerclass, the way of implementation perfectly works for me but it is not giving caller object reference, if something gives the caller object then I can get the DB connection parameters then there is no need to pass the parameters in the hierarchy.You can add a parameter (of type Object) to your addition() method
and everywhere you call the addition() method also pass this (which from the POW of the addition() method will be a reference to the calling class instance).
There may be alternative solutions
but none that require less effort.

Similar Messages

  • Line Chart: It is possible to get the object reference from a flash chart

    Hi Folks,
    hope you feel well ...
    I wan't to get the Object Reference from a Chart Flash Object using javascript in the HTML Header of a Apex Page.
    It's long time ago with Oracle/Java and so my skills are really shity :-)
    The Functionbody works, but the following error occurs: chart.refresh is not a function
    It is necessary to CAST it ? with the Class AnyChart.js ?
    After 5 hours i give up ^^ is this kind of object handling possible ? THX4HELP@ll
    Apex Page HTML Header
    <script type="text/javascript">
    function hideSID2()
    var chart = document.getElementById("*c7067437546726610*");
    chart.refresh();
    </script>
    HTML File at runtime:
    <div class="rc-body"><div class="rc-body-r"><div class="rc-content-main"><object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
    codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0"
    width="1400"
    height="600"
    id="c7067437546726610"
    align="top"> ...

    If you are using adobe Flex Builder to develop SWF, please be sure using ExternalInterface class to expose the refresh() method.
    then you can should be able to call this method in Javascript.

  • How do I get an activeX object reference from a LabVIEW ActiveXContainer ref?

    How do I get an activeX object reference from a LabVIEW ActiveXContainer ref?
    I'm trying to control an ActiveX object (a Web Browser) from another VI and need to get the object reference programmatically. I can get the LabVIEW ActiveXContainer reference, but am lost on how to get the reference for the object _inside_ the container.

    Hi Lee,
    The reference to the container is actually also accessing the object inside the container. Use the Property Node and Invoke Node to access properties and launch methods for the object. I've attached a small example that passes the reference to a SubVI and invokes a method inside the SubVI.
    - Philip Courtois, Thinkbot Solutions
    Attachments:
    WebContainer.zip ‏21 KB

  • How to get the form reference in .js page from .jsp page

    hi
    i have written one form in jsp page omething like:-
    <html:form action="/shopping" onsubmit="return false;">
    can anybody tell me,how to get the form reference in .js page from .jsp page ,
    i have tried:-
    var formRef = document.forms[0];
    butits not working.
    Thanks.

    Its very simple......y cant u prefer google...Bad
    c this example...
    function submit()
    alert("textbox"+ document.forms[0].name.value);//to get textbox value in js
    document.forms[0].submit();//to submit jsp page using js
    <html:html>
    <html:form action="/shopping" onsubmit="submit()">
    <html:text property=name>
    learn to search in google..
    </html:form>
    </html:html>

  • How to get File  object from Document Object . ?

    In conventional Dom Parsing we pass file to DocumentBuilder to get Document Object .
      File file = new File("c:\\MyXMLFile.xml");
      DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
      DocumentBuilder db = dbf.newDocumentBuilder();
      Document doc = db.parse(file); // gOT Document here . My problem is how do i get File object back from Document . If i have Document object with mi.
    Please consider above code as example i dont have File object in my code . i am using Xhive DB API where i get Document directly from API method .
    I need to convert this Document to File to get size of file
    Please suggest solution on this
    Edited by: AmitChalwade123456 on Dec 5, 2008 6:10 AM

    Hello Guys any views on this topic

  • How to get POF object's field value from query result

    hi,all:
    I want to get field value from the query result, my code is below
    Set setResults = cache.entrySet(createFilter("homeAddress.state = 'MA'"));
    for (Iterator iter = setResults.iterator(); iter.hasNext(); )
    Contact c=(Contact)iter.next();
    System.out.println ("firstame####=" + c.getFirstName());
    * but I get error*
    Exception in thread "main" java.lang.ClassCastException: com.tangosol.util.ConverterCollec
    tions$ConverterEntrySet$ConverterEntry cannot be cast to com.oracle.handson.Contact
    at com.oracle.handson.QueryExample.printResults(QueryExample.java:159)
    at com.oracle.handson.QueryExample.query(QueryExample.java:86)
    at com.oracle.handson.QueryExample.main(QueryExample.java:43)
    who can tell me how to get POF object's field value from query result

    Hi,
    If you look at the Java Doc for the entrySet method here http://download.oracle.com/docs/cd/E15357_01/coh.360/e15725/com/tangosol/util/QueryMap.html#entrySet_com_tangosol_util_Filter_ you will see that it returns a Set of Map.Entry instances so you need to do this...
    Set setResults = cache.entrySet(createFilter("homeAddress.state = 'MA'"));
    for (Iterator iter = setResults.iterator(); iter.hasNext(); )
        Map.Entry entry = iter.next();
        Contact c=(Contact)entry.getValue();
        System.out.println ("firstame####=" + c.getFirstName());
    }JK

  • How To get getServletContext() object inside JSP from  Eclipse  IDE

    Dear friends,
    I can access methods in getServletContext class from Netbeans in my JSP web project using the following steps.
    String path=getServletContext().getRealPath("\mypath");
    . But In Eclipse when i try to build,it says that "can not find method -getServletContext()".
    How to get this object in my JSP Scriptlet From Eclipse IDE? Plz help me?

    use Expression Language instead.
    I would.
    http://java.sun.com/j2ee/1.4/docs/tutorial/doc/JSPIntro7.html
    regards,i

  • How to get the date starting from 1 to the current date from the system dat

    Dear all,
    Please tell me how to get the date starting from 1 based on the system date
    and it should come with respect of time also.
    example.
    suppose today is 6 Dec, 2006
    so ABAP report should find the 1 dec. 2006.
    Please help me as soon as possible.
    Regards,

    concatenate sy-datum0(2) '01' sy-datum4(4) into v_firstdate.
    or yo ucan use the fm:
    HR_JP_MONTH_BEGIN_END_DATE
    usage:
        call function 'HR_JP_MONTH_BEGIN_END_DATE'
             exporting
                  iv_date             = sy-datum
             importing
                  ev_month_begin_date = gv_begda
                  ev_month_end_date   = gv_endda.
    Regards,
    Ravi
    Message was edited by:
            Ravi Kanth Talagana

  • How to get auto proxy configuration from plugin?

    I need to retrieve the name of the client's proxy server to pass it along to my signed applet (because it doesn't seem to be getting the information automatically despite the fact that the java plugin is set to the use the browser settings for proxies).
    The Java Plugin loads the proxy server information based on the browser preferences, but I haven't figured out how to retrieve that proxy information from the Plugin itself. Sometimes the javaplugin.proxy.auto.url system property is null, even if the browser (MSIE) is configured to use an auto-configuration script/url for the proxy server configuration. I can see in the Java Console that the plugin knows the auto-config url, so how can I access that property from within my applet?
    Even if javaplugin.proxy.auto.url is not null, I don't know how to call the javascript function at that URL from within the applet to get the proxy server host name and port.
    Does anyone know how to get the proxy information from the plugin?

    Thank you! Indeed, the answer was there, but I hadn't been able to find it earlier (I guess I was searching on the wrong forums). For those who might be interested, here's the thread that helped:
    http://forum.java.sun.com/thread.jsp?forum=30&thread=281981

  • How can i use class reference from an array effeciently?

    Hi,
    I made some test here with getting a class reference from an array and using the reference's methods or variables.
    Basically arrayEx is a container of type Array and it contains the Person's class instance in it. Num is a number extracted from the Person's instance
    Example #1----Strongly typed
    Var reference:Person;
    Var num:int;
    //Assignation
    reference=arrayEx[0];-----IT IS SLOW HERE
    //Use
    num=reference.number --- IT IS FAST HERE
    Example #2---Not typed
    Var reference:*;
    Var num:int;
    //Assignation
    reference=arrayEx[0]; ---- IT IS FAST HERE
    //Use
    num=reference.number ---IT IS SLOW HERE
    No matter what i change in both code like casting Person on arrayEx, i cant seem to make them work both fast at the same time
    If someone knows how, please tell me,
    Dominik

    Hi,
    I made some test here with getting a class reference from an array and using the reference's methods or variables.
    Basically arrayEx is a container of type Array and it contains the Person's class instance in it. Num is a number extracted from the Person's instance
    Example #1----Strongly typed
    Var reference:Person;
    Var num:int;
    //Assignation
    reference=arrayEx[0];-----IT IS SLOW HERE
    //Use
    num=reference.number --- IT IS FAST HERE
    Example #2---Not typed
    Var reference:*;
    Var num:int;
    //Assignation
    reference=arrayEx[0]; ---- IT IS FAST HERE
    //Use
    num=reference.number ---IT IS SLOW HERE
    No matter what i change in both code like casting Person on arrayEx, i cant seem to make them work both fast at the same time
    If someone knows how, please tell me,
    Dominik

  • How to get Request object and LDAP user

    Hi All,
    How to get Request object, coz i want to see the out put of this code
    IUser myUser = request.getUser();
    String uid=myUser.getUid();
    I want to get only LDAP user from the server, for that i am having  code but i think this code is returning me all user from the server.
    com.sap.security.api.IUser user = null;
    try {
          IUserFactory userFactory = UMFactory.getUserFactory();
         IUserSearchFilter searchFilter = userFactory.getUserSearchFilter();
    ISearchResult searchResult = userFactory.searchUsers(searchFilter);
       int count = 0;
        List list = new ArrayList();
         while (searchResult.hasNext()) {
                      count++;
                       String uniqueid = (String) searchResult.next();
                        user = userFactory.getUser(uniqueid);
                        list.add(user.getUniqueName());
    This code is giving me all user from the server LDAP and as well as portal user.
    But i want only LDAP.
    Please help me out. It's urgent.
    Regards,
    Deepak

    Hi
    use the following code
    //Request
    IWDRequest = WDProtocolAdapter.getProtocolAdapter().getRequestObject();
    //User
    IWDClientUser = WDClientUser.getCurrentUser();
    Regards
    Ayyapparaj

  • How can I Call the MainVI from its SubVI, and this happen recursively?

    Hi All,
    How can I Call the MainVI from its SubVI, and this happen recursively?
    Actually, LAbView 7.1 doesn't support recurssion?
    Plz help me out!

    Dear GerdW,
    Thanks a lot 2 all of u guys,for all the brilliant responses.
    Actually, my basic aim is to call the Main VI, containing a SubVI.....
    Now, I want to call my main VI from this SubVI...recursively!!!!!..but whenever I tried to put the MainVI in this SubVI..an error message pops out saying recursive calling is not possible.
    I also tried using "Call by reference" but tht also didn't worked...an d error is somewat like...VI is invalid..or type matching..or state matching error.
    Here, Im attaching the snapshot of the MainVI... Im calling the SUBvi from it... It is running GOOD n FINE...
    But prob arrives when I call the Main from the SUBvi, which looks like same as MainVI(with little differences).
    I hope, Im clear in my words n not being ambigous.
    Plz, correct me where ever  im wrong.
    Thank You.
    Mishra_RnD
    Attachments:
    ScrShot.JPG ‏272 KB

  • How advantages of "Call By Reference" can be implemented using Java

    As I know that java doesnot support "Call By Reference" as C++
    does.
    I want to know that how advantages of Call by Reference can be
    implemented using Java.

    There is some misunderstanding here. Method arguments in Java are passed by value. However, if you pass a reference (to an object) by value, you can still modify the object that the (copy of the) reference points to.
    public void method1() {
      StringBuffer buf = new StringBuffer();
      // Here, method2 cannot change the value of the variable buf,
      // but it can modify the object that buf points to.
      method2(buf);
    public void method2(StringBuffer sb) {
      // You can modify the StringBuffer.
      sb.append("hello");
      // But this is useless, it will not change the variable buf
      // in the calling method.
      sb = new StringBuffer();
    }Jesper

  • How to get all the values from the dropdown menu

    How to get all the values from the dropdown menu
    I need to be able to extract all values from the dropdown menu; I know how to get all those values as a string, but I need to be able to access each item; (the value in a dropdown menu will change dynamically)
    How do I get number of item is selection dropdown?
    How do I extract a ?name? for each value, one by one?
    How do I change a selection by referring to particular index of the item in a dropdown menu?
    Here is the Path to dropdown menu that I'm trying to access (form contains number of similar dropdowns)
    RSWApp.om.GetElementByPath "window(index=0).form(id=""aspnetForm"" | action=""advancedsearch.aspx"" | index=0).formelement[SELECT](name=""ctl00$MainContent$hardwareBrand"" | id=""ctl00_MainContent_hardwareBrand"" | index=16)", element
    Message was edited by: testtest

    The findElement method allows various attributes to be used to search. Take the following two examples for the element below:
    <Select Name=ProdType ID=testProd>
    </Select>
    I can find the element based on its name or any other attribute, I just need to specify what I am looking for. To find it by name I would do the following:
    Set x = RSWApp.om.FindElement("ProdType","SELECT","Name")
    If I want to search by id I could do the following:
    Set x = RSWApp.om.FindElement("testProd","SELECT","ID")
    Usually you will use whatever is available. Since the select element has no name or ID on the Empirix home page, I used the onChange attribute. You can use any attribute as long as you specify which one you are using (last argument in these examples)
    You can use the FindElement to grab links, text boxes, etc.
    The next example grabs from a link on a page
    Home
    Set x = RSWApp.om.FindElement("Home","A","innerText")
    I hope this helps clear it up.

  • How to get the return values from a web page

    Hi all :
       how to get the return values from a web page ?  I mean how pass values betwen webflow and web page ?
    thank you very much
    Edited by: jingying Sony on Apr 15, 2010 6:15 AM
    Edited by: jingying Sony on Apr 15, 2010 6:18 AM

    Hi,
    What kind of web page do you have? Do you have possibility to for example make RFCs? Then you could trigger events (with parameters that could "return" the values) and the workflow could react to those events. For example your task can have terminating events.
    Regards,
    Karri

Maybe you are looking for

  • Cash Management - Bank Statement Open Interface

    Bank Statement Open Interface (The tables are ce_statement_headers_int_all and ce_statement_lines_interface) I am trying to load the bank statements with Journal Lines and trying to reconcile them using Autoreconcilation but I am getting error. ( I a

  • Error Message When Opening Interactive Demand Planning

    Hello Experts, I have one user who is receiving the following error message when trying to open Interactive Demand Planning Workbook.  Only one user is experiencing this issue.  Has anyone run into this before?  GP: Graphics product not available in

  • Dual boot machine- snow leopard and Lion

    It appears I will need to set up one of my machines as dual boot, containing partitions for Snow Leopard and Lion. The reason is that Quicken is NOT compatible with Lion, and will apparently never be. Intuits "solutions" are to go to other, far less

  • How to execute  the CONNECT command in sql

    Hi , I am using DB2 database and I need to execute the sql statement CONNECT TO Database user username USING password. Can anyone tell me how to execute this query in java. I tried this by using executeQuery but it was giving a sexception somtehing a

  • Strange Problem while deploying BPEL processes by ANT Script.

    Hi, Ant script is working fine in Dev environment but is failing in the other environment. Somehow the BPEL server is not able to pick the latest deployed process , due to this the dependent BPEL processes are failing. If we restart the server , it m