0

ResourceBundles in java. some useful statements

Posted by sanjay on 1:20 PM


Locale userLocale = Locale.getDefault();


Sets default locale.



private static String getFormatString(String formatStr, Object[] args) {
if (args != null) {
// MessageFormat is brain dead in the fact that it won't
// convert unknown or unhandled object types into Strings.
// So we have to do it...
for (int i=0, count=args.length; i Object obj = args[i];

// don't bother with bogus or handled types...
if (obj == null || obj instanceof String ||
obj instanceof Number || obj instanceof Date)
continue;

// convert anything unknown
args[i] = obj.toString();
}

formatStr = MessageFormat.format(formatStr, args);
}

return formatStr;
}


Returns formatted string from given string and argument list


public static String getFormatString(String rscBundleName, String msgKey, Object[] args) {
String formatStr = getString(rscBundleName, msgKey);

return getFormatString(formatStr, args);
}



getsFormatted string


public static String getFormatString(String rscBundleName, String msgKey, Object arg) {

if (arg == null) {
arg = "NULL";
}
Object[] args = {arg};
return getFormatString(rscBundleName, msgKey, args);
}


Gets formatted string with one argument


public static String getString(String rscBundleName, String msgKey) {
ResourceBundle resourceBundle = (ResourceBundle)rscBundlesTable.get(rscBundleName);

if (resourceBundle == null) {
Locale locale = getLocale();

if (locale == null) {
resourceBundle = ResourceBundle.getBundle(rscBundleName);
} else {
resourceBundle = ResourceBundle.getBundle(rscBundleName, locale);
}

// Cache resource bundle
rscBundlesTable.put(rscBundleName, resourceBundle);
}
String str;
try {
str = resourceBundle.getString(msgKey);
} catch (MissingResourceException mRE) {
str = null;
}
return (str == null) ? msgKey : str;
}


Gets string with no arguments

0

Use chatr to change program's internal attributes on HPUX

Posted by sanjay on 9:08 AM

man chatr
gives the following

chatr(1)

NAME
         chatr - change program's internal attributes
....


We needed to use chatr to enable libcrypto.sl to be loaded dynamically from SH_LIBPATH instead of statically from a location on HPUX32 bit system. This definitely poses a security risk... but it is convinient

This issue is related to the lib file is not taken from SHLIB_PATH, so we need to run the following command first, then it will work fine.
chatr +s enable / libcrypto.sl /ldapdelete
This will enable libcrypto.sl to be dynamically linked and picked up from SHLIB_PATH for ldapdelete. This will need to be done for all the binaries under the folder.


Once source binaries are modified with this attribute, they can be copied to another machine and they will still allow loading the libraries dynamically. Perhaps a

chatr +s disable /libcrypto.sl /ldapdelete

would disable dynamic loading. Need to experiment

0

DSL off your flash drive?

Posted by sanjay on 12:46 AM

Ok .. by DSL I'm referring to Damn Small Linux. I was looking at this article about installing DSL on USB flashdrives with GRUB.. One project, I'd love to try!

0

SAP JCO shared libraries

Posted by sanjay on 12:01 PM
Shared libraries are good to use. They make your code base smaller, but they do create some issues while deploying. Recently while deploying a Java provider for SAP JCO, I came across an issue where the dynamic library path was different for each platform. Why is it so? I do not know.. But here it is











OSDynamic Library Environment Variable
Windows NT, 2000, 2003PATH
LinuxLD_LIBRARY_PATH
Sun SolarisLD_LIBRARY_PATH
IBM AIX/td> LIBPATH
HP-UXSHLIB_PATH
HP Tru64LD_LIBRARY_PATH
Apple Mac OS X, Version 10.3.1DYLD_LIBRARY_PATH
IBM OS/400ADDENVVAR ENVVAR(LIBPATH) VALUE ('(sapjco-install-path)')
IBM z/OSLIBPATH


