private void deployServerResource(Resource resource) { ResourceDeployer deployer = getResourceDeployer(resource); if (deployer == null) { logger.log( Level.WARNING, ResourceLoggingConstansts.UNABLE_TO_FIND_RESOURCEDEPLOYER, new Object[] { resource.getIdentity() } ); return; } try { if (isServerResourceEnabled(resource, deployer)) { deployer.deployResource(resource); // deploy the resource; should be a no-op on the deployer if already deployed } else if (isServerResourceDeployed(resource)) { deployer.undeployResource(resource); // resource is not enabled in the config, undeploy it if the resource is already deployed } } catch (Exception e) { Object[] params = { ResourceUtil.getGenericResourceInfo(resource), e }; logger.log( Level.WARNING, ResourceLoggingConstansts.UNABLE_TO_DEPLOY, params); } }
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); } } } }
deployer.disableResource(resource); } else { deployer.enableResource(resource); deployer.enableResource(resource); } else { deployer.disableResource(resource); BindableResource bindableResource = (BindableResource) instance; if (getEnabledResourceRefforResource(bindableResource) && Boolean.valueOf(bindableResource.getEnabled())) { deployer.redeployResource(instance); redeployResource((Resource) instance); } else { deployer.redeployResource(instance); ResourceDeployer parentDeployer = getResourceDeployer(instance.getParent()); if (parentDeployer != null) parentDeployer.redeployResource(instance.getParent()); redeployResource((Resource) instance); } else { ResourceDeployer parentDeployer = getResourceDeployer(instance.getParent()); if (parentDeployer != null) parentDeployer.redeployResource(instance.getParent()); deployer.disableResource(resource); } else {
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); } } }
public synchronized Object create(Context ic) throws NamingException { if (actualResourceName == null) { actualResourceName = ConnectorsUtil.deriveResourceName (desc.getResourceId(), desc.getName(), desc.getResourceType()); try { if (serviceLocator == null) { serviceLocator = Globals.getDefaultHabitat(); if (serviceLocator == null) { throw new NamingException("Unable to create resource " + "[" + desc.getName() + " ] as habitat is null"); } } getResourceDeployer(desc).deployResource(desc); } catch (Exception e) { NamingException ne = new NamingException("Unable to create resource [" + desc.getName() + " ]"); ne.initCause(e); throw ne; } } return ic.lookup(actualResourceName); }
private boolean undepoyResource(Descriptor descriptor) { try{ ResourceDeployer deployer = getResourceDeployer(descriptor); deployer.undeployResource(descriptor); return true; }catch(Exception e){ _logger.log(Level.WARNING, "Unable to undeploy Descriptor [ " + descriptor.getName() + " ] ", e); return false; } }
/** * Validates the old resource configuration against new archive's modules. * @param allResources all resources (app scoped, module scoped) * @param oldApp Old Application config * @param newApp New Applicatoin config * @throws org.glassfish.resourcebase.resources.api.ResourceConflictException when it is not possible to map any of the resource(s) to * new application/its modules */ private void validatePreservedResources(Map<String, Resources> allResources, Application oldApp, Application newApp) throws ResourceConflictException { String appName = newApp.getName(); Resources appScopedResources = allResources.get(appName); if (appScopedResources != null) { for(Resource resource : appScopedResources.getResources()){ getResourceDeployer(resource).validatePreservedResource(oldApp, newApp, resource, appScopedResources); } } List<Module> newModules = newApp.getModule(); for(Module newModule : newModules){ Module oldModule = oldApp.getModule(newModule.getName()); if(oldModule != null){ Resources oldModuleResources = oldModule.getResources(); if(oldModuleResources != null){ for(Resource resource : oldModuleResources.getResources()){ getResourceDeployer(resource).validatePreservedResource(oldApp, newApp, resource, oldModuleResources); } } }//else its a new module in the archive being redeployed. } }
getResourceDeployer(desc).deployResource(desc); } catch (Exception e) { NamingException ne = new NamingException("Unable to create resource [" + desc.getName() + " ]");
resourceDeployer.undeployResource(instance); } else if (ResourceUtil.isValidEventType(instance.getParent())) { ResourceDeployer parentDeployer = getResourceDeployer(instance.getParent()); if (parentDeployer != null) parentDeployer.redeployResource(instance.getParent()); redeployResource((Resource) instance.getParent()); getResourceDeployer(resource); if (resourceDeployer != null) resourceDeployer.undeployResource(resource);
private void undeployResources(Resources resources, String appName, String moduleName) { if(resources != null){ for(Resource resource : resources.getResources()){ try{ //delete pools after resources if(!(resource instanceof ResourcePool)){ getResourceDeployer(resource).undeployResource(resource, appName, moduleName); } }catch(Exception e){ //ignore as this is cleanup } } Collection<ResourcePool> pools= resources.getResources(ResourcePool.class); for(ResourcePool pool : pools){ try{ getResourceDeployer(pool).undeployResource(pool, appName, moduleName); }catch(Exception e){ //ignore as this is cleanup } } } }
deployer.undeployResource(resource); } else if (enabledLocally) { if (logger.isLoggable(Level.FINE)) deployer.deployResource(resource);
ResourceDeployer deployer = getResourceDeployer(instance); if (deployer != null) deployer.deployResource(instance); } catch (Exception e) { Object params[] = {ResourceUtil.getGenericResourceInfo((Resource) instance), e};
/** * undeploy the given set of resources<br> * <b>care has to be taken for the case of dependent resources<br> * eg : all resources need to be undeployed <br> * before undeploying the pool that they refer to</b> * * @param resources list of resources */ public void undeployResources(Collection<Resource> resources) { for (Resource resource : resources) { try { ResourceDeployer deployer = getResourceDeployer(resource); if (deployer != null) deployer.undeployResource(resource); else { Object[] params = {resource.getIdentity()}; logger.log(Level.WARNING, ResourceLoggingConstansts.UNABLE_TO_UNDEPLOY, params); } } catch (Exception e) { Object[] params = {org.glassfish.resourcebase.resources.util.ResourceUtil.getGenericResourceInfo(resource), e}; logger.log(Level.WARNING, ResourceLoggingConstansts.UNABLE_TO_UNDEPLOY_EXCEPTION, params); } finally { removeListenerForResource(resource); } } }
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; }
ResourceDeployer deployer = getResourceDeployer(resource); if (deployer != null) deployer.deployResource(resource); } catch (Exception e) { Object[] params = {ResourceUtil.getGenericResourceInfo(resource), e};