Help

Built with Seam

You can find the full source code for this website in the Seam package in the directory /examples/wiki. It is licensed under the LGPL.

Ideas for the JSR-299 portable extensions package.

Bean declaration at constructor level

Allow the bean-level annotations to be specified by the constructor, and allow this for multiple constructors:

class Settings {

   @Constructs @ApplicationScoped @Default Settings() { ... }

   @Constructs @Custom Settings(@Default Settings defaults) { ... }

}

This feature is scheduled for inclusion in the JSR-299 maintenance release.

Abstract producer methods

Remap qualifiers, EL name and/or scope (or just alias them) using an interface method declaration:

@Produces @Named("foo") @Foo Baz foo(@Bar Baz bar);

This feature is scheduled for inclusion in the JSR-299 maintenance release.

Generic beans

Allow a portable extension to define a set of generic beans for a specific config annotation like @MessageBus. These beans can inject the configuration, and can inject each other.

@Generic(MessageBus.class)
@ApplicationScoped
class Topic {
	@Inject MessageBus config;
}
@Generic(MessageBus.class)
@RequestScoped
class Session {
	@Inject Topic topic;
	@Inject MessageBus config;
}

You can then add the config annotation to a producer field, together with whatever qualifier annotations you need:

@Produces
@MessageBus(topic="default") 
Topic topic;

@Produces @Prices 
@MessageBus(topic="prices") 
Topic prices;

@Produces @Deals 
@MessageBus(topic="deals") 
Topic deals;

And now, finally, we can inject the configured objects:

@Inject Topic topic;
@Inject Session session;

@Inject @Prices Topic topic;
@Inject @Prices Session session;

@Inject @Deals Topic topic;
@Inject @Deals Session session;

The trick here is that the @Prices Session gets the @Prices Topic injected, along with @MessageBus(topic="prices") , and the @Deals Session gets the @Deals Topic injected, along with @MessageBus(topic="deals").

@Optional annotation

Marking an injection point as accepting a null value when there is no matching bean.

@Transient annotation

The transient modifier is used to mark a field as accepting a non-passivation-capable dependency. The @Transient annotation would do the same for a method parameter.

@Exact qualifier

Each bean has an implicit qualifier @Exact(BeanClass.class), allowing the injection point to specify the exact implementation required.

@Inject @Exact FooBean foo;
@Inject @Exact(FooBean.class) Foo foo;

@Introduces annotation

Support the introduction of new bean types to an existing bean. This bean would have bean types Foo and Bar:

class Foo {

   @Introduces Bar getBar() { return ...; }

}

or

class Foo {

   @Introduces Bar bar = new Bar();

}

The class must be proxyable, so that invocations of the introduced interface can be delegated to the object that implements the introduced interface.

Compound name defaulting

Allow a package-level annotation to specify the qualifier for names of beans in the package.

@NameQualifier("org.jboss") package org.jboss;

Guice-style configuration API

An API for registering beans programmatically.

class MyModule extends Module {

   @Override void configure() {
      addManagedBean(FooBean.class)
         .withQualfiers(Bar.class)
         .withBeanTypes(Foo.class, Bar.class)
         .withName("foo");
   }

}

Where each Module is a 299 Extension.

@TransactionScoped custom scope

A custom scope for the JTA transaction.

JMS API injection

  • For a queue, the Queue, QueueConnection, QueueSession, QueueReceiver and/or QueueSender may be injected.
  • For a topic, the Topic, TopicConnection, TopicSession, TopicSubscriber and/or TopicPublisher may be injected.
class Jms {

   @Resource(name="java:global/env/jms/PaymentQueue") 
   @ConnectionFactory(@Resource(name="java:global/env/jms/ConnectionFactory")) 
   @Produces @PaymentProcessor Queue paymentQueue; 

}
@ConnectionFactory(@Resource(name="java:global/env/jms/ConnectionFactory")) 
class Jms { 

   @Resource(name="java:global/env/jms/Prices") 
   @Produces @Prices Topic pricesTopic; 
   @Resource(name="java:global/env/jms/PaymentQueue") 
   @Produces @PaymentProcessor Queue paymentQueue; 

}

Conversation/transaction-scoped extended persistence context support

Support specification of a scope with persistence context declarations:

@Produces @ConversationScoped 
@PersistenceContext(type=EXTENDED) EntityManager em;
@Produces @TransactionScoped 
@PersistenceContext EntityManager em;

Logger injection

Support injection of SLF4J Logger objects:

@Inject Logger log;

Properties object injection

Support injection of values from a properties file:

@Inject @Resource("/path/file") Properties properties;

Injection of web context objects

Support direct injection of the following objects:

  • ServletContext
  • HttpServletRequest
  • HttpSession
  • FacesContext

Events relating to servlet contexts

Map the events defined by the servlet specification to the 299 event bus:

  • @Initialized ServletContextEvent
  • @Destroyed HttpSessionEvent
  • Etc.

JMS event mappings

The ability to map event types to distribution via a JMS topic:

void distributedDeleteCustomer(@Observes CustomerEvent, @Events Topic topic, ConnectionFactory cf);

Conversations with natural ids

An enhanced conversation scope with support for natural ids.

Enhanced annotation constraints

A set of annotations for constraining the application of stereotypes, qualifier types, etc, beyond what is possible using @Target. For example, the ability to constrain the scope and/or bean types of beans with a certain stereotype.

XML-based configuration

Implement the typesafe XML-based configuration format that was defined in earlier revisions of the specification.

Integration with Spring, Guice, Seam2

To allow interoperation with the legacy proprietary DI solutions. Note that if/when 330 provides a configuration API, we will probably be able to implement a general-purpose integration layer with extremely minimal dependencies to 299 or proprietary code.

5 comments:
 
06. Oct 2009, 08:33 America/New_York | Link

Nested conversations? Or are they considered bad practice?

 

If a man speaks in the forest and there is no woman around to hear him, is he still wrong?

 
06. Oct 2009, 17:36 America/New_York | Link

Not sure. There is always going to be some uncertainty about what belongs in this package and what belongs in Seam. Also, some of the features I've listed here may really belong in their own packages (e.g. the XML configuration stuff).

 

Learn more about Weld...

 
20. Nov 2009, 09:49 America/New_York | Link

Looks promising! Apparently @Exact is not the same as @Typed?

 

If a man speaks in the forest and there is no woman around to hear him, is he still wrong?

 
20. Nov 2009, 18:41 America/New_York | Link

No, @Exact is a qualifier that you use at injection points, it's not a way to restrict the bean types at the level of the bean. However, they can be used to resolve some of the same ambiguities.

 

Learn more about Weld...

 
31. Dec 2009, 20:08 America/New_York | Link

Definitely looking forward to more injectables, especially the servlet contexts. I think it would make sense to add HttpServletResponse to the list to round things out.

When can we look forward to this or JSR 299 MR1?