How to implement a time watch for an object

Greetings!
I have a container called TupleSpace which consists of elements of type Tuple. Among the attributes, the Tuple also has a "time to live" (the maximum amount of time its presence is allowed on the TupleSpace). After this amount of time passes it should be automatically deleted from the TupleSpace. My question is: what is the best mechanism to implement this ?
My solution so far looks like this:
public void removeExpiredTuple(){
// ts = instance of TupleSpace class
          for (int i = 0; i < ts.size(); i++){
               ITuple currentTuple = (ITuple) ts.elementAt(i);
               long tupleAge = System.currentTimeMillis() - currentTuple.getTimeSubmitted();
// currentTuple.getTtl() = retrieves the Tuple's "time to live"
               if (tupleAge > currentTuple.getTtl())
                    ts.remove(i);
     }but I am not at all satisfied with it
Thanks in advance for your answers
Edited by: OctavianS on Jan 18, 2008 12:10 PM

ok, I'll give it a try and come back with a reply
LE: problem solved. thx again
Edited by: OctavianS on Jan 22, 2008 3:56 PM

Similar Messages

  • How to Implement a Time Limit Feature in an Online Test Application ?

    I am creating an Online Test application. The time limit can be stored for a Test in the database.
    How to implement a time limit such that when the test is started (user clicks on the Start button to go to the fragment containing the Questions) the time left is shown and the test ends (goes to home page) when the timer reaches zero.
    Thanks

    Hi,
    timestamp is a date and thus cannot be used directly to determine seconds passed. So what you need to do is to build the difference between a saved time stamp and the current time.
    http://docs.oracle.com/javase/1.4.2/docs/api/java/sql/Timestamp.html
    So if you have two time stamps, then calling getTime() on each and building the difference gives you a value, which is millisecond. So to get this to an int value you divide it by 1000
    Frank

  • How may implementations can we have for a BaDI?

    How may implementations can we have for a BaDI?

    if BADI check Multi-USE , then u can
    Multiple-Use Business Add-Ins
    You can differentiate between single-use and multiple use Business Add-Ins. The distinction is based on the procedure or event character of an enhancement. In the first case, the program waits for the enhancement to return something, usually a return code. A typical example could be a benefit calculation in HR. Depending on the implementation, alternative calculations can be executed. With multiple use add-ins, an event that may be of interest to other components is processed in program flow. Any number of components could use this event as a “hook” to hang their own additional actions on to.
    In addition to importing parameters, you can also use changing parameters for multiple-use Business Add-Ins. There is no sequence control for multiple-use implementations of BadIs. Therefore, using changing parameters can cause problems. There is no guarantee that implementations will not overwrite the results of previous implementations. Sequence control is technically impossible, since at the time of the definition the interface does not know which implementations there will be and which parameters will be changed by implementations. It is not possible to have a decision as to which implementation should be executed before which other (future) implementation.
    Example:
    In a particular application, you want to be able to continue processing indexes after another component has saved data (in other words, the system should allow you to use an add-in after saving). Since this point in time can be useful for different purposes, you can create an enhancement here that can be used by multiple subscribers.
    To create a multiple-use Business Add-In, proceed as follows:
           1.      Define an add-in and select the Multiple Use checkbox from the Administration tab.
           2.      Define an interface with the method OBJECT_SAVED'and the importing parameter OBJECTNAME.
    Calling your enhancement in the application program:
    program event.
    data exit_obj type ref to if_ex_event.
    call method cl_exithandler =>get_instance
         changing instance = exit.
    form save_object using obj_name type c.
    update …
    call method exit_obj->object_saved
         exporting objectname = obj_name.
    endform.
    For the caller it is irrelevant whether (and how many) subscribers use the event as a starting point for further actions. The active implementations are called in the adapter method.
    more in http://help.sap.com/saphelp_nw04/helpdata/en/ee/a1d548892b11d295d60000e82de14a/content.htm
    Regards
    Prabhu

  • How to Implement N-Level Approval for Bid,Live Auction,PO,Contract ?

    Hi Experts,
                  I am new to SRM 5.0. My requirement is how to implement N-Level Approval for Bid, Auction, PO and Contract? Which steps should I follow for        N-Level Approval? Can any one send me sample code and name of BADI where I have to implement the code.
    Abhijeet Panse

    Hi
    Please check for <b>BBP_WFL_APPROV_BADI</b> using SE18 transaction for relevant Code as well and standard SAP documentation.
    Related sample code and other useful pointers ->
    WS14500015 is not working for Multilevel approval
    Re: SRM / Shipping cart
    Re: N Step Approval BADI - BBP_WFL_APPROV_BADI
    Re: N-step BADI workflow
    http://help.sap.com/saphelp_srm50/helpdata/en/8b/4fa9585db211d2b404006094b92d37/content.htm
    http://help.sap.com/saphelp_srm50/helpdata/en/2c/e68d406b305537e10000000a1550b0/frameset.htm
    http://help.sap.com/saphelp_srm50/helpdata/en/17/40a86c773d6c41801d78af1a34b90f/frameset.htm
    Multiple Implementation For BBP_WFL_APPROV_BADI
    Re: Help needed on N-Step Approval WFL for SC
    Re: N-Step 14000109 workflow - Unable to identify Approvers
    Do let me know.
    Regards
    - Atul

  • How can I buy apple watch  for the space black stainless steel case and the black sport band for one order?

    How can I buy apple watch  for the space black stainless steel case and the black sport band for one order?

    Unfortunately no. I asked the same question when I went to the local Apple Store for my "try on" and as of now you would have to order the watch with the metal link band and the black sports band separately.

  • How to extend the time line for the premiere on mac pro mavericks

    how to extend the time line for the premiere on mac pro mavericks

    Wrong place.
    Try the Adobe Premiere forum.
    http://forums.adobe.com/community/premiere
    Good luck,
    x

  • How to analyse the time taken for a query

    Hey gurus ,
                          How to find the time taken for a query to execute .
    Regards,
    Venkatesh

    Hi,
    Time taken to execute a query = FRONT END TIME + OLAP TIME + DB TIME.
    front end time is time taken to do format in BEX.
    olap time is time taken to aggegate data in OLAP buffer.
    db time is tme taken to collect data at data target.
    to fine all these information
    goto RSRT -> give query name -> execute+debug -> it will display all the fields > check fields what ever u want.
    Regards,
    Haritha.

  • How to implement real-time refresh datas in obiee?

    How to implement real-time refresh datas in obiee?

    Can you elaborate more...
    If you want to see refreshed data in OBIEE Reports, you need to implement Caching mechanism based on how you often refresh warehouse..
    [http://download.oracle.com/docs/cd/E05553_01/books/admintool/admintool_QueryCaching6.html]

  • How to Implement the Search page for Workflow Notifications?

    Hi All,
    I want to implement the new Search page for Workflow Notifications. Search page containing Company, Paygroup, Source, Initiator, Supplier Name, From date & To date fields. These fields(Poplist & Calendar) are getting the values from different tables and these fields are not in WF_NOTIFICATIONS table only Initiator & dates are there. After selecting the values in all fields or one field based upon these values I want to display the all Workflow Notifications ( Those are satisfy the search criteria only not all ) in Advance Worklist Table RN in the Notifications page. Is it possible to create the Search page based upon the above scenario if Yes Let me know how to implement this search page for Workflow. Page was designed but how to get the sortlisted Notifications and how to pass these values to next page?
    Thanks in advance.
    Edited by: user635152 on Nov 13, 2008 10:53 AM

    Hi Guru,
    I crete the Search page having 5 poplists and select the values from dropdown list and click GO button it serch the records and displays that records in ResultsTable in same page.
    My case, Search page is running fine if I select the values and click GO button page is refreshed without errors but I am unable to displays the records in ResultsTable.
    What I am missing?
    My Select Stmt:
    SELECT * FROM      
    (select wn.nid notification_id
    ,ou.name company
              ,I.PAY_GROUP_LOOKUP_CODE paygroup
              ,'AP' source
              ,pf.full_name initiator
              ,pv.vendor_name supplier_name
              ,I.GL_DATE FROM_TO_DATE
    from ap_invoices_all i
    , po_vendors pv
         , hr_operating_units ou
         , per_all_people_f pf     
         , FND_USER FU
    , (SELECT trim(substr(substr(substr(WN.subject,(instr(WN.subject,'Invoice ') + 8),100),1,100),
    1,instr(substr(substr(WN.subject,(instr(WN.subject,'Invoice ') + 8),100),1,100),' for'))) inv_no
    ,notification_id nid
    FROM WF_NOTIFICATIONS WN
    WHERE WN.MESSAGE_TYPE = 'APINV'
    AND WN.STATUS NOT IN ('CANCELED','CLOSED')) wn
    where i.vendor_id = pv.vendor_id
    and i.invoice_num = wn.inv_no
    and i.WFAPPROVAL_STATUS = 'REQUIRED'
    and pv.vendor_name = nvl(:vendor_name,pv.vendor_name)
    and i.org_id = OU.organization_id
    AND OU.name like nvl(:company_name,name)
    and i.pay_group_lookup_code = nvl(:pay_group,i.pay_group_lookup_code)
    and exists (select ad.invoice_id
    from ap_invoice_distributions_all ad
    where ad.invoice_id = i.invoice_id
    and ad.accounting_date between nvl(:from_date,ad.accounting_date)
                                       and nvl(:to_date,ad.accounting_date))
    and 'AP' = nvl(:source,'AP')
         and i.created_by = fu.user_id
         AND fu.EMPLOYEE_ID = pf.person_id
         AND pf.full_name like nvl(:initiator, pf.full_name)
    UNION ALL
              select po_num.nid notification_id
              ,ou.name company
              ,ps.PAY_GROUP_LOOKUP_CODE paygroup
              ,'PO' source
              ,pf.full_name initiator
              ,pv.vendor_name supplier_name
              ,P.CREATION_DATE FROM_TO_DATE
         from po_headers_all p
         ,po_vendors pv
              ,po_vendor_sites_all ps
              ,hr_operating_units ou
              ,per_all_people_f pf
         ,(select trim(substr(wn.subject,24,instr(wn.subject,' for')-24)) po_no, notification_id nid
              FROM WF_NOTIFICATIONS WN
         WHERE WN.MESSAGE_TYPE = 'POAPPRV'
         AND WN.STATUS NOT IN ('CANCELED','CLOSED')
         and wn.subject like 'Standard Purchase Order%') po_num
         where p.SEGMENT1 = po_num.po_no
         and p.vendor_id = pv.vendor_id
         and p.org_id in(select organization_id
         from hr_operating_units
         where name like nvl(:company_name,name))
         and pv.vendor_name = nvl(:vendor_name,pv.vendor_name)
         and p.AUTHORIZATION_STATUS = 'IN PROCESS'
         and p.CANCEL_FLAG = 'N'
         and 'PO' = nvl(:source,'PO')
         and p.agent_id = pf.person_id
         and pf.full_name like nvl(:initiator, pf.full_name)
         and pv.vendor_id = ps.vendor_id
         and ps.org_id = ou.organization_id
         and ou.name like nvl(:company_name,name)
    and ps.PAY_GROUP_LOOKUP_CODE = nvl(:pay_group,ps.PAY_GROUP_LOOKUP_CODE)
         and trunc(p.creation_date) between nvl(:from_date,trunc(p.creation_date)) and nvl(:to_date,trunc(p.creation_date))
    In CO PFR Code:
    if (pageContext.getParameter("Go") != null)
    OAQueryUtils.checkSelectiveSearchCriteria(pageContext, webBean);
         String COMPANY = pageContext.getParameter("COMPANY");
    String PAYGROUP = pageContext.getParameter("PAYGROUP");
    String SOURCE = pageContext.getParameter("SOURCE");
    String INITIATOR = pageContext.getParameter("INITIATOR");
    String SUPPLIER_NAME = pageContext.getParameter("SUPPLIER_NAME");
    Boolean executeQuery = BooleanUtils.getBoolean(false);
    Serializable[] parameters = { COMPANY, PAYGROUP, SOURCE, INITIATOR, SUPPLIER_NAME, executeQuery};
    Class[] paramTypes = { String.class, String.class, String.class, String.class, String.class, Boolean.class };
    am.invokeMethod("initSearch", parameters, paramTypes);
    OAAdvancedTableBean table = (OAAdvancedTableBean)webBean.findChildRecursive("ResultsTable");
    table.queryData(pageContext, false);
    AM invoke Method():
    public void initSearch(String company,
    String paygroup,
    String source,
    String initiator,
    String supplier_name,
    Boolean executeQuery)
    WorklistFindVOImpl vo = getWorklistFindVO1();
    if (vo == null)
    MessageToken[] tokens = { new MessageToken("OBJECT_NAME", "WorklistFindVO1") };
    throw new OAException("AK", "FWK_TBX_OBJECT_NOT_FOUND", tokens);
    vo.initQuery(company, paygroup, source, initiator, supplier_name, executeQuery);
    VO Code:
    public void initQuery(String company,
    String paygroup,
    String source,
    String initiator,
    String supplier_name,
    Boolean executeQuery)
    StringBuffer whereClause = new StringBuffer(500);
    Vector parameters = new Vector(5);
    int clauseCount = 0;
    int bindCount = 0;
    setWhereClauseParams(null); // Always reset
    if ((company != null))
    String companyname = null;
    try
    companyname = new String(company);
    catch(Exception e) {}
    whereClause.append("COMPANY= :COMPANY");
    whereClause.append(++bindCount);
    parameters.addElement(company);
    clauseCount++;
    if ((paygroup != null) && (!("".equals(paygroup))))
    if (clauseCount > 0)
    whereClause.append(" AND ");
    whereClause.append("PAYGROUP = :PAYGROUP");
    whereClause.append(++bindCount);
    parameters.addElement(paygroup);
    clauseCount++;
    if ((source != null) && (!("".equals(source))))
    if (clauseCount > 0)
    whereClause.append(" AND ");
    whereClause.append("SOURCE = :SOURCE");
    whereClause.append(++bindCount);
    parameters.addElement(source);
    clauseCount++;
    if ((initiator != null) && (!("".equals(initiator))))
    if (clauseCount > 0)
    whereClause.append(" AND ");
    whereClause.append("INITIATOR = :INITIATOR");
    whereClause.append(++bindCount);
    parameters.addElement(initiator);
    clauseCount++;
    if ((supplier_name != null) && (!("".equals(supplier_name))))
    if (clauseCount > 0)
    whereClause.append(" AND ");
    whereClause.append("SUPPLIER_NAME = :SUPPLIER_NAME");
    whereClause.append(++bindCount);
    parameters.addElement(supplier_name);
    clauseCount++;
    setWhereClause(whereClause.toString());
    if (bindCount > 0)
    Object[] params = new Object[bindCount];
    parameters.copyInto(params);
    setWhereClauseParams(params);
    if ((executeQuery != null) && (executeQuery.booleanValue()))
    executeQuery();
    } // end initQuery()
    Please let me know what I did mistake in my code?
    I am unable to find it what I missing and there is no errors but no records displayed in Results Table.
    Please it's urgent.
    Thanks
    Nag.
    Edited by: user635152 on Nov 19, 2008 4:43 PM

  • How do I set time limits for my iphone?

    You know how there are parental controls on the macs in the settings. In there you can set up time limits of how long you can use the computer for but I can't find it on the iphone where you can set time limits for use. I looked at the restrictions sections but I don't see anything on setting time limit. How could I set time limits for use on my phone? I go on my phone too much and I really have to set restrictions to limit my time on it.

    There are apps you can download i believe to do this.
    https://itunes.apple.com/us/app/parental-timelock-time-limit/id689577280?mt=8
    for example

  • How to use the index method for pathpoints object in illustrator through javascripts

    hii...
    am using Illustrator CS2 using javascripts...
    how to use the index method for pathpoints object in illustrator through javascripts..

    Hi, what are you trying to do with path points?
    CarlosCanto

  • How to set the Default values for Info Objects in Data Selection of InfoPac

    Hi All,
    Flat file Extracion:
    How to set the Default values for Info Objects in Data Selection Tab  for Info Package
    ex: Fiscal Year Variant  Info Object having values 'K4' 'Y2' etc  in Flat file
    Initially  default value(not constant)  for this info Object value should be 'K4'  in Info Package
    If I set data selection value for this info object K4 it will retreive records with this selection only? how to handle
    Rgds,
    CV

    Hi,
    suppose as your ex. if you are having fiscalyear variant in the dataselection tab then specify K4 in the from column, again the ficalyearvariant row and click on insert duplicate row at the bottom . you will get another row . In that enter Y2 in the from column. now you can extract K4, y2 values .
    haritha

  • How to do the Unicode Check for Business Objects ?

    Hi all,
    How to do the Unicode Check for Business Objects ?
    Note: All business Objects are stored in BOR (Business Objects Repositary)
    Thanks in advance
    Sri..

    Hi..
    i have used the  UCCHECK  transaction for some business Objects
    For some business objects it is showing that No Unicode Errors found Ex: Z00MARA
    and for Business Objects it showing the message like : There is no program corresponding to this selection.
    Why system is showing like this ?
    Thanks in advance
    Sri..

  • How to implement countdown timer in apex

    Hi all,
    I want to implement timer in my application.i am working on apex 4.0 version.I am developing online test application,so for this i want to display timer for test.
    can anyone suggest me how can i implement countdown timer in my application.
    thanks
    jitu

    Hi,
    You can refer "Martin Giffy D'Souza's" Enhanced APEX Session Timeouts example
    http://www.talkapex.com/2009/09/enhanced-apex-session-timeouts.html
    Regards,
    Kartik Patel
    http://patelkartik.blogspot.com/
    http://apex.oracle.com/pls/apex/f?p=9904351712:1

  • How to implement 'Context Sensitive Help' for Workforce Performance Build Tool.

    Hi Gurus,
    We have a requirement to implement ‘Context Sensitive Help’ for Workforce Performance Build Tool. Please let me know how to go about implementing the "Context Sensitive Help".
    It will be great if you can share some links to the documents and screenshots.
    Thanks,
    Sanjiv Karmakar

    Hi Sanjiv,
    do you you mean expand the Help Menu => Pull Help or do you mean
    EPSS => push Help?
    in case pull help please tell me exactly which system GUI or EP and version you are using.
    many different scenarios are possible.
    Tom
    P.S. Please take care of  the name is Workforce Performance Builder or maybe in-official WPB.
    many people ask in the HCM area for help, this is the reason why we do not observe all discussion.
    The name in the title will help us to find your questions on time.

Maybe you are looking for

  • Storage Location check during 101

    Hi folks, I am facing a problem and need ur help... Though this is a security related issues but it requires Functional help... A user who does not have authorization for Storage Location ABC (M_MSEG_LGO) is executing MIGO and is being able to do GR(

  • Xml in datagrid instead of a proper result

    Hi I'm new to FDS and I have a problem to show my data in my data grid. As you can see below I have a datagrid and a button.When I click on the button I search for every item which contains 'BA' but instead of giving me all the items of my search res

  • Ticker tape during presentation??

    Hello all. I'm a newbie with iMac. I use it in an education context - our school's announcements are presented on a few flat screen VGAs in the school using Keynote. My question... is there a better program out there that will do the same thing (ie.

  • I can't backup to iCloud

    icloud Backup Failed There was a problem enabling iCloud Backup

  • Report Attribute Error Message

    Hello Everyone, I am trying to use the method report_attribute_error_message of if_wd_message_manager interface to display an error message if the user does not fill all the mandatory fields. My scenario is as follows:- I have one node po_items with