ApplicationProperties(String propertyFile) { try { ApplicationPropertiesHelper aph; if (StringUtils.isBlank(propertyFile)) { aph = new ApplicationPropertiesHelper(); } else { aph = new ApplicationPropertiesHelper(propertyFile); } // Get Logging Config File Name. loggingConfigFile = aph.getLoggerConfigFile(); // Get Logger Name/ loggerName = aph.getLoggerName(); // Get Log Level logLevel = aph.getLogLevel(); // Get Message Type/ messageLoggingFormat = aph.getMessageLoggingFormat(); // Get Logging Enabled. isLoggingEnabled = aph.getLoggingEnabled(); // Get Domain Objects List. domainObjectList = aph.getDomainObjectsList(); // Get HashMap of Identifier Attributes <ObjectName,Attribute> identifierAttributes = aph.getIdentifierAttributes(); } catch (Exception ex) { ex.printStackTrace(); if (logger.isDebugEnabled()) logger.debug("Error reading the Config File " + ex.getMessage()); } }
/** * Method checks the ObjectStateLogger Configuration for IdentifierAttribute for particular Domain * Object. * * @param domainObject The domainObject for which identifierAttributes are requested. * @return String If available returns the identifier attribute value from the configuration file * else returns null. */ public String getIdentifierAttribute(Object domainObject) { if (identifierAttributes.containsKey(domainObject.getClass().getName())) { String ia = (String) identifierAttributes.get(domainObject.getClass().getName()); if (!StringUtils.isBlank(ia)) return ia; } return null; }
/** @return Returns the single instance of this class */ public static ApplicationProperties getInstance(String propertyFile) { if (myInstance == null) { if (StringUtils.isBlank(propertyFile)) { myInstance = new ApplicationProperties(); } else { myInstance = new ApplicationProperties(propertyFile); } } // logger.info("Inside ApplicationProperties " + myInstance); return myInstance; }