javamanager/javaregistry/legacy/server/src/javaregserverscheduler.cpp
author Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
Thu, 15 Jul 2010 18:31:06 +0300
branchRCL_3
changeset 23 e5618cc85d74
parent 14 04becd199f91
permissions -rw-r--r--
Revision: v2.1.32 Kit: 2010127

/*
* Copyright (c) 2005-2006 Nokia Corporation and/or its subsidiary(-ies).
* All rights reserved.
* This component and the accompanying materials are made available
* under the terms of "Eclipse Public License v1.0"
* which accompanies this distribution, and is available
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
*
* Initial Contributors:
* Nokia Corporation - initial contribution.
*
* Contributors:
*
* Description:  javaregserverscheduler implementation
*
*/


// INCLUDES
#include "javaregserverscheduler.h"
#include "javaregserver.h"

using namespace Java::Manager::Registry;

// LOCAL CONSTANTS
_LIT(KNameJavaRegServerThread, "JavaRegServerThread");


// ---------------------------------------------------------------------------
// ThreadStart
// ---------------------------------------------------------------------------
TInt CJavaRegServerScheduler::ThreadStart()
{
    TInt err = KErrNoMemory;

    // get cleanup stack
    CTrapCleanup* cleanup = CTrapCleanup::New();

    // initialize all up to and including starting scheduler
    if (cleanup)
    {
        TRAP(err, CreateAndRunServerL());
        delete cleanup;
    }

    return err;
}


// ---------------------------------------------------------------------------
// CreateAndRunServerL
// ---------------------------------------------------------------------------
void CJavaRegServerScheduler::CreateAndRunServerL()
{
    // Rename thread
    TInt err = User::RenameThread(KNameJavaRegServerThread);
    __ASSERT_DEBUG(err == KErrNone, User::Invariant());

    // construct active scheduler
    CJavaRegServerScheduler*  self = new(ELeave) CJavaRegServerScheduler;
    CleanupStack::PushL(self);
    CActiveScheduler::Install(self);

    // construct server
    self->iServer = CJavaRegServer::NewL();

    // Initialisation complete, now signal the client
    RProcess::Rendezvous(KErrNone);

    CActiveScheduler::Start();

    // Destroy the scheduler
    CleanupStack::PopAndDestroy(self);
}


// ---------------------------------------------------------------------------
// Destructor
// ---------------------------------------------------------------------------
CJavaRegServerScheduler::~CJavaRegServerScheduler()
{
    delete iServer;
}

// End of File