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.

Similar Messages

  • Pass EJB reference to RMI object

    Hi all,
    I have RMI server outside JVM where app sever runs and some app server JVM. At app sever I have MDB bean and some statefull bean ejb (SB). Previously I create SB from MDB via calls from RMI server, but then I lose transaction propagation between MDB and SB. Now I need to create SB from MDB, because of transaction propagation problem, but RMI server must also have reference to SB ejb, because of some special functions. I try to pass handle of SB ejb to my RMI server, but if I want to call bussiness methods on SB ejb, it doesn't work and I got exception. My question is if it is possible or not, and if yes then how it is possible to do. Thanks.

    Could you tell us a bit more about the exception you get.
    Anyway, you shouldn't do that. For security reasons, most appservers prevent an handle to be used outside the client application that requested it. It seems to me that it is exactly what happens here.
    Your architecture seems a bit complex. Can't you simplify it a bit?
    /Stephane

  • How to pass EJB reference as a parameter?

    Hi,
    I am calling a method of EJB2 from within EJB1. I have done the lookup and got the reference of EJB2 to be called. One of the parameters of the called method (of EJB2) is the EJB remote reference of EJB1 so that EJB2 can call a method of EJB1. How do I send this remote reference. Can someone details in terms of actual code.
    Thanks,
    Prasad

    "One of the parameters of the called method (of EJB2) is the EJB remote reference of EJB1 so that EJB2 can call a method of EJB1."
    In all probablility, this is a design flaw.
    "How do I send this remote reference."
    Use javax.ejb.Handle objects.
    "Can someone details in terms of actual code."
    No.

  • Defining ejb references to other servers

    Hello,
    I'm using ejbs in a distributed environment and I haven't found any info on how to define bean references
    between servers on deploy.
    My problem is as follows:
    Session bean A needs to use session bean B which is located on another server.
    A doesn't know the location of server for B nor the fact that B even is on different server.
    A asks B from the local jndi environment using the name ejb/B.
    How can I define on deploy that the location of B is actually sess_iiop://serverB.com:port:sid/context/B?
    Is it somehow possible to define this mapping in the deployment descriptors?
    null

    Hi,
    The <ejb-ref> element is optional, you could use the actual JNDI name instead.
    The advantage with using <ejb-ref> is that, if you deploy the bean on another server, probably with a different JNDI name,
    your code can still continue using the same name as defined by <ejb-ref-name>.
    Internally, the <ejb-ref-name> will be mapped to the actual JNDI location, maybe using symbolic links.

  • Ejb-ref element references to other beans

    Hello,
    Can anyone tell me what ejb references to other beans are for? (ejb-ref element).
    I am completely missing the point and would be grateful if someone could tell me why I should have the overhead of writing this:
    <ejb-ref>
    <ejb-ref-name>ejb/waUserMgr</ejb-ref-name>
    <ejb-ref-type>Session</ejb-ref-type>
    <home>com.reuters.pds.webapp.bl.user.api.WAUserMgrHome</home>
    <remote>com.reuters.pds.webapp.bl.user.api.WAUserMgr</remote>
    <ejb-link>WAUserMgrEJB</ejb-link>
    </ejb-ref>
    Any comment welcome..
    Julien.

    Hi,
    The <ejb-ref> element is optional, you could use the actual JNDI name instead.
    The advantage with using <ejb-ref> is that, if you deploy the bean on another server, probably with a different JNDI name,
    your code can still continue using the same name as defined by <ejb-ref-name>.
    Internally, the <ejb-ref-name> will be mapped to the actual JNDI location, maybe using symbolic links.

  • How to pass Method Inner Class reference to other method?

    Hi All,
    I am trying to pass the reference of "method inner class".
    Can any one explain me how to pass the reference and where other method will sit in the class, I mean either in Outer Class or in Inner Class ?
    Thanks in advance for ur reply :)
    package methosInnerClass;
    public class MethodLocalInnerClass {
         private String outerName;
         private static String statOuterName;
         public MethodLocalInnerClass(String name, String statName) {
              outerName = name;
              statOuterName = statName;
         public void methodWithLocallClass() {
              class MethodInnerClass {
                   String innerName;
                   MethodInnerClass(String name) {
                        innerName = name;
                   public void displayOuterInner() {
                        System.out.println("Outer Name: " + outerName + "\nOuter StatName: " + MethodLocalInnerClass.statOuterName + "\nInner Name: " + innerName);
              MethodInnerClass methodInner = new MethodInnerClass("Harish");
              methodInner.displayOuterInner();
                    *Pass above reference to other method*
         public static void staticMethodWithLocallClass() {
              class MethodInnerClass {
                   String innerName;
                   MethodInnerClass(String name) {
                        innerName = name;
                   public void displayOuterInner() {
                        // We can not access the non-static instance variable since this method is a static method
                        //System.out.println("Outer Name: " + outerName + "\nOuter StatName: " + MethodLocalInnerClass.statOuterName + "\nInner Name: " + innerName);
                        System.out.println("Outer StatName: " + MethodLocalInnerClass.statOuterName + "\nInner Name: " + innerName);
              new MethodInnerClass("Shakshi").displayOuterInner();
         public static void main(String[] args) {
              new MethodLocalInnerClass("Abhishek","Neeshu").methodWithLocallClass();
              System.out.println("Calling innerClass within static method !!!");
              staticMethodWithLocallClass();
    }

    package donald.test.inner_class;
    public class OutterClass {
         private String outerName;
         private final OutterClass outterClass;
         public OutterClass() {
              outterClass = this;
         public void methodWithInnerClass(final String strValueToPassToInnerClass) {
              class InnerClass {
                   private InnerClass innerClass;
                   private String innerName;
                   InnerClass(String name) {
                        innerName = name;
                   public void displayOuterInner() {
                        System.out.println("Non-Static:\tOuter Name: " + outerName + "\tInner Name: " + innerName);
                        System.out.println("");
                        System.out.println("final String strValueToPassToInnerClass = " + strValueToPassToInnerClass);
                    * @return the innerClass
                   public InnerClass getInnerClass() {
                        return innerClass;
                    * @param innerClass the innerClass to set
                   public void setInnerClass(InnerClass innerClass) {
                        this.innerClass = innerClass;
                    * @return the innerName
                   public String getInnerName() {
                        return innerName;
                    * @param innerName the innerName to set
                   public void setInnerName(String innerName) {
                        this.innerName = innerName;
              InnerClass methodInner = new InnerClass("Inner.Donald");
              methodInner.displayOuterInner();
              System.out.println("My OutterClass " + outterClass.getOuterName());
        // Unknown "MethodInnerClass "
         public void passReferenceOfInnerClassToOtherMethod(     ) {
          * @param args
         public static void main(String[] args) {
              OutterClass outterClass = new OutterClass();
              outterClass.setOuterName("Outter.Donald");
              outterClass.methodWithInnerClass("This Donald is so very cool...!!!  Yeah...!!!");
          * @return the outerName
         public String getOuterName() {
              return outerName;
          * @param outerName the outerName to set
         public void setOuterName(String outerName) {
              this.outerName = outerName;
          * @return the outterClass
         public OutterClass getOutterClass() {
              return outterClass;
    }

  • Arrays are passed by reference or value ?

    Hi peoples,
    I have something interesting here which I need to know. Look into the following classes :
         public class example1 {
         int i[] = {0};
         public static void main(String args[]) {
         int i[] = {1};
         change_i(i);
         System.out.println(i[0]);
         public static void change_i(int i[]) {
         i[0] = 2;
         i[0] *= 2;
         public class example2 {
         int i[] = {0};
         public static void main(String args[]) {
         int i[] = {1};
         change_i(i);
         System.out.println(i[0]);
         public static void change_i(int i[]) {
         int j[] = {2};
         i = j;
    Among the above classes, the class named 'example1' returns the value 4 whereas, the class named 'example2' returns the value 1.
    Any explanations to this one please....
    Cheers,
    Rasmeet

    minglu, you are not doing right.
    i just don't get it why you have i[] as instance variable but never use it ( i[] is declared in every method so each i you refer to in the method is a local varable not member variable that can be shared for the object ).
    your first solution work. but that i = j line is not needed because it has no effect you still cannot change the referrence of i to other int[]. your first soultion just need to be
    public static int[] change_i(int i[]) {
    int j[] = {2};
    return j;
    }anyway, using this solution, the method name will be misleading because the method didnot change i in anyway. i is changed because you assign the return array (j) to i.
    for that second solution also, you didn't use your member variable i at all. what you change is the content of i you pass so the result is correct. but then how is this method different from the first method the original poster posted?
    moreover, java never pass argument to the method by reference it ALWAYS pass by copy.i suppose you define passing by reference in the same way C++ does. all object variable in java is a refernce to Object so passing the variable to method is surely passing the reference to the method but that's not passing by reference. it's passing by copy because what is passed is the copy of the reference to the object, not the reference to the reference to Object. if it is really passing by refernce, then you will be able to change your reference to object to point anywhere because you have the access the address of the reference. but since you don't (you only know where the passed reference is pointing to (you have the COPY of value of reference) but you don't know where the refernce store its value) you can only change the content of the pointed object but not changing the pointed object.
    let me restate this, java always pass by reference.

  • Passing a variable from one thread to another

    Hi. I'm trying to produce a chat program in Java but need to pass a variable between two threads. I have included a snipet of the code.
    import java.io.*;
    import java.net.*;
    class IndividualConnection extends Thread
         public Socket clientSocket;
         String userName = "";
         public IndividualConnection(Socket connectingSocket)
              clientSocket = connectingSocket;
    public login(String name)
    userName = name;
         public void messageUser(Socket socket, String msg)
              try
                   Socket newSocket = new Socket("192.168.0.162",5163);     
                   DataOutputStream outToServer = new DataOutputStream(socket.getOutputStream());
                   outToServer.writeBytes(msg + '\n');     
              catch(Exception e)
                   System.out.println("The connection with the client has been closed.");
                   this.stop();
    public void run()
         Socket global = clientSocket;
    // etc etc
    A number of threads are created based on code similar to the above. Each thread communicates to a different client on the chat program. However, I want to be able to send messages between the clients.
    Each thread has a method called messageUser(Socket socket, String msg). I should (hopefully) be able to send a message to anyone using the prog if I can access their socket. The problem is that the socket objects for each client is held in the clients own thread. I have tried writing some code to find the Socket object in another thread but to no success. The code I am trying is shown below.
         public Socket findContact(String name)
              ThreadGroup currentGroup = Thread.currentThread().getThreadGroup();
              int numThreads = currentGroup.activeCount();
              Thread[] listOfThreads = new Thread[numThreads];
              currentGroup.enumerate(listOfThreads);
              for (int i = 0; i < numThreads; i++)
                   String threadName = listOfThreads.getName();
                   if (threadName.compareTo(name) == 0)
                   //     Socket tempSocket = threadName[i].getClass().getField(clientSocket);
              return tempSocket;
    The line I have commented out does not work. Please could someone tell me how to carry out this task. I have spent many hours trying to solve this but am not able to. The chat server is nearly complete now. I just need to find a way of obtaining another threads socket.
    I hope the problem is comprehensible. I have found it difficult to explain clearly. Many thanks.

    Really simple, inelegant solution:
    class MyThread extends Thread {
    Socket socket;
    MyThread( Socket s ) { socket = s; }
    public Socket getSocket() { return socket; }
    }Better: create a master object that includes an array
    of sockets. Each time you create a Thread, update the
    master object's list of sockets with a reference to
    each Thread's socket. Under the current memory model, the socket field should be declared volatile. The proposed new memory model will guarantee that this will work if the socket field is declared final.
    Sylvia.

  • Drag and Drop - Transferable, how to pass a reference? (URGENT)

    I've a tree that supports drag and drop correctly but every time I exchange a node position the old parent instance remaining on the tree is different from the one I was referencing with the dragged child before the drag occurred. I absolutely need to maintain all references and cannot work with copies.
    Is there any way to use the Transferable interface to pass the original object instead of a copy?
    Thanks to Tedhill who raised the problem, trying to get a quick answer.
    ;o)

    hi guys let me close this thread:
    Thanks to asjf and sergey35 who helped me.
    Actually the isDataFlavorSupported method you suggest passes a reference and not a copy.
    Too bad I fell into another problem with the reloading of the
    moving-node Object after the DnD.
    But finally the working code is:
    public class XJTreeDnD extends XJTree implements DragGestureListener, DragSourceListener, DropTargetListener{
      private DefaultMutableTreeNode dragNode = null;
      private TreePath dragParentPath = null;
      private TreePath dragNodePath = null;
      private DragSource dragSource;
      private DropTarget dropTarget;
      private TransferableTreePath transferable;
      private boolean DnDEnabled = true;
      //private boolean CnPEnabled = false;
      public XJTreeDnD(XNode node) {
        super(node);
        // Set up the tree to be a drop target.
        dropTarget = new DropTarget(this, DnDConstants.ACTION_MOVE, this, true);
        // Set up the tree to be a drag source.
        dragSource = DragSource.getDefaultDragSource();
        dragSource.createDefaultDragGestureRecognizer(this, DnDConstants.ACTION_MOVE, this);
      private DefaultMutableTreeNode getTreeNode(Point location) {
        TreePath treePath = getPathForLocation(location.x, location.y);
        if (treePath != null) {
          return((DefaultMutableTreeNode) treePath.getLastPathComponent());
        } else {
          return(null);
    //dragGesture implementation
        public void dragGestureRecognized(DragGestureEvent e) {
          if(DnDEnabled){
            TreePath path = this.getSelectionPath();
            if (path == null || path.getPathCount() <= 1) {
              System.out.println("Error: Path null, or trying to move the Root.");
              return;
            dragNode = (DefaultMutableTreeNode) path.getLastPathComponent();
            dragNodePath = path;
            dragParentPath = path.getParentPath();
            transferable = new TransferableTreePath(path);
            // Start the drag.
            e.startDrag(DragSource.DefaultMoveDrop, transferable, this);
    //dragSource implementation
        public void dragDropEnd(DragSourceDropEvent e) {
          try {
            if (e.getDropSuccess()) {
              ((BaseXJTreeModel)this.getModel()).removeNodeFromParent(dragNode);
              DefaultMutableTreeNode dragParent = (DefaultMutableTreeNode) dragParentPath.getLastPathComponent();
              XNode xnodeParent = (XNode)dragParent.getUserObject();
              ((BaseXJTreeModel)this.getModel()).valueForPathChanged(dragParentPath, xnodeParent);
          } catch (Exception ex) {
            ex.printStackTrace();
        public void dragEnter(DragSourceDragEvent e) {
          // Do Nothing.
        public void dragExit(DragSourceEvent e) {
          // Do Nothing.
        public void dragOver(DragSourceDragEvent e) {
          // Do Nothing.
        public void dropActionChanged(DragSourceDragEvent e) {
          // Do Nothing.
    //dropTarget implementation
        public void drop(DropTargetDropEvent e) {
          try {
            Point dropLocation = e.getLocation();
            DropTargetContext dtc = e.getDropTargetContext();
            XJTreeDnD tree = (XJTreeDnD) dtc.getComponent();
            TreePath parentPath = tree.getClosestPathForLocation(dropLocation.x, dropLocation.y);
            DefaultMutableTreeNode parent = (DefaultMutableTreeNode)parentPath.getLastPathComponent();
            Transferable data = e.getTransferable();
            DataFlavor[] flavors = data.getTransferDataFlavors();
            for (int i=0;i<flavors.length;i++) {
              if (data.isDataFlavorSupported(flavors)) {
    e.acceptDrop(DnDConstants.ACTION_MOVE);
    TreePath movedPath = (TreePath) data.getTransferData(flavors[i]);
    DefaultMutableTreeNode treeNodeMoved = (DefaultMutableTreeNode) movedPath.getLastPathComponent();
    DefaultMutableTreeNode treeNodeLeft = (DefaultMutableTreeNode) this.dragNodePath.getLastPathComponent();
    XNode xnodeParent = (XNode)parent.getUserObject();
    XNode xnodeChild = (XNode)treeNodeLeft.getUserObject();
    /** @todo check the parent whether to allow the drop or not */
    if(xnodeParent.getPath().startsWith(xnodeChild.getPath())){
    System.out.println("cannot drop a parent node on one of its children");
    return;
    if(xnodeParent.getPath().getPath().equals((xnodeChild.getPath().getParentPath()))){
    System.out.println("node is already child of selected parent");
    return;
    // Add the new node to the current node.
    xnodeParent.addChild(xnodeChild);
    ((BaseXJTreeModel)this.getModel()).valueForPathChanged(parentPath, xnodeParent);
    ((BaseXJTreeModel)this.getModel()).insertNodeInto(treeNodeMoved, parent, parent.getChildCount());
    ((BaseXJTreeModel)this.getModel()).valueForPathChanged(movedPath, xnodeChild);
    e.dropComplete(true);
    } else {
    System.out.println("drop rejected");
    e.rejectDrop();
    } catch (IOException ioe) {
    ioe.printStackTrace();
    } catch (UnsupportedFlavorException ufe) {
    ufe.printStackTrace();
    public void dragEnter(DropTargetDragEvent e) {
    if (isDragOk(e) == false) {
    e.rejectDrag();
    return;
    e.acceptDrag(DnDConstants.ACTION_MOVE);
    public void dragExit(DropTargetEvent e) {
    // Do Nothing.
    public void dragOver(DropTargetDragEvent e) {
    Point dragLocation = e.getLocation();
    TreePath treePath = getPathForLocation(dragLocation.x, dragLocation.y);
    if (isDragOk(e) == false || treePath == null) {
    e.rejectDrag();
    return;
    // Make the node active.
    setSelectionPath(treePath);
    e.acceptDrag(DnDConstants.ACTION_MOVE);
    public void dropActionChanged(DropTargetDragEvent e) {
    if (isDragOk(e) == false) {
    e.rejectDrag();
    return;
    e.acceptDrag(DnDConstants.ACTION_MOVE);
    private boolean isDragOk(DropTargetDragEvent e) {
    /** @todo gestire i casi in cui il drop non sia concesso */
    return (true);
    public void setDragAndDropEnabled(boolean enabled){
    this.DnDEnabled = enabled;
    public boolean isDragAndDropEnabled(){
    return this.DnDEnabled;
    Thanks again.
    flat

  • About pass-by-reference

    From my current understanding, the recommended way (with ARC enabled) of 'pass by reference' is like:
        -(void)somefunc:(someclass **)byref;
        // and 'someclass **' should be inferred to 'someclass * __autoreleasing *'
        // am i right?
        //or we could just explicitly define it like
        -(void)somefunc:(someclass * __autoreleasing *)byref;
    However, from the answer to this thread, http://stackoverflow.com/questions/8814718/handling-pointer-to-pointer-ownership -issues-in-arc.
    It seems -(void)somefunc:(someclass *__strong *)byref could do the trick as well (in demo2 of above link).
        1.-(void)somefunc:(someclass * __autoreleasing *)byref;
        2.-(void)somefunc:(someclass *__strong *)byref
    For the first one, as documented by Apple it should be implicitly rewritten by compiler like this:
        NSError * __strong error;
        NSError * __autoreleasing tmp = error;
        BOOL OK = [myObject performOperationWithError:&tmp];
        error = tmp;
    It seems the second one has a better performance? Because it omits the process of 'assign the value back' and 'autoreleasing'. But I rarely see functions declared like this. Is it a better way to use the second function to do the 'pass by reference' job?
    Any suggestion or explanation? Thanks in advance.

    Why do you need to do this? Because Objective-C is based on pointers rather than objects, you already have pass by reference. In C++ it is a big deal to pass objects by value compared to by reference. Just passing by pointer, as in the case with Objective-C, is usually all you need for pass by reference. It is only in rare circumstances that you really need to pass a pointer and have the pointer itself get changed. Apple does this to return error pointers. That is only because so many programmers are unable to do exceptions properly.

  • EJB references

    I have a small j2ee app (ear file).. It is working fine with Orion server..
    I want to deploy this app on wl6 but I have some problems with the JNDI
    context..
    I am using the j2ee recomandation (5.3.1.1 Programming interfaces for EJB
    references) but my client gets an - javax.naming.NameNotFoundException:
    java:comp; remaining name ''
    Client.java file
    Object homeObject = context.lookup("java:comp/env/ejb/mybean");
    weblogic-ejb-jar.xml file
    <jndi-name>ejb/mybean</jndi-name>
    jndi.properties file (used by the client)
    java.naming.provider.url=t3://localhost:7001
    java.naming.factory.initial=weblogic.jndi.WLInitialContextFactory
    Bogdan Ghidireac

    J2EE clients are components that are deployed much like EJB components. The client deployer is the class weblogic.ClientDeployer. It takes an ear file and the name of the client, say foo, and expects a jar file for that client in the ear file, i.e., foo.jar, and a runtime XML file in the current directory, i.e., foo.runtime.xml. The runtime XML is compatible with the reference implementation. I am including an example.
    <resource-ref>
    <res-ref-name>jdbc/DB1</res-ref-name>
    <jndi-name>oracle/bigbox</jndi-name>
    </resource-ref>
    <ejb-ref>
    <ejb-ref-name>ejb/External</ejb-ref-name>
    <jndi-name>my/favorite/bean</jndi-name>
    </ejb-ref>
    <env-entry>
    <env-entry-name>interval</env-entry-name>
    <env-entry-value>100</env-entry-value>
    </env-entry>
    This relates component local names, i.e., java:/comp/jdbc/DB1 and java:/comp/ejb/External, to global JNDI names in the target server for this deployment. It also specifies a binding for java:/comp/env/interval.
    The deployment results in a launchable jar file in the current directory, i.e, foo.jar. It is launched with weblogic.j2eeclient.Main, which takes the launchable jar, i.e., foo.jar, and the server URL. Any additional arguments are passed on to the main program of the J2EE client component.
    Anno
    "Bogdan Ghidireac" <[email protected]> wrote in message news:[email protected]..
    I have a small j2ee app (ear file).. It is working fine with Orion server..
    I want to deploy this app on wl6 but I have some problems with the JNDI
    context..
    I am using the j2ee recomandation (5.3.1.1 Programming interfaces for EJB
    references) but my client gets an - javax.naming.NameNotFoundException:
    java:comp; remaining name ''
    Client.java file
    Object homeObject = context.lookup("java:comp/env/ejb/mybean");
    weblogic-ejb-jar.xml file
    <jndi-name>ejb/mybean</jndi-name>
    jndi.properties file (used by the client)
    java.naming.provider.url=t3://localhost:7001
    java.naming.factory.initial=weblogic.jndi.WLInitialContextFactory
    Bogdan Ghidireac
    [att1.html]

  • Caching EJB references

    Hi all,
    I was wondering if anyone could give me a conclusive explanation regarding the caching options for EJB objects(SLSB, and Entity Beans), both home/remote and localHome/local.
    I have read a lot of various EJB documentations including a fairly thorough look into the spec, and have about 2 years of practical expirience with EJBs.
    The matter that is still vague to me after all this time is the matter of caching and reusing EJB references. practical expirience and some documentation lead me to believe that caching an EJB reference of any kind is hazardous. From what I saw the spec never adresses this issue in a straightforward conclusive manner. It does discuss some failover scenarios and the use of EJB handles as both optionally a persistent reference and a "long living" refernce, but never in a context that is "spec mandatory" and "encapsulates" the whole picture.
    Now, there is no fundamental difference between caching a reference or using one that is locally scoped in a single method, except the time it is expected to be "alive", which is, by definition, a relative and unmeasurable matter.
    Theoretically, I am sure there is no problem implementing references, which are actually client "proxies", stubs, in a way that will not be dependent of an exact instance, but rather on an abstract EJB ID(which may indeed cause a performance overhead).
    Anyway, I don't want to get into implementation details, I am simply looking for a clear explanation about the matter of "long living" references, and what is mandatory by EJB specification.
    Thanks for any insights....
    I also crossposted to EJB forum -> http://forum.java.sun.com/thread.jsp?forum=13&thread=538526&tstart=0&trange=15

    A locally scoped reference is only on the stack while the cached reference is on the heapOf course, but in the context of what I'm talking about here, that doesn't really matter. The point is that in both cases there is a reference to an EJB object/home, that is used for a longer/shorter time.
    I think the main reason for not caching the references is that is interfere's with the server's ability to manage it's resources. OK, sounds reasonable enough. So why doesn't the specification provide clear rules, even restrective ones that say no caching can be applied? Looks to me as if it would be safe to say that home objects for example are safe to cache working with any EJB server as long as the EJB server isn't restarted. Why isn't it written anywhere?
    It always refers to Handles as "long living" references. How can one measure "long"?
    Now, I may have gotten the wrong picture. Maybe there are some widely agreed issues on this matter, for example that caching SLSB as you've mentioned, and home objects is always safe in the scope of an EJB server life time(from the point in which it starts to the point it goes down).
    The thing is, where ever I looked I saw different strategies, and never it was clear what exactly they came to solve. For instance, an EJBHome service locator that caches the home object as is, vs. a service locator that caches the home handle.

  • Pass Boolean b/t parallel threads

    Dear Labview Board,
    I have two Labview processes that run in parallel.   One performs data input and the other data output.   They where originally designed to run independent of each other, but today I need them to perform some modest integration.   Both processes are very complex, so I would like to avoid a costly rebuild.   I'm looking for a quick and dirty solution.
    I need process #1 (which is loop based) to temporarily hold execution based on a condition (Boolean indicator) in process #2.   I am not familiar with parallel processing techniques in labview, and I'm wondering if I'm making this harder than it really is.   Can I place a wait loop in one process that references an indicator in another process?   What is the easiest way to pass Boolean data between parallel threads?
    Thank you,
    Zach
    Solved!
    Go to Solution.

    F. Schubert wrote:
    It is written in only one place [..] global variable?
    Yes.
    Felix
    "But can't I get away with just using a penny instead of a fuse for now?"
    For the current application and assuming
    1) the code will never change and
    2) if it does change you will be that person and
    3) you will remeber you used a global and
    4) also remeber that gloabls have the potential of a race condition.
    I code by the hour and do so such that my customers can confidently twaek their app without getting me involved. If I have to be involved, then I failed in my goal (sorta like what I do here on the forums )
    So if the question is "can I get away with it?" then yes.
    "Would I allow one of my rookies to do it?" NO
    Ben
    Ben Rayner
    I am currently active on.. MainStream Preppers
    Rayner's Ridge is under construction

  • Sharing EJB references.

    Hi,
    I have two JSP pages which use the same EJB. Both pages are doing their own JNDI lookup for the home interface and do a home.create to obtain the remote interface. The two pages are thus not "sharing" the same reference to the EJB.
    To speed up EJB access, I would have preferred to be able to share the remote reference in session or application scope (=normal stateless EJB behaviour) but unfortunately Oracle does not support the stateless model.
    1) Can I share the same EJB reference between all webserver sessions to avoid the lookup/create penalty? (ie place it in "application" scope)
    2) Failing that, can I share the same EJB reference between all requests in the same session (ie place it in "session" scope)?
    3) In both cases above (or in any other way), can I prevent blocking if an EJB comes across a locked record (see thread "Preventing blocking: EJBs").
    Cheers
    Nic
    null

    I think you might have some fundamental EJB stuff confused. First we would need to know what kind of EJBs you are using. Stateful session, stateless session, entity? With stateless session you need not worry about cleaning up. The client has no control over when the ejbRemove method is called (when the EJB is placed in an inactive state). In fact, it may be called between method calls. In either case, you needn't worry about it. If you are using stateful session beans, I would ask why you are using the HttpSession with them. Stateful session beans provide this functionality for you. If you are using entity beans, there are more things to consider such as CMP/BMP. A short answer without more information is not possible.
    If you have a cluster of machines, or plan on it, putting the remote reference in the session may not actually help performance as binding it to the session will cause the remote reference to be replicated around the cluster.
    If you check the EJB specification, the container is not required to call the ejbRemove method when a client calls the remove method on the remote interface for a session bean. (I assume you are using session since calling remove on an entity will remove the data from the database.) So I would ask what exactly you are trying to accomplish by that call?
    I'll venture a guess that the call, in your case, is unnecessary. If I have assumed something incorrectly, please post more information.
    Hope this helps.

  • How do you pass vi references from one event to another

    I have a vi which gets vi references (thereby loading the vi's into memory) for all the vi's in a given directory when a user clicks a button on the front panel. To do this I use an event structure. My question is whether it is possible to have another event (user button on the front panel) which unloads the vi's from memory. I have tried passing the vi references that are initially generated to the close reference function but whenever I do I get a 'vi reference invalid' error. Does this have to do with trying to pass the vi references between one event and another? If I use a local variable simply pass a reference to another indicator and then probe it, the originally-generated refnum and the local vari
    able refnum match up. However once I try to wire that same indicator to the close reference function I get the 'vi reference invalid' error. Is there a different/better way to unload the vi's from memory based on a user button click? Any suggestions would be welcome.
    Jason
    Attachments:
    Load_Directory_of_vi's.vi ‏57 KB

    Several problems with your code:
    1... Bad idea to use lights as buttons. Yes it can be done, but it's not "natural".
    2... If you've gotta do that, set their mechanical action to "LATCH WHEN RELEASED"
    3... Because of #2, you are getting TWO copies of every array when you click the LOAD VIs light (er... button).
    4... No need for the conversion from path to string and back - use BUILD PATH to append each file name to he folder path.
    5... Set the BROWSE OPTIONS on your PATH control to EXISTING DIRECTORY to allow browsing of directories, not files.
    6... Your code doesn't care whether the file is a .VI file, or a .ZIP file, or a .TXT file, or what. Use the PATTERN input on the LIST function to discriminate.
    7... Your code is only storing the latest refer
    ence, not the array of references.
    8... An ERROR DIALOG on the OPEN REFERENCE function will tell you that you're getting an error. Why? You are asking to prepare a non-reentrant VI for reentrant execution (why use options = 8?)
    9... Because of #8, the latest VI reference is invalid.
    Steve Bird
    Culverson Software - Elegant software that is a pleasure to use.
    Culverson.com
    Blog for (mostly LabVIEW) programmers: Tips And Tricks

Maybe you are looking for

  • Using MD5 to generate Dimension IW Keys

    Hi Guys I had wanted to use MD5 to hash concatenated strings in a dimension table to come up with IW Keys. I must be missing something because I couldn't find much around the net when looking for it. Basically were looking at facts and dimension data

  • SAPGUI JAVA 7.10 rev 3 (OSX 10.5.2): ALV reports freeze

    Dear All, I've tried to use rev 3 of sapgui for java for mac osx. I have serious issues with ALV reports that makes it unusable (rev 2 is ok so far). With big lists ALV freezes after showing about half of the first screen lines. Is anyone experiencin

  • Jsp calling a function in js -- object expected runtime error

    Hi, I have a js file. script.js *function popup( url ) {* newWin=window.open(url,'popupWindow,resizable=yes,menubar=no,status=no,toolbar=no,scrollbars=yes'); newWin.focus(); void(0); and a jsp calling the function in js *<HTML>* *<HEAD>* *<SCRIPT>* *

  • Not able to update Start/End Date with updateUser API

    Hello all, I am trying to update start and end date using the updateUser API, but the dates are not being set. I know the updateUser call works since I tested by changing the user's first name and it worked fine (verified through OIM web app). Below

  • Is it possible to integrate AUR into Apper?

    Hello! At the moment I use pacman and AUR as they suppose to be used (at least thats what I try!) to update and manage my software. Now out of curiosity I installed Apper as GUI for software management. There's two things I don't understand: - Is it