public InitialContext getInitialContext() { GlassfishNamingManager gfNamingManager = services.getService(GlassfishNamingManager.class); return (InitialContext)gfNamingManager.getInitialContext(); }
final UserTransaction getUserTransaction() { // Only session beans with bean-managed transactions // or message-driven beans with bean-managed transactions // can programmatically demarcate transactions. if ( (isSession || isMessageDriven) && isBeanManagedTran ) { try { UserTransaction utx = (UserTransaction) namingManager.getInitialContext().lookup(USER_TX); return utx; } catch ( Exception ex ) { _logger.log(Level.FINE, "ejb.user_transaction_exception", ex); throw new EJBException("Unable to lookup UserTransaction", ex); } } else throw new IllegalStateException( "ERROR: only SessionBeans with bean-managed transactions" + "can obtain UserTransaction"); }
private void unbindConnectorDescriptor(String moduleName) throws ConnectorRuntimeException { if(ConnectorRuntime.getRuntime().isServer()){ try { String descriptorJNDIName = ConnectorAdminServiceUtils. getReservePrefixedJNDINameForDescriptor(moduleName); _runtime.getNamingManager().getInitialContext().unbind(descriptorJNDIName); if(_logger.isLoggable(Level.FINEST)){ _logger.finest("ResourceAdapterAdminServiceImpl :: destroyActiveRA " + moduleName + " removed descriptor " + descriptorJNDIName); } } catch (NamingException ne) { if(_logger.isLoggable(Level.FINEST)){ _logger.log(Level.FINEST, "rardeployment.connector_descriptor_jndi_removal_failure", moduleName); } } } }
final UserTransaction getUserTransaction() { // Only session beans with bean-managed transactions // or message-driven beans with bean-managed transactions // can programmatically demarcate transactions. if ( (container.isSession || container.isMessageDriven) && container.isBeanManagedTran ) { try { UserTransaction utx = (UserTransaction) container.namingManager.getInitialContext().lookup(USER_TX); return utx; } catch ( Exception ex ) { _logger.log(Level.FINE, "ejb.user_transaction_exception", ex); throw new EJBException(_logger.getResourceBundle(). getString("ejb.user_transaction_exception"), ex); } } else { throw new IllegalStateException(localStrings.getLocalString( "ejb.ut_only_for_bmt", "Only session beans with bean-managed transactions can obtain UserTransaction")); } }
private PersistentEJBTimerService(String ejbName, boolean removeOldTimers) throws Exception { super(); timerLocal_ = (TimerLocal) ejbContainerUtil.getGlassfishNamingManager(). getInitialContext().lookup(ejbName); this.removeOldTimers = removeOldTimers; initProperties(); // Verify that the DataSource ref is correct and store it to check if connections can be aquired if // the timeout fails lookupTimerResource(); // The default value for ReadDBBeforeTimeout in case of PE // is false. setPerformDBReadBeforeTimeout(!isDas); }
/** * Returns a databaseName that is populated in pool's default DATABASENAME * @param poolInfo * @param mcf * @return * @throws javax.naming.NamingException if poolName lookup fails */ private String getDefaultDatabaseName(PoolInfo poolInfo, ManagedConnectionFactory mcf) throws NamingException { // All this to get the default user name and principal String databaseName = null; ConnectorConnectionPool connectorConnectionPool = null; try { String jndiNameForPool = ConnectorAdminServiceUtils.getReservePrefixedJNDINameForPool(poolInfo); Context ic = _runtime.getNamingManager().getInitialContext(); connectorConnectionPool = (ConnectorConnectionPool) ic.lookup(jndiNameForPool); } catch (NamingException ne) { throw ne; } databaseName = ccPoolAdmService.getPropertyValue("DATABASENAME", connectorConnectionPool); // To avoid using "" as the default databasename, try to get // the databasename from MCF. if (databaseName == null || databaseName.trim().equals("")) { databaseName = ConnectionPoolObjectsUtils.getValueFromMCF("DatabaseName", poolInfo, mcf); } return databaseName; }
try { String jndiNameForPool = getReservePrefixedJNDINameForPool(poolInfo); Context ic = ConnectorRuntime.getRuntime().getNamingManager().getInitialContext(); connectorConnectionPool = (ConnectorConnectionPool) ic.lookup(jndiNameForPool);
javax.naming.Context ic = namingManager.getInitialContext(); result = ic.lookup(envAnnotationName); } else {
glassfishNamingManager.getInitialContext().lookup(lookupName);
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); } } }
glassfishNamingManager.getInitialContext().lookup(lookupName);
public Object lookup(GenericResourceInfo resourceInfo, String name, Hashtable env) throws NamingException{ String applicationName = resourceInfo.getApplicationName(); String moduleName = resourceInfo.getModuleName(); moduleName = org.glassfish.resourcebase.resources.util.ResourceUtil.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); } } }