jsr345-experts@ejb-spec.java.net

[jsr345-experts] Re: MDB improvements?

From: Jean-Louis MONTEIRO <jeanouii_at_gmail.com>
Date: Thu, 30 Aug 2012 09:37:46 +0200

Interested? definitely!
Already discuss that point the first time David publish a blog entry.

JCA has always been over complex and restricted in my mind.
Nowadays most users think it's dedicated to JMS.

Anyway, +1 for the feature.

Jean-Louis


2012/8/29 David Blevins <david.blevins_at_gmail.com>

> Following up on some of these.
>
> On Jul 27, 2012, at 2:09 PM, Marina Vatkina wrote:
> >
> > 3. Use the "beanClass" instead of the "ejbClass" for the property name?
>
> We can definitely do that.
>
>
> > 2. Can we skip the marker interface altogether? If there is no
> implementing interface, it's a no-interface view. Plain and simple.
>
> The only reason to keep it is because of the intricate roll it plays in
> deployment and linking MDBs to Connectors.
>
> An simple alternative thought would be instead of requiring Connectors to
> supply a 'public interface Foo' as the message listener interface that is
> implemented by the MDB, allow the Connector to supply a 'public @interface
> Foo' as the message listener interface and have the MDB use that on the
> bean class.
>
> From there on out everything would be identical.
>
> So using the telnet example from this page:
>
>
> We'd leave our ra.xml the same:
>
> <connector version="1.5">
> <description>Telnet ResourceAdapter</description>
> <display-name>Telnet ResourceAdapter</display-name>
> <vendor-name>SuperConnectors</vendor-name>
> <eis-type>Telnet Adapter</eis-type>
> <resourceadapter-version>1.0</resourceadapter-version>
> <resourceadapter id="TelnetResourceAdapter">
>
> <resourceadapter-class>com.superconnectors.telnet.adapter.TelnetResourceAdapter</resourceadapter-class>
> <inbound-resourceadapter>
> <messageadapter>
> <messagelistener>
>
> <messagelistener-type>com.superconnectors.telnet.api.TelnetListener</messagelistener-type>
> <activationspec>
>
> <activationspec-class>com.superconnectors.telnet.adapter.TelnetActivationSpec</activationspec-class>
> </activationspec>
> </messagelistener>
> </messageadapter>
> </inbound-resourceadapter>
> </resourceadapter>
> </connector>
>
> Then our <messagelistener-type>, TelnetListener, is turned into an
> annotation
>
> package com.superconnectors.telnet.api;
>
> import java.lang.annotation.Target;
> import java.lang.annotation.Retention;
> import java.lang.annotation.ElementType;
> import java.lang.annotation.RetentionPolicy;
>
> @Target({ElementType.TYPE})
> @Retention(RetentionPolicy.RUNTIME)
> public @interface TelnetListener {
> }
>
> Then we just use the annotation instead:
>
> package org.developer.application;
>
> import com.superconnectors.telnet.api.Command;
> import com.superconnectors.telnet.api.Option;
> import com.superconnectors.telnet.api.TelnetListener;
>
> import javax.ejb.MessageDriven;
>
> @MessageDriven
> @TelnetListener
> public class MyMdb {
>
> private final Properties properties = new Properties();
>
> @Command("get")
> public String doGet(@Option("key") String key) {
> return properties.getProperty(key);
> }
>
> @Command("set")
> public String doSet(@Option("key") String key, @Option("value")
> String value) {
>
> final Object old = properties.setProperty(key, value);
> final StringBuilder sb = new StringBuilder();
> sb.append("set ").append(key).append(" to ").append(value);
> sb.append("\n");
> if (old != null) {
> sb.append("old value: ").append(old);
> sb.append("\n");
> }
> return sb.toString();
> }
>
>
> -David
>
>