Correct Approach

Hi, need some advise here.
I am required to venture into network programming and have an approach to it. However I am not sure whether it's the correct approach using RMI.
I am writing a (Server-Host)RMI server which will manage multiple threads. Each of the threads are required to communicating with unique channels provided by the vendor's server program and they will persist throughout the lifespan of the JVM. A RMI client will be written to connect to the RMI server and echo simple requests which translates to specified functionalities provided by the thread objects. The RMI server is also required to perform logging of activities for reporting purpose.
Here's my question...Which design is better or which is impossible?
1.
Program the threads to be exported as remote objects on startup and let the RMI server will act as a form of registry to register a client connect and allocate it to desinated remote thread objects. Let the server focus on other services.
2.
Program the RMI server as the main control to receive and interpret all client requests and in turn invoke the required thread methods.
I need to add further that timing/latency is critical in this instance.
Thanks!

bschauwe, thanks for your help!
I guess as well. My main concern is latency because real-time response is critical for the program to work. Come to think about it, I probably ponder too much about it that I forgot that java Objects are thread-ready to handle such requirements.
As for the threads to the vendor's server, each of the threads is suppose to open up a single channel to a unique device managed by the vendor's server. The vendor has provided the API to connect and use their devices via the server. I wanted to use threads to managed response time and at the same time perform some sort of queue like you mentioned to ensure that only a single client is connected to each of the channels opened. All this is part of a bigger implementation where users can perform real-time supervising from the server side.
Right now, I just want to get the client/server implementation up and running.

