|
From: <ad...@jb...> - 2005-05-24 21:20:29
|
"sco...@jb..." wrote : Do we have all the pieces in place for this scenario: | | - A named pojo instance (in its most strict form this could be a singleton) that has two Properties maps attributes | + The pojo has methods to manipulating the Properties contents | + The pojo has these methods exposed via JMX | Yes anonymous wrote : | - Another pojo needs the named pojo instance Properties maps injected to function correctly. This pojo only has a default ctor, and the only point for injecting the Properties maps is this initialize method: | | | | public void initialize(Subject subject, CallbackHandler callbackHandler, | | Map sharedState, Map options) | | | | The Properties should be found in the options argument under the keys "users" and "roles". However, by the time the initialize method is called, the options Map is a read-only object. | | Do we have a framework that can acomplish this wiring yet? | No. Do we really want to support an xml scripting language in the configuration? Complicated/Programmatic config like this can be handled by "lifecycle advices". I'd guess in this case it would be "create"? But it could also be construction or any other joinpoint. i.e. advice depends upon properties (or named pojo) "another" depends upon advice View the original post : http://www.jboss.org/index.html?module=bb&op=viewtopic&p=3878965#3878965 Reply to the post : http://www.jboss.org/index.html?module=bb&op=posting&mode=reply&p=3878965 |
|
From: <sco...@jb...> - 2005-05-24 21:51:19
|
By wiring I did not mean that it had to be strictly via configuration level constructs between the two pojos. There actually is a natural point for joining these before having to deal with the initialize() method. The usecase here is a login configuration with a login module that may take its options from a static configuration, or injection of another object's attributes. static: | <application-policy name="testXMLLoginModule"> | <authentication> | <login-module code="SomeLoginModule" flag="required"> | <module-option name="users"> | <lm:users xmlns:lm="urn:jboss:jaas"> | <lm:user name="user1" password="pass1" /> | <lm:user name="user2" password="pass2" /> | </lm:users> | </module-option> | <module-option name="roles"> | <lm:roles xmlns:lm="urn:jboss:jaas"> | <lm:user name="user1"> | <lm:role name="Role1"/> | <lm:role name="Role2"/> | <lm:role name="callerJduke" group="CallerPrincipal" /> | </lm:user> | </lm:users> | </module-option> | ... | injection: | <application-policy name="testXMLLoginModule2"> | <authentication> | <login-module code="SomeLoginModule" flag="required"> | <module-option name="users"> | <depends name="PropertiesSource" property="Users" /> | </module-option> | <module-option name="roles"> | <depends name="PropertiesSource" property="Roles" /> | </module-option> | ... | View the original post : http://www.jboss.org/index.html?module=bb&op=viewtopic&p=3878967#3878967 Reply to the post : http://www.jboss.org/index.html?module=bb&op=posting&mode=reply&p=3878967 |
|
From: <ad...@jb...> - 2005-05-24 22:17:39
|
Ok, so you just want to inject a bean's property rather than the bean value.
The only way this could be done with the current metadata model would
be to put a dummy factory inbetween that did the getting.
But this seems such a trivial usecase that I don't see why it could not be supported
directly.
In MC XML (note the property attribute is what we are talking about and is not currently supported)
| <property name="roles">
| <inject bean="PropertiesSource" property="roles" />
| </property>
|
Whether we want to go further into xml scripting is another issue, e.g.
| <inject bean="PropertiesSource" script="getRoles().toString()" />
| <inject bean="PropertiesSource" script="getRoles().get("Value1"))" />
| // transient property PropertiesSource.getRoles().getSize()
| <inject bean="PropertiesSource" property="roles.size" />
| etc.
|
Including "abitrary" initialize methods could also be supported
with something like
| <depends>
| <create method="initialize">
| <parameter><inject bean="PropertiesSource" property="roles"/></parameter>
| </create>
|
One problem with the latter (besides it fails the 95%/5% use case rule)
is that the annotation version requires parameter annotations
(although it isn't something you want to do in this case :-)
| @CreateLifecycle
| public void initialize(
| @Inject(bean="PropertiesSource", property="users")
| Map users,
| @Inject(bean="PropertiesSource", property="roles")
| Map roles
| )
| {
| // Do it
| }
|
View the original post : http://www.jboss.org/index.html?module=bb&op=viewtopic&p=3878970#3878970
Reply to the post : http://www.jboss.org/index.html?module=bb&op=posting&mode=reply&p=3878970
|
|
From: <ad...@jb...> - 2005-05-24 22:21:22
|
I'd only anticapted supporting lifecycle methods with no arguments. View the original post : http://www.jboss.org/index.html?module=bb&op=viewtopic&p=3878971#3878971 Reply to the post : http://www.jboss.org/index.html?module=bb&op=posting&mode=reply&p=3878971 |
|
From: <ad...@jb...> - 2005-05-27 21:29:27
|
I just added support for the property injection, passing parameters in lifecycle operations will come soon... Commit message: | Add support for injecting a property of a bean rather than a bean, | e.g. | <bean name="MyService" class="MyClass"> | <property name="transactionManager"> | <inject bean="TransactionManagerService" property="instance"/> | </property> | </bean> | or | MyClass.setTransactionManager(TransactionManagerService.getInstance()); | | This also works anywhere there is an injection, i.e. properties, factories, | parameters, collections, etc. | View the original post : http://www.jboss.org/index.html?module=bb&op=viewtopic&p=3879316#3879316 Reply to the post : http://www.jboss.org/index.html?module=bb&op=posting&mode=reply&p=3879316 |
|
From: <ad...@jb...> - 2005-05-31 20:06:03
|
The ability to override lifecycle methods is now supported.
e.g. rather than doing
| <bean>
| <depends>SomeName</depends>
| </bean>
|
You can now do
| public void initialize(SomeBean bean)
| {
| // etc.
| }
| <bean>
| <create method="initialize">
| <parameter><inject bean="SomeName"></parameter>
| </create>
| </bean>
|
Of course, other parameters such as plain values, collections, bean properties
are also supported.
View the original post : http://www.jboss.org/index.html?module=bb&op=viewtopic&p=3879631#3879631
Reply to the post : http://www.jboss.org/index.html?module=bb&op=posting&mode=reply&p=3879631
|