Wednesday Dec 02, 2009

Java EE Connector Architecture 1.6 Reference Implementation

GlassFish : Connector 1.6 Reference Implementation

Java EE Connector Architecture 1.6 Reference Implementation :

Connector 1.6 Specification is approved now ! Also refer the announcement by Siva. GlassFish v3 is the reference implementation of this version of the specification.
Developers can write resource-adapters leveraging the new features introduced in this specification and deploy the resource-adapters in
GlassFish v3. GlassFish v3 builds are available now !

Major features of Connector 1.6 specification available in GlassFish v3 :

  • Ease of Use : Annotation

    • It is now possible to develop a resource-adapter using various annotations defined in Connector 1.6, without deployement descriptor (ra.xml)
      • Refer the blog made available during GlassFish v3 Preview SDK release
  • Generic and Standard Work Context Mechanism

    • Generic work context contract enables a resource adapter to control the contexts in which the work instances submitted by it are executed by the application server's WorkManager.
      • Connector 1.6 mandates the following Work Context mechanisms to be supported by all application servers
        • Transaction Context (Similar to existing ExecutionContext)
        • Security Context 
        • Hints Context
  • Bean Validation support for resource-adapters

    • With Bean Validation mechanisms made available in Java EE 6 specification, Connector 1.6 allows resource-adapters to use Bean Validation mechanisms to validate various resource-adapter artifacts ie., ResourceAdapter, AdministeredObject, ManagedConnectionFactory, ActivationSpec JavaBeans.

Miscellaneous :

  • ClassLoading Requirements

    • Connector 1.6 specification recommends that the availability of resource-adapters to applications should be based on the reference of resource-adapter in the application's deployment-descriptor (or its equivalent annotations). These references can be via resource-ref (connector-resource), resource-env-ref (administered-object), resource-adapter-mid (for inbound). By default, GlassFish v3 supports the above recommendation.
  • Runtime Transaction Support

    • With the introduction of javax.resource.spi.TransactionSupport, a ManagedConnectionFactory artifact can dynamically request a transaction support level (XA/Local/NoTransaction) at runtime to override the value specified via deployment-descriptor (or its equivalent annotation)

In the coming weeks, you can look forward for more articles, tutorials, blogs on these features.

References :

Sunday May 31, 2009

Resource Adapter Annotations

Connector Annotations

Annotating a Resource Adapter

Java EE Connector Architecture 1.6 Specification introduces new features that include meta-data annotations.
These annotations are used to define various resource-adapter artificats and hence it is possible to have a resource-adapter
without deployment descriptor (ra.xml).


@Connector :

Specify that the JavaBean is a resource adapter JavaBean. Used to provide metadata about the capabilities provided by the resource adapter. It is optional to provide a JavaBean implementing the ResourceAdapter interface.

@ConnectionDefinition(s) :

Annotations to represent a connection definition with managed-connection-factory, connection-factory artifact details.

@AdministeredObject :

Designates a JavaBean as an administered object.

@Activation :

Designates a JavaBean as an ActivationSpec JavaBean. Also provides Message Listener details.

@ConfigProperty :

Specifies to the application server, that the decorated property is a configuration property for that JavaBean. Configuration Properties are now auto-discoverable by the application server and hence need not be specified using the deployment descriptor.

Connector annotations support in GlassFish :

GlassFish V3 will be the reference implementation for Java EE 6 Specification (and hence Java EE Connector Architecture 6 Specification)
GlassFish V3 Preview release has support for connector annotations, so one can deploy an annotated resource-adapter.

Java EE 6 Preview SDK will have samples bundle demonstrating various new features introduced.
Mail Connector RA sample will demonstrate a resource-adapter without deployment descriptor.
This sample was bundled in J2EE SDK 1.4 and is now bundled in Java EE 6 Preview SDK with annotations instead of deployment descriptor.

Java EE 6 Preview SDK is available here, soon.

Connectors sample will be available in "SAMPLES_DIR/javaee6/connectors/apps/mailconnector"
Read the documentation of connectors sample ("SAMPLES_DIR/javaee6/connectors/apps/mailconnector/docs") for more details.

Deployment descriptor elements and equivalent annotations:

<connector xmlns="" xmlns:xsi="" xsi:schemaLocation="" version="1.5">
   <description>Sample adapter using the JavaMail API</description>
    <vendor-name>Sun Microsystems, Inc.</vendor-name>

        description = "Sample adapter using the JavaMail API",
        displayName = "InboundResourceAdapter",
        vendorName = "Sun Microsystems, Inc.",
        eisType = "MAIL",
        version = "1.0",
        authMechanisms = {
                    authMechanism = "BasicPassword",
                    credentialInterface = AuthenticationMechanism.CredentialInterface.PasswordCredential

        // Since the following attribute values denote the default values of the annotation,
        // they need not be specified explicitly

        transactionSupport = TransactionSupport.TransactionSupportLevel.NoTransaction,
        reauthenticationSupport = false

public class ResourceAdapterImpl
    implements ResourceAdapter,
        connectionFactory = samples.connectors.mailconnector.api.JavaMailConnectionFactory.class,
        connectionFactoryImpl = samples.connectors.mailconnector.ra.outbound.JavaMailConnectionFactoryImpl.class,
        connection = samples.connectors.mailconnector.api.JavaMailConnection.class,
        connectionImpl = samples.connectors.mailconnector.ra.outbound.JavaMailConnectionImpl.class
public class ManagedConnectionFactoryImpl implements
    ManagedConnectionFactory, Serializable
            type = String.class,
            defaultValue = "UnknownHostName"
    public void setServerName(String serverName)
        String oldName = this.serverName;
        this.serverName = serverName;
        changes.firePropertyChange("serverName", oldName, serverName);

                            <description>Normally imap or pop3</description>
        messageListeners = {samples.connectors.mailconnector.api.JavaMailMessageListener.class}

public class ActivationSpecImpl implements javax.resource.spi.ActivationSpec,
    // serverName property value
    private String serverName = new String("");

    // userName property value
    private String userName = new String("");

    // password property value
    private String password = new String("");

    // folderName property value
    private String folderName = new String("Inbox");

    // protocol property value
    // Normally imap or pop3
            description = "Normally imap or pop3"
    private String protocol = new String("imap");






« February 2015