[Design the new POJO MicroContainer] - Re: Way to control when injection happens?
by alesj
"adrian(a)jboss.org" wrote : It's here:
| https://jira.jboss.org/jira/browse/JBMICROCONT-81
| but Ales has closed it.
|
| He's done it for annotations but not for xml.
|
| Which maybe enough if you do?
|
Sure. ;-)
I've written two examples (they are commited to the trunk)
of what you can do to enable this:
(1) annotation based
| <deployment xmlns="urn:jboss:bean-deployer:2.0">
|
| <bean name="AnnotationHandlerFactory">
| <constructor factoryClass="org.jboss.kernel.plugins.annotations.BeanAnnotationAdapterFactory" factoryMethod="getInstance" />
| </bean>
| <bean name="AnnotationHandler">
| <constructor factoryMethod="getBeanAnnotationAdapter">
| <factory bean="AnnotationHandlerFactory"/>
| </constructor>
| <incallback method="addAnnotationPlugin" />
| <uncallback method="removeAnnotationPlugin" />
| </bean>
| <bean name="SuperDemandAnnotationPlugin" class="org.jboss.test.kernel.deployment.support.SuperDemandAnnotationPlugin" />
|
| <bean name="Manager" class="org.jboss.test.kernel.deployment.support.SomeCacheTreeManager">
| <property name="clusteredCache"><inject bean="HAPartitionCacheHandler" property="cache"/></property>
| <annotation>@org.jboss.test.kernel.deployment.support.SuperDemand(demand="Partition", whenRequired="Configured", dependentState="Start")</annotation>
| </bean>
|
| <bean name="HAPartitionCacheHandler" class="org.jboss.test.kernel.deployment.support.HAPartitionCacheHandler"/>
|
| <bean name="Partition" class="org.jboss.test.kernel.deployment.support.HAPartition">
| <property name="handler"><inject bean="HAPartitionCacheHandler"/></property>
| </bean>
|
| </deployment>
|
(2) install
| <deployment xmlns="urn:jboss:bean-deployer:2.0">
|
| <bean name="SuperDemand" class="org.jboss.test.kernel.deployment.support.SuperDemandCreator"/>
|
| <bean name="Manager" class="org.jboss.test.kernel.deployment.support.SomeCacheTreeManager">
| <property name="clusteredCache"><inject bean="HAPartitionCacheHandler" property="cache"/></property>
| <install bean="SuperDemand" method="createDependency" whenRequired="Instantiated">
| <parameter><inject fromContext="name"/></parameter>
| <parameter>Partition</parameter>
| <parameter>Configured</parameter>
| <parameter>Start</parameter>
| </install>
| </bean>
|
| <bean name="HAPartitionCacheHandler" class="org.jboss.test.kernel.deployment.support.HAPartitionCacheHandler"/>
|
| <bean name="Partition" class="org.jboss.test.kernel.deployment.support.HAPartition">
| <property name="handler"><inject bean="HAPartitionCacheHandler"/></property>
| </bean>
|
| </deployment>
|
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4182301#4182301
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4182301
16 years, 3 months
[Design of POJO Server] - Re: JBAS-6061 or weird nested jar
by adrian@jboss.org
"alesj" wrote :
| Perhaps we should add another (hard keeping track of all) flag to VFS,
| that would also ignore everything - as did the old code.
A single flag in VFS would make it hard to control. i.e. it might be ok
for the deployers to ignore the error in the classpath but for other uses it
would not be ok.
Also the VFS would have to cache/remember the brokeness since there is no
way to "weed out" the problem during startup. Otherwise it would continually
try to copy the jar and get the same error.
I personally don't think it is even ok for the deployers/classloader to ignore the error
and the example Luc provides is correctly rejected.
i.e. the real solution is to fix the deployment
The reason I think it needs addressing is because we never really used to
look at nested deployments in server/default/lib (i.e. those specifed on
a -service.xml classpath).
The reason we are doing so now is because the PackageVisitor is triggering
the VFS to unpack the archive when it is scanning for the packages in the jars.
Maybe a simpler (but less inclusive fix) would be to have the PackageVisitor
ignore archives in its VFS visit()?
e.g.
| public boolean accepts(VirtualFile file)
| {
| // This is our current root
| if (file.equals(root))
| return true;
|
| + // Don't go into nested archives
| + if (file.isArchive())
| + return false;
|
| // Some other root, it will be handled later
| for (VirtualFile other : roots)
| {
| if (file.equals(other))
| return false;
| }
| // Is this an excluded roots?
| if (excludedRoots != null)
| {
| for (VirtualFile other : excludedRoots)
| {
| if (file.equals(other))
| return false;
| }
| }
|
| // Ok
| return true;
| }
|
But I'm not sure if that is too late in terms of the archive getting unpacked?
It would certainly be an optimization in terms of the scanning anyway. ;-)
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4182193#4182193
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4182193
16 years, 3 months