Results 1 to 5 of 5

Thread: Environment variables for java IceBoxin IceGrid

  1. #1
    Sameerrele's Avatar
    Sameerrele is offline Registered User
    Name: Sameer Rele
    Organization: TRG
    Project: SOA
    Join Date
    Aug 2006
    Location
    New York
    Posts
    18

    Environment variables for java IceBoxin IceGrid

    I have java services running within IceBox. These services read system properties and act on it. I am on windoze !

    When IceBox is started in standalone mode I pass the system properties either by setting them explicitly in the environment or via -D in the java command line.

    I would like to deploy the same services running within java IceBox in IceGrid and need to pass the same system properties.

    I have tried following and would appreciate your help / input to achieve the best solution.

    Also, in the following cases ONLY case 3 works for me and values for environment variables are not set in case 1 and case 2. I really dont want to hard code the values in the xml file. (I have tried setting the system environment properties)

    Thanks for your help in advance

    Case 1
    Code:
    <icegrid>
        <application name="DevIceBox">
            <node name="localhost">
                <icebox id="DevIceBox" exe="java" activation="on-demand">
                    <option>-DAPP_FILE=%APP_FILE%</option>
                    <option>-DENV_FILE=%ENV_FILE%</option>
                    <option>IceBox.Server</option>
                    <service name="MyService" entry="com.xxx.myservice">
                        <adapter name="${service}" endpoints="tcp -p 10010" register-process="true"/>
                    </service>
                </icebox>
            </node>
        </application>
    </icegrid>
    Case 2
    Code:
    <icegrid>
        <application name="DevIceBox">
            <node name="localhost">
                <icebox id="DevIceBox" exe="java" activation="on-demand">
                    <env>APP_FILE=%APP_FILE%</env>
                    <env>ENV_FILE=%ENV_FILE%</env>
                    <option>IceBox.Server</option>
                    <service name="MyService" entry="com.xxx.myservice">
                        <adapter name="${service}" endpoints="tcp -p 10010" register-process="true"/>
                    </service>
                </icebox>
            </node>
        </application>
    </icegrid>
    Case 3
    Code:
    <icegrid>
        <application name="DevIceBox">
            <node name="localhost">
                <icebox id="DevIceBox" exe="java" activation="on-demand">
                    <option>-DAPP_FILE=c:\config\config.xml</option>
                    <option>-DENV_FILE=c:\config\dev.properties</option>
                    <option>IceBox.Server</option>
                    <service name="MyService" entry="com.xxx.myservice">
                        <adapter name="${service}" endpoints="tcp -p 10010" register-process="true"/>
                    </service>
                </icebox>
            </node>
        </application>
    </icegrid>
    Sameer Rele
    Global Enterprise Solutions Architect

    The Rohatyn Group
    280 Park Avenue, 27th Floor - West
    New York, NY 10017
    Tel : (212) 984 2946
    sameer.rele@rohatyngroup.com

  2. #2
    benoit's Avatar
    benoit is offline ZeroC Staff
    Name: Benoit Foucher
    Organization: ZeroC, Inc.
    Project: Ice
    Join Date
    Feb 2003
    Location
    Rennes, France
    Posts
    2,196
    Hi,

    Case 1 won't work, you can only reference environment variables from an environment variable definition.

    Case 2 should set the APP_FILE or ENV_FILE environment variables with the value of the %APP_FILE% or %ENV_FILE% environment variable (defined in the IceGrid node environment -- before the node is started) in the Java process environment. However, I don't think this will set any system properties. You should be able to access these environment variables with System.getenv() though (assuming you use JDK 1.5).

    Cheers,
    Benoit.

  3. #3
    Sameerrele's Avatar
    Sameerrele is offline Registered User
    Name: Sameer Rele
    Organization: TRG
    Project: SOA
    Join Date
    Aug 2006
    Location
    New York
    Posts
    18
    Benoit,

    Thanks for the reply.

    I have tried setting the environment variables in the script that launches icegridnode and also the system environments.

    In the java iceservice I am accessing these variables using System.getProperty( ) which returns null.

    Does it mean that when IceBox server instance is started the existing system properties are refreshed?
    Sameer Rele
    Global Enterprise Solutions Architect

    The Rohatyn Group
    280 Park Avenue, 27th Floor - West
    New York, NY 10017
    Tel : (212) 984 2946
    sameer.rele@rohatyngroup.com

  4. #4
    benoit's Avatar
    benoit is offline ZeroC Staff
    Name: Benoit Foucher
    Organization: ZeroC, Inc.
    Project: Ice
    Join Date
    Feb 2003
    Location
    Rennes, France
    Posts
    2,196
    I don't think you can access environment variables through system properties with System.getProperty() (unless of course you explicitely specify a -D<name>=<value> option for each environment variable). You have to use System.getenv() to get the value of an environment variable but this method is only available in the JDK >= 1.5.

    Note that another mechanism to pass environment specific configuration to the servers started by an IceGrid node is to use the IceGrid node "IceGrid.Node.PropertiesOverride" configuration property. This property allows you to specify Ice properties that will be passed to each server started by the IceGrid node.

    Cheers,
    Benoit.

  5. #5
    Sameerrele's Avatar
    Sameerrele is offline Registered User
    Name: Sameer Rele
    Organization: TRG
    Project: SOA
    Join Date
    Aug 2006
    Location
    New York
    Posts
    18
    Thanks for your help.

    I will work on your suggestions.

    Regards
    Sameer Rele
    Global Enterprise Solutions Architect

    The Rohatyn Group
    280 Park Avenue, 27th Floor - West
    New York, NY 10017
    Tel : (212) 984 2946
    sameer.rele@rohatyngroup.com

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. icegrid xml environment variables
    By area51 in forum Help Center
    Replies: 2
    Last Post: 12-02-2010, 07:20 AM
  2. icebox environment variables
    By rpeters in forum Help Center
    Replies: 12
    Last Post: 06-30-2010, 06:40 PM
  3. What Development Environment to use for Java
    By gsteele9 in forum Help Center
    Replies: 5
    Last Post: 07-18-2008, 02:22 PM
  4. Using environment variables with config.txt
    By stephan in forum Help Center
    Replies: 1
    Last Post: 09-25-2006, 04:22 PM
  5. IceGrid variables Ice-3.0.1
    By xdm in forum Help Center
    Replies: 1
    Last Post: 01-26-2006, 05:25 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •