javauis/javalegacyutils/src/eventserver/Close.cpp
changeset 76 4ad59aaee882
parent 69 773449708c84
child 79 2f468c1958d0
equal deleted inserted replaced
69:773449708c84 76:4ad59aaee882
     1 /*
       
     2 * Copyright (c) 1999-2001 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #include <mevents.h>
       
    20 #include <j2me/jdebug.h>
       
    21 
       
    22 void CJavaEventSourceBase::DoFinalize(CJavaEventSourceBase* aThis)
       
    23 //
       
    24 // Server-side invokation function for finalization
       
    25 //
       
    26 {
       
    27     aThis->FinalizeSvr();
       
    28 }
       
    29 
       
    30 EXPORT_C void CJavaEventSourceBase::Close(JNIEnv& aJni)
       
    31 //
       
    32 // Remove a reference to the object, this is either from Dispose(),
       
    33 // or due to event dispatch. When no longer referenced, the object is
       
    34 // destroyed completely.
       
    35 //
       
    36 {
       
    37     if (User::LockedDec(iRef)==0)
       
    38     {
       
    39         __ASSERT_DEBUG(IsDisposed(),User::Invariant());     // must have called Dispose()
       
    40         // server side finalization
       
    41         if (iServer.Handle()!=0)
       
    42         {
       
    43             ExecuteV(&CJavaEventSourceBase::DoFinalize,this);
       
    44         }
       
    45         // JNI object finalization
       
    46         FinalizeJni(aJni);
       
    47         // remove our own weak reference
       
    48         if (iPeer)
       
    49             aJni.DeleteWeakGlobalRef(iPeer);
       
    50         // finally destroy the object
       
    51         delete this;
       
    52     }
       
    53 }
       
    54 
       
    55 void CJavaEventSourceBase::OnVmClose()
       
    56 //
       
    57 // Remove a reference to the object, this is either from Dispose(),
       
    58 // or due to event dispatch. When no longer referenced, the object is
       
    59 // destroyed completely.
       
    60 //
       
    61 {
       
    62     if (User::LockedDec(iRef)==0)
       
    63     {
       
    64         __ASSERT_DEBUG(IsDisposed(),User::Invariant());     // must have called Dispose()
       
    65         // server side finalization
       
    66         if (iServer.Handle()!=0)
       
    67         {
       
    68             //ExecuteV(&CJavaEventSourceBase::DoFinalize,this);
       
    69         }
       
    70 
       
    71         // finally destroy the object
       
    72         delete this;
       
    73     }
       
    74 }