Pass "this" reference within SessionBean to other classes

Can "this" reference for a SessionBean be passed to other helper classes?
For example,
public class MySb implements SessionBean {
MyClass a = new MyClass();
public void myBusinessMethod() {
a.methodA(this);
It looks strange that MyClass.methodA is expecting a SessionBean as opposed to a EJBObject interface as parameter. I also thought about passing the SessionContext object. Can someone tell me the pros and cons?
Thank you.

Thanks for the reply.
There are disadvantages using the EJBObject directly. However, since the call always comes from the EJBObject instance and the helpers simply call its methods within the same method call. For performance reason, will it hurt to do that? i.e.
public class MyStatefulSessionBean ... {
public void methodA() {
helperA.methodA(this, parms);
void changeState(StateHelper helper){this.helper=helper;}
class helperA {
methodA(EJBObject obj, parms){
obj.changeState(new HelperB);
My other alternative is to pass the SessionContext to the helpers and helpers can call its getObject() to retrieve the remote interface. Then performance suffers and unwanted private method (changeState) has to be exposed to the public interface.

Similar Messages

  • Accessing class level variable in other class.

    Hi All,
    I have one variable declared at class level i.e. global variable (non-static). In one method I am setting one value in this variable.Now I want to access this variable with this new set value in other class.
    Can anybody tell me how to do this?
    Thanks in advance.
    Neha

    Neha_20 wrote:
    Thanks for your reply. But its business req. to have byte[] as return type.
    Pls suggest me other approches as well.Comments embedded.
    Neha_20 wrote:
    *Decode.java*
    class Decode
    byte[] decodeMessage(byte []datatoReceive)
    for(int i=0,j=6; i<dataLen && j<j+responseData.length;i++,j++)
    responseData[i] = datatoReceive[j];
    System.out.println("Response Data [ "+i +" ]"+responseData);
    Syntax syntaxObj1 = new Syntax(); // this creates a Syntax instance     
    syntaxObj1.returnData(responseData); // this populates it
    return responseData; // now it goes out of scope and disappears
    Neha_20 wrote:
    *User.java*
    class User
    public static void main(String args[])
    // this creates a new unpopulated Syntax instance
    Syntax syntaxObj = new Syntax();
    for(int i =0;i<syntaxObj.dataRet.length;i++)
    System.out.println("dataRet [ "+i+ " ]"+syntaxObj.dataRet);

  • How to pass entire class as a parameter in a method of other class- OpenScr

    Hi Folks,
    Whenever we create a script in OpenScript, it can contain only one class. However I want to declare several variables in a class/script and pass this entire class B as a parameter in a methodA of classA.
    What I mean by mean that is , I create ClassB something like below
    public class MyParams.....
    variable1;
    variable2;
    variable3;
    variable4;
    variable5;
    public class Original.....
    public void methodA(MyParams params)
    params = new MyParams();
    field1 = params.variable1;
    field2 = params.variable2;
    field3 = params.variable3;
    field5= params.variable5;
    Edited by: OATS Explorer on Mar 8, 2012 1:53 AM

    Hi
    I have a stand alone program (can be used by all other users) which will accept request_id and To_Email as parameters. I am developing a new request set in which I want to incldue this stand alone program and want to pass Prog#1 request Id to the 2nd stand alone program as a parameter so that I can send the output of the Prog#1 to the users through E-mail.
    Do we have any options to pass Prog#1 requeset id in to Prog#2 as a parameter in the request set without modifying the stand alone concurrent program code.
    Please note that i dont want to change stand alone program code becuase this code/program was developed to work in general for all the users and I dont want to change this code for new requirement/purpose...
    Hope you understood my requirement...
    Thanks!!

  • Passing instance to other classes

    Hi,
    I have the following class
    public class myApp extends SingleFrameApplicationWhen I pass the instance like as given below, the instance of SingleFrameApplication is passed. How can I pass the instance of myApp along with this, so that I can access the variables of myApp class from other classes and packages.
    new TreeTableView(this);Please help.
    Any help in this regard will be well appreciated with points.
    Warm Regards,
    Rony

    Hi,
    i think the constructor of TreeTableView looks sth. like TreeTableView(SingleFrameApplication app), so the TreeTableView takes a SingleFrameApplication and not a myApp. you have two possibilities to access your methods and variables.
    1. Extend TreeTableView with a constructor TreeTableView(myApp app)
    or
    2. You cast the SingleFrameApplication to a myApp everytime you have to access myApp
    =>
    a = ((myApp)singleFrameApplicationInstance).variable;

  • Passing variables to other classes

    Hi the problem im having is ive made 3 classes class A, A1 and A2 when i create A i also create A1 what i am wanting to do is if a condition in A1 is met it will pass a variable to A so A can delete A1 and then create A2, im having some dificulty in passing this variable back to A.
    Any help appreciated

    You mean you want to return a variable from a method in class A?
    Read:
    http://java.sun.com/docs/books/tutorial/getStarted/application/objects.html

  • Passing data to other classes

    I have two seperate classes in my program.
    The class with main sends an LinkedList to the other class with this statement...
    PanelB a = new PanelB();
    a.setLink(points);Then in my other class I have this code...
    public LinkedList q;Then I have a subclass with this code to accept the LinkedList...
    public void setLink(LinkedList p, Graphics g){
    q = p;At this point everything is great the data is passing along nicely.
    Until I try to send the data to another sub class in the same class...
    public void paint(Graphics g, LinkedList q) {
           int k = q.size();
           System.out.println(k);It compiles fine but the program does not print out the size of the LinkedList. It does print it out at every step though before this one. What am I missing or is there a better way of doing all of this?

    Okay I messed with the code a little bit this is what I got.
    public class shapeDraw{
    public static void main (String[] args) {
      JFrame frame = new JFrame("Shape Outline");
      JPanel panel = new PanelB();
      panel.setPreferredSize(new Dimension(500,500));
      frame.getContentPane().add(panel);
      frame.pack();
      frame.setVisible(true);
      LinkedList points = new LinkedList();
      PanelB a = new PanelB();
      a.setLink(points);
    }}I left a lot out of the code to make it easier and quicker to read. This is my next class that is called by this class.
    public class PanelB extends JPanel {
    public LinkedList q;
    public void setLink(LinkedList p){
         q = p;
    public void paint(Graphics g) {
         Graphics2D g2 = (Graphics2D)g;
         g2.setPaint(Color.red);
         Point trig = new Point(10,200), trigB = new Point (50, 300);
         double x1=trig.getX();
         double x2=trigB.getX();
         double y1=trig.getY();
         double y2=trigB.getY();
         super.paint(g);
         g2.draw(new Line2D.Double(x1, y1, x2, y2));
    }This code draws a line. I would like bring my ListLinked to this subclass because I want to use the points I have stored in it to draw a picture.

  • Getting an enclosing class's this reference

    I'm creating a custom button and notifying registered ActionListeners whenever the button is clicked. In my code below, I want to create a new ActionEvent with the event source as "Button" instead of Button$Listener.
    From the Listener class, how can I obtain the parent's this reference? I've tried using Button.this, but when the listener calls getClass().getName() on the event, it says its an ActionEvent, not a Button. That also confuses me.
    public class Button extends JPanel
        private void notifyListeners(ActionEvent e)
            /* I could do it this way, but I'd rather not
            e.setSource(this);
            for ( ActionListener l : listeners )
                l.actionPerformed(e);
        private class Listener implements MouseListener
            public void mouseClicked(MouseEvent e)
                notifyListeners(new ActionEvent(this,
                                                ActionEvent.ACTION_PERFORMED,
                                                "clicked"));
    }

    I've tried using Button.this, but when the listener
    calls getClass().getName() on the event, it says its
    an ActionEvent, not a Button. Huh?
    public class Outer {
      public static void main(String[] args) throws Exception {
        Outer outer = new Outer();
        Outer.Inner inner = outer.new Inner();
        inner.foo();
      class Inner {
        void foo() {
          System.out.println(Outer.this.getClass().getName());
    prints "Outer"

  • HT4061 I am unable to load Adobe Flash player on my Apple Ipad are there any clues out there how to by pass this,I can not get certain programs without it ,so I am returning my IPAD,any other programs I can load to get my programs

    I am unable to load Adobe Flash player on my Apple Ipad are there any clues out there how to by pass this,I can not get certain programs without it ,so I am returning my IPAD,any other programs I can load to get my programs

    Apple's iOS platform (iPhone, iPad, and iPod Touch) has never, and will never support flash.
    First on this; Thoughts on Flash. This is from Steve Jobs regarding Apple's views on Flash (2010)
    Second; Adobe stops making Flash for mobile devices. This is from Adobe themselves last year stating that they would stop making Flash for mobile devices.
    If you can find the App equivalent of the programs you are looking for, then congratulations, however, if you require specific 'programs' requiring flash, then the iPad is certainly not for you, and returning it would be the best choice (granted you are still within the return period).
    The lesson in this; Research what a device can and cannot do prior to purchase

  • Passing values and calling other classes?

    Hello all.
    I have 2 classes(separate .java files). One is a login class and the other is the actual program. Login class(eventually exe file) should open the other class and pass the login parameters if you know what I mean. Is this possible, or do the 2 classes need to be part of one file?
    Thanks alot
    Milan D

    Login class can be another class in another file
    wht u have to do is to make an instance of login class in the class u want to use that class
    like login lg = new Login();
    and call method of login class
    lg.setUser(username);
    where setUser(String user); is a method of login class
    this way u can pass the parameters to login class
    i hope this might be helpful
    regards
    Moazzam

  • When trying to upload a PDF to an interactive site I get the announcement:"The attached PDF file references a non-embedded font Tahoma. Please remove file, embed the font and reattach." How do I embed this, or in fact any other font ?

    When trying to upload a PDF to an interactive site I get the announcement: "The attached PDF file references a non-embedded font Tahoma. Please remove file, embed the font and reattach."
    I could not get rid of the Tahoma font in the WORD file.
    How do I embed this, or in fact any other font ?

    Thank you very much !
    Indeed, I was unaware of the enormous number of options that can be selected when converting a WORD file to PDF.
    I went thru the settings and found the right one for embedding the fonts.
    Thanks again !
    Oren

  • Correct references to other classes

    I'm working on a student project and I'm in some troubles.
    I have a schema "2010_12209" on faculty 11g Oracle DB.
    I have successfully loaded Class A (that has no references to other class) in Oracle DB using SQL Developer.
    Then I try to load Class B (that has references to class A) and I get error: java.sql.SQLException: ORA-24344: success with compilation error ORA-06512: at line 1
    which I'm pretty sure that's from the incorrect classes references.
    So what's the correct syntax to properly reference to class A
    ex: 2010_12209.A or ???

    References to other classes will be links only if the class is in the one of the packages you generate the javadoc in, or if you use the -link option to link your javadoc to other javadocs.

  • Passing EJB reference to other Thread

    Hi,
    If I have EJB reference, can I pass it to other thread safely?
    COM had concept of Apartments to handle thread problems and we had to marshal the interfaces if passed to another thread.
    What we do in EJB? Is there any concept like apartments that is hidden?
    Thanks,
    Unmesh

    Within the appserver, EJBs should not be doing anything with threads.
    If we are talking about an external app (ie: a client GUI) holding references, then yes these can be passed around between threads freely.

  • HT4113 I forgot my restrictions pass code how can I fix this without losing all my other stuff?

    I forgot my restrictions passcode how can I fix this without losing all my other stuff

    Forgotten RESTRICTIONS Passcode
    - Place the iOS device in Recovery Mode and restore via iTunes. For how to restore: iTunes: Restoring iOS software
    You have to either:
    - Restore from a backup that was make before you added the Restrictions passcode. If you restore from a backup made with the Restrictions passcode the Restrictions passcode is also restored.
    - Restore to factory settings/new iPod
    You can redownload most iTunes purchases by:
      Downloading past purchases from the App Store, iBookstore, and iTunes Store
    - You can get some photos back if you used PhotoStream then try getting them from your PhotoStream. See that topic of:
    iOS: Importing personal photos and videos from iOS devices to your computer
    - You can likely get some data from the restored iPod via How to perform iPad recovery for photos, videos
    Wondershare Dr.Fone for iOS: iPhone Data Recovery - Wondershare Official     
    http://www.amacsoft.com/ipod-data-recovery.html
    iPod recovery software to restore lost music files      
    -iPod touch Deleted Photo Recovery Tips You Should Know

  • How can I pass a value from Client to EntityImpl class?

    Hi everyone,
    I am using ADF BC to develop my Application.
    I want to do something in the EntityImpl class.
    My job needs a value from Client.
    I can't find any way to slove the problem.
    Is there anyone have an ideal, please tell me.
    Thanks,
    Tuan Vu Minh
    FPT Software Solution Company (Oracle partner)
    FPT Coporation
    Add: 3th Fl., 51 Le Dai Hanh Builiding,
    Hai Ba Trung Dist,
    Hanoi,
    The Socialist Republic of VietNam
    Tel: (84,4) 9745476
    Fax: (84,4) 9754475
    Email: [email protected]
    Website: http://www.fss.com.vn , http://www.fpt.com.vn

    Firstly, let me state that I'm not a Swing programmer, so your mileage may vary. However I don't think a Swing solution is what you need. ADF BC will do this for you.
    Assumptions on my answer:
    1) You're generating the log_id from a database sequence and it is automatically populated in the UserLog table.
    2) You have 2 VOs, namely UserLogView and ActionLogView based on the EOs.
    Create a View Link between each VO making UserLogView the master.
    In your UI, once the user has inserted into UserLogView, include a bound create button for the ActionLogView such that it creates an associated ActionLogView record for the user when they wish to enter the log details. ADF BC will populate the ActionLogView Log_id with the parent's UserLogView log_id automatically. You'll then need to navigate to the ActionLogView screen to allow the user to enter the rest of the details.
    As such, you don't need to expose the log_id to the client, ADF BC will take care of the population of the log_id correctly for you when creating the detail record.
    Another approach may be to define one VO encompassing both EOs, where the ActionLog is a reference. Look at the JDevelope help page "View Object Wizard - Entity Objects Page", specifically at the "Reference" section for more info. You'll need to test out the updateable flag for both EOs defined within the VO to ensure you can update the values of both.
    Test this out in the Business Components Browser before writing the UI to see if the ADF BC solution works, and saving you time in writing the UI.
    Hope this helps.
    CM.

  • While using data pump (impdp) how to rename references within objects?

    using 10g;
    what i want to accomplish is to change schema & tablespace ownership using the data pump method via the command line; i have had success using the command line for expdp / impdp. Problem is that there are objects that reference the old schemas that DO NOT get updated (e.g. procedure may reference usr1.table1 in the PL/SQL statement) and this is where i have been UN-successfull). Anyone know of a way to change references from old schema to new schama name in objects(procedures, views, etc) via the command line?
    this is what i currently use that works to change schema, tablespace, but will not change references within my objects;
    expdp system/<pass> schemas=usr1,usr2 DIRECTORY=dp_dir DUMPFILE=dataPump_BothSchemas.dmp LOGFILE=expdpAllSchema.log parallel=2
    impdp system/<pass> DIRECTORY=dp_dir DUMPFILE=dataPump_BothSchemas.dmp LOGFILE=impbothSchToEE.log remap_schema=usr1:newUsr1,usr2:newUsr2 remap_tablespace=old_ts_tables:new_ts_tables full=y
    Thanks!
    p.s. I have acomplished this using the enterprise manager.

    (e.g. procedure may reference usr1.table1 in the PL/SQL statement) If you hard coded such reference in stored procedure, you have to manually correct them. Consider use synonym if your storage procedure referencing other schema's objects.

Maybe you are looking for