Similar Messages

  • Correct Approach in uploading a file

    Which is the correct approach in uploading an image file.
    Upload the file to the ApplicationServer and save the path in the DataBase
    OR
    Upload the file to the DataBase as BLOB.

    Usually I think you should just be storing the
    location of the image in the database rather than the
    image itself. However there are a couple of
    disadvantages, chiefly that you need to keep the
    database and file system in sync with each other and
    that you don't have the database security to protect
    your images.Perhaps more importantly (depending on your setup) there's the problem of accessing these auxilliary files from different hosts, and keeping the directory tidy. You can, of course, generally access through NFS but then your configuration on different machines had to take account of different file paths.
    And you've got a second set of permissions to worry about.

  • The correct approach to intercept TAB key

    Dear Experts,
    I have developed a GUI out of javax.swing. The GUI consists of JFrame, several JPanels and javax components, such as JTextField, JLabel, JComboBox, JTable and many more.
    Now, I want to change the behavior when user presses TAB key. By default TAB key moves focus from a component to another component. How can I disable this?
    I come to two alternatives that I am not sure which one is the correct approach. Could you please advise me?
    Alternative 1.
    Use key binding on GlassPane.
    Alternative 2.
    Use event-handling on GlassPane.
    If those alternatives are not the best one, could you please provide another alternative?
    I have tried the following, but they didn't work...
    Action doNothing = new AbstractAction() {
        public void actionPerformed(ActionEvent e) {
            System.out.println("Tab-key is pressed.");
    cmbPCode.getInputMap().put(KeyStroke.getKeyStroke(KeyEvent.VK_TAB, 0), "doNothing");
    cmbPCode.getActionMap().put("doNothing", doNothing);or
    getRootPane().getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke(KeyEvent.VK_TAB, 0), "doNothing");
    getRootPane().getActionMap().put("doNothing", doNothing);where cmbPCode is a JComboBox that receives focus when the GUI shows up.
    Thanks for your help,
    Patrick
    Edited by: Patrick_Stiady on Mar 31, 2009 6:51 AM

    Thank you for the advice. I am developing an application where the user is not computer literated, so that I have to limit functional key as many as possible and only allow several keys to be active. For example, I don't want TAB key to change the focus, instead I want TAB key to do nothing.
    I have tried keybinding, because I think this is the most relevant, but somehow I failed to recognize which component should be bound with keybinding. I have tried to change the input map of the component that receives the focus when the GUI is displayed (cmbPCode) as can be seen on my first post. I also tried to change the input map of the root pane. Both are not successful.
    Now, I wonder whether
    1. it does not work because the key is not consume()?
    2. Or should I use key listener, which I would only use if keybinding were unable to serve my goal?
    3. Or should I learn how to intercept key on the glass pane?
    4. Is keybinding able to nullify default action, such as changing focus by TAB key? I am asking this, because I'm going to nullify other important key such as ENTER key.
    Thank you for any guidance,
    Patrick

  • Displaying  list of  items , in  a jsp , using STRUTS--Correct approach

    I have a requiremnet tht on click of a button , a list of items should be displayed on a jsp page , so tht a user can select items from tht list.
    But the problem is tht , the list is very large(Conatins 1500 record).
    So wht approach should i adopt.
    One approach is tht , i have a link on my main.jsp , where user has a link (addItems) , and on clicking this link , another page(Items.jsp), opens up , where i dispaly the list of users , and user here can select multiple items , and then those items will be shown in Main.jsp.
    Is this appraoch correct,
    also plz tell me how can i incorporate previous and next functionality , so tht 20 records per page are shown
    Can anyone tell me how 2 go abt it.
    I m using STRUTS , and weblogic.

    Hiiii
    When u want2 add textboxes dynamically,
    then declare ur proprerty in action form as of type String[]
    <form-bean
    name="userForm"
    type="org.apache.struts.validator.DynaValidatorForm">
    <form-property name="name" type="java.lang.String[]"/>
    <form-bean>
    When u add textboxes dynamically , and if the textboxes name is same as that in form bean,
    then automatically this form bean property gets populated.
    If u require further assistance do tell me

  • Correct approach and load time estimation

    Hi,
    We are planning to load  19 million Business partner data  from SQL to SAP-CRM as part of initial load.
    We are using XI as middle ware and we are planning to use JDBC adapter at sender side and ABAP proxy at receiver side.
    I have few questions:
    1)Is it correct to use XI for initial load from SQL to CRM? Is there any other better  
       tool.( There may be other better tools, but my point is anyway  we are going to
       use XI to create BP’s from SQL to CRM after go-live for real time scenarios (
       apart from initial load). So, why cant we use the same scenario for initial load
       also.)
    2) Is it correct to user ABAP proxy at receiver side?
    3) Receiver side we can user IDOC adapter or ABAP proxy. Which one is
        efficient? ( we don’t have much transformations )
    4) How to estimate the time to load 19 million  BP’s into CRM. What parameters I
        have to consider in both XI and CRM system.
    Thanks in advance...

    Hi
    <u>19 million Business partner data</u>
    I feel XI is not a better approach for this.
    <i>3) Receiver side we can user IDOC adapter or ABAP proxy. Which one is
    efficient? ( we don’t have much transformations )</i>
    Proxies will the most efficient ones.The biggest advantage of the proxy is that it always by passes the Adapter Engine and will directly interact with the application system and Integration engine - so it will and should give us a better performance.
    Thanks

  • What is the correct approach to the SAP HR Certifications?

    Hi Experts,
    I was contemplating on taking the SAP HR Certification and wanted to know if it is really useful. I also read a few threads in which people were rushing to take the certification right after their initial training. I personally believe that unless you have the relevant experience in using the system it would not really matter. Could you please give me an insight and also advise on what should be the correct roadmap and if any books would be helpful?
    Thanks,
    Swami

    Hi,
    1. What is the Certification for HR functional consultants?
    Visit [SAP HR Certification Test|http://www12.sap.com/services/education/certification/certificationtest.epx?context=%5b%5bC_THR12_05%5d%5d%7c].
    Visit [SAP Eduction|http://www12.sap.com/asia/services/education/schedule/schedule_IN.htm] under section Human Capital Management ECC 6.0.   
    2. How do I prepare for the Certification? What material do I need and where can I get it, books and eBooks etc?
    You would attend the certification course if you are not an experienced consultant. If you are an experienced consultant and do not want to attend the certification, you will need your company to provide you required documents to submit to SAP.
    You can find books at [SAP Press|http://www.sappress.com/].
    3. Do we need some type of training?
    You will have to attend training if you are not an experienced consultant.
    Also, visit:
    Re: Guidance.
    Regards,
    Srilatha.

  • BDT - Question about the correct approach.

    Hi,
    We are already live with SAP CRM but there is a new requirement to add a new checkbox to the BP transaction to be held against each business partner.
    This flag is to be used to flag a Sold-To Party as a certain type of customer.
    If I extend BUT000 by creating a new field on an append structure is this risky as we are live with CRM.
    Or is a better approach to create a new Z table e.g. BP Number and Flag as the fields and enhance the BP transaction this way?
    Many Thanks
    David

    Hi David,
    For your current requirement, it is better if you try adding new fields to Business Partner through Easy Enhancement Work bench, (transaction eewb ).
    Using the Easy Enhancement Workbench (EEW) for business partner in SAP CRM you can easily extend the data model of business partner by new fields or tables and integrate them in the business processes.
    For more information on the steps involved in adding a new field in Business Partner and other useful information, please go through the link provided below:
    [http://help.sap.com/saphelp_crm50/helpdata/en/81/1d5303c023da438e792316c9d25a84/content.htm]
    Wish this is useful to you
    regards
    Srikantan

  • Best approach for post-update (Oracle Forms equivalent) operations?

    Hi
    Having scanned all the available literature / blogs / forum posts I can find, I'm not sure of the correct way to proceed here, can anybody advise?
    I am planning to build a custom OAF page to update rows in a seeded Apps table.
    After any update via my page, I want to insert a message into a custom audit table, to record the event for reporting purposes. In Forms I would have used a POST-UPDATE trigger to do that, but there doesn't seem to be a direct equivalent in OAF.
    Here are the approaches I have considered
    1. Db trigger, or related approach. I don't want to do this on a seeded table.
    2. Create a pl/sql EO on the seeded table, use the pl/sql code to store the audit rows on update (this seems easiest to me ...).
    3. Use CallableStatement to create the rows in AM and call from CO (or EO?).
    4. Create java EOs for both the seeded table and the audit table, and implement the audit table update by manipulating the audit table EO.
    From all I have read, I believe #4 is the correct approach as pl/sql EOs are not recommended (except to leverage existing APIs), but it's not clear to me how to go about coding it, could somebody help me get started please?

    Gyan Darpan wrote:
    Step 1- create a Custom method in AM.
    Step 2 - Create a Eo & EOVO for the Audit table.
    Step 3- Get all the value from the page ..which u want to save inside the audit table.
    Step 4 - Once u get the value..set the same to the EOVO using setAttribute();
    Step 5 - Call this method before calling commit.
    Thanks Gyan, that's very helpful. I have a table with multiple updates, and I wasn't confident about how to identify the
    updated records to process them one by one, so after some more searching/experimentation I end up with this approach :
    1. Created an EO + EOVO for the Audit table (not sure VO actually required in this approach).
    2. Exposed the doDML method in the Seeded EO by clicking Data Manipulation Methods on the EO's 'Java' page.
    3. In the doDML method, I added code like this, which is called on every update : ( RequestsEO is the EO of the table being updated, MessagesEO is the audit table also being inserted into. )
           // Get New Message ID and instantiate a MessagesEO row.
           Number Id=Rtr.getSequenceValue("XX_MESSAGES_SEQ");
           NameValuePairs nvp = new NameValuePairs(new String[]{"LineId"},new Object[]{Id.toString()});
           MessagesEOImpl Msg = (MessagesEOImpl)getOADBTransaction().createEntityInstance("oracle.apps.xx.testaudit.server.MessagesEO",nvp);
           // Set various required fields in MessagesEO.
           Msg.setLineId(Id);
           Msg.setLineType("A");
           Msg.setSourceName("AUDITSREQ");
           Msg.setSourceId("1");
           // Build Audit message from fields in updated record.
           Number RequestId=getRequestId();
           String sRequestId=RequestId.toString();
           String sAttribute5=getAttribute5();
           Msg.setTextline("Updated Request ID [" +sRequestId + "] to [" +sAttribute5 + "].");
           // Update Request
           super.doDML(operation, e);
             I'm pretty happy with the result, but am I doing anything I "shouldn't" here?
    In particular, should I try to use VO and/or calling a method in the AM rather than coding direct in the EO?
    Thanks again
    RMH

  • Function Body Returning Query -  Questioning my Approach

    Application Express 3.2.0.00.27
    Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - Production
    I have some concerns that I am not using this in the optimal manner.
    Essentially I have all my queries in a package body and I call each report as follows:
    declare
    v_query varchar2(4000);
    begin
    v_query := apex.report_name(p1=>   :page_item_1,
                                                  p2=>   :application_item2);
    return 'select * from ('|| v_query||' )';
    end;I then generate the string in the report_name procedure
    and concatenate the string.
    This results in a valid sql string being returned to the database , however if I pass a different value
    then I will get a different sql string.
    I would rather be able to use bind variables using this approach if at all possible.
    So is this the correct approach is there a better approach?
    Edited by: Keith Jamieson on Jan 18, 2012 12:50 PM
    Edited by: Keith Jamieson on Jan 18, 2012 1:40 PM

    Current project makes extensive use of packages containing Function Body Returning Query report sources to dynamically build queries from SQL modules. However, the queries generated by any function are all used within one page. This enables page item bind variable references to be fixed within the SQL:
    function emp (p_commission in number) return varchar2
    is
      q_emp_qry varchar2(4000) := q'{select * from emp where 1 = 1 }';
      k_has_comm constant varchar2(2000) := q'{and comm >= to_number(:p2_sales_comm)}';
    begin
      if p_commission is not null
      then
        q_emp_qry := q_emp_qry || k_has_comm;
      end if;
      return q_emp_qry;
    end emp;

  • ORACLE DATABASE REPLICATION -- ANY APPROACH @ THANKS FOR YOUR HELP

    HI ALL,
    I am new to Oracle as a developer.Please help me if you find sometime regarding the following requirement .
    we are replicating the database (TARGET Database 9.2) with the source database(10G) .
    My Idea was to create dblinks for Source DB in Target and use some cursors to populate the data required for destination tables
    (Here i have to update the destination table when the records are updated in source DB and insert the records in Destination DB when no record is found in destination).
    For this requirement , i am planning to use ORACLE MERGE CONCEPTS.As my destination database is 9.2 and merge with 9.2 is not powerful as per my requirement .
    EG :
    1)I do not need WHEN MATCHED CLAUSE SOMETIMES )
    2)ALSO I NEED MERGE IN TO MULTIPLE DESTINATION TABLES
    I came across the following code in one of your posting .If this really works with 10g version .I think i am in the correct path (I can write stored programs in source Database (It is 10g))
    IF NOT THIS ....ANY OTHER APPROACH...
    drop table external_tbl;
    drop table dim1;
    drop table dim2;
    drop table fact_tbl;
    create table external_tbl ( dim1_cd char(1), dim2_cd char(1), qty number );
    insert into external_tbl values ( 'A', 'B', 1 );
    insert into external_tbl values ( 'B', 'C', 2 );
    insert into external_tbl values ( 'A', 'D', 3 );
    create table dim1 ( dim1_cd char(1) primary key, dim1_description varchar2(20) );
    insert into dim1 values ( 'A', 'At the Earth''s Core');
    insert into dim1 values ( 'B', 'Barsoom');
    create table dim2 ( dim2_cd char(1) primary key, dim2_description varchar2(20) );
    insert into dim2 values ( 'B', 'Buck Rogers');
    insert into dim2 values ( 'C', 'Carter, John');
    create table fact_tbl ( dim1_cd char(1) references dim1, dim2_cd char(1) references dim2, qty
    number )
    MERGE ALL
    USING(SELECT dim1_cd, dim2_cd, current_qty
    FROM external_tbl) b
    INTO fact_tbl a
    ON ( b.dim1_cd = a.dim1_cd
    AND b.dim2_cd = a.dim2_cd)
    WHEN NOT MATCHED THEN
    INSERT
    (dim1_cd, dim2_cd, current_qty)
    VALUES
    (b.dim1_cd, b.dim2_cd, b.qty)
    WHEN MATCHED THEN
    UPDATE current_qty
    SET qty = b.qty
    INTO dim1 d1
    ON (b.dim1_cd = d1.dim1_cd)
    WHEN NOT MATCHED THEN -- insert a dummy record
    INSERT INTO dim1 ( dim1_cd, dim1_description )
    VALUES (b.dim1_cd, 'unknown' )
    INTO dim2 d2
    ON (b.dim1_cd = d2.dim2_cd)
    WHEN NOT MATCHED THEN -- insert a dummy record
    INSERT INTO dim2 ( dim2_cd, dim2_description )
    VALUES (b.dim2_cd, 'unknown' )
    and the results to be:
    select * from dim2;
    D DIM2_DESCRIPTION
    B Buck Rogers
    C Carter, John
    D unknown -- added during the MERGE to maintain ref integrity
    select * from fact_tbl;
    D D QTY
    A B 1
    B C 2
    -----THANKS FOR READING MY QUESTION

    Hi ,
    Thanks for the reply....
    How can i convert 9i merge to 10g merge (update set column_name = column_name i did not get this )....
    Also , My requirement is to update only the updated columns in the source table not the entire row ..I tried like this (but not sure whether it is correct or not)
    Compare source to destination and update if not equal
    MERGE
    INTO red_cust tgt
    USING (
    SELECT --red_cust_id_seq .nextval  as CUST_ID ,
    red_cust_nos(i) as CUST_NO,
    red_cust_names(i) as CUST_NAME,
    red_cust_inactive_dates(i) as INACTIVE_DATE ,
    red_cust_insert_users(i) as INSERT_USER ,
    red_cust_insert_dates(i) as INSERT_DATE ,
    red_cust_update_users(i) as UPDATE_USER ,
    red_cust_update_dates(i) as UPDATE_DATE
    FROM master_table
    ) src
    ON ( src.cust_no= tgt.cust_no )
    WHEN NOT MATCHED
    THEN
    INSERT (tgt.CUST_ID ,
    tgt.CUST_NO,
    tgt.CUST_NAME,
    tgt.TAX_EXEMPT_INDIC,
    tgt.INACTIVE_DATE,
    tgt.INSERT_USER,
    tgt.INSERT_DATE
    VALUES (src.cust_id
    src.cust_no ,
    src.CUST_NAME,
    src.TAX_EXEMPT_INDIC,
    src.INACTIVE_DATE,
    src.INSERT_USER,
    src.INSERT_DATE
    WHEN MATCHED
    THEN
    UPDATE
    set
    tgt.cust_name =src.cust_name where tgt.cust_name !=src.cust_name ;
    /*Is this correct approach : what i mean by this is :compare src customer_name and target customer name when they are not equal assign it to the destination source name*/
    I repeated above for the other columns
    tgt.TAX_EXEMPT_INDIC,
    tgt.INACTIVE_DATE,
    tgt.INSERT_USER,
    tgt.INSERT_DATE
    After i tried this , i got the computability error again ..as i am merging from 10g to 9i .........(ERROR: Optional where clause in merge is not available in DESTINATION i.e 9i)
    If my approach above is correct , is there any alternative for where clause in merge in 9i
    I am struck here...Please guide me through the correct path.....
    I appreciate your help

  • SAP BO Upgrade approach

    Dear BO Architects,
    I have a Dev, Test & Prod environment in BO 3.1 and working on preparing a plan to upgrade to SAP BO 4.1.
    From what I understand, we can perform this in more than one way but I am unsure of the recommended approach.
    1) SAP BO 3.1 Prod to SAP BO 4.1 Prod and then move contents from SAP BO 4.1 Prod to Test to Dev with appropriate testing
    2) SAP BO 3.1 Prod to SAP BO 4.1 Dev and then move contents from SAP BO 4.1 Dev to Test to Prod with appropriate testing
    3) SAP BO 3.1 Dev to SAP BO 4.1 Dev, SAP BO 3.1 Test to SAP BO 4.1 Test, SAP BO 3.1 Prod to SAP BO 4.1 Prod
    Can you please advise me on the correct approach?
    Appreciate all the help!
    Regards,
    Vino

    Hi
    1) SAP BO 3.1 Prod to SAP BO 4.1 Prod and then move contents from SAP BO 4.1 Prod to Test to Dev with appropriate testing
    Go with this approach if would like to do real time testing. This will import users, Personal reports and inboxes to prod and you could exclude them in your copies to test and dev. This approach will save a lot of migration time since you could do realtime testing. Be careful rights as some additional rights are available in 4.1 and a few have been removed. Note that you have to have a plan as to what exactly you were looking at since you are implementing production first.
    2) SAP BO 3.1 Prod to SAP BO 4.1 Dev and then move contents from SAP BO 4.1 Dev to Test to Prod with appropriate testing
    This is only ideal if you have a huge environment with lot of reports and you want to spend more time on tests and validation
    3) SAP BO 3.1 Dev to SAP BO 4.1 Dev, SAP BO 3.1 Test to SAP BO 4.1 Test, SAP BO 3.1 Prod to SAP BO 4.1 Prod
    This will work perfectly, But you have to implement the learnt lessons from each step to the next step. If you faced an issue and fixed that during migration from DEV to DEV, you still have to fix the same issue again on test to test and prod to prod
    If the environment is not too huge its better to go with Approach 1 and copy the content way back to TEST and DEV selectively.
    Regards
    Anil    

  • Clients connect to wifi with certificate that expires every month - correct way to handle expired certificates?

    Hi all
    I'm sorry if this is the wrong forum to ask this question. Also my knowledge in this area is somewhat limited, which I why I need your help :-)
    We use wireless networks primarily in my company for all our clients and use a certificate to authenticate to the network. This certificate expires after 1 month and we automatically renew them 1 week before expiry. Relatively often we have users that
    are not connected to the network for a few weeks or more and then the certificate expires before being renewed. Then we have to connect them to the wired network to get the certificate updated, so they can connect to the wireless network again.
    What is the correct approach to solve this issue? We feel extending the life of the certificate would be a too big security compromise. Is there some way you could automatically allow an expired certificate briefly with the sole purpose of renewing the certificate?
    Or how would you normally resolve this issue?
    Thanks for any help/knowledge you can provide :-)

    > Setting the validity period that high, means that the certificate could be cracked before expiry.
    then you should be scary of CAs which validity is 10 or more years. And they use the same cryptography as end-entity certificates (key length and signature algorithms). It is a paranoya. Just make sure if client certificates use at least 2048 bit long
    keys and use SHA1 (or better) signature algorithm. In this case there is a little chance that certificate will be successfully cracked in 2 years.
    If there is an evidence (or indications) of client private key compromise -- immediately revoke the certificate and publish new CRL ASAP. You cannot protect clients from key compromise by using short-living certificates, because key compromise is ususally
    achieved by gaining a control over the private key (malware on client computer). Therefore, there is nothing wrong in issuing client certificates with 1 or 2 year validity.
    My weblog: en-us.sysadmins.lv
    PowerShell PKI Module: pspki.codeplex.com
    PowerShell Cmdlet Help Editor pscmdlethelpeditor.codeplex.com
    Check out new: SSL Certificate Verifier
    Check out new:
    PowerShell FCIV tool.

  • Correct way to AddOrUpdate Property of Class in a ConcurrentDictionary?

    I have a ConcurrentDictionary we'll call ParamaterList.  And a class named Parameter. 
    Class parameter{
    public string Username = string.Empty;
    public string FirstName = string.Empty;
    public string LastName = string.Empty;       
    public bool enabled = false;
    ConcurrentDictionary<string, parameter> ParameterList = new ConcurrentDictionary<string, parameter>;
    I want to confirm that I'm doing this correctly and there isn't a better way.  To update a class I am doing this:
    ParameterList.AddOrUpdate("username", true, (k, v) => {v.enabled = true; return v;});
    Is that the correct approach or is there a 'correct' way to update a property of v directly without returning a full 'new' class? My classes are small now but I would like to learn best practices for concurrentDictionaries. 

    1) TryGetValue is thread safe.  If someone is trying to modify the collection while you're retrieving it then they will block until you have the value.
    2) Yes another thread could remove the item after you get it but there is no concurrent collection that guarantees otherwise. A concurrent collection simply guarantees that while a particular method on the collection is being executed that no other
    thread will cause changes that will cause it to fail.  Once the method returns another thread can do whatever it wants.  90% of the time that is perfectly fine and expected.  In the few cases where you need to ensure an item remains in a collection
    for some fixed period of time then you'll have to use a lock instead.  But after the lock is released the item can still be removed. 
    Removing an item from the collection does not invalidate your copy of that item.  You still have a reference to the item and it'll exist and be usable as long as you hold onto it.  Whether it is in the collection or not doesn't matter.  In
    general multiple writers to a collection is not a good thing to have so you'll want to consider modifying your code to have a single writer but any # of readers.  This will simplify your code and make it easier to maintain.
    3) If you want to update an item if it exists or create a new one if it doesn't then you have to make some decisions.  TryAddUpdate would be the way to go if you want to recreate the item each time whether it is already there or not. If you only want
    to create it if it doesn't exist then use TryGetValue and if that fails then use TryAdd to add a new one. However a concurrent collection doesn't prevent modifications between these calls so between the time you get the value and update/add it somebody else
    could remove it, add it or both.  If you need a gurantee that the collection does not change during these calls then you have to use a lock because the collection itself doesn't provide a long enough lock. 
    If you do decide to use TryAddUpdate note that each time you will add a new object to the collection and this will cause problems for other threads.  For example another thread may use TryGetValue to get the object and then set one of the properties. 
    But if another thread calls TryAddUpdate during this time a new object is created and added to the collection so the original thread's changes are lost and they are none the wiser.  However if you use TryGetValue first and only call TryAdd if the item
    doesn't exist yet then you will always be working against the same object across threads and by using the return value of the methods you can determine whether you got a value or successfully added it.  This is the cost of using multiple writers.
    4) The collections are thread-safe, not the objects in them.  There is no guarantees around the thread safety of the objects in the collection. If you need thread safety on the objects themselves then either the object type needs to be thread safe or
    you have to use a lock.  For the case of a single writer, multiple readers then you are better off using a ReaderWriterLock instead of a concurrent dictionary.

  • Is my code correct?

    "Each set of items in the data file is terminated by an empty line. Therefore, when the text read in is equal to the empty string (""), you know that there are no more items for the
    current category."
    while ((line= in.read()) = ""
            System.out.println ("There are no more items for the current category");Is this the most effective way?

    What everyone is telling is:
    No, it is not right. It is not even a correct approach to do it and it is probably not even the correct Java expression to use.
    First off:
    Are you responsible for doing the read operation for your project? From what you have said so far, you are just detecting the end of an item list--IF THIS IS THE CASE, then you accept the already read in character as an argument and do your checking. (this caps characters does not mean I am yelling at you--I just want you to not miss it) YOU WILL NOT READ. YOUR PROJECT SHOULD ONLY HAVE ONE READ STATEMENT TO GET YOUR DATA, otherwise, you are NOT going to be able to tell what is list and what is end condition.
    2ndly:
    a WHILE is a loop. What ever is in the conditional while(condition){} defines when the block it controls is run. The block is run continuously until the conditional evaluates to false. Unless you are responsible for the main read loop, you SHOULD NOT BE READING to change the conditional in the first place.
    3rdly:
    You need to look through your notes, read the book, study the tutorial, ask the teacher or TA what "=" does.

  • Multilingual XML Approach

    Hi,
    I need to discuss one thing regarding multilingual implementation for an application. The requirement is given below.
    1. only master data(user entry) of the application will support multilingual.
    2. Application will support 'n' languages becuase it will be installed for each country.
    Our Approach:
    1. We created one column with datatype XMLTYPE and store data as XML. The data is stored like below.
      <ROOT>
    <ROW LANG_ID="22">JROEMVRTFK</ROW>
    <ROW LANG_ID="34">سشيشي</ROW>
    <ROW LANG_ID="4">نههلت</ROW>
      </ROOT>
    where LANG_ID is the language id of language master table.
    2. We created one index for XMLTYPE data type.
         CREATE INDEX <<index_name>> ON <<table_name>> (<<column_name>>) INDEXTYPE IS XDB.XMLINDEX PARAMETERS ('PATHS (INCLUDE (/ROOT/ROW))');
    3. We created 10,000 rows into that table.
    Why this Approach:
    Let's take an example. Assume that, Client 1 wants the application to support 3 languages. Client 2 wants , the application to support 4 languages and so on. For a column based approach our database patch will differ for each client. So for Client 3, who wants support for 2 languages the system will be isolated from our base version of database.
    Performance:
    1. From the performance aspect, the query execution will be 4 times slower than the traditional column wise approach. The query will look like:
                   SELECT
    TRIM(EXTRACT(VALUE(c), '/ROW/@LANG_ID')) LANG_ID,
                            TRIM(EXTRACT(VALUE(c), '/ROW/text()')) STATE_NAME
                   FROM
    STATE_MASTER d,
                            TABLE(XMLSEQUENCE(EXTRACT(d.STATE_NAME,'/ROOT/ROW'))) c
                    WHERE
                                      EXTRACT(VALUE(c), '/ROW/text()').GETSTRINGVAL() LIKE ‘ACN%’
    Question:
    1.  Is it the correct approach?
    2. If not what will be the approach for supporting 'n' languages for a single database.
    3. How to improve the performance?

    The rewritten XML approach :
    -- master table with Binary XMLType column
    create table state_master (id integer, xml_state_name xmltype)
    xmltype column xml_state_name store as securefile binary xml;
    -- structured XMLIndex
    create index state_master_sxi on state_master (xml_state_name)
    indextype is xdb.xmlindex
    parameters (q'~
      XMLTABLE state_master_xt
      '/ROOT/ROW'
      PASSING xml_state_name
      COLUMNS lang_id    number         PATH '@LANG_ID'
            , state_name varchar2(4000) PATH '.'
    ~'
    -- secondary index on LANG_ID
    create index state_master_xt_lang_id_i on state_master_xt (lang_id);
    SQL> insert into state_master values (
      2    1
      3  , xmlparse(document '<ROOT><ROW LANG_ID="1">Hello</ROW><ROW LANG_ID="2">Bonjour</ROW></ROOT>')
      4  );
    1 row created.
    SQL> insert into state_master values (
      2    2
      3  , xmlparse(document '<ROOT><ROW LANG_ID="1">Goodbye</ROW><ROW LANG_ID="2">Au revoir</ROW></ROOT>')
      4  );
    1 row created.
    SQL> set autotrace on explain
    SQL> set lines 200
    SQL>
    SQL> select t.id, x.lang_id, x.state_name
      2  from state_master t
      3     , xmltable('/ROOT/ROW' passing t.xml_state_name
      4         columns lang_id    number         path '@LANG_ID'
      5               , state_name varchar2(4000) path '.'
      6       ) x
      7  ;
      ID    LANG_ID STATE_NAME
       1          1 Hello
       1          2 Bonjour
       2          1 Goodbye
       2          2 Au revoir
    Execution Plan
    Plan hash value: 1735897579
    | Id  | Operation                    | Name                     | Rows  | Bytes | Cost (%CPU)| Time  |
    |   0 | SELECT STATEMENT             |                          |     4 |   144 |     5   (0)| 00:00:01 |
    |   1 |  NESTED LOOPS                |                          |       |       |            |       |
    |   2 |   NESTED LOOPS               |                          |     4 |   144 |     5   (0)| 00:00:01 |
    |   3 |    TABLE ACCESS STORAGE FULL | STATE_MASTER             |     2 |    30 |     3   (0)| 00:00:01 |
    |*  4 |    INDEX RANGE SCAN          | SYS166533_166534_RID_IDX |     2 |       |     0   (0)| 00:00:01 |
    |   5 |   TABLE ACCESS BY INDEX ROWID| STATE_MASTER_XT          |     2 |    42 |     1   (0)| 00:00:01 |
    Predicate Information (identified by operation id):
       4 - access("T".ROWID="SYS_SXI_1"."RID")
    SQL>
    SQL>
    SQL>
    SQL>
    SQL> select t.id, x.state_name
      2  from state_master t
      3     , xmltable('/ROOT/ROW' passing t.xml_state_name
      4         columns lang_id    number         path '@LANG_ID'
      5               , state_name varchar2(4000) path '.'
      6       ) x
      7  where x.lang_id = 1
      8  ;
      ID STATE_NAME
       1 Hello
       2 Goodbye
    Execution Plan
    Plan hash value: 1089002068
    | Id  | Operation                    | Name                      | Rows  | Bytes | Cost (%CPU)| Time  |
    |   0 | SELECT STATEMENT             |                           |     2 |    72 |     4   (0)| 00:00:01 |
    |   1 |  NESTED LOOPS                |                           |     2 |    72 |     4   (0)| 00:00:01 |
    |   2 |   TABLE ACCESS BY INDEX ROWID| STATE_MASTER_XT           |     2 |    42 |     2   (0)| 00:00:01 |
    |*  3 |    INDEX RANGE SCAN          | STATE_MASTER_XT_LANG_ID_I |     2 |       |     1   (0)| 00:00:01 |
    |   4 |   TABLE ACCESS BY USER ROWID | STATE_MASTER              |     1 |    15 |     1   (0)| 00:00:01 |
    Predicate Information (identified by operation id):
       3 - access("SYS_SXI_1"."LANG_ID"=1)

Maybe you are looking for

  • Problem installing Flash

    I am having three problems with Adobe Flash and would like some assistance in resolving them. 1)  Problem number ONE:  Several months ago installing an antivirus program broke my Internet Explorer.  All attempts to fix or upgrade IE have failed.  Not

  • I got my new Imac today, first mac, AMAZING - how to setup security?

    Hello, what a computer, i was scared of the glossy screen , but is amazing all is amazing so far. What should i do regarding the security ? ( spyware, virus etc ) I found the firewall and set it to he most secure mode, so I only allow the programs I

  • Oracle ADF Jdeveloper(11.1.1.4) opera support

    Hi Is there any official link to validate whether opera browser is supported/not supported for Oracle ADF on Jdeveloper(11.1.1.4)?

  • Unable to search by responsibility in cProjects 3.0 after BP re-set

    Dear Forum, We are using cProjects 3.0 and had trouble with a user showing up properly as a resource in a cproject template.  I deleted the user, business partner  and re-set him up again from scratch. He is now unable to see any of his previously su

  • Cs6 focus distance in exif data.

    cs6 doesn't save the focus distance in the exif data (Canon 7D) like cs5, is there a fix for this?