Reading an external property file for adapter configurations (How-To)

One thing that has bugged me is having to change an Adapter's property settings in the context file and then build and re-deploy the bundle to effect those changes. This really becomes a problem when you want to test a bundle in different server environments (Development, QA, Staging) and then finally deploy that same bundle to Production. Here at EnerNOC, all those environments have different message servers and database schema names, making it a real challenge to insure you're building the same bundle each time for the different environments.
I played with a number of different ideas, but I wanted the solution to be Spring based. I finally settled on a rather simple solution to use external property files with the <util:properties/> tag of Spring, and then injecting the bean created from this into the adapters requiring different configurations.
First, in the context file, I needed to add a new Spring namespace - http://www.springframework.org/schema/util:
+<beans xmlns="http://www.springframework.org/schema/beans"+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"*
xmlns:osgi="http://www.springframework.org/schema/osgi"*
xmlns:wlevs="http://www.bea.com/ns/wlevs/spring"*
xmlns:util="http://www.springframework.org/schema/util"*
xsi:schemaLocation="*
http://www.springframework.org/schema/beans*
http://www.springframework.org/schema/beans/spring-beans.xsd*
http://www.springframework.org/schema/osgi*
http://www.springframework.org/schema/osgi/spring-osgi.xsd*
http://www.springframework.org/schema/util*
http://www.springframework.org/schema/util/spring-util-2.5.xsd*
http://www.bea.com/ns/wlevs/spring*
http://www.bea.com/ns/wlevs/spring/spring-wlevs-v11_1_1_3.xsd">*
Next, I defined a bean for my property file:
+*<util:properties id="serverProperties" location="file:./applications/MyApplication/server.properties"/>*+
And then finally, I modified my adapter to inject a Properties object and use that to define the other properties in the Adapter:
+*<wlevs:adapter id="MyMessageAdapter" class="com.enernoc.cep.message.adapter.MyMessageAdapter" >*+
+*<wlevs:instance-property name="properties" ref="serverProperties"/>*+
+*<wlevs:listener ref="HAInputAdapter"/>*+         
+*</wlevs:adapter>*+
With this change, I can now build and deploy a bundle once to whatever servers I choose, and modify the server.properties file in each environment to make the necessary changes for message servers and databases. In a multi-server enviroment this becomes really handy as our deploy script needs to only create and push server.properties files and not new bundles.
As a nice-to-have feature someday, it would be great if Oracle could enable their <wlevs:/> namespace to recognize the Spring PropertyPlaceholderConfigurer feature, so that we could use placeholder variables for property values of <wlevs:/> specific tags.
Edited by: Jim Leary on Feb 28, 2011 4:11 PM
Edited by: Jim Leary on Feb 28, 2011 4:14 PM
Edited by: Jim Leary on Feb 28, 2011 4:15 PM
Edited by: Jim Leary on Feb 28, 2011 4:16 PM
Edited by: Jim Leary on Feb 28, 2011 4:17 PM
Edited by: Jim Leary on Feb 28, 2011 4:18 PM
Edited by: Jim Leary on Feb 28, 2011 4:19 PM

Jim,
You can use com.bea.wlevs.spring.support.ConfigurationPropertyPlaceholderConfigurer, which is based on org.springframework.beans.factory.config.PropertyPlaceholderConfigurer. For example,
<bean class="com.bea.wlevs.spring.support.ConfigurationPropertyPlaceholderConfigurer">
<property name="location" value="file:config/test.properties"/>
</bean>
<wlevs:adapter id="myAdapter" class="oracle.cep.sample.MyTestAdapter" >
<wlevs:instance-property name="serverAddress" value="${serverAddress}"/>
</wlevs:adapter>
Manju.

