/** * bind proxy for the resource * @param resource config object of the resource * @param jndiName jndi name with which the resource need to be deployed * @throws NamingException */ private void bindResource(org.glassfish.resourcebase.resources.api.ResourceInfo resourceInfo, Resource resource) throws NamingException { org.glassfish.resourcebase.resources.api.ResourceProxy proxy = resourceProxyProvider.get(); proxy.setResource(resource); proxy.setResourceInfo(resourceInfo); resourceNamingService.publishObject(resourceInfo, proxy, true); } }
public Object create(Context ic) throws NamingException { //this is a per-lookup object and once we have the resource, //we remove the proxy and bind the resource (ref) with same jndi-name //hence block synchronization is fine as it blocks only callers //of this particular resource and also only for first time (initialization) synchronized(this){ try{ if(result == null){ getResourceDeployer(resource).deployResource(resource, resourceInfo.getApplicationName(), resourceInfo.getModuleName()); } result = namingService.lookup(resourceInfo, resourceInfo.getName(), ic.getEnvironment()); }catch(Exception e){ throwResourceNotFoundException(e, resourceInfo); } } return result; }