Multiple Listeners for one class?

I have 2 listeners that increment a function
synchronized public void increment()
a long task...
print statements..
It seems that when I run one or the other listener it works fine.
but when both are running then only one of the functions shows up. The
other gets completely ignored even though both listeners are active..
I was wondering if this is an issue where the second increment() is responding but since the first one is running it neglects to show the output.
Since both listeners are on different threads. and responding to the same class would that cause a problem?
The server I send the listeners to seems to be working just fine..
Thank you in advance

okay =). Here is as much as I can put up hopefully it is satisfactory.
I am submitting listeners to Server and waiting for a response.
I wrote an explanation in the run() function.
The three main areas I think are the run(),submitImageOrder() and the Listeners that are doing the incrementing...
public class JavaTest
    /** Creates a new instance of JavaTest */
    String xmlpath = "path";
    Hashtable images,prd;
    OrderManager manager /* gets connection from server */
    int inc = 0;
    int delay = 10000;
    static String IMAGE_ONLY = "Image";
    static String PRODUCTION_ONLY = "Produce";
    static String LABEL_ONLY = "Label";
    static String ALL = "All";
    String[] args;
    public JavaTest(String[] args)
        manager= OrderManager.getInstance();
        images = new Hashtable();
        prd = new Hashtable();
        inc = 0;
        this.args = args;
    public static void main(String[] args)
        System.out.println("start");
        JavaTest test = new JavaTest(args);
        test.run();
        System.out.println("end..");
    public SystemManager getSystemManager()
        SystemManager SysManager = SystemManager.getInstance();
        try
            SysManager.connect(PO_CLIENT_ID, USER_HOST,USER_PORT);   
        catch(Exception e1)
                System.out.println("Failed to setup connection with " + USER_HOST + " at port " + USER_PORT);
                System.out.println("The application will be shut down in 5 seconds. Please try again.");
                System.exit(1);
        return SysManager;
    public void run()
        JobMinderParser parser = new JobMinderParser();
        Entry entry;
        images = parser.createImage(args);
        SystemManager SysManager = getSystemManager();
        inc = 0;
        System.out.println(images.size());
        Enumeration enum = images.keys();
        int y=0;
          Parses XML File and puts all the "Entry classes"
          in a hashtable then the program runs through the hashtable
          submitting it to the manager in the submitImageOrder Function
          Then listens to the response and increments a global field
          called inc when the inc == images.length it has recieved a
          response from all the submitted orders..
        while(enum.hasMoreElements())
            String id = (String)enum.nextElement();
            entry = (Entry)images.get(id);
            String type = entry.getType();
            entry.getLabel().createLabel();
            if(type.equals(IMAGE_ONLY) || type.equals(this.ALL))
                submitImageOrder(entry);
        while(inc < images.size())
            sleep(delay);
        try
          SysManager.disconnect();
        catch(Exception e)
            e.printStackTrace();
    public synchronized void increment()
        inc++;
    public void submitImageOrder(Entry entry2)
       String oxml = createImageOrder(entry);
                    ImageOrderDescription odesc = new ImageOrderDescription();
                    try
                        System.out.println("Parsing oxml...");
                        parseXML(oxml);
                        System.out.println(oxml);
                        System.out.println("Submiting oxml");
                        odesc.setOrderId("Image"+ entry.getId());
                        odesc.setClientId(entry.getClient());
                        odesc.setOriginator("PO_ORIGINATOR");
                        entry.setImageOrderDescription(odesc);
                        manager.submitOrder(odesc,oxml, (OrderStatusListener)new StatusListener());
                        System.out.println("Done...");
                     catch(Exception e)
                       e.printStackTrace();
    public String createImageOrder(Entry entry)
        Vector inputfile,inputdir;
        String orderid;
        Hashtable files;
        inputfile = entry.getInputFile();
        inputdir = entry.getInputDir();
        orderid = "Image" + entry.getId();
        String xml  = "<?xml version=\"1.0\" encoding=\"UTF-16\"?>"
                    + "<!DOCTYPE ImageOrder SYSTEM \"" + xmlpath + "ImageOrder_1.0.dtd\">"
                    + "<ImageOrder ClientId=\"" + entry.getClient() + "\" OrderId=\"" + orderid + "\" Originator=\"IO01\">"
                    +  "<Target/><Format><PCMACFormat ISO=\"2\"/><FormatOptions/></Format><Source>";
                    if(inputfile != null)
                        for(int i = 0; i < inputfile.size(); i++)
                            xml +=  "<EditList EditListPath=\"" + inputfile.get(i) + "\" />";
                    if(inputdir != null)
                        for(int i = 0; i < inputdir.size(); i++)
                            xml +=  "<ParentFolder ParentFolderPath=\"" + inputdir.get(i) + "\" />";
                    xml +=  "</Source><Output ImageFile=\"" + entry.getOutputFile() + "\" Size=\"74\" Type=\"PowerImage\"/></ImageOrder>";
        return xml;
    private void sleep(int time)
      try
        Thread.sleep(time);
      catch (InterruptedException ie)
        System.out.println("Failed to sleep " + time/1000 + " second(s).");
        ie.printStackTrace();
        System.exit(1);
    private String getElementAtt(Document document, String tagName, String attribute)
      NodeList list = document.getElementsByTagName(tagName);
      Node thisStatusNode;
      NamedNodeMap thisNamedNodeMap;
      // Loop throught the list
      for (int i=0; i<list.getLength(); i++)
          thisStatusNode = list.item(i);
          thisNamedNodeMap = thisStatusNode.getAttributes();
          if (thisNamedNodeMap == null) continue;
          if (thisNamedNodeMap.getNamedItem(attribute) == null) continue;
          if (thisNamedNodeMap.getNamedItem(attribute) instanceof org.w3c.dom.Node)
             return thisNamedNodeMap.getNamedItem(attribute).getNodeValue();
      return null;
    private Document parseXML(String xmlOrderStatus)
      DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
      Document document = null;
      // Specifies that the parser produced by this code will validate
      factory.setValidating(true);
      try
        DocumentBuilder builder = factory.newDocumentBuilder();
        document = builder.parse(new InputSource((Reader)new StringReader(xmlOrderStatus)));
      catch(Exception e)
        e.printStackTrace();
      return document;
    private class StatusListener implements OrderStatusListener
        public void onStatus(String str)
            Document document = parseXML(str);
            if(document == null)
                return;
            String state = getElementAtt(document, "Status", "State");
            System.out.print( "Imaging " + state.toLowerCase() + ": " + getElementAtt(document, "Status", "PercentCompleted") + "% completed.\n");
            System.out.println(getElementAtt(document,"ImageOrderStatus","OrderId"));
            if ( state.equals( "COMPLETED" ) )
                String id = "";
                String field = document.getDocumentElement().getTagName();
                    id = getElementAtt(document,"ImageOrderStatus","OrderId");
                    String key = id.substring("Image".length());
                    Entry entry = (Entry)images.get(key);
                    stopListeningForOrder(entry);
                    entry.setStatus("Done");
                    increment();
              return;
            String errMsg = getElementAtt(document, "Status", "ErrorMessage");
            String errCode = getElementAtt(document, "Status", "ErrorCode");
            if(errMsg != null || errCode != null)
               System.exit(0);
}

