In JavaEE a datasource generally means a pool. So if you have two persistence units using the same physical datasource it can be very interesting to be able to use the same pool (easier to configure the pool size for instance).
Was not as easy as it in TomEE and OpenEJB. That’s why we added an attribute to our resources: aliases.
Now you are able to say that a resource has some aliases in both XML and properties configuration formats.
Here some little samples:
- in xml
<Resource id="datasource1" aliases="datasource2,datasource3" type="DataSource"> <!-- config as usual --> </Resource>
- and in properties
datasource1 = new://Resource?type=DataSource&aliases=datasource2,datasource3
This attribute is considered as the id one so it can be use in persistence.xml for [non-]jta-datasource, to lookup the datasource…