[jboss-user] [Snowdrop] - Speeding up Spring, coupled to JBoss

Tejas Mehta do-not-reply at jboss.com
Thu Jul 11 19:09:31 EDT 2013

Tejas Mehta [https://community.jboss.org/people/tmehta] created the discussion

"Speeding up Spring, coupled to JBoss"

To view the discussion, visit: https://community.jboss.org/message/827646#827646

Hello all,

We, the Snowdrop Dev team, have been trying to speed up Spring's Component Scanning.

Typically, Spring Applications make use of the context namespace to add beans to the Spring Container, example: <context:component-scan base-package="foo.bar"/>. In order to identify the beans it needs to initialize, Spring looks through the package and scans for @Component and its extensions. For packages with large number of Components, this process is fairly slow.

The specific steps are as follows:

After bootstrapping, the set of application components and service that need to be created are identified. AbstractbeanDefinitionReader will read resource definitions. DefaultListableBeanFactorywill be used as default bean factory based on bean definition objects.XmlBeanDefinitionReader.loadBeanDefinitions() load bean definitions from the specified XML file in which the BeanDefinitionParser will identify the context namespaces and parses the applicationContext xml. The resources are identified by the implementation of ResourcePatternResolver:, ie PathMatchingResourcePatternResolver in which the location patterns are found like an ant-style. Internally it uses ClassLoader.getResources(String name) method which returns an Enumeration containing URLs representing classpath resources. Then the ComponentScanBeanDefinitionParser will parse through the context definition nodes.

It is this last step that we want to speed up and to do so we are attempting to leverage JBoss' Jandex module.

At the start of deployment in JBoss, the Jandex module scans the classes and creates an Annotation Index. We would like to be able to utilize this Index to skip the scanning step and just initialize the pre-identified components.

Potential Solution:

Component-Scan within snowdrop's jboss namespace -  https://github.com/snowdrop/snowdrop/tree/CustomBeanScanner: https://github.com/snowdrop/snowdrop/tree/CustomBeanScanner:
One option is to add our custom component scanner to snowdrop's namespace. So instead of <context:component-scan base-package="foo.bar"/>, the user would use: <jboss:component-scan base-package="foo.bar"/>.

While this has the downside that the user has to change their application to make use of the feature, it forces the user to make a conscious decision. 

What do you think of this feature and of how it couples a Spring app with JBoss?  Is the intentional coupling worth the speed increase?

Thanks in advance for the feedback,

Tejas M. on behalf of the Snowdrop Team

Reply to this message by going to Community

Start a new discussion in Snowdrop at Community

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/jboss-user/attachments/20130711/d3f80790/attachment-0001.html 

More information about the jboss-user mailing list