Learn how to a build a cloud-first strategyRegister Now


Getting System Variables / Environment information using spring ??

Posted on 2005-04-21
Medium Priority
Last Modified: 2010-03-31

InitialContext ic = new InitialContext();

                  String rootDirectory = (String)ic.lookup("java:comp/env/rootDirectory");
                  String pathSeparator = (String)ic.lookup("java:comp/env/pathSeparator");

These can get you the system pathseperator and rootDirectory information using any J2EE Compliant container....

How to acheive the same using spring ??

Question by:letsbedecent
1 Comment
LVL 15

Accepted Solution

aozarov earned 1500 total points
ID: 13839431
Isn’t that defeating the philosophy of IoC container.
Jndi elements under java:comp/env are local variable to the specific J2EE item.
I think in the spring world you are suppose to do that by having a property on the bean and let spring initialize it for you.
  <bean id="your_bean_id" class="full_class_name">
    <property name="otherBeanRef">
        <ref bean="a reference to another bean via that bean id"/>
  <property name="pathSeparator">
          <value><![CDATA[/]]></value> <!—any constant value &#61664;
 <property name="rootDirectory">
          <value><![CDATA[/home/xxx/]]></value> <!—any constant value &#61664;

where your bean should have setters/getters for pathSeparator and rootDirectory

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Java had always been an easily readable and understandable language.  Some relatively recent changes in the language seem to be changing this pretty fast, and anyone that had not seen any Java code for the last 5 years will possibly have issues unde…
In this post we will learn different types of Android Layout and some basics of an Android App.
This tutorial explains how to use the VisualVM tool for the Java platform application. This video goes into detail on the Threads, Sampler, and Profiler tabs.
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …
Suggested Courses
Course of the Month20 days, 17 hours left to enroll

810 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question