public void publishObject(ResourceInfo resourceInfo, Object object,boolean rebind) throws NamingException{ String jndiName = resourceInfo.getName(); publishObject(resourceInfo, jndiName, object, rebind); }
/** * 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); } }
/** * 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); } }
/** * Installs the given custom resource. It publishes the resource as a * javax.naming.Reference with the naming manager (jndi). This method gets * called during server initialization and custom resource deployer to * handle custom resource events. * * @param customRes custom resource */ public void installCustomResource(CustomResource customRes, ResourceInfo resourceInfo) { try { if (_logger.isLoggable(Level.FINE)) { _logger.log(Level.FINE,"installCustomResource by jndi-name : "+ resourceInfo); } // bind a Reference to the object factory Reference ref = new Reference(customRes.getResType(), customRes.getFactoryClass(), null); // add resource properties as StringRefAddrs for (Iterator props = customRes.getProperties().iterator(); props.hasNext();) { ResourceProperty prop = (ResourceProperty) props.next(); ref.add(new StringRefAddr(prop.getName(), (String) prop.getValue())); } // publish the reference cns.publishObject(resourceInfo, ref, true); } catch (Exception ex) { _logger.log(Level.SEVERE, "customrsrc.create_ref_error", resourceInfo); _logger.log(Level.SEVERE, "customrsrc.create_ref_error_excp", ex); } }
namingService.publishObject(resourceInfo, ref, true);
private void registerDSDReferredByApplication(String appName, DataSourceDefinitionDescriptor dsd) { // It is possible that JPA might call this method multiple times in a single deployment, // when there are multiple PUs eg: one PU in each of war, ejb-jar. Make sure that // DSD is bound to JNDI only when it is not already deployed. if(!dsd.isDeployed()){ DataSourceDefinitionProxy proxy = habitat.getComponent(DataSourceDefinitionProxy.class); ResourceNamingService resourceNamingService = habitat.getComponent(ResourceNamingService.class); proxy.setDescriptor(dsd); //String appName = application.getAppName(); String moduleName = null; if(dsd.getName().startsWith(ConnectorConstants.JAVA_APP_SCOPE_PREFIX)){ dsd.setResourceId(appName); } if(dsd.getName().startsWith(ConnectorConstants.JAVA_GLOBAL_SCOPE_PREFIX) /*|| next.getName().startsWith("java:module/")*/ || dsd.getName().startsWith(ConnectorConstants.JAVA_APP_SCOPE_PREFIX)){ ResourceInfo resourceInfo = new ResourceInfo(dsd.getName(), appName, moduleName); try { resourceNamingService.publishObject(resourceInfo, proxy, true); dsd.setDeployed(true); } catch (NamingException e) { Object params[] = new Object[]{appName, dsd.getName(), e}; _logger.log(Level.WARNING, "dsd.registration.failed", params); } } } }
try { _runtime.getResourceNamingService().publishObject(poolInfo, jndiNameForPool, connectorPoolObj, true); ManagedConnectionFactory mcf = obtainManagedConnectionFactory(poolInfo); if (mcf == null) {
/** * 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); } }
connectorRuntime_.getResourceNamingService().publishObject(resourceInfo, ref, true); } catch (NamingException ex) { String i18nMsg = localStrings.getString(
namingService.publishObject(resourceInfo, ref, true); _registry.addResourceInfo(resourceInfo); }catch(NamingException ne){
ManagedConnectionFactory mcf = null; try { _runtime.getResourceNamingService().publishObject(poolInfo, jndiNameForPool, ccp, true); mcf = obtainManagedConnectionFactory(poolInfo);
_runtime.getResourceNamingService().publishObject(poolInfo, jndiNameForPool, origCcp, true);