public Object lookup(GenericResourceInfo resourceInfo, String name) throws NamingException{ return lookup(resourceInfo, name, null); }
public void publishObject(ResourceInfo resourceInfo, Object object,boolean rebind) throws NamingException{ String jndiName = resourceInfo.getName(); publishObject(resourceInfo, jndiName, object, rebind); }
if(!isGlobalName(resourceInfo.getName()) && applicationName != null && moduleName != null ){ namingManager.unbindModuleObject(applicationName, moduleName, getModuleScopedName(jndiName)); }catch(NameNotFoundException e){ try { alreadyBoundObject = namingManager.lookupFromModuleNamespace(applicationName, moduleName, getModuleScopedName(jndiName), null); } catch (NameNotFoundException e) { JNDIBinding bindings = new ModuleScopedResourceBinding(getModuleScopedName(jndiName), object); List<JNDIBinding> list = new ArrayList<JNDIBinding>(); list.add(bindings); if(_logger.isLoggable(Level.FINEST)){ debug("application=" + applicationName + ", module name=" +moduleName+", binding name=" + jndiName); }else if(!isGlobalName(resourceInfo.getName()) && applicationName != null ) { namingManager.unbindAppObject(applicationName, getAppScopedName(jndiName)); }catch(NameNotFoundException e){ try { alreadyBoundObject = namingManager.lookupFromAppNamespace(applicationName, getAppScopedName(jndiName), null); } catch (NameNotFoundException e) { JNDIBinding bindings = new ApplicationScopedResourceBinding(getAppScopedName(jndiName), object); List<JNDIBinding> list = new ArrayList<JNDIBinding>(); list.add(bindings);
private void bindAppScopedNameForAppclient(Object object, String jndiName, String applicationName) throws NamingException { String internalGlobalJavaAppName = cnu.composeInternalGlobalJavaAppName(applicationName, getAppScopedName(jndiName)); if(_logger.isLoggable(Level.FINEST)){ debug("binding app-scoped-resource for appclient : " + internalGlobalJavaAppName); } namingManager.publishObject(internalGlobalJavaAppName, object, true); }
public void unpublishObject(GenericResourceInfo resourceInfo, String jndiName) throws NamingException { String applicationName = resourceInfo.getApplicationName(); String moduleName = resourceInfo.getModuleName(); moduleName = ConnectorsUtil.getActualModuleName(moduleName); if(!isGlobalName(resourceInfo.getName()) && applicationName != null && moduleName != null){ namingManager.unbindModuleObject(applicationName, moduleName, getModuleScopedName(jndiName)); }else if(!isGlobalName(resourceInfo.getName()) && applicationName != null) { namingManager.unbindAppObject(applicationName, getAppScopedName(jndiName)); unbindAppScopedNameForAppclient(jndiName, applicationName); }else{ namingManager.unpublishObject(jndiName); } }
public Object lookup(GenericResourceInfo resourceInfo, String name, Hashtable env) throws NamingException{ String applicationName = resourceInfo.getApplicationName(); String moduleName = resourceInfo.getModuleName(); moduleName = ConnectorsUtil.getActualModuleName(moduleName); if(!isGlobalName(resourceInfo.getName()) && applicationName != null && moduleName != null){ return namingManager.lookupFromModuleNamespace(applicationName, moduleName, getModuleScopedName(name), env); }else if(!isGlobalName(resourceInfo.getName()) && applicationName != null) { if(pe.getProcessType().isServer() || pe.getProcessType().isEmbedded()){ return namingManager.lookupFromAppNamespace(applicationName, getAppScopedName(name), env); }else{ String internalGlobalJavaAppName = cnu.composeInternalGlobalJavaAppName(applicationName, getAppScopedName(name)); if(_logger.isLoggable(Level.FINEST)){ debug("appclient lookup : " + internalGlobalJavaAppName); } return namingManager.getInitialContext().lookup(internalGlobalJavaAppName); } }else{ if(env != null){ InitialContext ic = new InitialContext(env); return ic.lookup(name); }else{ return namingManager.getInitialContext().lookup(name); } } }
/** * Rebinds the connection pool with matchning flag set. * * @param poolInfo pool for which matching need to be switched on * @throws ConnectorRuntimeException , if a Naming error occurs. */ public void switchOnMatching(PoolInfo poolInfo) throws ConnectorRuntimeException { try { ConnectorConnectionPool origCcp = getOriginalConnectorConnectionPool(poolInfo); origCcp.setMatchConnections(true); //now rebind the object in jndi String jndiNameForPool = ConnectorAdminServiceUtils.getReservePrefixedJNDINameForPool(poolInfo); _runtime.getResourceNamingService().unpublishObject(poolInfo, jndiNameForPool); _runtime.getResourceNamingService().publishObject(poolInfo, jndiNameForPool, origCcp, true); } catch (NamingException e) { ConnectorRuntimeException ex = new ConnectorRuntimeException(e.getMessage()); throw(ConnectorRuntimeException) ex.initCause(e); } }
getReservePrefixedJNDINameForPool(poolInfo); try { ccp = (ConnectorConnectionPool) namingService.lookup(poolInfo, jndiNameForPool); } catch (NamingException ne) { ccp = (ConnectorConnectionPool) namingService.lookup(poolInfo, jndiNameForPool); } catch (NamingException e) { Object params[] = new Object[]{poolInfo, e}; ccp = (ConnectorConnectionPool) namingService.lookup(poolInfo, jndiNameForPool); namingService.publishObject(resourceInfo, ref, true); _registry.addResourceInfo(resourceInfo); }catch(NamingException ne){
private void deleteResource(com.sun.enterprise.config.serverbeans.CustomResource customResource, ResourceInfo resourceInfo) throws NamingException { if (ResourcesUtil.createInstance().isEnabled(customResource, resourceInfo)){ // converts the config data to j2ee resource //JavaEEResource j2eeResource = toCustomJavaEEResource(customRes, resourceInfo); // removes the resource from jndi naming cns.unpublishObject(resourceInfo, resourceInfo.getName()); }else{ _logger.log(Level.FINEST, "core.resource_disabled", new Object[] {customResource.getJndiName(), ConnectorConstants.RES_TYPE_CUSTOM}); } }
private void unbindAppScopedNameForAppclient(String jndiName, String applicationName) throws NamingException { String internalGlobalJavaAppName = cnu.composeInternalGlobalJavaAppName(applicationName, getAppScopedName(jndiName)); namingManager.unpublishObject(internalGlobalJavaAppName); }
try { _runtime.getResourceNamingService().publishObject(poolInfo, jndiNameForPool, connectorPoolObj, true); ManagedConnectionFactory mcf = obtainManagedConnectionFactory(poolInfo); if (mcf == null) { _runtime.getResourceNamingService().unpublishObject(poolInfo, jndiNameForPool); String i18nMsg = localStrings.getString("ccp_adm.failed_to_create_mcf", poolInfo); ConnectorRuntimeException cre = new ConnectorRuntimeException(i18nMsg); } catch (NullPointerException ex) { try { _runtime.getResourceNamingService().unpublishObject(poolInfo, jndiNameForPool); } catch (NamingException ne) { if(_logger.isLoggable(Level.FINE)) {
/** * Un-installs the external jndi resource. * * @param resource external jndi resource */ public void uninstallExternalJndiResource(JavaEEResource resource, ResourceInfo resourceInfo) { // removes the jndi context from the factory cache //String bindName = resource.getResourceInfo().getName(); JndiProxyObjectFactory.removeInitialContext(resource.getResourceInfo()); // removes the resource from jndi naming try { namingService.unpublishObject(resourceInfo, resourceInfo.getName()); /* TODO V3 handle jms later //START OF IASRI 4660565 if (((ExternalJndiResource)resource).isJMSConnectionFactory()) { nm.unpublishObject(IASJmsUtil.getXAConnectionFactoryName(resourceName)); } //END OF IASRI 4660565 */ } catch (javax.naming.NamingException e) { if (_logger.isLoggable(Level.FINE)) { _logger.log(Level.FINE, "Error while unpublishing resource: " + resourceInfo, e); } } }
/** * Create a ConnectorConnectionPool from information in memory */ private ConnectorConnectionPool getOriginalConnectorConnectionPool( PoolInfo poolInfo) throws NamingException { ConnectorConnectionPool ccpOrig = null; String jndiNameForPool = ConnectorAdminServiceUtils.getReservePrefixedJNDINameForPool(poolInfo); try { ccpOrig = (ConnectorConnectionPool)_runtime.getResourceNamingService().lookup(poolInfo, jndiNameForPool); } catch (NamingException ne) { throw ne; } return ccpOrig; }
ManagedConnectionFactory mcf = null; try { _runtime.getResourceNamingService().publishObject(poolInfo, jndiNameForPool, ccp, true); mcf = obtainManagedConnectionFactory(poolInfo); if (mcf == null) { try{ _runtime.getResourceNamingService().unpublishObject(poolInfo, jndiNameForPool); }catch(NamingException e){ _logger.log(Level.WARNING,"Unable to unbind the pool configuration object " +
/** * Installs the given mail resource. This method gets called during server * initialization and from mail resource deployer to handle resource events. * * @param mailResource mail resource */ public void installMailResource(com.sun.enterprise.resource.beans.MailResource mailResource, ResourceInfo resourceInfo) { try { MailConfiguration config = new MailConfiguration(mailResource); javax.naming.Reference ref = new javax.naming.Reference(javax.mail.Session.class.getName(), MailNamingObjectFactory.class.getName(),null); SerializableObjectRefAddr serializableRefAddr = new SerializableObjectRefAddr("jndiName", config); ref.add(serializableRefAddr); // Publish the object namingService.publishObject(resourceInfo, ref, true); } catch (Exception ex) { _logger.log(Level.SEVERE, "mailrsrc.create_obj_error", resourceInfo); _logger.log(Level.SEVERE, "mailrsrc.create_obj_error_excp", ex); } }
namingService.unpublishObject(resourceInfo, resourceInfo.getName());
/** * Checks if a conncetor connection pool has been deployed to this server * instance * * @param poolInfo * @return */ public boolean isConnectorConnectionPoolDeployed(PoolInfo poolInfo) { try { String jndiName = ConnectorAdminServiceUtils. getReservePrefixedJNDINameForPool(poolInfo); _runtime.getResourceNamingService().lookup(poolInfo, jndiName); return true; } catch (NamingException e) { return false; } }
_runtime.getResourceNamingService().unpublishObject(poolInfo, jndiNameForPool); _runtime.getResourceNamingService().publishObject(poolInfo, jndiNameForPool, origCcp, true);
/** * 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(ResourceInfo resourceInfo, Resource resource) throws NamingException { ResourceProxy proxy = genericResourceProxy.getComponent(ResourceProxy.class); proxy.setResource(resource); proxy.setResourceInfo(resourceInfo); resourceNamingService.publishObject(resourceInfo, proxy, true); } }
namingService.unpublishObject(resourceInfo, resourceInfo.getName()); } catch (NamingException ne) {