Multithreaded client: which listener to use?

I've got a client program that needs to talk to a server. Instead of building in all the RMI and server-aware stuff into the client, I'm making a layer between then, called ClientHookup. This way, we can write alternate front-ends, and just make sure they all talk nicely with ClientHookup.
ClientHookup will receive requests for data from the client (returning a request ID), spawn a thread to process the request, and then notify the client when the data has arrived. This way the client is free to do things while data is coming, it's not just locked up.
I need to make my client implement a listener interface of some sort (like ActionListener), and register this with the ClientHookup, so I can snag events as data is returned.
Am I doing this right? Is there an example somewhere I could look at? What kind of listener should I implement? What kinds of events do I throw?
ActionListener seems to be in java.awt, but I don't really need that stuff. There is an EventListener, but it seems to be a "tagging" interface, whatever that is.
Thanks!
--- Eric

Actually, I found a very wonderful explanation of how to use events and listeners (how to build you own, basically) in another thread. So, never mind! I have what I need.
--- Eric

Similar Messages

  • Mail clients, which do you use?

    Just curious what mail clients people use. I am always interested in improving my workflow.
    Some of my friends are 100% gmail. That is all they use.
    Others use gmail when they are out and about, but use a desktop mail app when they are at home (fetch via pop).
    I tend to use a desktop client (claws), and crappy ol' squirrelmail (from my isp) when I dont have my laptop. I have considered going gmail, but I cant bring myself to do it. I have a gmail account, but I mostly use it for garbage...

    I tried out numerous applications. But I always come back to Thunderbird. I don't have really special things I like to do with my mail-clients, so Thunderbird does everything I need.
    It has GnuPG-Enigmail support, with automatic download of missing keys, a really good Spam filter.
    And most of all I really like that it stores accounts, mails and even extensions in one folder.
    With an initial "thunderbird -ProfileManager" I can use the same mail-folder from different Computers or Distros/BSs and have all my data there.
    I really like KMail but the settings and mails are too cluttered, to really have it portable or distributed.
    Downsides:
    -It integrates badly with KDE and GNOME, has ugly Win95-ish interface, where it shows through that it's not really good GTK
    -It loads and repaints slowly

  • Client, which should always listen to the server

    Hello,
    I have question regarding socket communication using standard java means. Since I would call myself a beginner in java please be patient and generous. Every hint would be appreciated.
    In my scenario I have a server that sends messages via TCP/IP from time to time to its client. The server is up and running and I cannot change it. My part is the implementation of a client that should receive the message of the server. The client will handle this message and eventually send a response or follow-up to the server.
    So far so good. The scenario is implemented and working. But my problem is the way I convinced the client to listen all the time. I use an endless while-loop (while (true) {...}) and check whether the input stream of the socket contains any data. As soon as there is any data I fetch and process this data. Afterwards the loop goes on. I am wondering whether this consumes a lot of CPU workload. Is there a better way to always listen to the server? I assume the while-loop is not very clever. Any hints would be greatly appreciated.
    Thanks in advance for your help and comments
    Slarti

    Hello pkwooster,
    thanks a lot for your quick reply.
    It was my fault that I have not been precise enough. Actually I already have one thread that listens to the server and another one that will send answers. Both are created and started in main. Nevertheless I still have an endless loop in the thread, which listens all the time.
    The application itself does not have any UI since it should run in background. So the main method creates and starts the threads. As soon as the listening thread receives data it eventually passes it to a third thread, which processes the data. Afterwards the sending thread might be called to respond to the server.
    I am sorry but I did not understand how the thread can wait for data to arrive without using an endless loop.
    Best regards, slarti

  • Which listener should be used in a standalone grid infrastructure env?

    gurus:
    I installed a 11.2.0.2 standalone grid infrastructure on a linux box and created a database manually. I then used netca to create my listener which created 2 listener files:
    a. under my DB home:
    aml6:/u00/app/oracle/product/11.2.0/dbhome_1/network/admin > cat listener.ora
    # listener.ora Network Configuration File: /u00/app/oracle/product/11.2.0/dbhome_1/network/admin/listener.ora
    # Generated by Oracle configuration tools.
    LISTENER_ETL =
    (DESCRIPTION_LIST =
    (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = aml6.lynk.lynksystems.com)(PORT = 1521))
    (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521))
    ADR_BASE_LISTENER_ETL = /u00/app/oracle
    b. under my grid home:
    aml6:/u00/app/11.2.0/grid/network/admin > cat listener.ora
    LISTENER_ETL=(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=IPC)(KEY=LISTENER_ETL)))) # line added by Agent
    ENABLE_GLOBAL_DYNAMIC_ENDPOINT_LISTENER_ETL=ON # line added by Agent
    I observed that the one under my DB home was the one that really got used when I tried to logon to a database.
    Here are my questions:
    1. what is the use for the listener under my DB home?
    2. what is the use for the listener under my grid home?
    3. the grid infrastructure document says that the default home for listener and tnsnames files are grid home, however, it seemed that I have to use the listener under my db home directory.
    4. which listener is the ASM instance use?
    Thanks a lot for your help.
    dz

    Raj Mareddi wrote:
    Thanks Levi and Sebastian.
    We have separate listeners in DB homes for Stand Alone grids.
    Cluster Grids have got the listeners (SCAN..etc) running out of Grid Home. Still, we have exceptions for the Cluster grid for EBS databases where SCAN is not supported yet and still have a separate listeners for the databases.
    This OTN doc also describes a listener in the DB home: http://www.oracle.com/webfolder/technetwork/tutorials/obe/db/11g/r2/prod/install/gridinstss/gridinstss.htm
    Hi Raj,
    In this OBE, the author explains why he is setting a new Listener for ASM.
    To Configure EM Database Control to manage ASM, perform the following steps:
    To manage the ASM instance in Enterprise Manager Database Control. you must configure the ASM Instance as a target.
    When you configure the ASM target, you must provide the port for the ASM listener.
    The Grid Infrastructure installs a listener by default on port 1521, and configures the ASM instance to use this listener.
    In this tutorial the database is already installed and has a listener configured on port 1521, the Grid Infrastructure places a listener on port 1522 and the ASM instance is registered with the grid listener.Before Install Grid Infrastructure he already had a database running with the Listener configured and running.
    To ensure that the service of ASM will be registered in the Listener of same release he set a new Listener using GUI HOME.
    This procedure is correct because the Grid Infrastructure (ASM) is the highest release (So, it's necessary configure Listener in same release), to not use a Listener with prior to release of the Grid Infrastructure(ASM) he created new Listener.
    He also could deconfigure the Listener of Oracle Home (database) and configure in the GUI Home. It's a matter of choice.
    Observing requirement of the paragraph below, we can set listener from anywhere there is no restriction, it is a matter of best practices only.
    The release of the listener must be the same as or later than the latest release of all Oracle databases being serviced through the listener.Cheers,
    Levi Pereira
    Edited by: Levi Pereira on Nov 8, 2011 4:23 PM

  • Which Listener I should use if I drag and Drop an image/icon into a JPanel?

    Dar Friends:
    Happy new year.
    I try to drag and Drop an image/icon into a JPanel, and hope I can immediately detect it after DND,
    Which Listener I should use in this JPanel if I drag and Drop an image/icon into a JPanel??
    Thanks

    Thank camickr .
    I can dnd an image into a JPanel called JPanelOld already, I hope to use another JPanel or JTree to listen to any Dropped Image in JPanelOld later on so I can take some action in another JPanel or JTree.
    so what kind of Listener I should use for my purpose??
    where to add this Listeners??
    Happy New Year.

  • Which listener should be used for JTextArea

    Hi,
    I need to add a listener for JTextArea particualy when
    the text in the jtextarea is changed. I don't think
    mouse listener is enough, since the user can use tab to
    get to the jtextarea and edit the text. In this case,
    which listener should I use. Sample code would be
    helpful.
    In addition, I have a problem with the jtextarea that
    when user uses tab to go to different gui components,
    such as jtextfield, jcombobox, jtextarea, jlist, etc, the
    tab stays in the jtextarea and keeps appending to it. It does
    not go to next component, such as jlist. How can I make it
    work?
    Thanks in advance,
    Pin

    It doesn't work. Are you using 1.4 or 1.3? I am using
    1.4.
    In the 1.4 API, it says that isManagingFocus is
    "Deprecated".
    Here is what I have:
    JTextArea descrptArea = new JTextArea() {
    public boolean isManagingFocus() {
    return false;
    descrptArea.setRows(3);
    descrptArea.setLineWrap(true);
    descrptArea.addKeyListener(new KeyAdapter() {
    public void keyTyped(KeyEvent e) {
    // DO SOMETHING
    I found the following code which says it will do it.
    However, I got the exeception:
    java.lang.ClassCastException:
    n: javax.swing.KeyStroke
    at java.util.TreeMap.compare(TreeMap.java:1081)
    at java.util.TreeMap.put(TreeMap.java:459)
    at java.util.TreeSet.add(TreeSet.java:205)
    Set forwardTraversalKeys = new TreeSet();
    forwardTraversalKeys.add(KeyStroke.getKeyStroke('\t'));
    forwardTraversalKeys.add(KeyStroke.getKeyStroke(KeyEven
    .VK_TAB,
    InputEvent.CTRL_MASK));
    textArea.setFocusTraversalKeys
    (KeyboardFocusManager.FORWARD_TRAVERSAL_KEYS,
    forwardTraversalKeys);
    Set backwardTraversalKeys = new TreeSet();
    backwardTraversalKeys.add(KeyStroke.getKeyStroke(KeyEve
    t.VK_TAB,
    InputEvent.SHIFT_MASK));
    backwardTraversalKeys.add(KeyStroke.getKeyStroke(KeyEve
    t.VK_TAB,
    InputEvent.SHIFT_MASK |InputEvent.CTRL_MASK));
    textArea.setFocusTraversalKeys(
    KeyboardFocusManager.BACKWARD_TRAVERSAL_KEYS,
    backwardTraversalKeys);
    Any idea???
    PinI'm not using 1.4 but the class cast exceptions look like they come from : Set forwardTraversalKeys=new TreeSet() etc
    try : TreeSet forwardTraversalKeys=new TreeSet()
    you cant cast from a Set to a TreeSet because a TreeSet is a Set but a Set is NOT a TreeSet.
    hope this helps.

  • CUA can be used between 2 clients which are in the central system

    Hi
    Question 1:
    In case of CUA, we have the conecept of central system and child systems.  From Central system we will be able to administer child system.  Buy my question is can we implement     CUA with the clients which are also on the central system ?
    Question 2:
    Normally LDAP is connected to central system and central system inturn will be connected to child systems. But Can we connect Central system and LDAP to the child system at a time ? Is there any situaitons where we will come up with this situations ?
    Thanks
    Kumar

    Hi,
    > In case of CUA, we have the conecept of central system and child systems.  From Central system we will be able to >administer child system.  Buy my question is can we implement     CUA with the clients which are also on the central system ?
    >
    Yes, you can control other clients of the central system through CUA.
    > Question 2:
    > Normally LDAP is connected to central system and central system inturn will be connected to child systems. But Can we >connect Central system and LDAP to the child system at a time ? Is there any situaitons where we will come up with this >situations ?
    If you want to use CUA then your LDAP must be connected to your central system.
    Thanks
    Sunny

  • Properties that are updateable and which ones not using epma batch client

    Can anyone provide list of properties (HFM/Essbase etc.) that are updateable and which ones not using epma batch client?

    This will be documented in the batch client and related documentation on the EPM documentation portal

  • Which listener should I use?

    Now I want to listen the JFrame's location changing event. Which listener should i use?

    Add a ComponentListener to the JFrame

  • Which Listener in PJC  can I use to change for example the UPDATE_ALLOWED P

    Hi,
    i have wrote a PJC that change a few properties of a Forms object. For example a label, the foreground color...
    My Problem is, with which Listener can i change a few forms objects at the same time.
    For example to change the Update Allowed Property for 5 forms objects at the same time?
    What is a customListener?
    Thanks
    Wolle

    I thought a VBUTTON or VTEXTFIELD is a origin FORM
    CLASS not a swing CLASS OR?
    Forms is based on Java not on Swing! I can switch the
    backgorund color the enable Property of a forms
    object, so i thought every forms property is a
    property in the id CLASS.
    WolleSo, you think that Swing is not Java ?
    Ok, have a good luck ;o)
    Francois

  • Design Problem : How to design/code a java client which is deployed to all the machines in a cluster and make sure that only one of the java client is active

              hi ,
              I have to design a java client (which is basically a JMS message listener)which
              is deplloyed to all the servers in the cluster. But as these are message listeners,
              i want only one of the instance to be active at a time.
              If the server on which the client is active goes down , I want the second server
              to start listening to messages.
              How do i design this ? Also is there a public api for multicasting that we can
              use ?
              Anybody has an idea on how to go about this..
              Thanks
              nisha
              

    Hi Nisha,
              Failover message listeners? Sounds like you want MDBs, which are deployed on all nodes in a
              cluster. If your JMS destination is a queue, then only one MDB will pick up the message. And just
              like any other ejb service, MDBs failover.
              Gene
              "Nisha" <[email protected]> wrote in message news:[email protected]..
              hi ,
              I have to design a java client (which is basically a JMS message listener)which
              is deplloyed to all the servers in the cluster. But as these are message listeners,
              i want only one of the instance to be active at a time.
              If the server on which the client is active goes down , I want the second server
              to start listening to messages.
              How do i design this ? Also is there a public api for multicasting that we can
              use ?
              Anybody has an idea on how to go about this..
              Thanks
              nisha
              

  • Why remote listener is used in RAc environment

    why remote listener is used in RAc environment

    I'm sure there is something in some concepts papers anywhere on tahiti.
    But as I'm as lazy to search as you are, I will try to answer:
    local_listener is the listener which serves the instances which register to it (as local_listener).
    remote_listener(s) should be all the listeners which serve the other instances belonging to the database.
    every pmon tells all the local and remote listeners the load of the system where it resists.
    In server side load balancing, the listener will redirect the client to the listener on the system with the lowest load.
    hth
    Martin

  • Always On: Detect from client which replica is active

    Since the client simply connects to the listener and gets an IP, is there a way through either the client object model or a query which I can use from the client to determine which replica is on the other end of the connection? 
    Thanks,
    Philo
    Philo Janus, MCP Bridging business & Technology: http://www.saintchad.org/ Telecommuter? http://www.homeofficesurvival.com/ Author: Pro InfoPath 2007 & Pro InfoPath 2010 Pro PerformancePoint 2007 Pro SQL Server Analysis Services 2008 Building Integrated
    Business Intelligence Solutions

    Hello,
    If you just want to know which replica you are on, you can check @@ServerName, if the replica can be hosted on a FCI then you'll want to check the node's physical name through SERVERPROPERTY('ComputerNamePhysicalNetBIOS').
    Is this what you're after?
    -Sean
    The views, opinions, and posts do not reflect those of my company and are solely my own. No warranty, service, or results are expressed or implied.

  • How to identified which instance is associated with which Listener

    Hi all,
    i created one DB instance. suppose named as "B". but there is already another DB instance present. Named as "A".
    Then i created one listener for DB instace "B".
    Now my Que. is that HOW i can identify which instance is associated with which Listener,.
    2) if i create listener then a service also created. if i stopped that service and then can i fire query OR Login again, WHAT will be the expected result.
    I tried by asking people for my answer. but not satisfied.
    Please Help me For this.
    Thanks in Advance

    see the file listener.ora. path is usually, $ORACLE_HOME/network/admin/listener.ora
    You will see which listener is associated with which file,
    Details will be usually like this
    >
    LSNR1 =
    (DESCRIPTION_LIST =
    (DESCRIPTION =
    (ADDRESS_LIST =
    (ADDRESS = (PROTOCOL = TCP)(HOST = instance1)(PORT = 1666))
    LSNR2 =
    (DESCRIPTION_LIST =
    (DESCRIPTION =
    (ADDRESS_LIST =
    (ADDRESS = (PROTOCOL = TCP)(HOST = instance2)(PORT = 2666))
    >
    >
    if i create listener then a service also created. if i stopped that service and then can i fire query OR Login again, WHAT will be the expected result.
    I tried by asking people for my answer. but not satisfied.
    >
    A listener is used when a client wants to connect to the database server. If you are logging in directly on the server without using instance name, then you can login even if you stop the service.
    check this,
    C:\Windows\system32>lsnrctl stop
    LSNRCTL for 32-bit Windows: Version 10.2.0.3.0 - Production on 03-MAY-2011 23:06
    :22
    Copyright (c) 1991, 2006, Oracle.  All rights reserved.
    Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=EXTPROC1)))
    The command completed successfully
    C:\Windows\system32>sqlplus ganesh
    SQL*Plus: Release 10.2.0.3.0 - Production on Tue May 3 23:06:36 2011
    Copyright (c) 1982, 2006, Oracle.  All Rights Reserved.
    Enter password:
    Connected to:
    Oracle Database 10g Enterprise Edition Release 10.2.0.3.0 - Production
    With the Partitioning, OLAP and Data Mining options
    SQL> select * from dual;
    D
    X
    SQL>But if you try to connect from a client, or use the instance name while connectineg
    you get the error like this,
    SQL> conn ganesh@ganesh
    Enter password: ******
    ERROR:
    ORA-12541: TNS:no listener
    Warning: You are no longer connected to ORACLE.
    SQL> If you see, I used the instance name @ganesh.
    G.

  • Design Pattern for multithreaded client server program

    I asked this question in another post, but with other stuff, so I'll distill this one.
    I am creating a multi-threaded client server program (just for learning - a chat program at this point). I built the server and client in swing, and I'm wondering what the best design pattern is for this setup. Right now all the swing stuff is in the MyServer class. In that class I have a loop accepting client connections to the serverSocket and creating a new MyServerThread (threaded client connection).
    The problem is that all the work of creating input streams, interacting with the server, all that stuff is done in the MyServerThread class, but I want that text to be written up to the Swing objects - which is in the MyServer class. So right now in the MyServerThread class I pass the MyServer object into it, but I'm not sure if that is really the most robust thing to do. Does anybody have any suggestions as to how this should be done. If somebody has an article they'd like to point to I'll check it out too. But if it's just the run-of-the-mill multithreaded client-server article, I've read alot and most don't specifically address my question.

    Thanks for the reply Kaj, and I think I'll keep my design for now, since it's just quick and dirty. I've read the MVC concept a while ago and I'll revisit it again when I get more serious. But I have a question, why should I be using a callback interface, why an interface at all? And then make MyServer implement that interface...why not just pass MyServer to the thread object? Or is there something down the line that I did not forsee?

Maybe you are looking for

  • Why won't my ipod download apps

    My iPod wont let me download apps. I downloaded hey tell and got a message saying cant connect to iTunes store. I tried another app (bejeweled blitz) and it just said waiting when i reboot the ipod it just said unable to purchase app. My internet is

  • Cannot see all my pictures in apple tv 2

    I noticed that in my apple tv 2, I'm not seeing all my pictures from my iphoto library even though I have selected to share entire library.  I have tried many things like editing file names to end with .jpg, create a new library and restore previous

  • IS THERE ANY MALWARE SOFTWARE FOR MAC

    I am hoping someone can help me with this I am searching for malware detection and removal software for my MakBook Pro.  I am about ready to throw it threw a window and use my windows desktop (which is what I am using to ask this question).  When usi

  • Urgent - Error when opening web template

    Hello, I was trying to open few CRM SAP standard web template in WAD. When I try to open the web template, getting the following error: 'The selected web template contains HTML fragments, non-supported web items or it is not designed to be edited wit

  • Basis in computing for breakdown duration

    Hi All, Good afternoon. I would just like to ask as to what is the basis in computing the breakdown duration generated upon completing a breakdown report? Is it standard that it is computed based on 24hrs a day? If it is, is there a way to change it