javaextensions/centralrepository/inc/centrepfunctionserver.h
branchRCL_3
changeset 77 7cee158cb8cd
equal deleted inserted replaced
71:d5e927d5853b 77:7cee158cb8cd
       
     1 /*
       
     2 * Copyright (c) 2010 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 #ifndef CENTREPFUNCTIONSERVER_H
       
    20 #define CENTREPFUNCTIONSERVER_H
       
    21 
       
    22 #include "monitor.h"
       
    23 #include "functionserver.h"
       
    24 #include "legacyeventserverwrapper.h"
       
    25 
       
    26 namespace java
       
    27 {
       
    28 namespace centrep
       
    29 {
       
    30 
       
    31 /**
       
    32  * If we have to execute some operation that essentially
       
    33  * needs ActiveScheduler, then we use this CentrepFunctionServer.
       
    34  *
       
    35  * We must however be careful not to make callbacks through FunctionServer.
       
    36  * Reason: If in callback, app calls another method that needs FunctionServer
       
    37  * to execute, we enter a deadlock.
       
    38  */
       
    39 
       
    40 class CentrepFunctionServer: public java::util::FunctionServer,
       
    41         public LegacyEventServerWrapper
       
    42 {
       
    43 public:
       
    44 
       
    45     CentrepFunctionServer() :
       
    46             java::util::FunctionServer("JavaCentrepFunctionServer")
       
    47     {
       
    48         JELOG2(EJavaCentrep);
       
    49 
       
    50         //Creates a new thread and starts active scheduler
       
    51         //This results in call to doServerSideInit()
       
    52         createServerToNewThread();
       
    53         mServer = reinterpret_cast<java::util::FunctionServer*>(this);
       
    54     }
       
    55 
       
    56     ~CentrepFunctionServer()
       
    57     {
       
    58         JELOG2(EJavaCentrep);
       
    59         stopServer();
       
    60     }
       
    61 
       
    62     java::util::FunctionServer* getFunctionServer() const
       
    63     {
       
    64         JELOG2(EJavaCentrep);
       
    65         return mServer;
       
    66     }
       
    67 
       
    68 private:
       
    69 
       
    70     void doServerSideInit()
       
    71     {
       
    72         JELOG2(EJavaCentrep);
       
    73         FunctionServer::doServerSideInit();
       
    74     }
       
    75 
       
    76 private:
       
    77 
       
    78     java::util::FunctionServer* mServer;
       
    79 };
       
    80 
       
    81 } //end namespace centrep
       
    82 } //end namespace java
       
    83 
       
    84 #endif // CENTREPFUNCTIONSERVER_H