Similar Messages

  • Multiple SQLNET Listeners for One Oracle Home

    Is it possible to have multiple SQL NET listeners for one oracle home? I do not want have 2 oracle homes in order to accomplish this. Thanks in advance.

    This will allow me to have different security settings for each sqlnet listener? I would like one to require encryption for one specific IP address, and the other not to worry about it.

  • Can you have multiple users for one account?

    Can you have multiple users for one account? if so how do you set it up.
    We are using it for our department and it would be great to see who created what form instead of it being all one name.

    Each person should have their own account. You can easily share the forms with other people in your department. You will be able to see who the author of the form is.
    More information on how to share :
    http://forums.adobe.com/docs/DOC-2462
    Information on how to copy a forms to a different account :
    http://forums.adobe.com/docs/DOC-1390
    Hope this helps
    Gen

  • How do i scan multiple pages for one attachment

    I know how to scan but I don't know how to scan multiple pages for one attachement....Help please

    Hi dagda24,
    You can scan multiple pages into a single document with the scan to PDF option.  Use the following steps to do so:
    1.  Open MP Navigator.
    2.  Click One Clcik.
    3.  Click Save to PC.
    4.  Change the File Type from PDF to PDF (multiple pages).
    5.  Make any other changes as needed, then click scan.
    Did this answer your question? Please click the Accept as Solution button so that others may find the answer as well.

  • How to open multiple sessions for one user?

    Sorry for the silly question but I couldn't find it googling or searching through this forum, so I started wondering whether it's possible in SQL Developer to open multiple sessions for one user. I'm fairly new to SQL Developer and databases in general.
    When I open SQL Developer and connect to a schema, a worksheet opens named MYSCHEMA. If I disconnect then connect, another worksheet opens, named MYSCHEMA~1. I assumed these were different sessions, but if I enter into one worksheet:
    select col1 from my_table where row_id = 1
    -- shows result is 1
    update my_table set col1 = 0 where row_id = 1
    select col1 from my_table where row_id = 1
    -- shows result is 0and then enter into the second worksheet:
    select col1 from my_table where row_id = 1
    -- shows result is 0I would have expected the second worksheet to report 1 because the first worksheet did not issue a COMMIT. Thus, I'd guess both worksheets are the same session? Is that right? If so, how do I have two sessions open simultaneously (opened by same user)?
    I'm trying to implement the code at the bottom of this post, for which testing requires at least two sessions:
    Re: Help with Procedure
    Edited by: tem on Apr 18, 2012 6:44 AM

    Thanks Jim,
    Ctrl-Shift-N doesn't do anything for me. I'm on a mac -- by experimenting it looks like command-N does what you're looking for. This appears to be the same as left-clicking on the "New" icon in the top left corner of SQL Developer, or selecting from the pull-down menu, File > New.
    This opens "Create a New" window that appears to be a wizard. What would I select at this point? Options are: Database Connection, Table, View, Package, ...
    I don't see an option for "Worksheet".
    UPDATE:
    OK, I found that if I select "SQL File", a worksheet becomes available. Perhaps this is what you intended. However, when I issue the command
    select col1 from my_table where row_id = 1;it still returns 0 instead of 1. Hmm, maybe my initial assumption was wrong -- if this is a second (e.g. different) session, should I expect the changes made in the first session in SQL Developer (the UPDATE command) WITHOUT a commit, to be observed in this second session? I thought that changes made in one session were not viewable in a different session until these changes are committed in the first session? If so, how to show this in SQL Developer? I must be missing something basic here.
    Or, is SQL Developer issuing some sort of "auto-commit" without my knowledge?
    Edited by: tem on Apr 18, 2012 8:00 AM

  • Multiple Values For one Condition in Choose From List

    I have used one Business Partner Choose From List in my form but i want to give condition in that choose from list on GroupCode .But the condition will have multiple values like 100,102,104 then how i will write the code to incorporate multiple values for one single condition.

    Hi,
    Check this thread
    How to set a Multiple condition in a single CFL
    Hope that helps,
    Vasu Natari.

  • Multiple Labels for One Order

    Can anybody tell me if it is possible to produce multiple labels for one order. For example a customer orders 4 units. A standard package holds 3 units so an additional package is required for the fourth unit. As a result two packing labels are required. Does OM 11i support this?

    Hi Aj
    Thanks for your quick response. I was think on the same lines and you have confirmed that we will have to split the line into several lines on sales order.
    I am trying to do that now in our ECC box i.e item 10 with payer 1 and item 2 with payer 2. But as soon as I try to change the payer on item 2, i get the following error message which relates to credit management being active.
    I am assuming once we decativate CM, we should be good to go. PLease confirm. Also once its time for billing, will SAP automatically split the billing into different invoices per sales order line item based upon number of payers on the line items?
    PLease confirm your thoughts.
    Regards
    Jai

  • Multiple currency for one vendor

    Hi,
    Is there any way to have multiple currency for one Vendor?

    Hi Siva,
    Yes, It is possible to maintain multiple currency for one vendor. How ? The procedure as follows.
    During vendor creation using T-code XK01 and currency enter input data screen select Extra option on the top of the screen click and display  'Add Purchasing Data'  option click opened new screen and give input data plant, tick mark of the option Data retent.at plant level allowed and tick for OK.
    After that, you have enter multiple currency for the same vendor during vendor creation time, then you will create PO using T-code ME21N the currency field you have fill as you required currency by default first currency of vendor created will be display.
    Hope, it is useful for you.
    Regards,
    K.Rajendran

  • Multiple choose for one parameter

    Hi, does Oracle Report support the multiple choose for one parameter? i used a IN statement inside my WHERE conditions as following
    Select ....
    where ....
    content.style IN (:p_style)
    (content.style is a column in table "content", and "p_style" is a bind variable)
    i want user can have multiple choises on p_style value. but in the parameter form i only can make one choise. Does any one know how to do the multi choise from parameter form? if you do, please help me. Thank you very much.
    Li

    <BLOCKQUOTE><font size="1" face="Verdana, Arial">quote:</font><HR>Originally posted by whl:
    Hi, does Oracle Report support the multiple choose for one parameter? i used a IN statement inside my WHERE conditions as following
    Select ....
    where ....
    content.style IN (:p_style)
    (content.style is a column in table "content", and "p_style" is a bind variable)
    i want user can have multiple choises on p_style value. but in the parameter form i only can make one choise. Does any one know how to do the multi choise from parameter form? if you do, please help me. Thank you very much.
    Li<HR></BLOCKQUOTE>
    you can do that by flowing the stap
    at first you will write a select statement
    select ...
    From ...
    where Style (colomn name) = &style1
    then you create a user parameter soupose wich name is P_style and which valus is x, y, and z you should enter another value soupose that name is 'All' (All means x + y + Z)
    then you write in after parameter form trigger...
    IF :P_style = 'All' then
    :style1 := null;
    Else :style1 := 'and style (style means your column name) = :P_style;
    end if;
    null

  • Multiple Vendors for one Document Number in BW

    Hello All,
    We are getting Multiple Vendors for one document in BW. In R/3, standard table and RSA3, we are able to see correct vendor where as when it is coming into BW it is showing incorrect vendor in PSA and Data Target.
    All issues are coming for Process Key 1 only.
    *For Example:*
    Document: 9400000007
    Schedule Line:1
    Doc Item: 1
    Vendor:
    0010019229 - Incorrect Vendor
    0010018962 - Correct Vendor
    Committed Quantity: 0
    Doc Type:
    ZNB
    ZNPP
    Process Key: 1
    Not sure how to upload screen shot.
    Please suggest.
    Thanks,
    Vijay

    Hi ,
    Are you loading for the first time ? If yes have you checked Transaction BF11 settings.
    Regards
    Rahul Bindroo

  • Multiple payers for one sold to party

    Hi All,
    Can we have multiple payers for one sold to party?
    Thanks

    Hi
    Yes, you can have multiple PAYER for one Sold-to-party (only in the Customer master).
    This Partner relationship is maintained in two places. They are,
    > Customer master ( sales area data > partner function tab )
    > Sales documents (at Header level and Item level)
    In Customer master data, you can have multiple partners ( e.g, multiple Payers) for one Partner function( e.g, SH,BP,PY).
    But in Sales document, you can have only one Partner for one Partner function.
    So, you can have only in Customer master data multiple pertners. So, first create the different Payers through XD01 ,choosing Account group "Payer".
    Then assign all those PAYERS  in the master data of the Sold-to-party by going in the change mode XD02 and save it.
    When you create the Billing document, system will give a pop-up of those list of Payers and you have to choose one . You can have only one Payer in one Billing document.

  • Can we have more than one contructor for one class?

    I need to provide more than one constructor for one class because I need to have one parameter passed to one constructor and many to another. Is that possible and how it will affects in the instantiation of the object?
    Thanks again
    Jorg3

    One more note about constructors...
    if you define a constructor to take argument(s)
    and don't define the default constructor it is not available.
    Example
    public class myClass
       public static void main(String args[])
          // Ok
          myClass c = new myClass("Hello World");
         // Not Ok
         myClass c2 = new myClass();
       } // main
       public myClass(String name)
          named = name;
       } // myClass
      String named = null;
    } // myClassIf you want to be able to construct the object with the default and parameter constructors, you must declare them all...
    public class myClass
       public static void main(String args[])
          // Ok
          myClass c = new myClass("Hello World");
         // Ok
         myClass c2 = new myClass();
       } // main
       public myClass()
          named = "No Name";
       } // myClass
       public myClass(String name)
          named = name;
       } // myClass
      String named = null;
    } // myClass

  • Maximum no'of Objects for one class

    Hello friends
    Please, tell me....Maximum no'of Obects for One Java class.
    Thanks & Regards
    S.Rajakrishna

    Is there any limit of creating the objects for One class?Instantiated objects go into the heap. There is only one heap for the whole JVM. There is no correlation between objects in the heap and the individual class files.
    100,000 objects may or may not fit into the heap. In general they probably will. If you don't, then yes, you'll get an Out Of Memory exception.
    Regardless there is no excuse for loading 100,000 objects just to render a JSP! You don't imagine your user is going read all of them do you? Restrict them to the number of objects that the user is actually going to be able to handle at any given time.
    You can do this by putting WHERE clauses on the hibernate query, and/or by setting limits (setFirstResult and setMaxResult) on the Query object before listing it.

  • Lightroom 5 slowdown, my post processing times have tripled and the develop tasks take multiple seconds for one adjustment, Please Help. . . .

    my post processing times have tripeled and the develop tasks take multiple seconds for one adjustment, Please Help. . . .

    my post processing times have tripeled and the develop tasks take multiple seconds for one adjustment, Please Help. . . .

  • On my contact list I have multiple names for one person

    On my contact list I have multiple names for one person.

    The Account Owner can see the call/text logs for all lines on the account, but each line needs its own My Verizon account for messaging and backups.  Those lines will be listed as Account Members and will have limited info. available to them regarding the account.

