Use Enum to keep config attributes.

Hi Guys,
There´s some restrictions to keep config atributes on enum??? Thanks !! I have an xml and use the folow code to retrieve data, and i think to replace this with a enum ...
public static Map loadFolderConfig()
    if (xmlConfig != null)
      return xmlConfig;
    try
      String docFullPath = "/my-config.xml";
      DocumentBuilder db = JAXPFactory.getInstance().getFactory();
      Document xml = db.parse(DocumentoHelper.class
          .getResourceAsStream(docFullPath));
      NodeList nodeListPrincipal = xml.getElementsByTagName("myconfig");
      NodeList nodeList = nodeListPrincipal.item(0).getChildNodes();
      Node nodeAtual = nodeListPrincipal.item(0).getFirstChild();
      xmlConfig = new LinkedHashMap();
      for (int f = 0; f < nodeList.getLength(); f++)
        NamedNodeMap attributes = nodeAtual.getAttributes();
        if (nodeAtual != null && attributes != null)
          String value = attributes.item(0).getNodeValue();
          xmlConfig.put(attributes.item(0).getNodeName(), value);
        nodeAtual = nodeAtual.getNextSibling();
    }Edited by: PaulH on 30/03/2012 12:09

An XML file is the better way to go in my opinion.
If you use an Enum to store your config attributes, you have to compile your Java code any time an attribute needs to be changed.
Using an XML config file, you don't need to recompile your code so it makes for easier modifications of config attributes.
Another option might be keeping your config attributes in a database table as that makes for easy modification without recompiling as well.

