Resource references and the Blueprint Container

Blueprint components can access WebSphere® Application Server resource references by using resource reference declarations.

You declare each resource reference in a Blueprint XML file. Each bundle in an OSGi application can contain any number of resource reference declarations in its various Blueprint XML files. You can secure each resource reference by using a Java™ Platform, Enterprise Edition (Java EE) Connector Architecture (JCA) authentication alias.

Blueprint resource reference bindings are configured when you add the enterprise bundle archive (EBA) asset to a business-level application.

To use resource references, you use the following Blueprint namespace, which contains the resource-reference, res-auth, and res-sharing-scope elements:

https://www.ibm.com/appserver/schemas/8.0/blueprint/resourcereference

The following example defines a Blueprint component with a component ID of resourceRef. The component is like a service reference. This component will be bound to a Java Naming and Directory Interface (JNDI) resource that has the JNDI name jdbc/Account and type javax.resource.cci.ConnectionFactory.

<blueprint xmlns="https://www.osgi.org/xmlns/blueprint/v1.0.0" xmlns:rr=
   "https://www.ibm.com/appserver/schemas/8.0/blueprint/resourcereference">
   <rr:resource-reference id="resourceRef" 
      interface="javax.resource.cci.ConnectionFactory"
      filter="(osgi.jndi.service.name=jdbc/Account)">
      <rr:res-auth>Application</rr:res-auth>
      <rr:res-sharing-scope>Shareable</rr:res-sharing-scope>
   </rr:resource-reference>
</blueprint>

To declare a resource reference, you must specify both the interface and filter attributes. The filter must contain a JNDI resource in the form osgi.jndi.service.name=name, where name is the JNDI name of the resource.

Use the res-auth element to set whether authorization is application-managed or container-managed. The res-auth element takes the following values:
Application
Authorization is application-managed.
Container
Authorization is container-managed. This is the default value.
Use the res-sharing-scope element to set whether a resource reference can be shared. The res-sharing-scope element takes the following values:
Shareable
A resource reference can be shared
Unshareable
A resource reference cannot be shared. This is the default value.

You can also use a resource reference to configure a data source for a persistence bundle by using a blueprint:comp/resource_ref_id JNDI name. For more information, see JPA and OSGi Applications.

When you secure resource references, those resource references can be bound only to JCA authentication aliases that exist on every server or cluster that the OSGi application is deployed to. An OSGi application can be deployed to multiple servers and clusters that are in the same security domain. Therefore, each JCA authentication alias must exist in either the security domain of the target servers and clusters, or the global security domain.