[jboss-dev-forums] [Design the new POJO MicroContainer] - Re: Case sensitivity in injecting a bean's property
alesj
do-not-reply at jboss.com
Thu Dec 6 17:02:37 EST 2007
I already added this check while working on ProfileService:
| protected static String getAttributeName(String name)
| {
| if (name == null || name.length() == 0)
| throw new IllegalArgumentException("Illegal name: " + name);
|
| char firstCharacter = name.charAt(0);
| if (Character.isLowerCase(firstCharacter))
| {
| String attributeName = String.valueOf(Character.toUpperCase(firstCharacter));
| if (name.length() > 1)
| attributeName += name.substring(1);
| return attributeName;
| }
| return name;
| }
|
| public Object get(String name) throws Throwable
| {
| return getMBeanServer().getAttribute(objectName, getAttributeName(name));
| }
|
| public void set(String name, Object value) throws Throwable
| {
| Attribute attribute = new Attribute(getAttributeName(name), value);
| getMBeanServer().setAttribute(objectName, attribute);
| }
|
Since we explicitly go over MBeanServer, when accessing MBean's property in MC --> ServiceControllerContext, I see no need to do a switch check.
The test - ConfigureMCFromJMXWithPropertyUnitTestCase - was added to the system-jmx tests.
It checks access to the MBean's attribute both ways - uppercase and lower case first letter.
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4111008#4111008
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4111008
More information about the jboss-dev-forums
mailing list