How to get Refrence of the calling Object in the called method

Is there any way to achive below without having explicitly passing or storing a's refrence.??
class A {
public void run(){
B b= new B();
b.doStuff();
public static void main(String [] args){
A a = new A();
a.run();
class B {
public void doStuff(){
/* ??????????? Is it possible to get Instance of A, a's refrence without changing doStuff() signature */
If not, how does the following join() method of Thread gets the refrence of the Instance of Calling Instance(t1 & t2) , so as to attach the calling Thread at the end of called Thread(t) ??
class TestThread extends Thread{
public void run(){
for (int i=0; i < 10; i++)
     System.out.println("Iteration:"+i+" of TestThread");
class A extends Thread{
Thread t;
public A(Thread t){
this.t=t;
public void run(){
try {
t.join();
}catch (InterruptedException e){}
for (int i=0; i < 10; i++)
     System.out.println("Iteration:"+i+" of A Instance"+this);
public class Main{
public static void main(String [] args) {
TestThread t = new TestThread();
A t1 = new A(t);
A t2 = new A(t);
t1.start();
t2.start();
t.start();
}

Reposting with markup.
class A {
    public void run(){
        B b= new B();
        b.doStuff();
    public static void main(String [] args){
        A a = new A();
        a.run();
class B {
    public void doStuff(){
         * ??????????? Is it possible to get Instance of A, a's
         * refrence without changing doStuff() signature
}If not, how does the following join() method of Thread gets the refrence of the Instance of Calling Instance(t1 & t2) , so as to attach the calling Thread at the end of called Thread(t) ??
class TestThread extends Thread{
    public void run(){
        for (int i=0; i < 10; i++) System.out.println("Iteration:"i" of TestThread");
class A extends Thread{
    Thread t;
    public A(Thread t){
        this.t=t;
    public void run(){
        try {
            t.join();
        }catch (InterruptedException e){}
        for (int i=0; i < 10; i++) System.out.println("Iteration:"i" of A Instance"+this);
public class Main{
    public static void main(String [] args) {
        TestThread t = new TestThread();
        A t1 = new A(t);
        A t2 = new A(t);
        t1.start();
        t2.start();
        t.start();
}

Similar Messages

  • 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.

  • How to pass the java object into the spring controller

    Hi Friends
    When I hit the url at the first time my call goes to the spring controller and sets the userDetails objects in the modelAndView.addObject("userDetails", userDetails.getUserDetails()) and returns the userDetails.html page. if I click any link in the same page i want to pass same (userDetails) object thru javascript or jquery and calls the another(controller) method and returns the same (userDetails.html) page.
    It means how can i pass the java object thru javascript or jquery and calls the controller. if i get the same object in my controller i can avoid calling the db again. please help me out to resolve this issue. i am tired of fixing this issue.
    Regards
    Sherin Pooja

    If you want to avoid calling the database again then cache the data.
    However before you do that make sure that calling the database, in the context of YOUR system, is going to be an actual problem.
    For example there is absolutely no point in caching a  User object when only one user an hour is actually using the system.

  • Getting the Request Object in the EJB published as a Web Service

    Hi experts,
    I have a Portal Service that call a BAPI in a back-end system with the Connector Framework. I have a Portal Component that calls the Portal Service, passing the Locale (request.getLocale()) and the User (request.getUser()) object. It's work fine!
    I need to call the Portal Service by an EJB that is published as a Web Service. The connection between the EJB and Portal Service is ok, but I don't know how to get the Locale and the User object in the EJB to pass to the Portal Service.
    Is possible to get the request object from the HTTP SOAP Request?
    Thanks,
    Gustavo

    Hey Alice!
    The Feature Hashing module is actually a wrapper around
    Vowpal Wabbit's implementation of the murmurhash. Thus, it takes text in, and produces 2^N new features based on the text, where N is the bitsize specified in the module. These features (and not the original text!) should be used during model training.
    The Learner will then keep track of these features behind the scenes.
    When you publish your web service and these features are recomputed for new input text (same N), they are used as the features for scoring.
    Does that make sense?
    Regards,
    AK

  • How to get list of modified repository objects in SPAU

    Hi,
    While applying Support pack for HR (SAP ERP 6.0) I get SPAU prompt with message:
    "The system detected that 10 of the repository objects in the Support Packages have been modified in
    your system . Check whether you want to retain or restore these changes you have made. Fore more
    info about performing modification adjustment see modification adjustment help..."
    Now as I call SPAU i get the screen with following options:
    Correction in SAP Note
    With modification Assistant
    Without  modification Assistant
    etc..
    Can someone guide me How to get list of modified repository objects in SPAU.
    Thanks & Regards
    Vishal

    Hi,
    In SPAU you will get with modification assistence. just expand the subtree, and follw standard process .
    This is to retain the enhancement. If there are any data dictionary related correction go to SPDD.
    Regards
    Rahul

  • How to get Date Format from Local Object.

    Hi All,
    I am new to Web Channel.
    I need to know Date format From date of locale.
    suppose there is a date "01/25/2010" date in date field I want to get string "mm/dd/yyyy". Actually I have to pass date format to backend when I call RFC. 
    Is there any way to get Date format from "Locale" object. I should get date format for local object
    I get local object from "UserSessionData" object but how to get Date format from it.
    I am not looking for Date value. I am looking for current local date format ("mm/dd/yyyy or dd/mm/yyyy or mon/dd/yyyy) whatever local date format.  I could not find example which show how to get date format from "Locale" object.
    Any help will be appreciated with rewards.
    Regards.
    Web Channel

    Hi,
    You can get it from "User" or "Shop" business object.
    Try to get User or Shop Business Object as shown below.
    BusinessObjectManager bom = (BusinessObjectManager) userSessionData.getBOM(BusinessObjectManager.ISACORE_BOM);
    User user = bom.getUser();
    char decimalNotation = user.getDecimalPointFormat().getGroupingSeparator();
    If you are seeing "1,234.00" then above code will return "."
    I hope this information help you to resolve your issue.
    eCommerce Developer.

  • How to get structure of IDOC into xi in the scenario is IDOC - XI - File

    hi XI Guys,
          When i want to Integrate SAP sys(IDOC) with File how to get structure of IDOC into XI, As we will define Data types in File -> XI -> File. Please send Step by Step process as i am new to Netweaver(XI)
    ThankYou,
    B.Pushparaju.

    When i want to Integrate SAP sys(IDOC) with File how to get structure of IDOC into XI
    >>>>
    import the IDoc under the imported object in your SCV. Note that import should be allowed for the SCV.
    As we will define Data types in File -> XI -> File.
    >>>>
    Ref. these blogs to help you out ..
    /people/venkat.donela/blog/2005/03/02/introduction-to-simplefile-xi-filescenario-and-complete-walk-through-for-starterspart1
    /people/venkat.donela/blog/2005/03/03/introduction-to-simple-file-xi-filescenario-and-complete-walk-through-for-starterspart2

  • How do I embed a pdf document into an existing pdf so that the user double clicks on the pdf object within the pdf and it opens? i've looked everywhere on various forums and tried attachments - but still not working. Thanks

    I've tried various methods but to no avail. I have a pdf document and within the pdf I'd like to embed a couple pdf documents so that all the user has to do is double click on the pdf object inside the pdf and it opens in a new window. I've tried using attachments to do it and linking it...but to no avail. Anyone know how to do? I'm using Acrobat Pro Version 11. Thanks

    The "embed" feature common to MS Office applications is not applicable to PDF (for the why and wherefore of PDF get comfortable and read the ISO Standard for PDF - ISO 32000-1:2008).
    You can insert other PDF files' pages into any given PDF.
    You can attach files of supported formats to a PDF (of course a PDF is supported).
    You cannot "embed". So, nothing is broken.
    Be well...

  • [JS][CS3]how to get refrence for source file

    Hi All
    I am new and learning javascript Gradually Could any one help on this as i do have a code for load style but don't know how to get refrence for "source file" and "targetDoc"
    targetDoc.importStyles(charImport, sourceFile, clashPolicy);
    targetDoc.importStyles(paraImport, sourceFile, clashPolicy);
    Can any one figure it out
    Many Thanks

    I'm not sure what you are trying to achieve, could you please elaborate?
    Do you want to load all the styles from one document into all 100 documents, or do you want all the styles from the 100 documents into 1 document or what is the goal?
    The following will let you choose a folder of files, open each of the files in it and import the styles from source document. It is not a complete script, make sure to test and modify before running on anything else than test files :-)
    var MyFolderWithFiles = Folder.selectDialog ("Choose a folder");
    var sourceFile = File.openDialog("Choose the styles source");
    var myFiles = MyFolderWithFiles.getFiles("*.indd");
    for(i = 0; i < myFiles.length; i++) {
        theFile = myFiles[i];
        app.scriptPreferences.userInteractionLevel = UserInteractionLevels.NEVER_INTERACT;
        var targetDoc = app.open(theFile, true);
        app.scriptPreferences.userInteractionLevel = UserInteractionLevels.INTERACT_WITH_ALL;
        targetDoc.importStyles(ImportFormat.CHARACTER_STYLES_FORMAT, sourceFile, GlobalClashResolutionStrategy.LOAD_ALL_WITH_OVERWRITE);
        targetDoc.importStyles(ImportFormat.PARAGRAPH_STYLES_FORMAT, sourceFile, GlobalClashResolutionStrategy.LOAD_ALL_WITH_OVERWRITE);
        targetDoc.close(SaveOptions.YES);
    Thomas B. Nielsen
    http://www.lund-co.dk

  • How to get absolute path of a form within the Forms

    Aslam o Alikum (Hi)
    How to get absolute path of a form within the Forms 6i or 9i
    For example
    i am running a from "abc.fmx" from C:\myfolder directory
    can i get the form path 'C:\myfolder' by calling any any function from "abc.fmb"

    There is no direct call that will always work. What you need to do is call get_application_property(current_form). This may have the full path in it, depending on if that path was defined when the form was launched. If there is no path, then you need to use TOOL_ENV.GETVAR to read the Forms<nn>PATH and the ORACLEPATH, parse those out into individual directories and then check for the FMX in each.
    I already have some code to do all this for you see:
    http://www.groundside.com/blog/content/DuncanMills/Oracle+Forms/?permalink=4A389E73AE26506826E9BED9155D2097.txt

  • How to set Where clause in the View Object of the MessageChoice ?

    Hi,
    How to set Where clause in the View Object of the
    MessageChoice ?
    Example:
    <bc4j:rootAppModuleDef name="EdEscolaCampusView1AppModule"
    definition="ed00050.Ed00050Module"
    releaseMode="stateful" >
    <bc4j:viewObjectDef name="EdEscolaCampusView1" >
    <bc4j:rowDef name="CreateEdEscolaCampusView1" autoCreate="true" >
    <bc4j:propertyKey name="key" />
    </bc4j:rowDef>
    </bc4j:viewObjectDef>
    <bc4j:viewObjectDef name="ListaTipLocalView1"
    rangeSize="9999">
    </bc4j:viewObjectDef>
    </bc4j:rootAppModuleDef>
    </bc4j:registryDef>
    messageChoice declaration:
    <bc4j:messageChoice name="SeqTipoLocalCampus"
    attrName="SeqTipoLocalCampus"
    prompt="Local do Campus">
    <contents>
    <bc4j:optionList attrName="SeqTipoBasico"
    textAttrName="NomTipoBasico"
    voName="ListaTipLocalView1"/>
    </contents>
    </bc4j:messageChoice>
    I would like set where clause of ViewObject, with dinamic parameters (using attribute1 = :1), before populate messageChoice.
    thanks...
    Danilo

    Hi Andy,
    I try set a where clause using the message:
    Set where Clause parameter using UIX , but my UIX Page have 2 messageChoice's of different ViewObject's, then I need implement this Java Class:
    //Nome da Package da Tela Detail
    package br.com.siadem.siaed.ed00050;
    // Importa as Bibliotecas necessárias
    import oracle.jbo.ViewObject;
    import oracle.jbo.ApplicationModule;
    import oracle.jbo.client.Configuration;
    import oracle.cabo.servlet.BajaContext;
    import oracle.cabo.servlet.Page;
    import oracle.cabo.servlet.event.PageEvent;
    import oracle.cabo.servlet.event.EventResult;
    import oracle.cabo.data.jbo.servlet.bind.*;
    import oracle.cabo.ui.data.BoundValue;
    import oracle.cabo.ui.data.DataBoundValue;
    import javax.servlet.http.HttpServletRequest;
    import br.com.siadem.siaed.util.*;
    import javax.servlet.http.Cookie;
    import oracle.cabo.data.jbo.def.NestedAppModuleDef;
    import oracle.cabo.data.jbo.def.ViewObjectDef;
    import oracle.cabo.data.jbo.def.AppModuleDef;
    // Classe que configura os parametros para a execução da Query,
    // utilizando variáveis de Sessao
    public class FunPreQueryLista
    public static EventResult FunConfiguraQuery(BajaContext context, Page page, PageEvent event) throws Throwable
    // TrataDadosSessao - Classe utilizada para retornar os valores das variáveis de sessão genéricas
    // Ex: CodCliente, CodMunicipio etc...
    TrataDadosSessao varDadosSessao = new TrataDadosSessao();
    // 1o. Parametro Configurado - Através da classe TrataDadosSessao, utilizando um método Get
    // <alterar>
    String valor1 = varDadosSessao.getCodCliente();
    String valor2 = varDadosSessao.getCodMunicipio();
    //Cria o objeto que retorna o ApplicationModule
    ApplicationModule am = ServletBindingUtils.getApplicationModule(context);
    // Início das Configurações da Query da Lista
    //Cria o objeto que retorna o view object da lista desejada
    //alterar
    ViewObject TipoLocal = am.findViewObject("ListaTipoLocalView1");
    //Configuração dos parametros definidos na query do view Object
    //alterar
    TipoLocal.setWhereClauseParam(0,valor1);
    TipoLocal.setWhereClauseParam(1,valor2);
    // Executa a Query
    TipoLocal.executeQuery();
    // Fim das Configurações da Query da Lista
    // Início das Configurações da Query da Lista
    //Cria o objeto que retorna o view object da lista desejada
    //alterar
    ViewObject TipoDestLixo = am.findViewObject("ListaDestinoLixoView1");
    //Configuração dos parametros definidos na query do view Object
    //alterar
    TipoDestLixo.setWhereClauseParam(0,valor1);
    TipoDestLixo.setWhereClauseParam(1,valor2);
    // Executa a Query
    TipoDestLixo.executeQuery();
    // Fim das Configurações da Query da Lista
    // Retorna o Resultado para a Página
    return new EventResult(page);
    The code works very well...
    And, I'm sorry for my two repost's in UIX Forum about this in a few time.
    Thank very much...
    Danilo

  • EEWB :  how to determine the business object and the extension type ?

    Hi,
    I ask myself how to determine the business object and the extension type to use to add new fields in a new tab of a specific transaction ? what means each business object, does that correspond to a specific transaction ?
    I need to add a new tab in the ‘BaMI’ business activity in transaction CRMD_ORDER just after the tab 'Actions' at header level.
    Could you help me please to determine which business object and extension type I have to select during creation of the project and which business object category I have to select during creation of the extension (wizard) ?
    Thanks for your help,
    Marie

    Marie,
    In order to determine what type of transaction you are extending, you will need to look at the customizing for the transaction.
    In the IMG:
    Goto:
    Customer Relationship Management->Transactions->Basic Settings->Define Transaction Types.
    You will then choose the transaction defined that you want to extend.  If you display the details of the transaction you will find an attribute called:
    "Leading Transaction Category".  This tells you the general context in which the transaction is used.  The other item to view is the assignment of business transaction categories found in the maintenance screen.
    This information general corresponds to one of the options that the EEWB will give you on the transaction type.
    As far as extensions go, my recommendation is the following:
    - Use CUSTOMER_H Customer Header Extensions for any new fields at the header level.
    - Use CUSTOMER_I Customer Item Extensions for any new fields at the item level.
    Unless you have a specific requirement to extend a segment of the transaction, I recommend placing all new fields in these segments.  The CUSTOMER_H & CUSTOMER_I segments are considered "standard" segments, that are already built into all the necessary API structures. 
    Let me know if you have any further questions.
    Good luck,
    Stephen

  • How to get event when any library object added to indesign doc?

    I want to do some operation when any library object is added to doc. So please tell me how to get event when any library object is added to the doc. better provide some code snippet.

    Daves61,
    I need to clarify what kind of event you're interested in.
    1. When you click once on page/spead widget in the Pages panel and only widget becomes selected. The layout window remains unchanged. OR
    2. When you doubleclick on page/spread widget the selected master spread appears in the layout window.
    In the first case you work with Pages panel.
    Have a look to file PageTransitionsPanelObserver.cpp from SDK. 
    PageTransitionsPanelObserver::LazyUpdate()
    In the second case you work with Layout window.

  • How do i query the module object for the interface of the module-specific interface I require

    Hi there.
    Currently using LabVIEW 2012/TestStand 2012.
    I am attempting to edit the LabVIEW Text Sequence Translator, and in the CreateStep.vi I am trying to create a step that is of type WIS_Sequence_Call (a custom version of NI_Types.ini-->SequenceCall).
    I need to set the file pathname, sequence name and parameter values in the step.  I believe I need to get access to the SequenceCallModule class to do this.
    This help file SequenceCallModule states in the description: "To access the properties and methods of a specific module class, query the Module object for the interface of the module-specific interface you want to acquire.".
    What exactly is meant by "query" here?  It looks like "Specify" might be what I am after, but I want this done programmatically, ie no dialog boxes.
    See my snippet below.
    Thanks.

    Thanks for the reply Charles.
    I have been using the 2012 version of the poster.
    I can get access to the Module class from the Step Class as shown in the snippet above, but I can't see how to get to SequenceCallModule? The "To more specific class" VI doesn't seem to work for TS refs. Is there no way to derive the SequenceCallModule from this?
    Also I can use the TSAdp.SequenceCallModule reference, but I need to link this to the relevant step that I've just created.  Can NI please provide me with a link to any examples on this?
    Thanks

  • How do i query the module object for the interface of the module-spe​cific interface I require

    Hi there.
    Currently using LabVIEW 2012/TestStand 2012.
    I am attempting to edit the LabVIEW Text Sequence Translator, and in the CreateStep.vi I am trying to create a step that is of type WIS_Sequence_Call (a custom version of NI_Types.ini-->SequenceCall).
    I need to set the file pathname, sequence name and parameter values in the step.  I believe I need to get access to the SequenceCallModule class to do this.
    This help file SequenceCallModule states in the description: "To access the properties and methods of a specific module class, query the Module object for the interface of the module-specific interface you want to acquire.".
    What exactly is meant by "query" here?  It looks like "Specify" might be what I am after, but I want this done programmatically, ie no dialog boxes.
    See my snippet below.
    Thanks.
    Christopher Farmer
    Certified LabVIEW Architect
    Certified TestStand Developer
    http://wiredinsoftware.com.au
    Solved!
    Go to Solution.

    Thanks for the reply Charles.
    I have been using the 2012 version of the poster.
    I can get access to the Module class from the Step Class as shown in the snippet above, but I can't see how to get to SequenceCallModule? The "To more specific class" VI doesn't seem to work for TS refs. Is there no way to derive the SequenceCallModule from this?
    Also I can use the TSAdp.SequenceCallModule reference, but I need to link this to the relevant step that I've just created.  Can NI please provide me with a link to any examples on this?
    Thanks
    Christopher Farmer
    Certified LabVIEW Architect
    Certified TestStand Developer
    http://wiredinsoftware.com.au

  • How to get an empty form when we run the page?

    Hi all!
    Hope you are well
    My question is, how to get an empty form at run time? means when we run the page, text fields are filled with blank....Could anyone please help me with this..
    Thanks in advance,
    nanda.

    Hi Nanda,
    Just follow these steps:
    1) Create a bounded taskflow (uncheck the create with fragments checkbox)
    2) Drag the CreateInsert operation on your bounded taskflow and mark it as the default activity
    3) Drag a view and link the CreateInsert to the view component using a control flow case
    4) Double click on the view to create the page
    5) Drag the view object on the page as an ADF form
    6) Go back to your bounded taskflow and from the General tab make sure under visibitliy you select "url-invoke-allowed"
    Run you tasfklow and your form will be rendered in insert mode.
    Regards
    Antonis

Maybe you are looking for

  • How to setup a PDF file with photo insertion

    Hi I am new to the PDF interactive world. I have recieved a document which i need to create field of text and photo insertion. I have figured out the text field. But i cannot figure out how to create a photo insertion field. I am trying to make a doc

  • When new events are added they are not in chronilogical order. How do I fix this?

    Whenever I would add new photos to my library, the new event would be created in chronological order ... oldest to newest.  To my knowledge I made no changes in my set-up, but now the newest event is created immediately before the oldest event.  In o

  • Fonts problem after I converted to pdf from .ps file

    I have completed a .ps file and then use the acrobat distiller to convert to pdf file and resulted in unreadable text. See below comments from the distiller: Source: /Users/chanrick/Desktop/HKCN-Energy3.ps Destination: /Users/chanrick/Desktop/HKCN-En

  • Import error -43 in 6.0.1

    Can anyone help? I am trying to import an existing iMovie project into a new one without success as I get an error message -43. My iMac is less than one month old, I have not added any plug-ins & I have not taken anything away. I have tried importing

  • Check before deleting Payment Proposals ( F110 )

    Hi gurus, I have the following scenario: When the user runs F110 and creates a payment proposal we start a workflow for approbation of the payment. I have successfully found a badi to start the workflow, the problem arises when the same user that cre