Locking and Objects

I have been looking up a lot of information on locking
shared-scope variables lately, because I dont really do it at all
and I probably should. My question revolves around something else I
had posted about a couple of days ago about creating objects in the
session scope.
I have user.cfc that holds information such as username.
etc... I have methods such as getFirstName(), getLastName(), and
setUser(userID). These variables are references as
#Session.User.getFirstName()# as expected.
My question is, since this is a session variable... should it
be locked before access?

jeby wrote:
> My question is, since this is a session variable...
should it be locked before
> access?
>
Probably not very often. You should not have to do a lock
when you are
just reading values. And you would only need to do a lock
when changing
a value in your object if you are concerned about race
conditions.
Which for session variables are relatively rare.
If you where dealing with an object stored in the Application
or Server
scope then there would be a much greater chance for race
conditions to
occur. Thus you would generally be more concerned about
locking
modifying code for these types of objects.
In early versions of ColdFusion there where memory leak
problems with
these persisted scopes and the work around was to always lock
every
thing. This issue has long been resolved, but the old cannon
of locking
all the time still persists.
But there can be serious performance, scalability and
throughput issues
to over locking your application. So the better pratice is to
only lock
when there is a reason to lock.

Similar Messages

  • Locking and Unlocking an Object

    Hi all,
    I have a requirement of chaging the characteristics of the Equipment but when i use the BAPI BAPI_OBJCL_CHANGE by passing the Equipment number and the required values i get a return message saying that the equipment is locked by User WF-BACTH but when i open the same equipment using the IE02 i do not see any locks........
    i want to know the funstion modules which can be used to put a lock and unlock an Equipment...........
    Regards,
    Ravi G

    hI
    Enqueue and Dequeue using BAPI can be used to lock an object.
    For example :
    If we need to lock and employee number to be edited only by the person who set the lock, we can use a BAPI.
    Do read the documentation of 'BAPI_EMPLOYEE_ENQUEUE'. It will give you a better idea of how to implement Enqueue for a BAPI.
    Refer the link -
    Re: Enqueue and Dequeue consept----Please explain urgent

  • HR OM  LOCK and UNLOCK object!

    hi!
    some one know HR OM object's LOCK and UNLOCK object ?
    thank you very much!

    Hi ,
    these can be used to lock/unlock  om objects..
    CALL FUNCTION 'HR_ENQUEUE_OBJECT'
           EXPORTING
                PLVAR            = ACT_ENQK-PLVAR
                OTYPE            = ACT_ENQK-OTYPE
                OBJID            =  ACT_ENQK-OBJID
                ENQUEUE_ONCE     = ' '
           IMPORTING
    call function HR_DEQUEUE_OBJECT
    These can be used to lock the OM objects..
    Br,
    Vijay.

  • Feature restore request. (allow locked and grouped objects to be able to tagged.

    In CS2, using the direct selection tool, I'm able to select and tag the image even if it's grouped and locked, no script needed at all, no sweat and fast!
    Furthermore this XML element can also be moved freely in the structure hierarchy after tagged and remains grouped and locked.
    In CS3 and CS4,
    I can't do that.
    It will give a warning message "Cannot modify elements that contain locked content, or are contained by locked content. Please unlock or check out the content and try again."
    So need to write script to unlock the image's parent first, and then tag and locked the object back automatically.
    (This script is essential so as to prevent any unintentional and accidental change on the page layout if it's done manually)
    But to make matter worse, grouped objects will need to also find out all these ancestors and have them unlocked first!
    It creates alot of hassle! Really being user-unfriendly in CS3/CS4 when doing such a simple xml tagging task.
    PLEASE please restore the wonderful CS2 feature back in the next version of Indesign.
    MILLIONS of thanks!!

    I'd suggest you submit your suggestion through the iTunes application feedback page. It's more likely to be seen by the iTunes development group that way.

  • What is the difference between acquiring lock on a CLASS and OBJECT (instance) of that class

    What is the difference between acquiring lock on a CLASS and OBJECT (instance) of that class

    What is the difference between acquiring lock on a CLASS and OBJECT (instance) of that class
    The Java Tutotials has several trails that discuss both implicit and explicit locking, how they work and has code examples.
    The Concurrency trail has the links to the other sections you need to review
    http://docs.oracle.com/javase/tutorial/essential/concurrency/index.html
    The Synchronized Methods and Intrinsic Locks and Synchronization trails discusse Synchronized Methods and Statements
    http://docs.oracle.com/javase/tutorial/essential/concurrency/syncmeth.html
    And the Lock Objects trail begins the coverage of explicit locking techniques.
    http://docs.oracle.com/javase/tutorial/essential/concurrency/newlocks.html

  • Re: what is difference between sap locking and database locking

    hi,
        what is difference between sap locking and database locking. Iam locked the table mara by using lock objects.
    But iam unable to unlock the mara table. I give u the coding. Please check it.
    REPORT zlock .
    CALL FUNCTION 'ENQUEUE_EZTEST3'
    EXPORTING
       MODE_MARA            = 'S'
       MANDT                = SY-MANDT
       MATNR                = 'SOU-1'.
    call transaction 'MM02'.
    CALL FUNCTION 'DEQUEUE_EZTEST3'
         EXPORTING
              mode_mara = 'E'
              mandt     = sy-mandt
              matnr     = 'SOU-1'.
    IF sy-subrc = 0.
      WRITE: 'IT IS unlocked'.
    ENDIF.

    Hi Paluri
    Here is the difference between SAP locks and Database locks, i will try to find the solution to your code.
    Regards
    Ashish
    Database Locks: The database system automatically sets database locks when it receives change statements (INSERT, UPDATE, MODIFY, DELETE) from a program. Database locks are physical locks on the database entries affected by these statements. You can only set a lock for an existing database entry, since the lock mechanism uses a lock flag in the entry. These flags are automatically deleted in each database commit. This means that database locks can never be set for longer than a single database LUW; in other words, a single dialog step in an R/3 application program.
    Physical locks in the database system are therefore insufficient for the requirements of an R/3 transaction. Locks in the R/3 System must remain set for the duration of a whole SAP LUW, that is, over several dialog steps. They must also be capable of being handled by different work processes and even different application servers. Consequently, each lock must apply on all servers in that R/3 System.
    SAP Locks:
    To complement the SAP LUW concept, in which bundled database changes are made in a single database LUW, the R/3 System also contains a lock mechanism, fully independent of database locks, that allows you to set a lock that spans several dialog steps. These locks are known as SAP locks.
    The SAP lock concept is based on lock objects. Lock objects allow you to set an SAP lock for an entire application object. An application object consists of one or more entries in a database table, or entries from more than one database table that are linked using foreign key relationships.
    Before you can set an SAP lock in an ABAP program, you must first create a lock object in the ABAP Dictionary.

  • Error "Problem occured locking WS object" while activating Proxy

    Hi All,
    I have move an Inbout proxy to a different Client(QA system) and in QA system that proxy shows incative.
    When i tried to activate that proxy/service in Sproxy, getting error "Problem occured locking WS object".
    Proxy was active in development system and was working fine without any error.
    Please provide some help, what need to be done to fix this issue
    Thanks
    Harshit

    Hi Harshit,
    Try with the following steps in sequence:
    1. Re-genarate the proxy in Development - Create a New Transport Reuest.
    2. Transport the Proxy from PI Dev to PI OA
    3. Confirm the Proxy in PI QA and then, transport the re-generated Request from ECC Dev to ECC QA.
    Regards,
    Pranav.

  • File Lock - How to lock and unlock a file ? Can we do that for an FTP File?

    Hi All,
    I like to retrieve a file from the FTP server using Apache Commons Net libraries.
    for example if the file size is 20MB. When the file is in the progress of copying or transferring from the FTP server i need to lock the local file which is in our local directory so that no other process will use the same local file which is in the process of copying otherwise partially copied files will be used by another process.
    the file should be locked when it was in the progress of copying from the server. I have an automatic process which will access file objects at certain time and try to process the files.
    I like to know the simplest and easiest way to lock and unlock a file object locally which is trying to copy a file from the FTP server which is of huge size.
    And also i like to know how to lock and unlock a file in general?
    Thanks,
    J.Kathir

    we can set it read only only when it complete finishing the writing.
    can we able to make the file as read-only while transferring data to file.
    How to achieve it ? pls give me some sample code

  • Lock and Commit work in INBOUND IDOC

    Hi Experts,
    Problem is about lock and commit work
    i need to receive idoc for Good receipt for purchase order.
    For one Purchase Order i can receive many good receipt Idoc at the same time and when first came in Lock the Purchase Order and further idoc came after give Errors becouse purchase Order is lock.
    Problem is not the serialization (the sequence is correct), but is the lock.
    Any idea on how to fix this issue? (maybe there is some std settings??)
    Cheers
    Boris

    Hello Guys
    the packetsize is already set to 1 but the problem still again..... and where i can find this setting   "in Customizing choose Engineering Change Management ® Define statuses for master record". ?
    Any way i try in function module in inbound to check the lock object with this sample code:
          DO 30 TIMES.
            CALL FUNCTION 'ENQUEUE_EMEKKOS'
             EXPORTING
               mode_ekko            = 'S'
               mandt                = sy-mandt
               ebeln                = goodsmvt_item-po_number
               _scope               = '2'
             EXCEPTIONS
               foreign_lock         = 1
               system_failure       = 2
               OTHERS               = 3.
            IF sy-subrc <> 0.
              WAIT UP TO 1 SECONDS.
            ELSE.
              EXIT.
            ENDIF.
          ENDDO.
    but also with this....problem syill again...
    thanks
    Boris

  • Lock and semaphore, what's better method for my case

    Hi all,
    I'm implementing a classic case: a consumption queue with infinite capacity. That's say I have a queue of infinity capacity, a thread to put objects into the queue, another thread take it out. Pseudo code is smth like below:
    void put(Object o) {
    put message into the queue
    if (consume thread is waiting) {
    lock();
    signal();
    unlock();
    void eat() {
    if (queue not empty)
    take object out;
    else
    lock;
    wait for signal from producer;
    wake up and take object out;
    unlock;
    I don't know if I should use semaphore or Lock interface to get the job done. Do you know which one is better in my case? I'm writing an apps which is very sensitive in latency so basically I want the eater to get the object as soon as possible. Any advices?
    Message was edited by:
    principles

    Blocking queue doesn't work for me as it is too slow.
    I don't need to lock the data because one thread
    adds too the tail, one thread consumes the head, so
    why bother?LinkedBlockingQueue allows concurrent access to the head and tail ie it uses two different locks.
    A Lock is a mechanism for mutual exclusion. It generally has a notion of ownership and so the thread that locks must be the thread that unlocks.
    A Semaphore is a resource counter. There are no constraints on which thread signals() after await(). It is only a protocol that you establish in your code that allows it to be used for exclusion.
    A bounded-buffer generally needs two synchronization aids:
    a) an exclusion control to ensure the data structure is not corrupted by concurrent access
    b) a coordination control to allow consumers to block when the buffer is empty, or producers to block when the buffer is full.
    These two can be combined by using "synchronized" methods and wait/notify. Or by using Lock and associated Condition objects. Or you can use "synchronized" blocks or Lock for exclusion, and handle the coordination using a seperate semaphore (which must use some form of internal synchronization too - but perhaps more efficient.)
    If you have a lock-free data structure, such as ConcurrentLinkedQueue then you don't need anything for (a) and so you only need coordination. So try using a Semaphore: put() increments it and take() decrements it.
    But the Semaphore still becomes a serialization point in your code.

  • Capability or admingroup to lock and unlock views

    Hi all,
    I am trying to lock and unlock users via
    lockObject(com.waveset.object.Type.USER, user, map); on a lighthouse session object and unlockObject((Object) com.waveset.object.Type.USER, user, map); on a session object
    but I get the error:
    WavesetException : com.waveset.util.WSAuthorizationException: View access denied to Subject AGROUPE1 on User: UTEST1.I tried to create an admingroup with this permission
      <Permissions>
        <Permission type='User' rights='View'/>
      </Permissions>But it didn't change the error.
    Any idea so that it could work ?

    You Can disable that functionality by disabling "Action Keys Mode" in the BIOS...
    Here is the document, that will help you with it... http://h10025.www1.hp.com/ewfrf/wc/document?docname=c02035108&cc=us&dlc=en&lc=en&jumpid=reg_R1002_US
    Although I am an HP employee, I am speaking for myself and not for HP.
    Make it easier for other people to find solutions, by marking my answer with 'Accept as Solution', if it solves your problem.
    Click on the BLUE KUDOS button on the left to say "Thanks"

  • FM to Lock and Unlock the Tcode CJ02

    Hi,
    I want to lock and unlock the Tcode CJ02, my code is as below.When I am executing the Report, I am able to create the Settlement Rule in first Row but I am getting an Error Mesage saying " Subproject 4-0123-02-01-01-10-01 is currently processed by USER" though there is no other session open under the user name when trying to create settlement rule in second row in the loop. Wbs element that ima using for creation of settlement rules is "4-0123-02-01-01-10-01".
    loop at it_src into wa_src.
    Lock the Tcode 'CJ02'.
    Perform BDC Recording to Create Settlement Rule.
    Unlock the Tcode 'CJ02'.
    endloop.
    Regards,
    Deepthi.

    Hi, you can block the Subproject with Lock Object, you can create this under SE11
    after you have created this, use these FM for Enqueue/Dequeue,
      call function 'ENQUEUE_EZ_ODAPROF_PO'
           exporting
                mode_ztma_odaprof_po = 'E'
                mandt                = sy-mandt
                ebeln                = cod_oda
                ebelp                = cod_pos
           exceptions
                foreign_lock         = 1
                system_failure       = 2
                others               = 3.
      call function 'DEQUEUE_EZ_ODAPROF_PO'
       exporting
         mode_ztma_odaprof_po       = 'E'
         mandt                      = sy-mandt
         ebeln                      = cod_oda
         ebelp                      = cod_pos

  • Lock and Unlock a table:AFVU

    Hi Folks.
    I want to modify a standard table (AFVU )  with new user dates from User.For this,First I need to lock and unlock the table.
    When I am trying for the standard table lock object (EAFVU) ,it was not there in the system.
    Is there any way to find out the lock object for a particular table?
    How to proceed for this?
    Any Pointers are much helpful.

    Hi,
    Go to SE11 and display your table - do a where used list and select lock objects.
    I really hope when you say you are modifying a standard table you are only updating custom appends on that table, and not directly updating standard SAP fields...
    Gareth.

  • Lock Selected objects

    Hi
    Any one please help me to use lock option in javascript
    i want to lock selected objects
    Thank
    APPU

    surendarappu wrote:
    help me to hide instead of lock
    To modify/change the code provided by Muppet Mark, from locking to hiding, see the following:
    // Change this line...
    // selectList[i].locked = true;
    // To the following...
    selectList[i].hidden = true;
    You could also change the two references of "lockSelection" for the function name and call, to something like "hideSelection" to avoid confusion as well if needed.
    * Was this helpful?

  • FM to find user who locked the object using enqueue...

    Hello,
    How can I find name of user who enqueued the lock object in ABAP ?
    Regards,
    Jainam.

    Hi Jainam,
    See the SAP documentation, e.g. [FAQ - Lock concepts|http://help.sap.com/saphelp_NW04/helpdata/en/cb/168237d30d974be10000009b38f8cf/content.htm]:
    How can I find out who is currently holding the ungranted lock? In other words, how can check the program after an ENQUEUE to determine which use is currently holding the lock so that I can let him or her know?                                 
    This graphic is explained in the accompanying text Answer
    When the ENQUEUE_... function module is returned, the name of the lock owner is listed in SY-MSGV1.
    If you don't want to attempt to lock an object and just check who might own a lock use function module ENQUEUE_READ. Lots of comments in the forum...
    Cheers, harald

Maybe you are looking for