How to get context information in your own class

Hi,
I'm new to Java and I'm trying to create my own class which stores some constants like for example mailServerHost. The class would look something like this:
public class AppSettings {
private static String mailServerHost="localhost";
static{
if(###online-server###)
mailServerHost="another mail server";
My problem is the if(###online-server###). I don't know how could I find informations about the underlying server.
Is there any way to find out informations about the context(server)?
Thanks,
IMIA

Do you still need ?n this case 2 different
property-files (one for dev and one for
online-servers).Yes, but they would have the same name. ;-)
After all when you need to load one
of them you'd still need in your AppSettings class on
which server your application is running. So I'd
still need that information.No, you use a fixed name, e.g. server.properties, for the config file.
You might find class java.util.ResourceBundle interesting.

Similar Messages

  • How to get context information?

    suppose i have created master detail.if i put mouse on any attribute of master ,related detail should be shown as context message.

    Hi,
    and the technology you use is?
    Frank

  • I am new to Mac Pro but am purchasing one online.  can anyone tell me how to get the information from my Toshiba onto the Mac.  there are no stores in the state I live in.  Do I need to find a location and will they do a transfer from my I Tunes etc?

    I am new to Mac Pro and am purchasing one online  tonight.  Can anyone tell me how to get my information - Itunes, photos, and videos transferred onto the Mac from my Toshiba.  the state I live in doesn't have an Apple store but I could take it to Minneapolis when I go.  Any ideas where to begin?

    You might profit from a visit to a Minneapolis Apple store. With a brand new Mac, I think they will be most helpful - not just with transferring files, but with other advice as well. And I strongly recommend you invest in a back up drive. The Apple folk can help with that as well.

  • How to get the information of the log related to t.code generated by basis.

    In the log generated by the basis personnel we found the details of user and corresponding t.code used details.  How to get the information reg. which document he went into using this t.code? For example me29 t.code used by 'x' user.  The log is showing time date t.code and user.  By using me29n which document he attended is the requirement. How to get this information. Let me know it pl.
    TS

    Thanks all for the help.
    Here is my solution. A mix from Julian and Thomas.
    In future I will encapsulate the code in a function module.
    DATA: BEGIN OF usr_tabl OCCURS 10.
            INCLUDE STRUCTURE uinfo.
    DATA: END OF usr_tabl.
    DATA: th_opcode(1) TYPE x.
    DATA: LV_TID LIKE  SY-INDEX.
    CONSTANTS: opcode_list LIKE th_opcode VALUE 2.
    CALL 'ThUsrInfo' ID 'OPCODE' FIELD opcode_list
      ID 'TAB' FIELD usr_tabl-sys.
    CALL FUNCTION 'TH_USER_INFO'
      EXPORTING
        CLIENT = sy-mandt
        USER   = sy-uname
      IMPORTING
        TID    = LV_TID.
    read table usr_tabl with key tid = lv_tid.
    IF sy-subrc = 0.
      CASE usr_tabl-type.
        WHEN 2.
          write :/ usr_tabl-type, 'SYSTEM'." (system)
        WHEN 4.
          write :/ usr_tabl-type, 'GUI'." (Gui)
        WHEN 32.
          write :/ usr_tabl-type, 'RFC'."(RFC)
        WHEN 202.
          write :/ usr_tabl-type, 'PLUG-IN'." (Plug-in &).
      endcase.
    ENDIF.

  • "See how to get instant updates on your phone" Doesn't go away. Help?

    In the Facebook app when I click on the notifications it says "See how to get instant updates on your phone" at the top. It doesn't go away from the top unless I enable push notifications for it. However, i don't want that. Help?

    There are 3 ways to exit a fullscreen app:
    Escape key
    Command+Control+F
    Hover the cursor at the top of the screen until the menu bar drops down then clcik the Arrow icon on the top right.
    Have you tried plugging it back into the TV?

  • How to get a confirmation when your email is delivered or read  ?

    With Mail app ,How to get a confirmation when your email is delivered or read?

    When I send mail with Mail app , there is flying letter pops up. But now I could not see anymore. Do you know how can I active that animation ?
    Thanks for your help

  • How I get a Information about how many Scheduling agree

    Dear friend,
       Can any one tell me a process ,How I get a information about how many scheduling agreement or Schedule lines created with in given time.Any standard tcode available  ?
    Regards
    Abrar AHmed

    Dear Abrar
    - To see how many scheduling agreement is created for a given period, use VA05, click on [Further sel criteria] and tick the box against [Sales Document type]  Now input the scheduling agreement type and execute.  You will get list of all scheduling agreements created within the specified period.
    - You can see how many line items are created in a sale order for a given period via VA05.
    thanks
    G. Lakshmipathi

  • How i get some informations about audio file?

    Hi to all,
    i would like to know how i get some informations about audio file, such as its artist, bitrate, file type, duration, ecc...
    Any help me?

    Ok, but which are the docs of audio format?Again, what does that have to do with Java?
    Where i can found these documents?Again, what does that have to do with Java?
    Thank you...For nothing.
    db

  • How to get Listener Information using PL/SQL code

    How to get Listener Information using PL/SQL code

    user2075318 wrote:
    How to get Listener Information using PL/SQL codeThis approach (somewhat of a hack) can be used - but it does not really provide meaningful data at application layer.
    SQL> create or replace function TnsPing( ipAddress varchar2, port number default 1521 ) return varchar2 is
      2          type THexArray is table of varchar2(2);
      3          --// tnsping packet (should be 10g and 11g listener compatible)
      4          TNS_PING_PACKET constant THexArray := new THexArray(
      5                  '00', '57', '00', '00', '01', '00', '00', '00',
      6                  '01', '39', '01', '2C', '00', '00', '08', '00',
      7                  '7F', 'FF', '7F', '08', '00', '00', '01', '00',
      8                  '00', '1D', '00', '3A', '00', '00', '00', '00',
      9                  '00', '00', '00', '00', '00', '00', '00', '00',
    10                  '00', '00', '00', '00', '00', '00', '00', '00',
    11                  '00', '00', '00', '00', '00', '00', '00', '00',
    12                  '00', '00', '28', '43', '4F', '4E', '4E', '45',
    13                  '43', '54', '5F', '44', '41', '54', '41', '3D',
    14                  '28', '43', '4F', '4D', '4D', '41', '4E', '44',
    15                  '3D', '70', '69', '6E', '67', '29', '29'
    16          );
    17 
    18          socket  UTL_TCP.connection;
    19          txBytes number;
    20          rxBytes number;
    21          rawBuf  raw(1024);
    22          resp    varchar2(1024);
    23  begin
    24          socket := UTL_TCP.open_connection(
    25                          remote_host => ipAddress,
    26                          remote_port => port,
    27                          tx_timeout => 10
    28                  );
    29 
    30          --// convert hex array into a raw buffer
    31          for i in 1..TNS_PING_PACKET.Count loop
    32                  rawBuf := rawBuf || HexToRaw( TNS_PING_PACKET(i) );
    33          end loop;
    34 
    35          --// send packet
    36          txBytes := UTL_TCP.write_raw( socket, rawBuf, TNS_PING_PACKET.Count  );
    37 
    38          --// read response
    39          rxBytes := UTL_TCP.read_raw( socket, rawBuf, 1024 );
    40 
    41          UTL_TCP.close_connection( socket );
    42 
    43          --// convert response to varchar2
    44          resp := UTL_RAW.Cast_To_Varchar2( rawBuf );
    45 
    46          --// strip the header from the response and return the text only
    47          return( substr(resp,13) );
    48  end;
    49  /
    Function created.
    SQL>
    SQL> select tnsping( '10.251.93.30' ) as TNSPING from dual;
    TNSPING
    (DESCRIPTION=(TMP=)(VSNNUM=169869568)(ERR=0)(ALIAS=LISTENER))
    SQL> select tnsping( '10.251.95.69' ) as TNSPING from dual;
    TNSPING
    (DESCRIPTION=(TMP=)(VSNNUM=0)(ERR=0)(ALIAS=LISTENER))
    SQL>

  • How to get this information for Conky

    Hi people,
    My question is how to get this information for show in Conky:
    - KDE version.
    - Last sync (pacman -Sy) and Last update (pacman -Su)
    For the first point could be use a script that execute $ kdesu --version and get information from there.
    I have no idea how get information from pacman (may be logs?).
    Any ideas?
    Thank you.

    I have had tremendous success with LUA in Conky on Arch. And all you need to to is put the text HI after the "TEXT" line. ^^;
    Examples of my LUA usage:
    http://fc02.deviantart.net/fs71/i/2010/ … usLink.png
    http://kittykatt.silverirc.com/screens/conky-HUD.png
    EDIT:  Also, I've had success with getting the KDE version by doing the following...
    kwin --version | awk '/^Qt/ {data="Qt v" $2};/^KDE/ {data=$2 " (" data ")"};END{print data}'
    This is the method I'm currently using in screenFetch. Tested it a couple of times myself, but besides that, I'm not sure if it will work or not.
    Last edited by kittykatt (2010-04-22 17:52:25)

  • I need reset my security information, I offered my user name and password is correct bout I can't get the information from your website in my email. So that I can't buy new app pay my money.

    I need reset my security information, I offered my user name and password is correct bout I can't get the information from your website in my email. So that I can't buy new app pay my money.

    Hi,
    Which website your are using to update the Adobe Flash player? No Adobe website ever ask for any id and password to update the flash player.
    If you are using MAC machine and its the password prompt while installing update that you are talking about then please follow What userid & password do I need to install Flash Player?
    -Varun

  • Interfaces for your own classes - do you bother?

    Hi All,
    before anyone gets upset, I did post a shorter version this to the Java Prog forum a couple of days ago. I'm reposting here because the thread was pushed down the list just as comments were getting interesting, and I was tossing up which forum was most appropriate anyway...
    OK, I'd like to pose a general question on the use of interfaces with your own classes. I am totally behind the concept of using appropriate interfaces for declaration of vars, parameters etc (i.e. use "List" rather than "Vector"), but what about your own classes?
    If I have a class in my application that doesn't fit into any kind of framework or class hierarchy, subclass of object basically, should I write an interface with all the same method sigs and use that rather than the class for my vars, params etc? This would make things more flexible in future, enabling you to swap classes in and out of your app more easily.
    Taking it a step further, how's this for a design methodology: For every class you write (once again classes that don't fit into your own or somebody else�s hierarchy or framework) do the following
    1. Create an interface (MyInterface) that maps 1 to 1 to that class (MyClass), with all the same method sigs.
    2. Make the constructor private and manage all the creation of instances of MyClass through a factory that returns objects of type MyInterface.
    If you do this there will be no mention of any of your concrete classes anywhere in your app except the factories, making it easier to refactor etc. Do this for all your classes.
    A little sketchy but I hope you get idea. Is this complete overkill? Is there a down side to this? Does anyone do anything like this?
    Cheers
    Matt

    Although the pattern you describes adds flexibility, it also adds complexety.
    Imagine somebody is looking at your code and from what he sees he deducts that the next thing to look at is the concrete class which is used at a given place.
    If you used an interface, he must find out which implementing class is actually used at this place. It's not a big thing, but if every single class has its seperate interface and factory I would consider it overkill ... after all you have to write all the boring code for this.
    In the case of doubt I'd agree it's better to throw in an interface and a factory instead of refactoring thousand lines of codes afterwards. But if nothing hints toward a second implementation of the interface, or another reason for using an interface don't bother to write one.
    As a general rule I use something like: Don't use a general rule. ;-)
    Spieler

  • How to create an object of our own class by using Class.forName()??

    how to create an object of our own class by using Class.forName()??
    plzz anser my qustion soon..

    Class.forName does not create an object. It returns a reference to the Class object that describes the metadata for the class in question--what methods and fields it has, etc.
    To create an object--regardless of whether it's your class or some other class--you could call newInstance on the Class object returned from Class.forName, BUT only if that class has a no-arg constructor that you want to call.
    Class<MyClass> clazz = Class.forName("com.mycompany.MyClass");
    MyClass mine = clazz.newInstance();If you want to use a constructor that takes parameters, you'll have to use java.lang.reflect.Constructor.
    Google for java reflection tutorial for more details.
    BUT reflection is often abused, and often employe when not needed. Why is it that you think you need this?

  • How to get maximal value from the data/class for show in Map legend

    I make WAD report that using Map Web Item.
    I devide to four (4) classes for legend (Generate_Breaks).
    I want to change default value for the class by javascript and for this,
    I need to get maximal value from the class.
    How to get maximal value from the data/class.
    please give me solution for my problem.
    Many Thx
    Eddy Utomo

    use this to get the following End_date
    <?following-sibling::../END_DATE?>
    Try this
    <?for-each:/ROOT/ROW?>
    ==================
    Current StartDate <?START_DATE?>
    Current End Date <?END_DATE?>
    Next Start Date <?following-sibling::ROW/END_DATE?>
    Previous End Date <?preceding-sibling::ROW[1]/END_DATE?>
    ================
    <?end for-each?>
    o/p
    ==================
    Current StartDate 01-01-1980
    Current End Date 01-01-1988
    Next Start Date 01-01-1990
    Previous End Date
    ================
    ==================
    Current StartDate 01-01-1988
    Current End Date 01-01-1990
    Next Start Date 01-01-2005
    Previous End Date 01-01-1988
    ================
    ==================
    Current StartDate 01-01-2000
    Current End Date 01-01-2005
    Next Start Date
    Previous End Date 01

  • How to get a char from a String Class?

    How to get a char from a String Class?

    Use charAt(int index), like this for example:
    String s = "Java";
    char c = s.charAt(2);
    System.out.println(c);

Maybe you are looking for

  • Jjmack! Please help me "adobe photoshop express version 2.7.2

    Please Jjmack!  Before i was buy "adobe photoshop express version 2.7.2." at app store.  But it's all removed. Please help me to be use able to adobe photoshop express version 2.7.2. I can't utterly version 3.0. Please teach me a way download.

  • Fixing Virtual PC 7 on Corporate LAN with Outlook

    I was having problems getting my new Quad with 10.4.3 and VPC 7.0.2 to work properly at home to connect my Outlook using my VPN into work. I tried a bunch of stuff and ran across the following post at Microsoft: http://support.microsoft.com/kb/824440

  • My pavilion dv2500 has no audio.

    my computer has no audio sound. my computer is pavilion dv2500 win7. pls help me to fix this problem. thank you

  • Can't load video to timeline

    Hi, I've just installed Premiere Pro on my Mac mini. I import a video, select a frame and then I try to attach it to the timeline and there's no way to do it. It doesn't display "video 1", "video 2", etc.. I don't know what to do since I'm quite amat

  • New Tab above New Window in FF 3.x

    Hi, so I recently used Firefox 4+ for the first time, and I like the way it puts the "Open link in new tab" above the "Open link in new window" (when one right-clicks on a link). It takes a bit of getting used to at first, but it's actually a lot mor