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.
| Online: | 1 Member of 12451 |
Ideas for the JSR-299 portable extensions package.
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.
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.
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").
Marking an injection point as accepting a null value when there is no matching bean.
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.
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;
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.
Allow a package-level annotation to specify the qualifier for names of beans in the package.
@NameQualifier("org.jboss") package org.jboss;
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.
A custom scope for the JTA transaction.
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;
}
Support specification of a scope with persistence context declarations:
@Produces @ConversationScoped @PersistenceContext(type=EXTENDED) EntityManager em;
@Produces @TransactionScoped @PersistenceContext EntityManager em;
Support injection of SLF4J Logger objects:
@Inject Logger log;
Support injection of values from a properties file:
@Inject @Resource("/path/file") Properties properties;
Support direct injection of the following objects:
Map the events defined by the servlet specification to the 299 event bus:
The ability to map event types to distribution via a JMS topic:
void distributedDeleteCustomer(@Observes CustomerEvent, @Events Topic topic, ConnectionFactory cf);
An enhanced conversation scope with support for natural ids.
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.
Implement the typesafe XML-based configuration format that was defined in earlier revisions of the specification.
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.
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?
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...
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?
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...
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?