Hey everyone, a question on mapping a java library using wirebox:
I am currently doing the following to use google’s libphonenumber library (http://code.google.com/p/libphonenumber/)
`
component displayname=“phoneValidation” hint=“Phone Validation Functions” {
property name=“javaloader” inject=“coldbox:plugin:JavaLoader” scope=“instance”;
public struct function splitPhoneNumber(required string phoneNumber) {
var phoneUtil = instance.javaLoader.create(“com.google.i18n.phonenumbers.PhoneNumberUtil”).getInstance();
var countryCode = phoneUtil.parse(arguments.phoneNumber,“US”).getCountryCode();
var nationalNumber = phoneUtil.parse(arguments.phoneNumber,“US”).getNationalNumber();
var data = {
countryCode = countryCode,
number = nationalNumber,
lastUpdated = now(),
status = “OK”
};
return data;
}
}
`
I want to use a mapping in wirebox.cfc, something like this:
`
map(“jPhoneUtil”).toJava(“javaLoader:com.google.i18n.phonenumbers.PhoneNumberUtil”).asSingleton();
`
But when I add the following property to my cfc:
`
property name=“jPhoneUtil” inject=“id:jPhoneUtil” scope=“instance”;
`
I get the following error:
Error Type: Object : [N/A]
Error Messages: Object Instantiation Exception.
Class not found: javaLoader:com.google.i18n.phonenumbers.PhoneNumberUtil
Note that I DONT get that error if the mapping is in wirebox.cfc and not used, ONLY once I have added the property to my cfc.
Any ideas would be greatly appreciated!
Ken