public static boolean isModuleScopedResource(GenericResourceInfo resourceInfo){ return resourceInfo != null && resourceInfo.getApplicationName() != null && resourceInfo.getModuleName() != null && resourceInfo.getName() != null && resourceInfo.getName().startsWith(ResourceConstants.JAVA_MODULE_SCOPE_PREFIX); } }
public static boolean isApplicationScopedResource(GenericResourceInfo resourceInfo){ return resourceInfo != null && resourceInfo.getApplicationName() != null && resourceInfo.getName() != null && resourceInfo.getName().startsWith(ResourceConstants.JAVA_APP_SCOPE_PREFIX); }
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; }
public void deployResources(String applicationName, String moduleName, Collection<com.sun.enterprise.config.serverbeans.Resource> resources, boolean postDeployPhase) throws Exception { for(Resource resource : resources){ if(resource instanceof BindableResource) { BindableResource bindableResource = (BindableResource)resource; ResourceInfo resourceInfo = new ResourceInfo(bindableResource.getJndiName(), applicationName, moduleName); if(getResourceDeployer(bindableResource).canDeploy(postDeployPhase, resources, bindableResource)){ resourcesBinder.deployResource(resourceInfo, bindableResource); } } else{ if(getResourceDeployer(resource).canDeploy(postDeployPhase, resources, resource)){ getResourceDeployer(resource).deployResource(resource, applicationName, moduleName); } } } }
@Override public void undeployResource(Object resource) throws Exception { ManagedExecutorService managedExecutorServiceResource = (ManagedExecutorService) resource; ResourceInfo resourceInfo = ResourceUtil.getResourceInfo(managedExecutorServiceResource); undeployResource(resource, resourceInfo.getApplicationName(), resourceInfo.getModuleName()); }
private void redeployResource(Resource resource) throws Exception { ResourceDeployer resourceDeployer = getResourceDeployer(resource); if (resourceDeployer != null) { ResourceDeployerValidator validator = getResourceDeployerValidator(resourceDeployer); if (validator != null) { if (validator.isEnabledLocally(resource)) { // Resource is currently enabled in the config, // call the redeploy op; the ResourceDeployer should // be able to handle this scenario resourceDeployer.redeployResource(resource); } else if (validator.isDeployedLocally(resource)) { // Resource is disabled in new config, and resource // is currently active, so undeploy resourceDeployer.undeployResource(resource); } } else { // No validator, just call deployer resourceDeployer.redeployResource(resource); } } }
/** * {@inheritDoc} */ public void undeployResource(Object resource, String applicationName, String moduleName) throws Exception { ExternalJndiResource jndiRes = (ExternalJndiResource) resource; ResourceInfo resourceInfo = new ResourceInfo(jndiRes.getJndiName(), applicationName, moduleName); deleteResource(jndiRes, resourceInfo); }
private ResourceStatus isValid(Resources resources, boolean validateResourceRef, String target){ ResourceStatus status ; if (jndiName == null) { String msg = localStrings.getLocalString("context.service.noJndiName", "No JNDI name defined for context service."); return new ResourceStatus(ResourceStatus.FAILURE, msg); } status = resourcesHelper.validateBindableResourceForDuplicates(resources, jndiName, validateResourceRef, target, ContextService.class); return status; }
boolean pingConnectionPool(String tmpJMSResource) throws ResourceException { PoolInfo poolInfo = new PoolInfo(tmpJMSResource); return connectorRuntime.pingConnectionPool(poolInfo); }
private void deleteResource(CustomResource customResource, ResourceInfo resourceInfo) throws NamingException { // converts the config data to j2ee resource //JavaEEResource j2eeResource = toCustomJavaEEResource(customRes, resourceInfo); // removes the resource from jndi naming cns.unpublishObject(resourceInfo, resourceInfo.getName()); }
/** * 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); } }
/** * deploy proxy for the resource * @param resourceInfo jndi name with which the resource need to be deployed * @param resource config object of the resource */ public void deployResource(org.glassfish.resourcebase.resources.api.ResourceInfo resourceInfo, Resource resource){ try{ bindResource(resourceInfo, resource); }catch(NamingException ne){ Object[] params = {resourceInfo, ne}; logger.log(Level.SEVERE,ResourceLoggingConstansts.BIND_RESOURCE_FAILED, params); } }
private boolean isServerResourceEnabled(Resource res, ResourceDeployer deployer) { if (res instanceof ServerResource && deployer != null) { ResourceDeployerValidator deployerValidator = getResourceDeployerValidator(deployer); if (deployerValidator != null && deployerValidator.isEnabledLocally(res)) return true; } return false; }
private boolean isServerResourceDeployed(Resource resource) { ResourceDeployer deployer = getResourceDeployer(resource); if (resource instanceof ServerResource && deployer != null) { ResourceDeployerValidator deployerValidator = getResourceDeployerValidator(deployer); if (deployerValidator != null && deployerValidator.isDeployedLocally(resource)) return true; } return false; }
@Override public void deployResource(Object resource) throws Exception { ManagedScheduledExecutorService ManagedScheduledExecutorServiceResource = (ManagedScheduledExecutorService) resource; ResourceInfo resourceInfo = ResourceUtil.getResourceInfo(ManagedScheduledExecutorServiceResource); deployResource(resource, resourceInfo.getApplicationName(), resourceInfo.getModuleName()); }
/** * {@inheritDoc} */ public synchronized void deployResource(Object resource, String applicationName, String moduleName) throws Exception { CustomResource customResource = (CustomResource) resource; ResourceInfo resourceInfo = new ResourceInfo(customResource.getJndiName(), applicationName, moduleName); deployResource(resource, resourceInfo); }
public void publishObject(ResourceInfo resourceInfo, Object object,boolean rebind) throws NamingException{ String jndiName = resourceInfo.getName(); publishObject(resourceInfo, jndiName, object, rebind); }
@Override public void undeployResource(Object resource) throws Exception { ManagedScheduledExecutorService ManagedScheduledExecutorServiceResource = (ManagedScheduledExecutorService) resource; ResourceInfo resourceInfo = ResourceUtil.getResourceInfo(ManagedScheduledExecutorServiceResource); undeployResource(resource, resourceInfo.getApplicationName(), resourceInfo.getModuleName()); }
/** * {@inheritDoc} */ public void undeployResource(Object resource, String applicationName, String moduleName) throws Exception { CustomResource customResource = (CustomResource) resource; ResourceInfo resourceInfo = new ResourceInfo(customResource.getJndiName(), applicationName, moduleName); deleteResource(customResource, resourceInfo); }
@Override public void deployResource(Object resource) throws Exception { ContextService contextServiceResource = (ContextService) resource; ResourceInfo resourceInfo = ResourceUtil.getResourceInfo(contextServiceResource); deployResource(resource, resourceInfo.getApplicationName(), resourceInfo.getModuleName()); }