users@connector-spec.java.net

[connector-spec-users] [jsr322-experts] ClassName in CF resource definition annotation (WAS: Re: Connector CF Resource Definition annotation - a proposal and request for comments.)

From: Sivakumar Thyagarajan <sivakumar.thyagarajan_at_oracle.com>
Date: Thu, 20 Dec 2012 23:17:41 +0530

Hi Jesper

On Monday 17 December 2012 09:38 PM, Jesper Pedersen wrote:
> Hi,
>
> On 12/17/2012 09:56 AM, Sivakumar Thyagarajan wrote:
...
>>> Class name:
>>>
>>> I would use the class name of the ManagedConnectionFactory as the class
>>> name of the Connection Factory can lead to situations where it isn't
>>> clear
>>> which MCF should be used, like
>>>
>>> SuperInterface
>>> |
>>> |-- SubInterface1 --> MCF1
>>> |
>>> |-- SubInterface2 --> MCF2
>>>
>>> where 'SuperInterface' is used in the definition. JMS has hierarchies
>>> like
>>> this.
>>
>> As per the connectionfactory-interface-uniqueness in the schema (CODE
>> EXAMPLE 20-1 of the Connectors 1.6 spec), there must be only
>> connection-definition with a connectionfactory-interface. An MCF can be
>> shared by multiple connection definitions.
>>
>> So, in the case described above, the JMS RA would define 3
>> connection-definitions, namely: cd1(with say MCF0) for SuperInterface,
>> cd2(with MCF1) for SubInterface1 and cd3 for SubInterface2(with MCF2).
>> The connector container then given the connection-factory-interface
>> alone should be able to figure out the right connection-definition, right?
>>
>
> It would be 2 MCFs with their unique CF (SubInterface1 and SubInterface2)
> -- SuperInterface would be an implementation detail. But the user would
> use SuperInterface in their code.

When a user uses SuperInterface, then I assume they inject the connection
factory through a @Resource or a lookup. For example

FooServlet {
...
@Resource(name="...", mappedName="...")
SuperInterface cf;
...
}.

In this case, it is the name and mappedName that is used by the container
to choose the right CF in JNDI that had been created earlier through
resource definition annotations.

The resource definition annotations, OTOH, would have to specify the
actual CF interface name because that is the unique part of the
connection-definition. (Two connection-definitions with different CF
interface names can share the same MCF class. In the example below, the
MyEISRA could have had one MCF class MCF1 for both subinterface1 and
subinterface2). So, to define CFs for subinterface1 and subinterface2, the
annotations would look as follows:

#1.
@ConnectorConnectionFactoryDefinition(name="java:comp/eis/cf-subinterface1",
className="subinterface1",
resourceAdapterName="MyEISRA")

and

#2.
@ConnectorConnectionFactoryDefinition(name="java:comp/eis/cf-subinterface2",
className="subinterface2",
resourceAdapterName="MyEISRA")

In the above example, if the user wants to inject a CF of subinterface1
but still refer to it as a superinterface, they would have the following
resource declaration:

#3.
@Resource(name="...", mappedName="java:comp/eis/cf-subinterface2")
SuperInterface cf;

and to inject CF of subinterface2 and use it as subinterface2, they would
have:

#4.
@Resource(name="...", mappedName="java:comp/eis/cf-subinterface1")
SubInterface2 cf;

This would all work. However, during the resource definition at #1 and #2
above, we would still need the user to specify the appropriate
subinterface during resource definition.

> I know it has been like this since the beginning of the spec. However,
> spec is one thing, and vendors does something else ;)
> ...
[rest covered in other threads]

Thanks
--Siva.