Thanks for the pointers David. I've just coded this up, and attached a patch to OPENEJB-1056 (https://issues.apache.org/jira/browse/OPENEJB-1056).
This seems to work well, although I did break the JndiNameTest. I've fixed this by using the StringTemplate that is used normally, and grabbing the format string from there. This seems a bit nasty but all the openejb-core tests pass now (and I'll run the rest tonight). I'll this committed if there's no objections. Jon On Wed, Aug 5, 2009 at 3:15 AM, David Blevins <[email protected]>wrote: > Whoops, just noticed the regex I posted doesn't accept a '.' > > > On Aug 4, 2009, at 6:59 PM, David Blevins wrote: > > So, the replacement we are doing now can be done without the swizzle >> StringTemplate code. Small snippet as so: >> >> import java.util.Map; >> import java.util.regex.Matcher; >> import java.util.regex.Pattern; >> >> private static final Pattern PATTERN = Pattern.compile("(\\{)(\\w+)(})"); >> >> static String format(String input, Map<String, String> map) { >> Matcher matcher = PATTERN.matcher(input); >> StringBuffer buf = new StringBuffer(); >> while (matcher.find()) { >> String key = matcher.group(2); >> String value = map.get(key); >> matcher.appendReplacement(buf, value); >> } >> matcher.appendTail(buf); >> return buf.toString(); >> } >> >> Then we just check the key for the ".lc", ".uc", and ".cc" suffixes, shave >> them off, and munge the map value appropriately. Maybe even support "Lc" >> and so on as a backwards compatible way to get rid of having to eagerly >> create some of the existing keys "FooLc" keys we have. >> >> We could probably even add this to a class called StringTemplate and use >> it as a drop in replacement. >> >> >> -David >> >> Begin forwarded message: >> >> Resent-From: <[email protected]> >>> From: David Blevins <[email protected]> >>> Date: August 4, 2009 4:03:32 PM PDT >>> To: [email protected] >>> Subject: Re: JNDI Names: lower case interfaceType.annotationName? >>> Reply-To: [email protected] >>> >>> I'll give you some tips on the dev@ list -- should be easy to do with >>> the swizzle-stream apis. >>> >>> -David >>> >>> On Aug 4, 2009, at 3:25 PM, Jonathan Gallimore wrote: >>> >>> I was thinking that as I was adding the new setting to the >>>> documentation. I >>>> think that's a neat idea - I'll see if I can code that up. >>>> >>>> Jon >>>> >>>> On Tue, Aug 4, 2009 at 11:18 PM, David Blevins <[email protected] >>>> >wrote: >>>> >>>> Maybe we should take all the entries we have and automatically make >>>>> both >>>>> ".lc" and ".uc" versions of them? (possibly even ".cc" for camel >>>>> case). Or >>>>> maybe smarten up our formatting so that they are only created on >>>>> demand. >>>>> >>>>> >>>>> >>>>> >>>>> On Aug 4, 2009, at 2:26 PM, Jonathan Gallimore wrote: >>>>> >>>>> Hi Mark, >>>>> >>>>>> >>>>>> I've just committed this for you. >>>>>> >>>>>> Cheers >>>>>> >>>>>> Jon >>>>>> >>>>>> On Tue, Aug 4, 2009 at 2:16 PM, Jonathan Gallimore < >>>>>> [email protected]> wrote: >>>>>> >>>>>> Hi Mark, >>>>>> >>>>>>> >>>>>>> This seems like a good addition to me, I'm more than happy to get >>>>>>> this in >>>>>>> (should be able to do it this evening). >>>>>>> >>>>>>> Cheers >>>>>>> >>>>>>> Jon >>>>>>> >>>>>>> >>>>>>> On Mon, Aug 3, 2009 at 4:35 PM, Mark Taylor <[email protected]> >>>>>>> wrote: >>>>>>> >>>>>>> First, thanks for a great project and I have a feature request. >>>>>>> >>>>>>>> >>>>>>>> It seems like the default JBoss JNDI name is: {beanName}/{lowercase >>>>>>>> annotation type} (ie local or remote). Hence I have an application >>>>>>>> full of @EJB mapped-names such as: "MyStatelessBean/local". From >>>>>>>> the >>>>>>>> document >>>>>>>> >>>>>>>> http://openejb.apache.org/3.0/jndi-names.html. >>>>>>>> >>>>>>>> It appears we can only use interfaceType.annotationName to get Local >>>>>>>> or Remote (ie uppercase). Would it be possible to add: >>>>>>>> interfaceType.annotationNameLowerCase to the JNDI Name formatting >>>>>>>> options? >>>>>>>> >>>>>>>> It could go in org.apache.openejb.assembler.classic.JndiBuilder: >>>>>>>> >>>>>>>> public String getName(Class interfce, Interface type) { >>>>>>>> StringTemplate template = templates.get(interfce.getName()); >>>>>>>> if (template == null) template = >>>>>>>> templates.get(type.getAnnotationName()); >>>>>>>> if (template == null) template = templates.get(""); >>>>>>>> >>>>>>>> Map<String,String> contextData = new HashMap<String,String>(); >>>>>>>> contextData.put("moduleId", deploymentInfo.getModuleID()); >>>>>>>> contextData.put("ejbType", >>>>>>>> deploymentInfo.getComponentType().name()); >>>>>>>> contextData.put("ejbClass", >>>>>>>> deploymentInfo.getBeanClass().getName()); >>>>>>>> contextData.put("ejbClass.simpleName", >>>>>>>> deploymentInfo.getBeanClass().getSimpleName()); >>>>>>>> contextData.put("ejbClass.packageName", >>>>>>>> packageName(deploymentInfo.getBeanClass())); >>>>>>>> contextData.put("ejbName", deploymentInfo.getEjbName()); >>>>>>>> contextData.put("deploymentId", >>>>>>>> deploymentInfo.getDeploymentID().toString()); >>>>>>>> contextData.put("interfaceType", type.getAnnotationName()); >>>>>>>> contextData.put("interfaceType.annotationName", >>>>>>>> type.getAnnotationName()); >>>>>>>> //*********************************************** >>>>>>>> // >>>>>>>> contextData.put("interfaceType.annotationNameLC", >>>>>>>> type.getAnnotationName().toLower()); >>>>>>>> // >>>>>>>> //*********************************************** >>>>>>>> contextData.put("interfaceType.xmlName", type.getXmlName()); >>>>>>>> contextData.put("interfaceType.xmlNameCc", >>>>>>>> type.getXmlNameCc()); >>>>>>>> contextData.put("interfaceType.openejbLegacyName", >>>>>>>> type.getOpenejbLegacy()); >>>>>>>> contextData.put("interfaceClass", interfce.getName()); >>>>>>>> contextData.put("interfaceClass.simpleName", >>>>>>>> interfce.getSimpleName()); >>>>>>>> contextData.put("interfaceClass.packageName", >>>>>>>> packageName(interfce)); >>>>>>>> return template.apply(contextData); >>>>>>>> } >>>>>>>> >>>>>>>> >>>>>>>> >>>>>>> >>>>>>> >>>>> >>> >>> >> >> >