Similar Messages

  • How to read an external XML file in a indesign Plugin?

    Hi All,
    Can you please guide in reading an external XML file in a indesign Plugin in MAC system. I am an windows user.We are using this file for reading some inputs.
    Thanks,
    Daniel

    Hello Daniel,
    I am uncertain about the actual question. If you are developing a plug-in or otherwise interfacing with the guts of ID, I suggest asking the question in the SDK forum:
    InDesign SDK Forum
    Otherwise, what is it you are wanting to know concerning importing XML into InDesign?
    Mike

  • Standard way to maintain property files for internationalization??

    Hi All,
    For multiple language support, normally we maintain a different property file for different languages.For example, consider English language.In my case, i placed all the labels for english in one property file through out my application.All french labels in one property file and so on.
    My question is, Is it better to maintain seperate property file for each page also??? Or else, one property file is good enough for one language??? which is better?(interms of complexity and performance)

    Here is how I mapped the taglibs in my XML file and it works fine:
    <taglib>
              <taglib-uri>/WEB-INF/struts-bean.tld</taglib-uri>
              <taglib-location>/WEB-INF/lib/struts-bean.tld</taglib-location>
    </taglib>The .tld files are in the WEB-INF/lib dir. To use them i put this line in the JSP file:
    <%@ taglib uri="/WEB-INF/struts-html.tld" prefix="struts_html" %>Hope this helped,
    Calin

  • Help Required on Reading an External XML file in flex

    Hi Experts
    I want some help regarding flex.
    I want to read an external xml file in flex and want to show
    different datas in different components
    So bacically i need what is the procedure to call an external
    xml file and the procedure to catch the value of the xml tags and
    the option (options means ex: "id" or "type inside" "row" tag ) in
    side the xml file.
    Here is My xml file named "skn_organ.xml"
    <?xml version="1.0" encoding="UTF-8"?>
    <slide>
    <r>7</r>
    <c>8</c>
    <row id="A01" type="g">
    <organ>Skn</organ>
    <link>
    http://www.designgarbage.com</link>
    </row>
    <row id="A02" type="g">
    <organ>Brt</organ>
    <link>
    http://www.designgarbage.com</link>
    </row>
    <row id="A03" type="g">
    <organ>Spl</organ>
    <link>
    http://www.designgarbage.com</link>
    </row>
    <row id="A04" type="g">
    <organ>Lnode</organ>
    <link>
    http://www.designgarbage.com</link>
    </row>
    <row id="A05" type="g">
    <organ>Ske</organ>
    <link>
    http://www.designgarbage.com</link>
    </row>
    <row id="A06" type="g">
    <organ>Lun</organ>
    <link>
    http://www.designgarbage.com</link>
    </row>
    <row id="A07" type="g">
    <organ>Sgl</organ>
    <link>
    http://www.designgarbage.com</link>
    </row>
    <row id="A08" type="g">
    <organ>Liv</organ>
    <link>
    http://www.designgarbage.com</link>
    </row>
    <row id="B01" type="g">
    <organ>Gal</organ>
    <link>
    http://www.designgarbage.com</link>
    </row>
    <row id="B02" type="g">
    <organ>Pan</organ>
    <link>
    http://www.designgarbage.com</link>
    </row>
    <row id="B03" type="g">
    <organ>Ton</organ>
    <link>
    http://www.designgarbage.com</link>
    </row>
    <row id="B04" type="g">
    <organ>Eso</organ>
    <link>
    http://www.designgarbage.com</link>
    </row>
    <row id="B05" type="g">
    <organ>Sto</organ>
    <link>
    http://www.designgarbage.com</link>
    </row>
    <row id="B06" type="g">
    <organ>Sto</organ>
    <link>
    http://www.designgarbage.com</link>
    </row>
    <row id="B07" type="g">
    <organ>Sbl</organ>
    <link>
    http://www.designgarbage.com</link>
    </row>
    <row id="B08" type="g">
    <organ>Col</organ>
    <link>
    http://www.designgarbage.com</link>
    </row>
    <row id="C01" type="g">
    <organ>Skn</organ>
    <link>
    http://www.designgarbage.com</link>
    </row>
    <row id="C02" type="g">
    <organ>Brt</organ>
    <link>
    http://www.designgarbage.com</link>
    </row>
    <row id="C03" type="g">
    <organ>Spl</organ>
    <link>
    http://www.designgarbage.com</link>
    </row>
    <row id="C04" type="g">
    <organ>Lnode</organ>
    <link>
    http://www.designgarbage.com</link>
    </row>
    <row id="C05" type="g">
    <organ>Ske</organ>
    <link>
    http://www.designgarbage.com</link>
    </row>
    <row id="C06" type="g">
    <organ>Lun</organ>
    <link>
    http://www.designgarbage.com</link>
    </row>
    <row id="C07" type="g">
    <organ>Sgl</organ>
    <link>
    http://www.designgarbage.com</link>
    </row>
    <row id="C08" type="g">
    <organ>Liv</organ>
    <link>
    http://www.designgarbage.com</link>
    </row>
    <row id="D01" type="g">
    <organ>Gal</organ>
    <link>
    http://www.designgarbage.com</link>
    </row>
    <row id="D02" type="g">
    <organ>Pan</organ>
    <link>
    http://www.designgarbage.com</link>
    </row>
    <row id="D03" type="g">
    <organ>Ton</organ>
    <link>
    http://www.designgarbage.com</link>
    </row>
    </slide>

    Hi sanjivsutar,
    Put your xml file under folder "assets", the application demo
    is as following
    ====================================================================
    <?xml version="1.0" encoding="utf-8"?>
    <mx:Application xmlns:mx="
    http://www.adobe.com/2006/mxml"
    initialize="init()">
    <mx:Script>
    <![CDATA[
    private var mainXML:XML;
    private var loader:URLLoader;
    private function init():void {
    loader = new URLLoader();
    loader.addEventListener(Event.COMPLETE, onComplete);
    loader.load(new URLRequest('assets/skn_organ.xml'));
    private function onComplete(evt:Event):void {
    mainXML = new XML(loader.data)
    out.text += "xml loaded, using E4X syntax: \n\n";
    out.text += "Row 1: "+mainXML.row[0]+"\n"
    out.text += "Row 6: organ = "+mainXML.row[5].organ+"\n"
    out.text += "Row(id='D02'): link =
    "+mainXML.row.(@id=="D02").link+"\n"
    ]]>
    </mx:Script>
    <mx:TextArea id="out" width="400" height="300"/>
    </mx:Application>
    ======================================================================
    Jeffrey

  • To install Photoshop CS6, I have already downloaded the 2 files for Windows.  How can I activate the product?

    To install Photoshop CS6, I have already downloaded the 2 files for Windows.  How can I activate the product?

    I am having the same problem. I did download the two files and started the .exe file. The .exe file appears to run downloading files. When the bar is full the window dissapears without any options. Both files are in the same folder. any thoughts?

  • What values to place in signer.properties file for Webutil configuration

    Hi. I'm not sure of what value to place in JDK_HOME in signer.properties for Webutil configuration. My current settings are:
    JDK_HOME=D:\ora9i\jdk
    JINIT_HOME=C:\Archivos de programa\Oracle\JInitiator 1.3.1.13
    #Certificate settings:
    # These are used to generate the initial signing certificate
    # Change them to suite your organisation
    DN_CN=Product Management
    DN_OU=Development Tools
    DN_O=Oracle
    DN_C=US
    JAR_KEY=webutil
    JAR_KEY_PASSWORD=webutil
    Is JDK_HOME the jdk for oracle or SDK for windows machine(how to find?)?. Also how do i repeat the process of makecert and signing of webutil.jar and jacob.jar?. If i try to repeat this process I get the following warnings or error?
    Makecert:
    keytool error: java.lang.Exception: Key pair not generated, alias <webutil> already exists
    Certificate created...

    JDK_HOME is just the location of a Java distribution with Keytool in it - have a look at the signer batch file and you'll see how each variable is used. Also if you run keytool from the command prompt it will show you the commands to delete and existing Key or list the keys that are currently stored.

  • Creating external mapping file for C# application

    Hi,
    I'm using Robohelp 7 and producing HTMLHelp files. So far, the programmers have been making internal links in the program to call my help, but I'd like to take this over using an external mapping file.
    Is it possible to use regular map files, using the built-in Map ID functionality, for C# .NET applications? If so, is there something special I have to do? Or do I just create a regular map file?
    Thanks!

    I mean that, in the past, they have hard-coded the link to each help page within the application. But, I'd like to take that over by maintaining a Map file where I specify the link between the topic and the Map ID.
    However, I'm not sure that the map file works for C# .Net applications, and the engineers aren't sure either. I told them I'd go investigate.
    Is there a way to create a Map file, or something that works like a map file, for a C# .Net application? Or do they have to go on hard-coding the links to each topic?

  • Reading an external text file in WAR file

    Greetings,
    I have a question. I have an web application that writes a text message and 0's and 1's based on checkboxes. Then I have a JSP that reads this text file and prints the message and enables/disables links based on the 1's and 0's. I don't have any problems with this when testing from localhost, but when I deploy to a server the application isn't reading the file. The text file and WAR file are in the same folder, same directory. I've tried using both relative and absolute paths to read the file, but to no avail. Is there an easy way to read an external file from a WAR file or is there an easier solution. Thanks
    Nick

    You should not try to force your text file to live in the same directory as the WAR file. Instead, you should remove that kind of dependency and instead be using something like System.getProperty("java.io.tmpdir") to use the temporary directory to create and delete these files.
    Edit: I also bet you don't even need to create & read a file here. You could probably store the information in one of the contexts of the web app, such as in a Session. I'll assume you know what that means.
    By creating a file, you are also running the risk of multiple threads (simultaneous users) vying for the same file name, thus walking on each other's data.
    Message was edited by:
    warnerja

  • How to read values from Property file into BPEL process local variable?

    I would like to use a Property file with some parameters e.g.
    <myparm1>12345</myparm1>
    How can I read from a BPEL process such a Property file and assign it into e.g. local variable "intparm1"?
    Where (in which directory) should I put this XML Property file to have it always available for reading?
    Peter

    Hi,
    You can also use
    ora:readFile( ) function as follow :
    ora:readFile(xml file location (ex. "file:///D:\\SOA\\FileAdapters\\readFile\\test\\test.xml"),xsd file location (ex."file:///D:\\SOA\\FileAdapters\\readFile\\test\\test.xsd"))
    inside the assign activity and assign this to the variable you want.
    regards
    arababah
    Edited by: arababah on Aug 10, 2009 12:55 AM

  • Separate property files for two builds

    Hi,
    I have two build files, one is build.xml and another is DB.xml which executes some targets in build.xml
    Eg :- 'customer' is a property which i need to enter both in build.xml and and DB.xml,
    Here the 'customer' property is been read from build.properties file but not from DB.properties file which is specific to DB.xml. But I want the properties to be independent for both build.xml
    and DB.xml i.e when i run DB.xml it should read the 'customer' property from DB.properties but not from build.properties
    can any body help
    thanks in advance

    Two options spring to mind.
    Properties in ant are read only. i.e. once they've been set, that's it.
    By putting <property file="DB.properties" /> at the top of DB.xml and <property file="build.properties" /> at the top of build.xml providing you're calling ant -buildfile DB.xml everything should work OK.
    Option 2.
    The targets in build.xml that are called by DB.xml should be parameterised.
    Common compile target in build.xml
    <target name="compile">               
       <javac srcdir="${srcdir}"
                    destdir="${destdir}" classpathref="compile.classpath"
              debug="${debug}"
                    fork="yes"
                    executable="${executable}"
              source="${source}" />
    </target>Code that uses the common compile target
    <import file="build.xml" />
    <target name="compile">
       <antcall target="compile">
          <param name="srcdir" value="${project.src}" />
          <param name="destdir" value="${project.build}" />
          <param name="debug" value="${release.java.debug}" />
          <param name="executable" value="${release.java.home}/bin/javac.exe" />
          <param name="source" value="${release.java.version}" />
          <reference refid="compile-src-classpath" torefid="compile.classpath" />
       </antcall>
    </target>

  • External xmp file for JPEG

    Hi,
    Is there any possibility to save develop settings for JPEG file into external XMP file - not inside JPEG?
    It is confusing for all backup software. Backup system have to transfer all modified JPEG files - not lightweight xmp files. Moreover, modification date of original JPEG file changes. I would like to have all my original JPEG files untouched as RAW files.
    Thanks for suggestions
    Sebastian

    ksebman wrote:
    My backup software transfers files through the Internet. So if I make small changes to hundreds of files, I have to transfer all JPEGs which are relatively huge. It takes a long time. External xmp file would be better because of its textual nature and size. Moreover I would like to have original files, not modified by any software (even if image data is untouched). I do like the way how RAW files are handled - no modifications at all.
    I know, there are people who like having metadata in JPEG files because they use other applications. Searching through the Internet I found that there is a lot of people who decide not to use LR from that reason (modified original JPEG file). They set read-only attribute for all JPEGs to prevent this behavior.
    It's really inconvenient - possibility to save external XMP file as in RAW files would be very helpful.
    Best Regards
    Sebastian
    You do not need to back up all those JPEGs after each change. Back them up once at the start, and then back up the lrcat file (maybe zipped) routinely. This means both the original image data and all your editing work are backed up, and you could reconstruct your picture collection perfectly from your backup. The sidecar-based backup scheme would mean that all your work wouldn't be backed up (or you'd be forced to avoid a range of Lightroom features).
    It's a wrong-headed reason to avoid LR. XMP is not written into proprietary raw files because Adobe consider it too risky. With JPEGs, it isn't - and if you are worried, just backup a virgin JPEG immediately after importing them.
    John

  • Read from a property file which is in a zip

    I have the problem, that I can�t read a property file in a zip. A class which I ca get in the same zip needs this property to init.
    I call this in a batchfile.
    The message is like:
    c:/xx/core.zip!/com/xx/Prop.properties
    Path of the zip Path of the Property in zip
    Syntax or name or path are not correct.
    Where is the problem?
    Thanks in advance
    Frank

    hm, am not sure I follow but
    it is not possible to instantiate the class. I only use this class. >Java will find the class in the same zip and path, but the property->File will not be loaded while a FileInputStream wonts to open it.FileInputStream can't be used to open a zipped file, you can get an InputStream from the ressources variable by using URL.openStream method and feed this into Properties.load
    if you post some code here that you are able to change, then people might be able to help more :)
    asjf

  • Developing site to use external javascript files for server access. my ain.js file just displays and does not execute. Why?

    My ain.js file is meant to work on and access server files for tracking all visitors to the site I am developing.
    One way to access it, in my plan, is to use index.htm. when I open index.htm it displays correctly and presents a link to ain.js with a query line (?a=zzzzz--e2).
    The entire file is displayed; but not executed.
    Short of building my own server (prior to publishing what I am developing) how do you propose I test what I have written?
    As a retiree, I have limited funds (the purpose of developing a website is meant to coorect that).

    This forum is for Firefox user support, very few of our contributors are developers.
    Try posting at the Web Development / Standards Evangelism forum at MozillaZine. The helpers over there are more knowledgeable about web page development issues with Firefox. <br />
    http://forums.mozillazine.org/viewforum.php?f=25 <br />
    You'll need to register and login to be able to post in that forum.

  • Looking at External SSD Drive for Lightroom Editing - How Can I Set This Up and Which Drive?

    I'd like to purchase an external SSD drive for Lightroom editing and am hoping somebody can provide a recommendation for me.
    I'm using a FW800 G-Drive to store my Lightroom Library and have been using this drive to edit.  I'd like to add an external SSD drive for editing photographs an am looking for recommendations on which drive and the best way to set this up.  I plan on having a 3rd (and maybe 4th) to save both the FW800 files and working SSD drive files as a backup.
    Any recommendations are sincerely appreciate. 

    I believe I was loading a preview file to 100%.  I think maybe I should just use what I have and work with it.  It's much faster than my 7 year old MBP performed that's for sure.
    I was just wondering if I could spend a few hundred for an external Thunderbolt or USB 3 drive to speed up my productivity.  With the full time job and the kids, I have a little time to work on photography.  I'd love to increase my output.  I'm more than willing to spend the money on the TB or USB 3 if it would help.
    The specs on the camera say 24.1 million pixels:  24.6 MB.  The raw files are
    NEF (RAW): 14 bit, compressed

  • I have built a Muse site for a manufacturer but My client needs his customers to be able  submit their files for quotation. How do I do this in Muse?

    Hi
    I have built a Muse site for a manufacturer. My client needs his customers to be able to upload their files for quotes. I notice that other web sites do have this facility in their contact form. How do I do this in muse?

    That question is best asked on the Muse forum here:
    Help with using Adobe Muse CC

Maybe you are looking for