javacommons/gcfprotocols/socket/socket/javasrc/com/nokia/mj/impl/properties/socket/SocketDynamicPropertyHandler.java
branchRCL_3
changeset 83 26b2b12093af
parent 77 7cee158cb8cd
child 84 0553e2305d00
equal deleted inserted replaced
77:7cee158cb8cd 83:26b2b12093af
     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 package com.nokia.mj.impl.properties.socket;
       
    19 
       
    20 import java.util.Hashtable;
       
    21 import java.io.IOException;
       
    22 import com.nokia.mj.impl.rt.support.Jvm;
       
    23 import com.nokia.mj.impl.rt.support.SystemPropertyProvider;
       
    24 import com.nokia.mj.impl.utils.Logger;
       
    25 
       
    26 public final class SocketDynamicPropertyHandler implements SystemPropertyProvider
       
    27 {
       
    28     static
       
    29     {
       
    30         try
       
    31         {
       
    32             Jvm.loadSystemLibrary("javasocket");
       
    33         }
       
    34         catch (Exception e)
       
    35         {
       
    36             Logger.ELOG(Logger.ESOCKET, e.toString());
       
    37         }
       
    38     }
       
    39 
       
    40     private static String SOCKET_LOCALHOST_NAME = "microedition.hostname";
       
    41 
       
    42     private static final int LOCALHOST_NAME = 1;
       
    43 
       
    44     private static Hashtable iPropertyKeys;
       
    45 
       
    46     static
       
    47     {
       
    48         iPropertyKeys = new Hashtable();
       
    49         iPropertyKeys.put(SOCKET_LOCALHOST_NAME, new Integer(
       
    50                               LOCALHOST_NAME));
       
    51 
       
    52     }
       
    53 
       
    54     /**
       
    55      * Retrieves socket localhost system property.
       
    56      *
       
    57      * @param aKey
       
    58      *            The property to retrieve as defined in this class.
       
    59      * @return The value of the property specified; null if the property is not
       
    60      *         defined
       
    61      */
       
    62     public String getProperty(String aKey)
       
    63     {
       
    64         String propertyValue = null;
       
    65         String propertyName = aKey;
       
    66 
       
    67         Object property = iPropertyKeys.get(propertyName);
       
    68         if (null == property)
       
    69         {
       
    70             return "localhost";
       
    71         }
       
    72         propertyValue = _getLocalhostname();
       
    73 
       
    74         return propertyValue;
       
    75     }
       
    76 
       
    77     public boolean isStatic(String aKey)
       
    78     {
       
    79         return true;
       
    80     }
       
    81 
       
    82     private static native String _getLocalhostname();
       
    83 }