/** * Open the specified database connection. * * @return Connection to the database */ protected Connection open() { try { Context context = null; if (localDataSource) { context = ContextBindings.getClassLoader(); context = (Context) context.lookup("comp/env"); } else { StandardServer server = (StandardServer) ServerFactory.getServer(); context = server.getGlobalNamingContext(); } DataSource dataSource = (DataSource)context.lookup(dataSourceName); return dataSource.getConnection(); } catch (Exception e) { // Log the problem for posterity containerLog.error(sm.getString("dataSourceRealm.exception"), e); } return null; }
/** * Open the specified database connection. * * @return Connection to the database */ protected Connection open() { try { Context context = null; if (localDataSource) { context = ContextBindings.getClassLoader(); context = (Context) context.lookup("comp/env"); } else { context = ((StandardServer)getServer()).getGlobalNamingContext(); } DataSource dataSource = (DataSource)context.lookup(dataSourceName); return dataSource.getConnection(); } catch (Exception e) { // Log the problem for posterity containerLog.error(sm.getString("dataSourceRealm.exception"), e); } return null; }
/** * Open the specified database connection. * * @return Connection to the database */ protected Connection open() { try { Context context = null; if (localDataSource) { context = ContextBindings.getClassLoader(); context = (Context) context.lookup("comp/env"); } else { context = ((StandardServer)getServer()).getGlobalNamingContext(); } DataSource dataSource = (DataSource)context.lookup(dataSourceName); return dataSource.getConnection(); } catch (Exception e) { // Log the problem for posterity containerLog.error(sm.getString("dataSourceRealm.exception"), e); } return null; }
/** * Open the specified database connection. * * @return Connection to the database */ protected Connection open() { try { Context context = null; if (localDataSource) { context = ContextBindings.getClassLoader(); context = (Context) context.lookup("comp/env"); } else { context = ((StandardServer)getServer()).getGlobalNamingContext(); } DataSource dataSource = (DataSource)context.lookup(dataSourceName); return dataSource.getConnection(); } catch (Exception e) { // Log the problem for posterity containerLog.error(sm.getString("dataSourceRealm.exception"), e); } return null; }
private void bindResource(ResourceBase res) { try { Context globalNamingContext = standardServer.getGlobalNamingContext(); Object value = globalNamingContext.lookup(res.getName()); String type = res.getType(); bindResource(res.getName(), value, type); } catch (NamingException e) { logger.error("Unable to lookup Global Tomcat resource " + res.getName(), e); } }
public void addResourceEnvRef(ContextResourceEnvRef resourceEnvRef) { try { Context globalNamingContext = standardServer.getGlobalNamingContext(); Object value = globalNamingContext.lookup(resourceEnvRef.getName()); String type = resourceEnvRef.getType(); bindResource(resourceEnvRef.getName(), value, type); } catch (NamingException e) { logger.error("Unable to lookup Global Tomcat resource " + resourceEnvRef.getName(), e); } }
private void bindResource(final ResourceBase res) { try { final Context globalNamingContext = standardServer.getGlobalNamingContext(); final Object value = globalNamingContext.lookup(res.getName()); final String type = res.getType(); bindResource(res.getName(), value, type); } catch (final NamingException e) { logger.error("Unable to lookup Global Tomcat resource " + res.getName(), e); } }
/** * Prepare for active use of the public methods of this Component. * * @exception LifecycleException if this component detects a fatal error * that prevents it from being started */ public synchronized void start() throws LifecycleException { // Perform normal superclass initialization super.start(); try { StandardServer server = (StandardServer) ServerFactory.getServer(); Context context = server.getGlobalNamingContext(); database = (UserDatabase) context.lookup(resourceName); } catch (Throwable e) { containerLog.error(sm.getString("userDatabaseRealm.lookup", resourceName), e); database = null; } if (database == null) { throw new LifecycleException (sm.getString("userDatabaseRealm.noDatabase", resourceName)); } }
public void addResource(ContextResource resource) { try { Context globalNamingContext = standardServer.getGlobalNamingContext(); Object value = globalNamingContext.lookup(resource.getName()); String type = resource.getType(); bindResource(resource.getName(), value, type); } catch (NamingException e) { logger.error("Unable to lookup Global Tomcat resource " + resource.getName(), e); } }
global = ((StandardServer) server).getGlobalNamingContext();
global = ((StandardServer) server).getGlobalNamingContext();
global = ((StandardServer) server).getGlobalNamingContext();
/** * Prepare for the beginning of active use of the public methods of this * component and implement the requirements of * {@link org.apache.catalina.util.LifecycleBase#startInternal()}. * * @exception LifecycleException if this component detects a fatal error * that prevents this component from being used */ @Override protected void startInternal() throws LifecycleException { try { Context context = ((StandardServer)getServer()).getGlobalNamingContext(); database = (UserDatabase) context.lookup(resourceName); } catch (Throwable e) { ExceptionUtils.handleThrowable(e); containerLog.error(sm.getString("userDatabaseRealm.lookup", resourceName), e); database = null; } if (database == null) { throw new LifecycleException (sm.getString("userDatabaseRealm.noDatabase", resourceName)); } super.startInternal(); }
/** * Prepare for the beginning of active use of the public methods of this * component and implement the requirements of * {@link org.apache.catalina.util.LifecycleBase#startInternal()}. * * @exception LifecycleException if this component detects a fatal error * that prevents this component from being used */ @Override protected void startInternal() throws LifecycleException { try { Context context = ((StandardServer)getServer()).getGlobalNamingContext(); database = (UserDatabase) context.lookup(resourceName); } catch (Throwable e) { ExceptionUtils.handleThrowable(e); containerLog.error(sm.getString("userDatabaseRealm.lookup", resourceName), e); database = null; } if (database == null) { throw new LifecycleException (sm.getString("userDatabaseRealm.noDatabase", resourceName)); } super.startInternal(); }
/** * Prepare for the beginning of active use of the public methods of this * component and implement the requirements of * {@link org.apache.catalina.util.LifecycleBase#startInternal()}. * * @exception LifecycleException if this component detects a fatal error * that prevents this component from being used */ @Override protected void startInternal() throws LifecycleException { try { Context context = ((StandardServer)getServer()).getGlobalNamingContext(); database = (UserDatabase) context.lookup(resourceName); } catch (Throwable e) { ExceptionUtils.handleThrowable(e); containerLog.error(sm.getString("userDatabaseRealm.lookup", resourceName), e); database = null; } if (database == null) { throw new LifecycleException (sm.getString("userDatabaseRealm.noDatabase", resourceName)); } super.startInternal(); }
OpenEJBNamingContextListener namingContextListener = new OpenEJBNamingContextListener(standardServer); if (standardServer.getGlobalNamingContext() != null) { namingContextListener.start();
OpenEJBNamingContextListener namingContextListener = new OpenEJBNamingContextListener(standardServer); if (standardServer.getGlobalNamingContext() != null) { namingContextListener.start();
public void start(final StandardServer server) { if (SystemInstance.get().isDefaultProfile()) { // add user tomee is no user are specified try { final NamingResourcesImpl resources = server.getGlobalNamingResources(); final ContextResource userDataBaseResource = resources.findResource("UserDatabase"); final UserDatabase db = (UserDatabase) server.getGlobalNamingContext().lookup(userDataBaseResource.getName()); if (!db.getUsers().hasNext() && db instanceof MemoryUserDatabase) { final MemoryUserDatabase mudb = (MemoryUserDatabase) db; final boolean oldRo = mudb.getReadonly(); try { ((MemoryUserDatabase) db).setReadonly(false); db.createRole("tomee-admin", "tomee admin role"); db.createUser("tomee", "tomee", "TomEE"); db.findUser("tomee").addRole(db.findRole("tomee-admin")); } finally { mudb.setReadonly(oldRo); } } } catch (final Throwable t) { // no-op } } }
final OpenEJBNamingContextListener namingContextListener = new OpenEJBNamingContextListener(standardServer); if (standardServer.getGlobalNamingContext() != null) { namingContextListener.start();