How to deal with a property file and EJB

Hello,
I'm quite new to the EJB technology.
My problem is, how to handle a property file?
Let's say I have a custom 'property.xml' (that holds some application specific constants) somewhere in my EJB jar or in a related jar (so it is in the classapth).
Usually (not with EJB) I would write a class (let's name it 'Props', see below) which reads the property file once and initialize some public static members.
In an object (see below 'MyClass') I would then use 'Props.memberName' if I want to have access to a constant property.
class with public static constants members; read the file only once; properties are in memory ...
public class Props
  public static String FOO = null;
  static
    Properties props = new Properties();          
    try
      props.loadFromXML(CConstants.class.getClass().getClassLoader().getResourceAsStream("propertyFile.xml"));
      FOO = props.getProperty("FOO");
    catch(Exception e){...}
}The class that uses the properties<br>
public class MyClass
  public void doSomething()
    String s = Props.FOO + " BAR";
}But unfortunately static things are not allowed in EJB ...
What is the preferred way to get access to the properties?
To read the file each time an EJB is used, will cause much disc-I/O and xml parsing (this is very unefficient).
Is there no mechanism to read such things once only?
I would be very pleased to get an answer, because I don't know how to solve this problem
Thanks

Use the @Resource annotation on fields representing the application-specific constants. Override those values as you see fit with the standard ejb-jar.xml file's env-entry element.