Ok two interesting points here. I was surprised to find that SAP JCO supports Mac OS X. Perhaps Mac OS X is big, but I really did not know that it would be used to run business software. I always thought of Macs as personal computers!.I am learning
The second interesting point I noticed is that on HP-UX the enviornment variable is SHLIB_PATH where as it is LD_LIBRARY_PATH on HP Tru64. Aren't they both sold by the same vendor? How come the names of the shared libraries are so different?

I know not.

0

Yahoo! Developer network

Posted by sanjay on 11:30 PM
Just came across this for Yahoo DN! Looks like a good start for creating custom Yahoo! applications. I also read recently that Yahoo! is getting more open with the YDN (that's what I'm calling it, don't know if they do) and publishing APIs to various applications (a la Google). This should be good opportunity for developers to look into learning more about web services and publish Patterns, as the link above does!

Wonder when they will release the Calendar API!

1

Real Estate Public Records

Posted by sanjay on 5:22 PM
Santa Clara County Assesor

Also interesting is the SCC FAQ

It says




Annual tax bills are mailed once a year no later than November 1, and can be paid in two installments. Every effort is made to get a copy of the tax bill to each new property owner. To avoid penalties, you should check the status of your property taxes and/or request a duplicate bill by calling our office. Our Interactive Voice Response System allows you to obtain information from the computer 24 hours a day, 7 days a week. (Don't wait until it's too late and you are required to pay penalties.) If you did not receive a bill, or if you recently purchased a property, you may obtain a duplicate tax bill by calling (408) 808-7900 or visiting our office.








2

Digital photographs

Posted by sanjay on 11:23 PM
Short Courses on digital photographs..

I looked at Book 3, Chapter 5 Understanding lenses -- it has some explanations of lenses and more importantly, it has sample photographs!

0

http://www.tldp.org/LDP/abs/html/

Posted by sanjay on 4:02 PM


#!/usr/bin/bash
RELEASE=${1}
RELEASE=${RELEASE:?No release specified. Please choose from available releases : `ls resources`}
source resources/${RELEASE}/env.sh
#VOB_HOME=/lhome/sravat/piglet/ccase/vobs/CommonTech/cis
VOB_PATH=$VOB_HOME/test/configToolTest/scripts/build
JAVA_HOME=/usr/local/j2sdk1.4.2_04
ANT_HOME=/lhome/sravat/tools/Ant/1.6.3beta1
WORKDIR=/lhome/sravat/workspace/CIS/scripts
HYPERION_HOME=/mnt/sravat3/Hyperion
PATH=$ANT_HOME/bin:$JAVA_HOME/bin:$PATH
ISMP_HOME=/lhome/sravat/local/ISMP/5.03
PROPERTIES_FILE=sravat.cis.build.properties
BUILD_LOG=build.log
export VOB_HOME VOB_PATH JAVA_HOME ANT_HOME WORKDIR HYPERION_HOME PATH ISMP_HOME PROPERTIES_FILE BUILD_LOG

TARGET=$2
TARGET=${TARGET:=makeConfigTest}
export TARGET

cp $WORKDIR/resources/${RELEASE}/${PROPERTIES_FILE} $WORKDIR/${PROPERTIES_FILE}
cp $WORKDIR/resources/${RELEASE}/ismp.cp ${ISMP_HOME}/ismp.cp
cp $WORKDIR/resources/${RELEASE}/alias.properties ${ISMP_HOME}/alias.properties
rm ${ISMP_HOME}/*.release
touch ${ISMP_HOME}/is.${RELEASE}.release

pushd $VOB_PATH
xterm -geometry 255x6+25+0 -e tail -f $WORKDIR/${BUILD_LOG} &
LOGTASK=$!
$ANT_HOME/bin/ant --noconfig -Dcis.build.properties=$WORKDIR/${PROPERTIES_FILE} -buildfile configToolTest.xml -logfile $WORKDIR/${BUILD_LOG} $TARGET
sleep 10
kill $LOGTASK
popd

echo "Done"


Copyright © 2009 Note my web All rights reserved. Theme by Laptop Geek. | Bloggerized by FalconHive.