-
1. Re: Registering a bean as an aspect in the bootstrap
kabirkhan Jan 26, 2007 2:29 PM (in response to starksm64)I don't think so unless there is a way to make the MainDeployer and deployers wait until the AspectManagerService is fully installed.
-
2. Re: Registering a bean as an aspect in the bootstrap
starksm64 Jan 26, 2007 5:22 PM (in response to starksm64)It should be possible because the MainDeployer is just a bean in the bootstrap process. The classes should all be in the same class loader space, and we should be able to know the aspects that will be applied before any bean class is loaded (unless that is a limitation of the current bean introspection implementation). Adrian thought this should be possible when I asked him about it this morning. I'm going to create a simpler testcase in the mc project to describe and validate the usecase I'm after.
-
3. Re: Registering a bean as an aspect in the bootstrap
starksm64 Jan 28, 2007 5:55 PM (in response to starksm64)I created two tests in the aop-mc-int project org.jboss.test.microcontainer.test.{DeployersInterceptedTestCase,DeployersLifecycleTestCase} that I was able to get working. However, the $instanceof{org.acme.IfA}->$implements(org.acme.IfA) pointcut expression is either not working or not working as expected. I left the DeployersInterceptedTestCase.xml descriptor with the pointcut that does not work. Can you look at why this fails to match anything?
Both $instanceof{org.acme.IfA}->*(..) and $instanceof{org.acme.IfA}->someMethod(..) are working.
Now I need to see if this can be made to work in the jboss5 bootstrap. -
4. Re: Registering a bean as an aspect in the bootstrap
starksm64 Jan 28, 2007 6:40 PM (in response to starksm64)The same type of configuration in the jboss5 conf/bootstrap-beans.xml fails to apply the deployer aspects. How are the org.jboss.aop.deployers.AspectManagerJDK5 and org.jboss.aop.AspectManager going to differ?
-
5. Re: Registering a bean as an aspect in the bootstrap
kabirkhan Jan 30, 2007 12:56 PM (in response to starksm64)I have fixed the pointcut in the test. I'll try to figure out the AspectManagerJDK5 issue around the training I am delivering
-
6. Re: Registering a bean as an aspect in the bootstrap
starksm64 Jan 31, 2007 3:10 PM (in response to starksm64)I'm also having problems with the bootstrap xml intercepting some classes. For example, if I add an org.jboss.deployers.spi.attachments.Attachments interceptor:
<bean name="AspectManager" class="org.jboss.aop.deployers.AspectManagerJDK5"> <constructor> <parameter><![CDATA[ <aop> <aspect name="deployers" class="org.jboss.profileservice.aop.DeployerAspects"/> <bind pointcut="execution(* $instanceof{org.jboss.deployers.spi.deployer.Deployer}->*(..))"> <advice name="invoke" aspect="deployers"/> </bind> <aspect name="mainDeployer" class="org.jboss.profileservice.aop.MainDeployerAspect"/> <bind pointcut="execution(* $instanceof{org.jboss.deployers.spi.deployment.MainDeployer}->process(..))"> <advice name="process" aspect="mainDeployer"/> </bind> <aspect name="track" class="org.jboss.profileservice.aop.TrackingAdvice"/> <bind pointcut="execution(* $instanceof{org.jboss.deployers.spi.attachments.Attachments}->addAttachment(..))"> <advice name="invoke" aspect="track"/> </bind> </aop>]]> </parameter> </constructor>
This is not applied. I had to go into one particular usage context (AbstractDeploymentContext) and wrap the Attachments instance I wanted to inercept in an aop proxy in order for the above aspect to be applied. -
7. Re: Registering a bean as an aspect in the bootstrap
kabirkhan Feb 1, 2007 5:03 PM (in response to starksm64)"scott.stark@jboss.org" wrote:
I'm also having problems with the bootstrap xml intercepting some classes. For example, if I add an org.jboss.deployers.spi.attachments.Attachments interceptor:
Is it a bean? Only beans get the proxy created automatically. Otherwise loadtime weaving will need to be turned on -
8. Re: Registering a bean as an aspect in the bootstrap
starksm64 Feb 1, 2007 6:05 PM (in response to starksm64)No its not a bean. I thought this might be the difference, but then I don't understand how the aop-mc-int test differ. There I am intercepting non-bean classes. I guess I need to understand the differences in how aop is integrated between the mc projects and jboss5.
-
9. Re: Registering a bean as an aspect in the bootstrap
kabirkhan Feb 1, 2007 6:42 PM (in response to starksm64)Some of the the aop-mc-int tests run with weaving enabled
-
10. Re: Registering a bean as an aspect in the bootstrap
kabirkhan Feb 1, 2007 6:57 PM (in response to starksm64)I have added some tests trying to mimic what is happening in the bootstrap. They are in org.jboss.test.microcontainer.test.DeployersInterceptedAspectManagerJMXTestCase and org.jboss.test.microcontainer.test.DeployersLifecycleAspectManagerJMXTestCase.
From DeployersInterceptedAspectManagerJMXTestCase, which works as expected:<?xml version="1.0" encoding="UTF-8"?> <deployment xmlns="urn:jboss:bean-deployer:2.0"> <bean name="JBossServer" class="org.jboss.test.microcontainer.support.deployers.JBossServer"/> <bean name="ProfileService" class="java.lang.Object"/> <bean name="JMXKernel" class="org.jboss.test.microcontainer.support.deployers.JMXKernel"> <property name="kernel"><inject bean="jboss.kernel:service=Kernel"/></property> <property name="serverImpl"><inject bean="JBossServer"/></property> </bean> <bean name="AspectManager" class="org.jboss.test.microcontainer.support.deployers.AspectManagerBean"> <constructor> <parameter><![CDATA[ <aop> </aop>]]> </parameter> </constructor> <property name="mbeanServer"><inject bean="JMXKernel" property="mbeanServer"/></property> </bean> <aop:lifecycle-configure xmlns:aop="urn:jboss:aop-beans:1.0" name="Deployers" class="org.jboss.test.microcontainer.support.deployers.DeployerAspects" classes="org.jboss.test.microcontainer.support.deployers.IDeployer" manager-bean="AspectManager" manager-property="aspectManager" pointcut="execution(* $instanceof{org.jboss.test.microcontainer.support.deployers.IDeployer}->$implements{org.jboss.test.microcontainer.support.deployers.IDeployer}(..))"> </aop:lifecycle-configure> <bean name="MainDeployer" class="org.jboss.test.microcontainer.support.deployers.SampleMainDeployer"> <property name="deployers"> <list> <bean name="SampleDeployer1" class="org.jboss.test.microcontainer.support.deployers.SampleDeployer"> <property name="type">aop</property> </bean> <bean name="SampleDeployer2" class="org.jboss.test.microcontainer.support.deployers.SampleDeployer"> <property name="type">beans</property> </bean> </list> </property> </bean> </deployment>
I've added some printlns to the KernelControllerContextAction to see when the difference actions get called:---> Describe JBossServer ====> AOPDependencyBuilder - Has dependencies: false ---> Instantiate JBossServer ---> Configure JBossServer ---> CreateDestroyLifecycle JBossServer ---> StartStopLifecycle JBossServer ---> Install JBossServer ---> Describe ProfileService ---> Instantiate ProfileService ---> Configure ProfileService ---> CreateDestroyLifecycle ProfileService ---> StartStopLifecycle ProfileService ---> Install ProfileService ---> Describe JMXKernel ====> AOPDependencyBuilder - Has dependencies: false ---> Instantiate JMXKernel ---> Configure JMXKernel ---> CreateDestroyLifecycle JMXKernel ---> StartStopLifecycle JMXKernel ---> Install JMXKernel ---> Describe AspectManager ====> AOPDependencyBuilder - Has dependencies: false ---> Instantiate AspectManager ---> Configure AspectManager ---> CreateDestroyLifecycle AspectManager ---> StartStopLifecycle AspectManager ---> Install AspectManager ---> Describe Deployers ====> AOPDependencyBuilder - Has dependencies: false ---> Instantiate Deployers ---> Configure Deployers ---> CreateDestroyLifecycle Deployers ---> StartStopLifecycle Deployers ---> Install Deployers ---> Describe Deployers$Aspect ---> Instantiate Deployers$Aspect ---> Configure Deployers$Aspect ---> CreateDestroyLifecycle Deployers$Aspect ---> StartStopLifecycle Deployers$Aspect 1688 DEBUG [Aspect] Bound aspect Deployers$Aspect; deployed:true ---> Install Deployers$Aspect ---> Describe Deployers$AspectBinding ---> Instantiate Deployers$AspectBinding ---> Configure Deployers$AspectBinding ---> CreateDestroyLifecycle Deployers$AspectBinding ---> StartStopLifecycle Deployers$AspectBinding ----> Added binding execution(* $instanceof{org.jboss.test.microcontainer.support.deployers.IDeployer}->$implements{org.jboss.test.microcont ainer.support.deployers.IDeployer}(..)) 1750 DEBUG [AspectBinding] Bound binding 5c4o02-s8c9is-exnuf357-1-exnuf3au-7 ---> Install Deployers$AspectBinding ---> Describe Deployers$IntroductionBinding ---> Instantiate Deployers$IntroductionBinding ---> Configure Deployers$IntroductionBinding ---> CreateDestroyLifecycle Deployers$IntroductionBinding ---> StartStopLifecycle Deployers$IntroductionBinding ---> Install Deployers$IntroductionBinding ---> Describe SampleDeployer1 1797 DEBUG [GenericBeanAspectFactory] Creating advice 5c4o02-s8c9is-exnuf357-1-exnuf3ae-6 1797 DEBUG [DeployerAspects] ctor ====> AOPDependencyBuilder - Has dependencies: true ---> Instantiate SampleDeployer1 2016 DEBUG [SampleDeployer] ctor 2219 DEBUG [SampleDeployer] ctor ---> Configure SampleDeployer1 ---> CreateDestroyLifecycle SampleDeployer1 ---> StartStopLifecycle SampleDeployer1 ---> Install SampleDeployer1 ---> Describe SampleDeployer2 ====> AOPDependencyBuilder - Has dependencies: true ---> Instantiate SampleDeployer2 2235 DEBUG [SampleDeployer] ctor 2281 DEBUG [SampleDeployer] ctor ---> Configure SampleDeployer2 ---> CreateDestroyLifecycle SampleDeployer2 ---> StartStopLifecycle SampleDeployer2 ---> Install SampleDeployer2 ---> Describe MainDeployer ====> AOPDependencyBuilder - Has dependencies: false ---> Instantiate MainDeployer ---> Configure MainDeployer 2297 DEBUG [SampleMainDeployer] setDeployers, size=2 ---> CreateDestroyLifecycle MainDeployer ---> StartStopLifecycle MainDeployer ---> Install MainDeploy
I have reduced the conf/bootstrap-beans to the following:<?xml version="1.0" encoding="UTF-8"?> <!-- The bootstrap of the server. This should only have the minimum needed to bootstrap the mc kernel and profile service. $Id:$ --> <deployment xmlns="urn:jboss:bean-deployer:2.0"> <bean name="ProfileService" class="org.jboss.system.server.profileservice.basic.ProfileServiceImpl"> <constructor> <parameter>${jboss.server.name}</parameter> </constructor> <property name="profileRoot">${jboss.server.home.url}/profile</property> </bean> <bean name="JMXKernel" class="org.jboss.system.server.jmx.JMXKernel"> <property name="kernel"><inject bean="jboss.kernel:service=Kernel"/></property> <property name="serverImpl"><inject bean="JBossServer"/></property> </bean> <bean name="AspectManager" class="org.jboss.aop.deployers.AspectManagerJDK5"> <constructor> <parameter><![CDATA[ <aop> <aspect name="mainDeployer" class="org.jboss.profileservice.aop.MainDeployerAspect"/> <bind pointcut="execution(* $instanceof{org.jboss.deployers.spi.deployment.MainDeployer}->process(..))"> <advice name="process" aspect="mainDeployer"/> </bind> <aspect name="persist" class="org.jboss.profileservice.aop.PersistAspect"/> <bind pointcut="execution(* $instanceof{org.jboss.managed.api.ManagedProperty}->setValue(..))"> <advice name="setValue" aspect="persist"/> </bind> </aop>]]> </parameter> </constructor> <property name="mbeanServer"><inject bean="JMXKernel" property="mbeanServer"/></property> <property name="enableLoadtimeWeaving">false</property> <property name="suppressTransformationErrors">true</property> <property name="prune">true</property> <property name="include">org.jboss.test, org.jboss.injbossaop, org.jboss.cache.jmx, org.jboss.cache.pojo.jmx, org.jboss.ha, org.jboss.invocation</property> <property name="exclude">org.jboss.</property> <property name="optimized">true</property> <property name="verbose">false</property> </bean> <aop:lifecycle-configure xmlns:aop="urn:jboss:aop-beans:1.0" name="Deployers" class="org.jboss.profileservice.aop.DeployerAspects" classes="org.jboss.deployers.spi.deployer.Deployer" manager-bean="AspectManager" manager-property="aspectManager" pointcut="execution(* $instanceof{org.jboss.deployers.spi.deployer.Deployer}->prepareDeploy(..))"> </aop:lifecycle-configure> <bean name="MainDeployer" class="org.jboss.deployers.plugins.deployment.MainDeployerImpl"> <property name="deployers"> <list> <bean name="AspectDeployer" class="org.jboss.aop.deployers.AspectDeployer"> <property name="type">aop</property> </bean> <bean name="BeanDeployer" class="org.jboss.deployers.plugins.deployers.kernel.BeanDeployer"> <property name="type">beans</property> </bean> </list> </property> </bean> </deployment>
And seem to be getting a completely different order for how the beans are created in JBoss?Kabir@KabirDell ~/sourcecontrol/jboss-head/build/output/jboss-5.0.0.Beta2/bin $ run.sh ========================================================================= JBoss Bootstrap Environment JBOSS_HOME: C:\cygwin\home\Kabir\sourcecontrol\jboss-head\build\output\jboss-5.0.0.Beta2 JAVA: /c/Java/jdk/jdk1.5.0_09/bin/java JAVA_OPTS: -Dprogram.name=run.sh -server -Xms128m -Xmx512m -Dorg.jboss.resolver.warning=true -Dsun.rmi.dgc.client.gcInterval=3600000 -Dsun.rmi.dgc.server.gcInterval=3600000 CLASSPATH: C:\cygwin\home\Kabir\sourcecontrol\jboss-head\build\output\jboss-5.0.0.Beta2\bin\run.jar;C:\Java\jdk\jdk1.5.0_09\lib\tools.jar ========================================================================= 23:54:34,156 INFO [ServerImpl] Starting JBoss (Microcontainer)... 23:54:34,156 INFO [ServerImpl] Release ID: JBoss [Morpheus] 5.0.0.Beta2 (build: SVNTag=JBoss_5_0_0_Beta2 date=200701261503) 23:54:34,203 INFO [ServerImpl] Home Dir: C:\cygwin\home\Kabir\sourcecontrol\jboss-head\build\output\jboss-5.0.0.Beta2 23:54:34,203 INFO [ServerImpl] Home URL: file:/C:/cygwin/home/Kabir/sourcecontrol/jboss-head/build/output/jboss-5.0.0.Beta2/ 23:54:34,203 INFO [ServerImpl] Library URL: file:/C:/cygwin/home/Kabir/sourcecontrol/jboss-head/build/output/jboss-5.0.0.Beta2/lib/ 23:54:34,203 INFO [ServerImpl] Patch URL: null 23:54:34,203 INFO [ServerImpl] Server Name: default 23:54:34,203 INFO [ServerImpl] Server Home Dir: C:\cygwin\home\Kabir\sourcecontrol\jboss-head\build\output\jboss-5.0.0.Beta2\server\default 23:54:34,203 INFO [ServerImpl] Server Home URL: file:/C:/cygwin/home/Kabir/sourcecontrol/jboss-head/build/output/jboss-5.0.0.Beta2/server/default/ 23:54:34,203 INFO [ServerImpl] Server Data Dir: C:\cygwin\home\Kabir\sourcecontrol\jboss-head\build\output\jboss-5.0.0.Beta2\server\default\data 23:54:34,203 INFO [ServerImpl] Server Temp Dir: C:\cygwin\home\Kabir\sourcecontrol\jboss-head\build\output\jboss-5.0.0.Beta2\server\default\tmp 23:54:34,203 INFO [ServerImpl] Server Config URL: file:/C:/cygwin/home/Kabir/sourcecontrol/jboss-head/build/output/jboss-5.0.0.Beta2/server/default/conf/ 23:54:34,203 INFO [ServerImpl] Server Library URL: file:/C:/cygwin/home/Kabir/sourcecontrol/jboss-head/build/output/jboss-5.0.0.Beta2/server/default/lib/ 23:54:34,203 INFO [ServerImpl] Root Deployment Filename: jboss-service.xml 23:54:34,218 INFO [ServerImpl] Starting Microcontainer, bootstrapURL=file:/C:/cygwin/home/Kabir/sourcecontrol/jboss-head/build/output/jboss-5.0.0.Beta2/server/default/conf/bootstrap-beans.xml ---> Describe ProfileService ====> AOPDependencyBuilder - Has dependencies: false ---> Instantiate ProfileService ---> Configure ProfileService ---> CreateDestroyLifecycle ProfileService ---> StartStopLifecycle ProfileService 23:54:35,531 INFO [ProfileImpl] Using profile root:C:\cygwin\home\Kabir\sourcecontrol\jboss-head\build\output\jboss-5.0.0.Beta2\bin\file:\C:\cygwin\home\Kabir\sourcecontrol\jboss-head\build\output\jboss-5.0.0.Beta2\server\default\profile ---> Install ProfileService ---> Describe JMXKernel ====> AOPDependencyBuilder - Has dependencies: false ---> Instantiate JMXKernel ---> Describe AspectManager ---> Instantiate AspectManager ---> Describe Deployers ====> AOPDependencyBuilder - Has dependencies: false ---> Instantiate Deployers ---> Configure Deployers ---> CreateDestroyLifecycle Deployers ---> StartStopLifecycle Deployers ---> Install Deployers ---> Describe Deployers$Aspect ---> Instantiate Deployers$Aspect ---> Describe Deployers$AspectBinding ---> Instantiate Deployers$AspectBinding ---> Describe Deployers$IntroductionBinding ---> Instantiate Deployers$IntroductionBinding ---> Describe AspectDeployer ---> Instantiate AspectDeployer ---> Configure AspectDeployer ---> CreateDestroyLifecycle AspectDeployer ---> StartStopLifecycle AspectDeployer ---> Install AspectDeployer ---> Describe BeanDeployer ====> AOPDependencyBuilder - Has dependencies: false ---> Instantiate BeanDeployer ---> Configure BeanDeployer ---> CreateDestroyLifecycle BeanDeployer ---> StartStopLifecycle BeanDeployer ---> Install BeanDeployer ---> Describe MainDeployer ====> AOPDependencyBuilder - Has dependencies: false ---> Instantiate MainDeployer ---> Configure MainDeployer ---> CreateDestroyLifecycle MainDeployer ---> StartStopLifecycle MainDeployer ---> Install MainDeployer ---> Describe JBossServer ====> AOPDependencyBuilder - Has dependencies: false ---> Configure JBossServer ---> CreateDestroyLifecycle JBossServer ---> StartStopLifecycle JBossServer ---> Install JBossServer ---> Configure JMXKernel ---> CreateDestroyLifecycle JMXKernel ---> StartStopLifecycle JMXKernel 23:54:38,312 INFO [ServerInfo] Java VM: Java HotSpot(TM) Server VM 1.5.0_09-b01,Sun Microsystems Inc. 23:54:38,312 INFO [ServerInfo] OS-System: Windows XP 5.1,x86 23:54:38,343 INFO [JMXKernel] Legacy JMX core initialized ---> Install JMXKernel ---> Configure AspectManager ---> CreateDestroyLifecycle AspectManager ---> StartStopLifecycle AspectManager ---> Install AspectManager ---> Configure Deployers$IntroductionBinding ---> Configure Deployers$Aspect ---> CreateDestroyLifecycle Deployers$IntroductionBinding ---> CreateDestroyLifecycle Deployers$Aspect ---> StartStopLifecycle Deployers$IntroductionBinding ---> StartStopLifecycle Deployers$Aspect ---> Install Deployers$IntroductionBinding ---> Install Deployers$Aspect ---> Configure Deployers$AspectBinding ---> CreateDestroyLifecycle Deployers$AspectBinding ---> StartStopLifecycle Deployers$AspectBinding ----> Added binding execution(* $instanceof{org.jboss.deployers.spi.deployer.Deployer}->prepareDeploy(..)) ---> Install Deployers$AspectBinding 23:54:38,546 INFO [ServerImpl] JBoss (Microcontainer) [5.0.0.Beta2 (build: SVNTag=JBoss_5_0_0_Beta2 date=200701261503)] Started in 4s:343ms
-
11. Re: Registering a bean as an aspect in the bootstrap
starksm64 Feb 1, 2007 7:41 PM (in response to starksm64)Even from within eclipse? The org.jboss.test.deployers.attachments.test.DeploymentAttachmentsInterceptUnitTestCase in the deployer project is the one that is most similar to this Attachments interface aspect usage, but its not really a full mc test. It uses the AspectXmlLoader to deploy a test specific aop xml descriptor.
-
12. Re: Registering a bean as an aspect in the bootstrap
starksm64 Feb 1, 2007 7:56 PM (in response to starksm64)There certainly are different dependencies. The jboss5 the AspectManager depends on the JMXKernel for the mbeanServer which in turn depends on the JBossServer, which is not in the bootstrap descriptor. Rather, its magically injected after the bootstrap, but before the validation by the jboss5 ServerImpl class, org.jboss.system.server.profileservice.ProfileServiceBootstrap.bootstrap method:
... deploy(bootstrapURL); Kernel kernel = getKernel(); controller = kernel.getController(); // Register the Server instance in the kernel if (server != null) { AbstractBeanMetaData metaData = new AbstractBeanMetaData("JBossServer", server.getClass().getName()); controller.install(metaData, server); } // Validate that everything is ok checkIncomplete();
So I guess this is causing issues. The JBossServer bean is the bean implementing the org.jboss.system.server.Server that is loaded to define the jboss server behavior. -
13. Re: Registering a bean as an aspect in the bootstrap
starksm64 Feb 1, 2007 8:09 PM (in response to starksm64)If the AspectManager does need an MBeanServer, this could be created as a bean and injected into the JMXKernel rather than having the AspectManager depend on the JMXKernel for it. A bean factory would be needed to created it similar to how the JMXKernel does things.
-
14. Re: Registering a bean as an aspect in the bootstrap
starksm64 Feb 1, 2007 8:25 PM (in response to starksm64)I moved the install of the JBossServer bean to before the loading of the bootstrap xml. Update your system module to pickup the org.jboss.system.server.profileservice.ProfileServiceBootstrap change and try that.