Sorry, should have included that in my last post.
It doesn't log the components. Using the '@Name' name works fine. It's as though the @Role annotation is being ignored. I've checked out the latest cvs version of seam.
I've had a look through the seam code it looks as though the only class that knows about roles in components is: org.jboss.seam.init.Initialization. It checks for the @Role/@Roles annotations in the compponents contained in the init context variable. When I run my example the init.getComponentClasses returns zero components.
Later on in Initilization, there are another few lines that add components using a Scanner instance which does not appear to be aware of @Role/@Roles annotaions. My components are picked up here.
Here is the block of code that contains the only references to the Role annotations that I could find. The body of the for loop does not get run as no component classes are returned. This is taken from org.jboss.seam.init.Initilization, line 165 onwards.
//TODO: move all this stuff into Init component?
for ( String className : init.getComponentClasses() )
{
try
{
Class<Object> componentClass = Reflections.classForName(className);
addComponent( componentClass, context );
if ( componentClass.isAnnotationPresent(Role.class) )
{
Role role = componentClass.getAnnotation(Role.class);
ScopeType scope = Seam.getComponentRoleScope(componentClass, role);
addComponent( role.name(), scope, componentClass, context );
}
if ( componentClass.isAnnotationPresent(Roles.class) )
{
Role[] roles =componentClass.getAnnotation(Roles.class).value();
for (Role role: roles)
{
ScopeType scope = Seam.getComponentRoleScope(componentClass, role);
addComponent( role.name(), scope, componentClass, context );
}
}
}
catch (ClassNotFoundException cnfe)
{
throw new IllegalArgumentException("Component class not found: " + className, cnfe);
}
}
Here is the scanner bit which appears to register components using only the @Name annotation. My component classes get picked up here, but their Role annotations are not looked at. This is taken from org.jboss.seam.init.Initilization, line 220 onwards.
if (isScannerEnabled)
{
for ( Class clazz: new Scanner().getClasses() )
{
if ( clazz.isAnnotationPresent(Name.class) )
{
addComponent(clazz, context);
}
}
}
I think I'm either doing something wrong which is stopping my components appearing in init.getComponentClasses() or I've found a bug.
Relavent startup output:
09:04:38,193 INFO [Scanner] scanning: /C:/Program Files/jboss-4.0.4RC1/server/default/tmp/deploy/tmp25621test.ear-contents/test.jar
09:04:38,240 INFO [Component] Component: fooaction, scope: SESSION, type: STATELESS_SESSION_BEAN, class: uk.foo.FooAction, JNDI: test/FooAction/local
09:04:38,271 INFO [Component] Component: test, scope: SESSION, type: JAVA_BEAN, class: uk.foo.TestBean
09:04:38,286 INFO [Initialization] done initializing Seam
The full log:
09:04:35,802 INFO [EARDeployer] Init J2EE application: file:/C:/Program Files/jboss-4.0.4RC1/server/default/deploy/test.ear
09:04:36,755 INFO [Ejb3AnnotationHandler] found EJB3: ejbName=FooAction, class=uk.foo.FooAction, type=STATELESS
09:04:36,818 FATAL [PersistenceXmlLoader] userDatabase JTA
09:04:36,833 INFO [Ejb3Deployment] EJB3 deployment time took: 140
09:04:36,849 INFO [JmxKernelAbstraction] installing MBean: persistence.units:ear=test.ear.ear,jar=test.jar.jar,unitName=userDatabase with dependencies:
09:04:36,849 INFO [JmxKernelAbstraction] jboss.jca:name=DefaultDS,service=ManagedConnectionFactory
09:04:36,911 INFO [ConnectionProviderFactory] Initializing connection provider: org.hibernate.ejb.connection.InjectedDataSourceConnectionProvider
09:04:36,927 INFO [InjectedDataSourceConnectionProvider] Using provided datasource
09:04:36,927 INFO [SettingsFactory] RDBMS: HSQL Database Engine, version: 1.8.0
09:04:36,927 INFO [SettingsFactory] JDBC driver: HSQL Database Engine Driver, version: 1.8.0
09:04:36,927 INFO [Dialect] Using dialect: org.hibernate.dialect.HSQLDialect
09:04:36,943 INFO [TransactionFactoryFactory] Using default transaction strategy (direct JDBC transactions)
09:04:36,943 INFO [TransactionManagerLookupFactory] instantiating TransactionManagerLookup: org.hibernate.transaction.JBossTransactionManagerLookup
09:04:36,943 INFO [TransactionManagerLookupFactory] instantiated TransactionManagerLookup
09:04:36,943 INFO [SettingsFactory] Automatic flush during beforeCompletion(): enabled
09:04:36,943 INFO [SettingsFactory] Automatic session close at end of transaction: disabled
09:04:36,943 INFO [SettingsFactory] JDBC batch size: 15
09:04:36,943 INFO [SettingsFactory] JDBC batch updates for versioned data: disabled
09:04:36,943 INFO [SettingsFactory] Scrollable result sets: enabled
09:04:36,943 INFO [SettingsFactory] JDBC3 getGeneratedKeys(): disabled
09:04:36,943 INFO [SettingsFactory] Connection release mode: after_statement
09:04:36,943 INFO [SettingsFactory] Default batch fetch size: 1
09:04:36,943 INFO [SettingsFactory] Generate SQL with comments: disabled
09:04:36,943 INFO [SettingsFactory] Order SQL updates by primary key: disabled
09:04:36,943 INFO [SettingsFactory] Query translator: org.hibernate.hql.ast.ASTQueryTranslatorFactory
09:04:36,943 INFO [ASTQueryTranslatorFactory] Using ASTQueryTranslatorFactory
09:04:36,943 INFO [SettingsFactory] Query language substitutions: {}
09:04:36,943 INFO [SettingsFactory] Second-level cache: enabled
09:04:36,943 INFO [SettingsFactory] Query cache: disabled
09:04:36,943 INFO [SettingsFactory] Cache provider: org.hibernate.cache.HashtableCacheProvider
09:04:36,943 INFO [SettingsFactory] Optimize cache for minimal puts: disabled
09:04:36,943 INFO [SettingsFactory] Structured second-level cache entries: disabled
09:04:36,943 INFO [SettingsFactory] Statistics: disabled
09:04:36,943 INFO [SettingsFactory] Deleted entity synthetic identifier rollback: disabled
09:04:36,943 INFO [SettingsFactory] Default entity-mode: pojo
09:04:36,943 INFO [SessionFactoryImpl] building session factory
09:04:36,943 INFO [SessionFactoryObjectFactory] Not binding factory to JNDI, no JNDI name configured
09:04:36,943 INFO [SchemaExport] Running hbm2ddl schema export
09:04:36,943 INFO [SchemaExport] exporting generated schema to database
09:04:36,958 INFO [SchemaExport] schema export complete
09:04:36,958 INFO [NamingHelper] JNDI InitialContext properties:{java.naming.factory.initial=org.jnp.interfaces.NamingContextFactory, java.naming.factory.url.pkgs=org.jboss.naming:org.jnp.interfaces}
09:04:36,974 INFO [JmxKernelAbstraction] installing MBean: jboss.j2ee:service=EJB3,ear=test.ear,jar=test.jar,name=FooAction with dependencies:
09:04:37,224 INFO [EJB3Deployer] Deployed: file:/C:/Program Files/jboss-4.0.4RC1/server/default/tmp/deploy/tmp25621test.ear-contents/test.jar
09:04:37,224 INFO [TomcatDeployer] deploy, ctxPath=/test, warUrl=.../tmp/deploy/tmp25621test.ear-contents/test-exp.war/
09:04:37,536 INFO [ServletContextListener] Welcome to Seam 1.0 beta 2
09:04:37,552 INFO [Initialization] reading properties from: /seam.properties
09:04:37,568 INFO [Initialization] initializing Seam
09:04:37,646 INFO [Component] Component: org.jboss.seam.core.init, scope: APPLICATION, type: JAVA_BEAN, class: org.jboss.seam.core.Init
09:04:37,693 INFO [Component] Component: org.jboss.seam.core.pages, scope: APPLICATION, type: JAVA_BEAN, class: org.jboss.seam.core.Pages
09:04:37,724 INFO [Component] Component: org.jboss.seam.core.manager, scope: EVENT, type: JAVA_BEAN, class: org.jboss.seam.core.Manager
09:04:37,771 INFO [Component] Component: switcher, scope: PAGE, type: JAVA_BEAN, class: org.jboss.seam.core.Switcher
09:04:37,818 INFO [Component] Component: conversation, scope: CONVERSATION, type: JAVA_BEAN, class: org.jboss.seam.core.Conversation
09:04:37,865 INFO [Component] Component: conversationList, scope: PAGE, type: JAVA_BEAN, class: org.jboss.seam.core.ConversationList
09:04:37,896 INFO [Component] Component: conversationStack, scope: PAGE, type: JAVA_BEAN, class: org.jboss.seam.core.ConversationStack
09:04:37,911 INFO [Component] Component: facesContext, scope: APPLICATION, type: JAVA_BEAN, class: org.jboss.seam.core.FacesContext
09:04:37,927 INFO [Component] Component: eventContext, scope: APPLICATION, type: JAVA_BEAN, class: org.jboss.seam.core.EventContext
09:04:37,943 INFO [Component] Component: sessionContext, scope: APPLICATION, type: JAVA_BEAN, class: org.jboss.seam.core.SessionContext
09:04:37,958 INFO [Component] Component: statelessContext, scope: APPLICATION, type: JAVA_BEAN, class: org.jboss.seam.core.StatelessContext
09:04:37,974 INFO [Component] Component: applicationContext, scope: APPLICATION, type: JAVA_BEAN, class: org.jboss.seam.core.ApplicationContext
09:04:37,990 INFO [Component] Component: conversationContext, scope: APPLICATION, type: JAVA_BEAN, class: org.jboss.seam.core.ConversationContext
09:04:38,005 INFO [Component] Component: businessProcessContext, scope: APPLICATION, type: JAVA_BEAN, class: org.jboss.seam.core.BusinessProcessContext
09:04:38,036 INFO [Component] Component: resourceBundle, scope: APPLICATION, type: JAVA_BEAN, class: org.jboss.seam.core.ResourceBundle
09:04:38,052 INFO [Component] Component: org.jboss.seam.debug.introspector, scope: EVENT, type: JAVA_BEAN, class: org.jboss.seam.debug.Introspector
09:04:38,146 INFO [ResourceBundle] resource bundle missing: messages
09:04:38,161 INFO [Component] Component: org.jboss.seam.debug.contexts, scope: APPLICATION, type: JAVA_BEAN, class: org.jboss.seam.debug.Contexts
09:04:38,193 INFO [Scanner] scanning: /C:/Program Files/jboss-4.0.4RC1/server/default/tmp/deploy/tmp25621test.ear-contents/test.jar
09:04:38,240 INFO [Component] Component: fooaction, scope: SESSION, type: STATELESS_SESSION_BEAN, class: uk.foo.FooAction, JNDI: test/FooAction/local
09:04:38,271 INFO [Component] Component: test, scope: SESSION, type: JAVA_BEAN, class: uk.foo.TestBean
09:04:38,286 INFO [Initialization] done initializing Seam
09:04:38,286 INFO [FacesConfigurator] Reading standard config org/apache/myfaces/resource/standard-faces-config.xml
09:04:38,599 INFO [FacesConfigurator] Reading config jar:file:/C:/Program Files/jboss-4.0.4RC1/server/default/tmp/deploy/tmp25569tomahawk.jar!/META-INF/faces-config.xml
09:04:38,708 ERROR [LocaleUtils] Locale name null or empty, ignoring
09:04:39,083 INFO [StartupServletContextListener] ServletContext 'C:\Program Files\jboss-4.0.4RC1\server\default\.\tmp\deploy\tmp25621test.ear-contents\test-exp.war\' initialized.
09:04:39,193 INFO [EARDeployer] Started J2EE application: file:/C:/Program Files/jboss-4.0.4RC1/server/default/deploy/test.ear