Similar Messages

  • I am trying to upgrade to itunes 10.7 using windows and keep getting the following error message: "Error writing to file: C:\Config.Msi\364460.rbf   Verify access to this dierctory". Help!

    I am trying to upgrade to itunes 10.7 using windows and keep getting the following error message: "Error writing to file: C:\Config.Msi\364460.rbf   Verify access to this dierctory". Help!

    Fixed! (win7 64 bit)! Just stop your antivirus during the upgrade/installation (I've got Kaspersky).
    Good luck!

  • Is there support in certmap.conf for using DN's with dc= attributes

    Hi Folks-
    The Question:
    Is there any support on certmap.conf (or the like) for dealing with suffixes that use the "dc=example,dc=com" format (in either 5.2 or 6.0)?
    The Details/Background:
    Like many places our suffixes are named ending with "dc" attributes (e.g. dc=example,dc=com). I've been setting up SSL Client Certificate based authentication. It's working via the CmapLdapAttr with a custom attribute/class added to the schema (I haven't finished with VerifyCert yet).
    The docs say that DNComps and FilterComps support the following RDN keywords: cn, ou, o, c, l, st, e, and mail. Notably missing from both is "dc". This seems to leave no valid value for DNComps (forcing all the searches to be across ALL suffixes including cn=config and co). With those global searches FilterComps also seems to be fairly limited (especially if uid is not part of the Certificate's Subject DN which it arguably shouldn't be in many situations).
    It seems all I'm left with is CmapLdapAttr (after creating the custom attribute & class) with every search across all suffixes. I don't think I can (or should) place indexes in the stuff in dse.ldif, hopefully they won't stop the other suffixes to be searched using their indexes and these should be small enough (and hopefully in memory) that they don't make a real difference.
    Thanks,
    -Scott-

    Ok, so as far as I can tell that just leaves using "CmapLdapAttr" with a custom attribute (& class) extension to the schema.
    Since I won't be able to restrict the suffix being searched it's going to do at least 6 separate scans: one each on userRoot (and any other user suffixes), NetscapeRoot, "", cn=schema, cn=config, and cn=monitor (based on what it's reported in the logs already).
    (1) Am I correct in my assumption that creating indexes on attributes in the suffixes in dse.ldif is probably not possible and would be a bad idea?
    My guess is that everything in dse.ldif gets loaded into memory on startup and stays there. Also these aren't that big so the combination should mean that their search time is negligible.
    (2) When automatically searching all 6+ suffixes (on every client certificate authenticated connection) will it perform indexed searches on userRoot & NetscapeRoot (assuming the correct indexes exist for CmapLdapAttr) and unindexed searches for the suffixes in dse.ldif? Or will the lack of indexes in the dse.ldif suffixes cause all of the searches to be unindexed?
    (3) Is there something I'm missing that would be a better approach?
    Thanks,
    -Scott-

  • Using OID in place of attribute name in an update operation

    Hi,
    I use Iplanet DS 5.0 on Solaris 8.0
    An application that I use needed a custom defined schema.
    This application tries to update entries using the OID of the attribute instead of the attribute name.
    ie. It uses
    Add: 2.5.4.58;binary
    instead of the name of the attribute -- attributeCertificateAttribute that has been defined in the directory.
    This operation fails with an objectClass violation.
    The developer pointed out that this was allowed by the RFC and that it worked with other directories.
    Later I tried replacing attribute names by their OIDs in corect LDIF files and these operations failed too.
    I have included an ethereal trace of the request and of the response.
    Question:
    Does this work on Iplanet DS? How can I get it to work ?
    Thanks,
    sriad
    Request
    =========================================
    Message Id: 2
    Message Type: Modify Request (0x06)
    Message Length: 437
    Distinguished Name: CN=User0,O=PERMIS,C=GB
    Add: 2.5.4.58;binary
    Response
    ======================================
    Message Id: 2
    Message Type: Modify Result (0x07)
    Message Length: 7
    Result Code: Objectclass violation (0x41)
    Matched DN: (null)
    Error Message: (null)

    Thank you ReubenC, the business has decided to not proceed with the LDAP configuration of web.config at this time and would rather stay with using the TNS entry for the time being; this is because we just mirgated their instance to an 11g environment and they want to ensure they have no issues with the migration before they take on web.config changes too.
    I will however try your recommendation when they choose to proceed and let you know how it turns out.
    Thank you,
    Charlie

  • BUG: JDeveloper 10.1.3.0.3 EA - Exception in switch using enum

    Hi,
    I was encountered runtime exception in switch statement, if I use enum.
    In the next example the exception:
    Exception in thread "main" java.lang.ClassFormatError: Invalid field attribute index 0 in class file com/crcdata/enumtest/client/EnumTest$1
         at java.lang.ClassLoader.defineClass1(Native Method)
         at java.lang.ClassLoader.defineClass(ClassLoader.java:620)
         at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:124)
         at java.net.URLClassLoader.defineClass(URLClassLoader.java:260)
         at java.net.URLClassLoader.access$100(URLClassLoader.java:56)
         at java.net.URLClassLoader$1.run(URLClassLoader.java:195)
         at java.security.AccessController.doPrivileged(Native Method)
         at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
         at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
         at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:268)
         at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
         at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319)
         at com.crcdata.enumtest.client.EnumTest.main(EnumTest.java:13)
    is thrown on line "switch (season)".
    package com.crcdata.enumtest.client;
    public class EnumTest {
      public enum Season { WINTER, SPRING, SUMMER, FALL }
      public EnumTest() {
      public static void main(String[] args) {
        EnumTest enumTest = new EnumTest();
        Season  season = Season.WINTER;
        switch (season) {
          case WINTER:
            System.out.println("Season: " + season.name());
            break;
          default:
            System.out.println("Another season");
            break;
    }This exception occur only if use ojc compiler. The javac compiler is OK.
    Versions:
    JDeveloper 10.1.3.0.3 EA
    J2EE 1.5.0_05
    Regards,
    Petr

    Thanks for reporting this. I filed bug 4720493 on this.

  • CS4 crashes when I send to print and pen tool loses the ability to keep the attributes of a multi-stroked line.

    Using Illustrator CS4 (can't upgrade because the office I am contracted with will not upgrade) on a Mac running Mavericks 10.9.5 (just upgraded from 10.6). CS4 crashes when I send to print (I've been saving as a PDF and printing that). Also, the pen tool loses the ability to keep the attributes of a multi-stroked line.

    Thanks, Larry. I should have remembered the "…Basic Appearance…" thingy. I've tutored enough people in Illustrator—it just never occurred to me. As for the printer, I'll give that a shot. I'll fumble my way around in that; not sure exactly how to go about doing it, but I'm game. Thank you for your help.   — Jim

  • I have itunes credit but it wont let me use it, and keeps asking me to put in credit card information. How do I get it to just use my iTunes credit?

    I have Itunes credit but it wont let me use it and keeps asking me for credit card information like it does if you dont have enough credit to pay for what you are buying. I tryed just clicking none but it wont let me, how do you get it to just take money from your itunes credit, not off a credit card?

    I would contact iTunes:
    Contact iTunes

  • On my iphone, icloud is set to an apple id that i no longer use and i keep getting asked to enter a password. Cannot remember the password. When i try to re-set the password, it sends a email to a address no longer used. Will not accept any dob i enter

    I have icloud on my phone with an apple id that I no longer use. I keep getting asked to enter the password for this ID. However I can't remember the password.
    When I try to re-set the password, a e-mail will be send to an address I no longer use and can't access.
    I then try to answer the security questions, but the date of births I enter are not accepted
    Any ideas?
    Paul

    Welcome to the Apple community.
    This feature has been introduced to make stolen phones useless to those that have stolen them.
    However it can also arise when the user has changed their Apple ID details with Apple and not made the same changes to their iCloud account/Find My Phone on their device before upgrading to iOS 7, or if you restore from a previous back up made before you changed your details.
    The only solution is to change your Apple ID back to its previous state with Apple at My Apple ID, verify the changes, enter the password as requested on your device and then turn off "find my phone".
    You should then change your Apple ID back to its current state, verify it once again, delete the iCloud account from your device and then log back in using your current Apple ID. Finally, turn "find my phone" back on once again.
    This article provides more information about Activation Lock.

  • How to use the same services-config for the local and remote servers.

    My flex project works fine using the below but when I upload my flash file to the server I doesn't work, all the relative paths and files are the same execpt the remote one is a linux server.
    <?xml version="1.0" encoding="UTF-8"?>
    <services-config>
        <services>
            <service id="amfphp-flashremoting-service"
                class="flex.messaging.services.RemotingService"
                messageTypes="flex.messaging.messages.RemotingMessage">
                <destination id="amfphp">
                    <channels>
                        <channel ref="my-amfphp"/>
                    </channels>
                    <properties>
                        <source>*</source>
                    </properties>
                </destination>
            </service>
        </services>
        <channels>
        <channel-definition id="my-amfphp" class="mx.messaging.channels.AMFChannel">
            <endpoint uri="http://localhost/domainn.org/amfphp/gateway.php" class="flex.messaging.endpoints.AMFEndpoint"/>
        </channel-definition>
        </channels>
    </services-config>
    I think the problem  is the line
            <endpoint uri="http://localhost/domainn.org/amfphp/gateway.php" class="flex.messaging.endpoints.AMFEndpoint"/>
    but I'm not sure how to use the same services-config for the local and remote servers.

    paul.williams wrote:
    You are confusing "served from a web-server" with "compiled on a web-server". Served from a web-server means you are downloading a file from the web-server, it does not necessarily mean that the files has been generated / compiled on the server.
    The server.name and server.port tokens are replaced at runtime (ie. on the client when the swf has been downloaded and is running) not compile time (ie. while mxmlc / ant / wet-tier compiler is running). You do not need to compile on the server to take advantage of this.
    Hi Paul,
    In Flex, there is feature that lets developer to put all service-config.xml file configuration information into swf file. with
    -services=path/to/services-config.xml
    IF
    services-config.xml
    have tokens in it and user have not specified additional
    -context-root
    and this swf file is not served from web-app-server (like tomcat for example) than it will not work,
    Flash player have no possible way to replace token values of service-config.xml file durring runtime if that service-config.xml file have been baked into swf file during compilation,
    for example during development you can launch your swf file from your browser with file// protocol and still be able to access blazeDS services if
    -services=path/to/services-config.xml
    have been specified durring compilation.
    I dont know any better way to exmplain this, but in summary there is two places that you can tell swf  about service confogiration,
    1) pass -services=path/to/services-config.xml  parameter to compiler this way you tell swf file up front about all that good stuff,
    or 2) you put that file on the webserver( in this case, yes you should have replacement tokens in that file) and they will be repaced at runtime .

  • How do I manage Lightroom photos when using 2 computers, keeping all edits made on either one?

    Based on http://forums.adobe.com/thread/1308132?tstart=0 I decided to add each question seperately:
    Hello, I'm quite interested in buying Lightroom 5.2. I tried the RC which ran out now. Yet, I have a several questions that I can't really find good conclusive answers to, that I'd like to get answered before buying LR. Please don't write maybe like this or that (assumptions), since I don't want to start my whole workflow and then realize that I have to change everything around, so please answer, if you know for sure that something works and you are, preferably, using that method too.
    This is the biggest question, where I mainly want a conclusive answer:  How do I manage Lightroom photos when using 2 computers, keeping all edits made on either one of them, using the same photos for editing. I won't use DNG. Details: I mainly use my older MacBook Pro, but would like to be able to use my PC as it's way better (Specs: i5 2500K, 16GB RAM, SSD, USB3, nVidia GTX 560 TI etc.). I have 2 external HDs that I could use, one for Backup and one for the actual Photos/Edits. I'll probably need to use it as my internal HDs are quite full, and I can't just delete stuff or move it to an (Developer programs, Lossless music, etc.).
    Based on this, how do I back up the whole thing e.g. Photos folder (all photos and edits, and preferably presets too)?

    I believe it should be possible to work cross-platform without having to relink files each time, or without having to keep exporting/importing the catalog, by keeping the single catalog and the image library on the one external drive which is then switched between systems as needed.
    Obvious first requirement is an external drive that is formatted in such a way (e.g FAT32) that it can be used on both platforms in read/write mode. Given that, if the catalog AND the images parent folder are both established at the same level in one overall parent folder, then it should be possible to take advatage of Lightroom's ability to use relative paths rather than absolute paths to detect the images, no matter if the drive is named (Mac) or lettered (PC). This is how "export as Catalog" works, i.e. it creates a "package", aka a parent folder, containing the catalog and a replica of the exported images folder hierarchy alongside the catalog. Take that "package" to another system (same OS or not) and "it just works" even if the drive letter is different or the OS is different....because the relative path from catalog to images is still the same.
    I haven't tested this cross-platform (though I have between different PC systems with different drive letters) so for me it's still just a theory, but there may be others who have done this successfully.

  • I just got a new ipod and i dont know how to use it. it keeps asking me for wifi connection or to log on to itunes. i logged on to itunes but its still not working please help

    please help me use my ipod touch. i just got it and im a little confused on how to use it. it keeps asking for a wifi connection even while im logged in on itunes

    iPod touch User Guide (For iOS 5.1 Software)
    Are you connected to wi-fi?
    If not, then connect.

  • When To Use redirect/ In faces-config.xml

    In what situations should I use <redirect/> in faces-config. I understand what that using it causes it to generate a HTTP redirect instead of redirection through the view handler.
    I have ran into situations where if I don't use redirect, evein in a request scoped bean data isn't completely cleared out of a form. IE I have a list of users with a list of their addresses. If I look at an address on user 1 I see the right details, if I then move to user2 and look at one of his addresses it reflects the information from user1. As soon as I add <redirect/> the problem disappears.

    You normally use it to fire a brand new request.
    If I look at an address on user 1 I see the right details, if I then move to user2 and look at one of his addresses it reflects the information from user1. As soon as I add <redirect/> the problem disappears.This rather sounds like faulty code logic. Debug it.

  • When trying to copy and paste on my MAC using firefox, I keep coming across a message "your browser security settings don't permit the editor to automatically execute pasting operations". This only happens with firfox, not Safari. any help??

    When trying to copy and paste on my MAC using firefox, I keep coming across a message "your browser security settings don't permit the editor to automatically execute pasting operations". This only happens with firefox, not Safari. any help??

    See:<br />
    http://kb.mozillazine.org/Granting_JavaScript_access_to_the_clipboard
    https://addons.mozilla.org/firefox/addon/852 - AllowClipboard Helper

  • How to create a user using XML and specifying addional attributes that are objects

    I'm trying to create a user using XML and specifying some attributes that are objects and not sure how to do it. How would I set the DirectoryUserAcl to Public?
    Here's the xml file:
    <?xml version = '1.0' standalone = 'yes'?>
    <SimpleUser>
    <UserName>mike2</UserName>
    <Password>abc123</Password>
    <AdminEnabled>false</AdminEnabled>
    <HomeFolderRoot>/home</HomeFolderRoot>
    <HasContentQuota>false</HasContentQuota>
    <DirectoryUserAcl> ??? </DirectoryUserAcl>
    <DefaultAclBundleAcl> ??? </DefaultAclBundleAcl>
    <HomeFolderPolicyBundleAcl> ??? </HomeFolderPolicyBundleAcl>
    </SimpleUser>

    I figured out the answer:
    <?xml version = '1.0' standalone = 'yes'?>
    <SimpleUser>
    <UserName>mike2</UserName>
    <Password>abc123</Password>
    <AdminEnabled>false</AdminEnabled>
    <HomeFolderRoot>/home</HomeFolderRoot>
    <HasContentQuota>false</HasContentQuota>
    <DirectoryUserAcl classname="SystemAccessControlList" refType="name">Public</DirectoryUserAcl>
    </SimpleUser>
    null

  • When I use safari I keep getting a small coloured circular icon which in turn does not allow me to navigate at all.  the only way I can get rid of it is to shut down and reboot.  Can anyone help?

    When I use safari I keep getting a small coloured circular icon which in turn does not allow me to navigate at all.  the only way I can get rid of it is to shut down and reboot.  Can anyone help?

    Start here.

Maybe you are looking for

  • Error while opening Adobe Interactive form.

    Hi , We have few custom applications  which contains an adobe interactive form. When it is getting called it throws the following error. com.sap.tc.webdynpro.clientserver.adobe.pdfdocument.base.core.PDFDocumentRuntimeException: Failed to  UPDATEDATAI

  • Using libraries burned on disc

    Hi, I have a bunch of albums burned to a DVD. I have deleted them from my current library. When I insert the DVD, iPhoto launches and displays them in the sidebar. I can go and view the photos without a problem. But with these albums on disc, I am un

  • Mac Pro transfer everything to a new (same) box

    Hi there, I own a Mac Pro 2009 2.26Ghz (8-core). Due to some scratches etc and as time goes by with use the cover case wores a bit off. Is it possible to transfer everything to a new Mac Pro box? Is it easy? Just a thought... Thanks and looking forwa

  • Aluminum Macbook stuck on apple logo page at startup

    I have an 2008 Aluminum Macbook and when I try boot, it gets stuck on the apple logo page with the spinning wheel below it.  I have tried to boot in safe mode but i get the error messsage "disc02: I/O error" .  I tried next to reset the PRAM but no r

  • How do I get the serial number they ask for in signing in , I bought the 19.99 a month program?

    how do I get the serial number they ask for at the sign in part, I paid for the 19.99 and cannot access it , thank you