-
1. Re: Install from Annotations
alesj Jun 23, 2009 9:51 AM (in response to gurkanerdogdu)The matching annotation plugin is missing usage of this name:
public class BeanAnnotationPlugin extends ClassAnnotationPlugin<Bean> { public static final BeanAnnotationPlugin INSTANCE = new BeanAnnotationPlugin(); protected BeanAnnotationPlugin() { super(Bean.class); } protected List<? extends MetaDataVisitorNode> internalApplyAnnotation(ClassInfo info, Bean annotation, BeanMetaData beanMetaData) { AbstractBeanMetaData abmd = checkIfNotAbstractBeanMetaDataSpecific(beanMetaData); if (abmd.getAutowireType() == null) abmd.setAutowireType(annotation.autowireType()); if (abmd.getMode() == null) abmd.setMode(annotation.mode()); if (abmd.getErrorHandlingMode() == null) abmd.setErrorHandlingMode(annotation.errorHandlingMode()); if (abmd.getAccessMode() == null) abmd.setAccessMode(annotation.accessMode()); // we don't put bmd back to be inspected // since the changes we apply *here* don't really // trigger any change in metadata - all enums return null; } }
I did put this comment herepublic @interface Bean { /** * Get the bean's name. * * This is only meant to be used before * bean meta data is already installed * in Controller. * * @return bean's name */ String name() default "";
But thinking about it more + your use case,
I'm not sure anymore why I left it out from the plugin.
You can create your temp @Bean annotation plugin and register it against BasicBeanMetaDataAnnotationAdapter.
I'll add this name usage + test if it breaks something. -
2. Re: Install from Annotations
gurkanerdogdu Jun 23, 2009 10:04 AM (in response to gurkanerdogdu)thanks for answer.
But if I do not mind to use -beans.xml, is it required to implement new plugin and register it ? Is there any other way ?
Actually my question is that, is there any discovery process/class to discover annotated bean classes without configuring XML at boot time? -
3. Re: Install from Annotations
alesj Jun 23, 2009 10:08 AM (in response to gurkanerdogdu)"gurkanerdogdu" wrote:
Actually my question is that, is there any discovery process/class to discover annotated bean classes without configuring XML at boot time?
Yes.
Check the Deployers project.
It's has @Bean auto-discovery as a test case. -
4. Re: Install from Annotations
alesj Jun 23, 2009 10:12 AM (in response to gurkanerdogdu)"alesj" wrote:
"gurkanerdogdu" wrote:
Actually my question is that, is there any discovery process/class to discover annotated bean classes without configuring XML at boot time?
Yes.
Check the Deployers project.
It's has @Bean auto-discovery as a test case.
http://anonsvn.jboss.org/repos/jbossas/projects/jboss-deployers/trunk/deployers-vfs/src/main/java/org/jboss/deployers/vfs/deployer/kernel/BeanScanningDeployer.java
http://anonsvn.jboss.org/repos/jbossas/projects/jboss-deployers/trunk/deployers-vfs/src/test/java/org/jboss/test/deployers/vfs/deployer/bean/test/BeanScanningUnitTestCase.java -
5. Re: Install from Annotations
gurkanerdogdu Jun 23, 2009 10:34 AM (in response to gurkanerdogdu)BeanDeployer class gets DeploymentUnit class as an input parameter. I just want is that when there is an empty *-beans.xml file in the standalone project's META-INF folder, its configured kernel collects all of annotated classes from classpath and register them with registry.
-
6. Re: Install from Annotations
alesj Jun 23, 2009 10:37 AM (in response to gurkanerdogdu)BeanDeployer != BeanScanningDeployer ;-)
-
7. Re: Install from Annotations
gurkanerdogdu Jun 23, 2009 10:38 AM (in response to gurkanerdogdu)"alesj" wrote:
BeanDeployer != BeanScanningDeployer ;-)
Upps, I mean BeanScanningDeployer
Thanks; -
8. Re: Install from Annotations
gurkanerdogdu Jun 24, 2009 3:48 AM (in response to gurkanerdogdu)Hi;
Is there any class responsible for creating BeanMetaData class from annotated bean ? AFAIK, there is a BeanMetaDataBuilder class, but you have to set all of its parameters.
Example :
@Bean(name="person")
class Person(){}
BeanMetaData metaData = MetaDataBuilder.parseClass(Person.class);
"parseClass", parse all annotations from class and return configured BeanMetaData instance.
Thanks; -
9. Re: Install from Annotations
alesj Jun 24, 2009 4:42 AM (in response to gurkanerdogdu)You are already using it, see your first post. ;-)
- AnnotationToBeanMetaDataFactory
Then it's up to the annotation plugins how they treat found annotations.
By default BasicBeanMetaDataAnnotationAdapter already has a bunch of them pre-configured.
But you can easily add your own, or override/replace existing. -
10. Re: Install from Annotations
gurkanerdogdu Jun 24, 2009 6:20 AM (in response to gurkanerdogdu)"alesj" wrote:
You are already using it, see your first post. ;-)
- AnnotationToBeanMetaDataFactory
I am totally lost my way in APIs, SPIs, Plugins :)
Thanks;