This is the wrong approach. The system property stuff is legacy from the MBean days.
It's certainly the wrong api to be extending, we need to let it die. :-)
The correct approach is should be to create your own ValueMetaData
| <deployment xmlns="urn:jboss:bean-deployer:2.0"
xmlns:ldap="urn:jboss:ldap:1.0">
|
| <bean name="LDAPLookUp" ...>
| <!-- ldap config here -->
| </bean>
|
| <bean name="blah">
| <property name="x"><ldap:property bean="LDAPLookUp"
key="ldapkeyhere" default="...">
| </deployment>
|
The ldap:property parses to an implementation of ValueMetaData,
something similar to the inject value metadata (AbstractDependencyValueMetaData),
except it gets the value from the LDAPLookUp bean.
(untested code)
| public Object getValue(TypeInfo info, ClassLoader cl) throws Throwable
| {
| ControllerState state = dependentState;
| if (state == null)
| state = ControllerState.INSTALLED;
| Controller controller = context.getController();
| ControllerContext lookup = controller.getContext(getUnderlyingValue(), state);
|
| if (isLookupValid(lookup) == false)
| throw new Error("Should not be here - dependency failed - " +
this);
|
| if (lookup == null)
| return null;
|
| Object ldap = lookup.getTarget();
| if (result instanceof LDAPLookup == false)
| throw new IllegalStateException("Not an LDAPLookup: " + ldap);
| LDAPLookup ldapLookup = (LDAPLookup) ldap;
| Object result = ldapLookup.lookup(key);
| if (result == null)
| return defaultValue;
| return result;
| }
|
But it is not documented how to do this, the only close example
is the javabean namespace but that just creates objects directly from the xml.
There maybe a case for abstracting this such that a bean could
implement a "ValueFactory" interface
| public interface ValueFactory
| {
| Object getValue(String key);
| }
|
and us including a generic piece of xml in our schema to enable its use
| <property name="x"><value-factory bean="LDAPLookup"
key="..." default="..."/></property>
|
Which would probably cover most simple use cases?
View the original post :
http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4066149#...
Reply to the post :
http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&a...