Maybe you are looking for

  • Query Active Directory + Problem with thumbnailPhoto

    Hi<o:p></o:p> I have a problem and I don't know if it is my SQL Query, so here goes <o:p></o:p> I have a view on my SQL server that Queries our Active Directory. I can see that there is data in the table.<o:p></o:p> But when I try to use the Image in

  • Can anybody help me with that crash report?

    Process:         Logic Pro X [522] Path:            /Applications/Logic Pro X.app/Contents/MacOS/Logic Pro X Identifier:      com.apple.logic10 Version:         10.0.0 (2911.1) Build Info:      MALogic-2911035000000000~1 Code Type:       X86-64 (Nati

  • I upgraded to itunes 6.0.4, it only launches when connected to the internet

    i recently upgraded my itunes to 6.0.4, ever since i did that, the itunes doesn't launch except when i have internet access, when i try to launch it anywhere else it says application not responding, what do i do?

  • Line-in Port Question

    Okay, I understand now that the port I thought was a mic port on my 2008 Macbook Pro is a line-in port. What I don't understand though is why my headset worked fine with it up until last week. Can anyone help me understand why this would be?

  • Why can't I download adobe flashplayer.  I have tried many times on both my computers

    Why can't I download Adobe Flash player.  I have tried many times on both computers.  It says it is downloaded, but I can't find it.