[Design the new POJO MicroContainer] - Re: Annotation features
by adrian@jboss.org
"alesj" wrote :
| "adrian(a)jboss.org" wrote :
| | Don't follow the rest of this, I still haven't had to look at what you and Kabir did in this area.
| |
| Any pointers then to follow?
| So that I don't go astray as in name-aware ... :-(
|
Discuss it with Kabir. He's your partner in crime in this area. :-)
Like I said before, I'll eventually get around to reviewing
it all and telling you what is wrong with it. :-)
In principle it should just be about populating the BeanMetaData from the annotations
where there it doesn't already exist - i.e. what the user provides overrides
(either xml or programmatic overrides the annotations).
The difficult part I can see comes from the factory processing where you don't know
the implementation class until the factory has instantiated the object.
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4065479#4065479
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4065479
18 years, 8 months
[Design of AOP on JBoss (Aspects/JBoss)] - Re: AOP ClassLoader/Scoping for the VFSClassLoader
by adrian@jboss.org
Looks like there is lot more work to this.
The original refactoring just dealt with the aop project (AspectManager).
There's also a lot of deep integration in the asintegration project (AspectManagerService).
I've manged to come up with an alternate integration interface that encapsulates all this:
| package org.jboss.aop.deployment;
|
| import java.io.File;
|
| import javassist.scopedpool.ScopedClassPoolFactory;
|
| import org.jboss.aop.ClassLoaderValidation;
| import org.jboss.aop.classpool.AOPClassLoaderScopingPolicy;
|
| /**
| * AOPIntegration.<p>
| *
| * This class is intended to identify all the integration
| * points AOP is making with the JBoss appserver.
| *
| * @author <a href="adrian(a)jboss.com">Adrian Brock</a>
| * @version $Revision: 1.1 $
| */
| public interface JBossIntegration extends ClassLoaderValidation, ScopedClassPoolFactory
| {
| /**
| * Create the AOPClassLoaderScopingPolicy
| *
| * @return the policy
| */
| AOPClassLoaderScopingPolicy createAOPClassLoaderScopingPolicy();
|
| /**
| * Create a scoped classpool factory
| *
| * TODO JBAOP-??? need to review whether ScopedClassPool should also be replaced with
| * some other policy, e.g. javassist ClassPath notion is closer to new classloader?
| * @param tmpDir the temporary directory for classes
| * @return the factory
| * @throws Exception for any error
| */
| ScopedClassPoolFactory createScopedClassPoolFactory(File tmpDir) throws Exception;
|
| /**
| * Attach the depreacted translator
| */
| void attachDeprecatedTranslator();
|
| /**
| * Detach the deprecated translator
| */
| void detachDeprecatedTranslator();
| }
|
And an implementation for the old stuff
| package org.jboss.aop.deployment;
|
| import java.io.File;
|
| import javax.management.Attribute;
| import javax.management.AttributeNotFoundException;
| import javax.management.InstanceNotFoundException;
| import javax.management.InvalidAttributeValueException;
| import javax.management.MBeanException;
| import javax.management.MBeanServer;
| import javax.management.ReflectionException;
|
| import javassist.ClassPool;
| import javassist.scopedpool.ScopedClassPool;
| import javassist.scopedpool.ScopedClassPoolFactory;
| import javassist.scopedpool.ScopedClassPoolRepository;
|
| import org.jboss.aop.AspectManager;
| import org.jboss.aop.classpool.AOPClassLoaderScopingPolicy;
| import org.jboss.aop.classpool.AOPScopedClassLoaderHelper;
| import org.jboss.aop.classpool.AOPScopedClassLoaderHelperBridge;
| import org.jboss.mx.loading.RepositoryClassLoader;
| import org.jboss.mx.util.MBeanServerLocator;
|
| /**
| * JBoss4Integration.<p>
| *
| * This class and its associated classes are
| * for the old JBoss4 integration with the LoaderRepository<p>
| *
| * <ul>Related Classes:
| * <li> {@link JBossClassPool}
| * <li> {@link JBossClassPoolFactory}
| * <li> {@link JBossScopedClassLoaderHelper}
| * <li> {@link LoaderRepositoryUrlUtil}
| * <li> {@link ScopedClassLoaderDomain}
| * <li> {@link ScopedJBossClassPool}
| * </ul>
| *
| * @deprecated TODO JBAOP-??? need to write a JBoss5 version
| * @author <a href="adrian(a)jboss.com">Adrian Brock</a>
| * @author <a href="mailto:bill@jboss.org">Bill Burke</a>
| * @author <a href="kabir.khan(a)jboss.com">Kabir Khan</a>
| * @version $Revision: 1.1 $
| */
| @Deprecated
| public class JBoss4Integration implements JBossIntegration
| {
| /** The delegate classpool factory */
| private ScopedClassPoolFactory delegateClassPoolFactory;
|
| public boolean isValidClassLoader(ClassLoader loader)
| {
| if (!(loader instanceof RepositoryClassLoader)) return false;
| return ((RepositoryClassLoader) loader).getLoaderRepository() != null;
| }
|
| public AOPClassLoaderScopingPolicy createAOPClassLoaderScopingPolicy()
| {
| AOPScopedClassLoaderHelper helper = new JBossScopedClassLoaderHelper();
| return new AOPScopedClassLoaderHelperBridge(helper);
| }
|
| public ScopedClassPoolFactory createScopedClassPoolFactory(File tmpDir) throws Exception
| {
| delegateClassPoolFactory = new JBossClassPoolFactory(tmpDir);
| return this;
| }
|
| public ScopedClassPool create(ClassLoader cl, ClassPool src, ScopedClassPoolRepository repository)
| {
| return delegateClassPoolFactory.create(cl, src, repository);
| }
|
| public ScopedClassPool create(ClassPool src, ScopedClassPoolRepository repository)
| {
| return delegateClassPoolFactory.create(src, repository);
| }
|
| public void attachDeprecatedTranslator()
| {
| AspectManager mgr = AspectManager.instance();
| MBeanServer server = MBeanServerLocator.locateJBoss();
| try
| {
| server.setAttribute(AspectManagerService.DEFAULT_LOADER_REPOSITORY, new Attribute("Translator", mgr));
| }
| catch (InstanceNotFoundException e)
| {
| throw new RuntimeException(e);
| }
| catch (AttributeNotFoundException e)
| {
| throw new RuntimeException(e);
| }
| catch (InvalidAttributeValueException e)
| {
| throw new RuntimeException(e);
| }
| catch (MBeanException e)
| {
| throw new RuntimeException(e);
| }
| catch (ReflectionException e)
| {
| throw new RuntimeException(e);
| }
| }
|
| public void detachDeprecatedTranslator()
| {
| MBeanServer server = MBeanServerLocator.locateJBoss();
| try
| {
| server.setAttribute(AspectManagerService.DEFAULT_LOADER_REPOSITORY, new Attribute("Translator", null));
| }
| catch (InstanceNotFoundException e)
| {
| throw new RuntimeException(e);
| }
| catch (AttributeNotFoundException e)
| {
| throw new RuntimeException(e);
| }
| catch (InvalidAttributeValueException e)
| {
| throw new RuntimeException(e);
| }
| catch (MBeanException e)
| {
| throw new RuntimeException(e);
| }
| catch (ReflectionException e)
| {
| throw new RuntimeException(e);
| }
| }
|
This is just an FYI warning, since I've committed it yet (not tested it).
The main work will be in writing a JBoss5 version that uses the new
jboss-classloading-spi instead so it can work with both the
RepositoryClassLoader and the VFSClassLoader.
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4065456#4065456
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4065456
18 years, 8 months
[Design the new POJO MicroContainer] - Re: Annotation features
by adrian@jboss.org
"alesj" wrote :
| There are some pointers to use the ClassInfo/BeanInfo:
| anonymous wrote :
| | The inspection should come from "reflection abstraction"
| | in the container module which is integrated via the
| | Configurator/BeanInfo.
|
| But is looks like this is not yet fully implemented:
| anonymous wrote :
| | Which AFAIK, (Kabir may know better) isn't properly integrated
| | except when AOP is used. i.e. The Bean/ClassInfo is not updated
| | with the annotation overrides.
| |
|
The plan to update the Bean/ClassInfo was dropped (or at least shelved)
since it was too much work for AOP.
Instead, you should use the MetaData from the MetaDataRepository for that instance.
That is where the overridden annotations are stored at the instance level.
anonymous wrote :
| Regarding the scattering:
|
| 1) I've started with a simple annotation handling with AnnotationDependencyBuilder and DependencyFactory(Lookup), but this is not yet enabled - DependencyBuilder is not pluged in.
| There was a question about using a chain of DependencyBuilders, but that's where it stopped.
| - http://www.jboss.com/index.html?module=bb&op=viewtopic&t=107268
|
| 2) But on the other hand I'm doing a whole annotation lookup through MetaDataRepository in PreInstallAction.
|
| 3) And I do a straight annotation lookup via BeanInfo in LifecycleAction.
|
| I like the AnnotationDependencyBuilder with DependencyFactory approach - ok, some weak caching is missing and some other features - but if we are able to provide a generic annotation handling that way ...
|
| I guess some of the actual annotation handling will/is depending on the ControllerState we are in - specially regarding classes being present and actual bean instantiation with beanfactory.
| Perhaps doing DependencyBuilders depending on the state?
|
| Is changing the BeanMetaData legal when handling annotations?
| Or we need to do the cloning before this?
Don't follow the rest of this, I still haven't had to look at what you and Kabir did
in this area.
IMHO, the BeanMetaData should always be cloned, even if it just avoids
| BeanMetaData bmd = ...
| controller.registerContext(bmd);
| bmd.changeIt() // oops - which version of bmd gets used?
|
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4065441#4065441
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4065441
18 years, 8 months