Similar Messages

  • How can we locate the property file and read from it in .js page?

    HI
    I am having an static html page where in the url is hardcoded,so i wanted to read it from a property file and which can be done by using .js files
    i wanted to know how to deal with property files in .js?
    Thankx

    I assume you know that Java and JavaScript only share a name and they are both programming languages but little else.
    You can load JavaScript in Java 6. However for questions on what the JavaScript should do I suggest you try a javascript forum.

  • How to deal with multiple mail files?

    Here's the story; it's sad but true: After a failed iSync spirited away all of my emails, the Apple Care techie I spoke to a month ago wasn't able to fully resolve the problem. So, currently in my Home Library folder I have 2 Mail files: #1 is labeled "Mail" and #2 is "Mail Copy."
    "Mail" has one sub-folder called "Mailboxes" and four other folders for each of my four POP email accounts (there are also a number of other files that I'm ignoring for the moment like--Envelope Index, Signatures.plist, ect.). All mail from the past 4 weeks is in the folder labeled "Mail." But...
    The other folder in my home library--"Mail Copy"--contains 3 POP email accounts and each one has sub-folders that contain mailboxes with my emails that go back many months. I want to keep the email in both folders, "Mail" and "Mail Copy."
    Problem: How to get the older messages out of "Mail Copy" and back into the current "Mail" folder. Clearly, it would be a mistake to simple drag them from one location to the other, since the "Contents" files and ".plist" files wouldn't match.
    I would be extremely grateful for any guidance the Mail authorities who contribute to this forum might be able to give.
    Also, for the life of me, I cannot figure out where the emails actually reside. The "Mail" folder contains a subfolder entitled "Mailboxes" and it contains subfolders for each mailbox like "Action.mbox" and "Hold.mbox." Then, inside each .mbox folder are other files and usually one folder. Most of these files have names like "content_index," "Info.plist," "mbox," and "tableofcontents." And there is a folder labeled "Messages" and it contains numerous ".emix" files and one "tableofcontents file." My confusion begins when I open a particular POP account folder and find .mbox folders also located there and those folders also contain .emix files. I've searched the entire knowledge base, and I find no explanation anywhere of which files/folders are located where and why.
    Many thanks for your time and trouble, Jay

    The easiest way to combine the old folders with the new is to use the "Import" option in Mail's File menu. Consult the Mail Help topic "Importing email into Mail" for comprehensive instructions for doing that. In your case, the "archived" messages will be the ones in "Mail Copy."
    The actual messages are stored in individual *.emlx files, inside each mailbox folder's "Messages" folder. (For instance, you would find a message in a locally stored, root level mailbox "Action" at path ~/Library/Mail/Mailboxes/Action.mbox/Messages/xxx.emlx, where "xxx" is a number.)
    Some of the files you mention are leftovers from Mail 1.x & are not needed with Mail 2.x. They won't do any harm if left in place, but you can remove them if you wish. (I suggest making a backup of the entire ~/Library/Mail/ folder beforehand, in case something you need accidentally gets deleted.)
    These files are not needed by Mail 2.x: "content_index," all "tableofcontents" files, & files named "mbox." All folders with names ending in ".mbox" are needed, since they contain the .emlx files. You may also find folders in ~/Library/Mail/Mailboxes/ with no ".mbox" extension pared with folders of the same name with the ".mbox" extension (like "Hold" & "Hold".mbox") -- do not delete any of these, as they contain "Messages" folders as well.

  • How to deal with non-continuous shapes and graphic styles

    I am not sure how to frame this question so I will try to describe the problem.
    Imagine I have two shapes. One is a hollowed out circle (like a doughnut chart). The second is a smaller filled in circle. The smaller filled in circle is then poitioned inside the hoolowed out one, so you have like a target but with no "middle" band. What I would like to do is apply a graphic style to the COMBINED shape. The problem is that if I select both shapes and apply the style, each shape will have its own style, whereas what I want is for the style to be distributed over the two shapes as if they were one. And if I use the shape builder tool, when I join the two shapes, from the outer hollowed out circle to the inner filled in circle, I fill in the shape for the "middle band" whereas I want that middle band to be empty.
    You can probably tell I don't know Illustrator and come from Photoshop. In PS, I would simply select my two shapes and apply a style. Since my selection forms a shape that ignores the middle band, the style applies evenly to the whole selection. Can I do something similar in Ilustrator? In reality my network of shapes is more complex that the example above and I do need to keep it a vector.
    Thank you for your suggestions.
    Chris

    There are really two types of Graphic Styles - Object level styles and Group level styles. There is no way to tell which style is which. So if you have an Object level Style and try to apply it to a group of objects or often a compound shape, you get each individual object having the style. If you have a Group level style and try to apply it to only an object, you often get nothing applied.
    It perhaps sounds like you have an Object level style and are trying to apply it to a group.
    There's no way to convert an Object level style to a Group level style or vice versa. The best (and pretty much only) way I've found to get around this is to apply the style to teh correct level then make a note of all the style settings, select the other level and recreate the style for that level.
    Whether or not a style applies correctly has a great deal to do with specific aspects of the style in addition to what level the style was generated from. This is a frustrating aspect of Graphic Styles.

  • AVCHD: how to deal with the .MTS files in FCP 5 or iMovie 08

    I just bought a Canon HF10 AVCHD camcorder and stumbles into the difficult editing process with FCP 5. Here are my steps:
    - Conversion of the camcorder .MTS files with iMovie 8; they are then transformed into a .MOV sequence. A 14secondes sequence recorded in the highest quality (FXP, 17Mbps) is captured as a 28MB .MTS file by the camcorder, rendered as a 231MB .MOV file by iMovie 8, and it took 53 sec to process it !
    - I export the sequence as: Share >Export Final Cut XML…
    - In FCP 5: import XML…then I tried different modes: AIC 1080i60 (image is overstreched), AIC 720p30 (proportion is OK, but I captured in 1080…), AIC DV NTSC 48kHz (not HD…) BUT none of the resulting sequence is rendered, I still have the red bar above the timeline.
    For financial reason, I’d like to avoid to go to FCP 6, which seems to work natively with the AVCHD format.
    My questions are:
    - is there a way to reduce the size of the iMovie converted files: 900MB per minute ?
    - is there a way not to have to render the imported files in FCP ?
    Can anyone help me ?

    I have the same camera and the reality is you're going to go through that translation from AVCHD to some sort of Quicktime file format no matter which tool you use. I do it with FCP6 and it needs to do the same translation from the .mts files to (they recommend) ProRes files. AVCHD is a highly compressed format and when you move it to an editable form, the file(s) is going to get much larger. It is HiDef content after all which can be quite large.
    In my case, once I do the transfer to ProRes format nothing needs to be rendered in the FCP timeline unless I add some sort of filter or effect to it.
    The rendering problem you are describing is often caused by the Sequence setting not matching the content settings. This is automated in FCP6 where it detects the content format of the video you're trying to add and changes the sequence settings to match the content. Take a look at the sequence settings and see if they match the structure of the content and that should resolve the 'everything needs to be rendered' situation.

  • Solution how to deal with cheap HDMI cables and some VGA adapters.

    I've purchased cheap HDMI cable which I couldn't force to work. Basically after plugging in the screen on my mac blink blue for a second, but then everything is going back to normal, and screen seems to be not recognized. I checked the cable with my friend's mac, and it was working just fine, so I thought hey something is wrong with my mac, either the MiniDisplay Port or Lion (10.7) has some bug (friend is working on (10.6).
    I was experimenting with VGA adapter and it showed that MiniDisplay Port is fine, unfortunatelly it is painfull because quality is lower, and audio has to be plugged in separately. Accidently I've plugged in HDMI while audio was connected regular way and it started. So I figured out that probably grounding in those cheap cable is not sufficient for some macs. So step, by step solution:
    1. Plug in HDMI cable to your TV
    2. Switch TV to the right setting (display given HDMI port)
    3. Connect audio cable to your TV
    4. Connect audio cable to your MAC
    5. Connect HDMI cable to your mac.
    6. Image should appear on your TV, you can change resolution if you like
    7. To enable sound on TV go to System Preferences, choose Sound, Output tab, and choose your HDMI connected TV.
    While testing my VGA adapter which was working fine but I never could make it work with my Panasonic TV, I found a way around. First you have to connect to regular monitor, or TV which is working, and then switch to TV. The reason why it is not working straight is probably to high resolution that mac is trying with this TV. In points:
    1. Plug VGA adapter to monitor or TV that you know it is working.
    2. Plug adapter to your mac
    3. With adapter connected to mac switch VGA cable to your panasonic plasma tv.
    I hope this soultions will help some of you.
    Enjoy!

    Templeton Peck said:
    "or you could just save yourself the trouble and buy cables and adapters from a reputable brand."
    Well, I got mine directly from the Apple Store in Amsterdam and I got the most expensive one they had.. iwire.
    Still stopped working after 4 weeks! (In Holland you have only 14 days to bring back stuff)
    so careful what you say.

  • How to deal with " and '

    hi evry one, i have query that insert a text in a table. The problem is that the text contain these caracters : ' and ", so how to deal with them.

    Use PreparedStatement and setString. That should escape the single and double quotes properly for you.
    If you've got a String with double quotes in it you'll just have to escape it properly:
    public class DoubleQuoteTester
        public static void main(String [] args)
            for (int j = 0; j < args.length; ++j)
                System.out.println(args[j]);
    }Here's a typical run:
    java DoubleQuoteTester "I quoted the president as saying, \"I forgot!\"" "Quoth the raven 'Nevermore'"
    I quoted the president as saying, "I forgot!"
    Quoth the raven 'Nevermore'

  • How to deal with '$' sign in the class name?

    I want to put my Java Applet game on my homepage. But the server which I set up my homepage doesn't support the file name like XXX$XXX.class, which has '$' sign in the file name. Would anyone can tell me how to deal with this problem? And how can I make the game work on my homepage? Thanks.

    Don't forget, this include both concrete inner classes as well as any anonymous inner classes you create, like
    myButton.addActionListener(new ActionListener()
      // Yada Yada Yada

  • Can SQL*PLUS deal with 'flat ASCII files' (input ) in UNIX ? and how?

    Can SQL*PLUS deal with 'flat ASCII files' (input ) in UNIX ? and how?

    No, but PL/SQL can. Look at utl_file.
    John Alexander www.summitsoftwaredesign.com

  • How to deal with file(for example .xml)? what format of dir should be?

    I'd like to operate the file in disk, and want to use relative directory?
    How to deal with file dir? what format of dir should be?

    Hi Kamlesh,
    Thanks for your response.
    Actually, In the "Process External Bank Statement" window, i see that there are few entries which is for the previous year and which has not been reconciled. I have never worked practically on BRS and hence, i am scared to make any changes in the clients database without being confident on what i am doing. I need to reconcile for one of their Bank a/c for the month of April '08. I have the copy of the statements for the month ending 31st Mar 08 and 30th Apr 08. The closing balances are as below:
    31/03/08 - 2300000.00
    30/04/08 - 3100000.00
    Now my OB for Bank a/c for April '08 in SAP is 2300000.00 Dr.
    When i go to External Bank Reconciliation - Selection Criteria Screen (Manual Reconciliation), here are the detail that i enter:
    Last Balance: INR -7,000,000.00000 (Grayed out by the system)
    Ending Balance: INR -3,100,000.00000 (Entered by me)
    End Date: 30/04/08 (Entered by me)
    "Reconciliation Bank Statement" Screen opens up and shows the below balances in the screen:
    Cleared Book Balance: INR -7,000,000.00000
    Statement Ending Balance: INR -3,100,000.00000
    Difference: INR 3,800,000.00000
    As per the Bank statement, i have found all the transactions listed out here for the month of Apr '08 but, i also found that the open transactions for the previous month from April '08 have been lying in "Process External Bank Statement" window.
    Could you please help me solve my issue as to what needs to be done or could you also get me some links from where i can get few documents for processing External Bank Reconciliations?
    That will be of a great help for me. I need steps as to what needs to be done first and then the next so that i can arrive at the correct closing balance for the month April '08.
    Thanks in Advance....
    Regards,
    Kaushal

  • How to deal with files ?!!!!

    hiii, guys i dont believe that a huge program like flash with
    all these abilities doesnt deal easily with files !!! I just want
    to do simple reading and writing to text files. Something veryyyyyy
    simple like writing a name and reading it again later
    !!!!!!!!!!!!!!!!!! i know how to load them by using loadVariable()
    ,,, but how can i write to the file ?!! it's really annoying if i
    have to use asp scripting or xml or ... to do such easy job !!! i'm
    facing difficulties because i know ActionScript and VB and C++
    only,,, I dont know how to deal with asp and xml !!! @_@
    But, if this is the only way to do this, plz tell me in steps
    how to write a name and read it again in flash, THANX

    If you are sticking to those three languages and you have
    Flash CS3, you may want to consider publishing to an AIR
    application. Adobe's done a lot of work to keep the security tight
    on Flash Player which is one (if not the only... not sure) reason
    that you cannot do this with Flash alone. You would have to use a
    server-side script to accomplish what you want with Flash Player.
    Here is a tutorial on an AIR app that writes to txt files:
    http://www.adobe.com/devnet/air/flash/quickstart/building_text_editor.html

  • How to deal with special character in source file

    Hi experts,
                      i am doing a file to file scenario in which my source file contains many special characters when i am puting this file into moni its going with the special character .My source file is a fixed length file so in content conversion i have specified the file length but due to these special charcters these field lenght is also varing.So please guide me how to deal with these special characters in sender adapter
    regards,
    Saurabh

    you could try using a Java Mapping to change the encoding manually. For that, set the encoding of the OutputFormat of the XML you'll serialize. Try the following code piece for the mapping (inside a try/catch declaration):
    DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
    DocumentBuilder documentBuilder = factory.newDocumentBuilder();
    Document input = documentBuilder.parse(in);
    OutputFormat format = new OutputFormat(XML, "ISO-8859-1", false);
    XMLSerializer serializer = new XMLSerializer(out, format);
    For more details check this guide:
    https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/com.sap.km.cm.docs/library/uuid/502991a2-45d9-2910-d99f-8aba5d79fb42

  • How to deal with conflict and potential conflict classes?

    Some classes are marked as conflict and potential conflict classes in the Classloader Analysis Tool.
    How to deal with them?
    How to use suggested solutions?

    Not double load them.
    Conflicting classes can lead to weird exceptions. One obvious example would be if you package
    an older servlet.jar version into your application and use the weblogic classloading features, such
    as prefer-web-inf-classes, to tell weblogic to use this class instead of the one provided in the
    system classpath. This one example which leads to weird exceptions, such as connot process jsp tag...
    If you really need a the version of the jar for your application, you have to test it through and through
    so that you know you do not run into weird production errors.

  • While installing latest version of iTunes error "This iTunes installer is intended for 32-bit versions of Windows. Please download and install the 64-bit iTunes installer instead" how to deal with it ?

    While installing latest version of iTunes error "This iTunes installer is intended for 32-bit versions of Windows. Please download and install the 64-bit iTunes installer instead" how to deal with it ?

    Doublechecking. What's the filename of the installer you've been downloading? (The 32-bit installer is called iTunesSetup.exe, and the 64-bit installer is called iTunes64Setup.exe.)

  • Mm issue:-how to deal with  gds sent for repairs and again issued for consm

    The main problem is that if something come for repairing it increase the stock for one period and decrease the R and M for that period. And when after 4 months when goods are received after repairing it disturbs the R and M expense in another period.  And this also disturbs the valuation of the material.
    Any one can suggest how to deal with the repairs done to materials without affecting the valuation price of  original material.
    my points is how everyone in india is dealing with goods sent for repairs outside their company.
    what all entries are generated from first receipt of goods in company till  good sent for consumption after received from vendor who repaired the goods.
    all a/c and mm entries

    what we have decided that we would have 2 valuation type
    1. sap-domestic :- normal stock
    2. sap-use/repair :- repaired items.
    All the goods should be received using sap-domestic valuation. from here goods are sent to shop floor. when ever repair is required goods are received in stock thru sap-use-repair at value zero and not moving price specific to sap-use/repair valuation.
    so till goods that require repair and that already repaired are kept in stock, they are kept at 2 different values one is zero and other is moving price specific to valuation type sap-use/repair.
    now goods are sent for repair at zero value but when these goods are received after repair then value of repair will affect the moving price of valution sap-use/rep.
    so this will solve our problem that goods should be received from shop floor to stock for repair at value zero.
    how can we achieve this that goods received from shop floor to stock for repair is received at zero value and not moving price specific to valuation sap-use/rep. where we will have do setting in this vaution type or wherever required.
    pls send some suggestions on it

Maybe you are looking for

  • View Object to read data from a java file

    Hi, I am using JDeveloper 11.1.1.4 and ADF-BC in my application. For one of my view objects , I want the data to be read from a java file which exposes some method to return a collection. I cannot use a static view object in this case. Please suggest

  • Dont show balances with 0 amount in Reports?

    Hi, Can we restrict reports, developed through Report Painter, not to display the items of which the posting/balance is 0. I have a requirement of not to show GL accounts that are with 0 balances in customized balance sheet? Thanks

  • Location of iCal Automator Scripts (Plugins?)

    AHHHH.  Apple you drive me crazy with this stuff!!! I need to alter an automator script I made for iCal.   ...  but I can't figure out where these things are stored in my hidden, buried, locked and unalterable system.  If I open a iCal set up in Auto

  • Schedule sent messages

    Can anyone tell me where to find a schedule to sent messages in a specific time and day, in Apple mail ?

  • Color management problem (Leopard) and 1.3.1

    I am getting good screen to print match with Photoshop CS3 printing with Leopard and the new Epson drivers, but Lightroom 1.3.1 prints like there is no, or very bad color management. The older (1.2) version on another computer prints fine. I am using