Creates an instance of {@link JndiConfigurationSource}.

@param context Context required to build the {@link JNDIConfiguration}
@throws NullPointerException when context is null
190104
public static JndiConfigurationSource create(Context context) {
    if (context == null) {
      throw new NullPointerException("context: null");
    }
    return new JndiConfigurationSource(createJndiConfiguration(context, null), DEFAULT_PRIORITY);
  }
966034
public void start(StartContext context) throws StartException {
    serviceContainer = context.getController().getServiceContainer();
    childTarget = context.getChildTarget();

    startTrackingServices();
    createJndiBindings();

    // set this implementation as Runtime Container
    RuntimeContainerDelegate.INSTANCE.set(this);
  }
1374388
public void setContext(Context context) {
        context.put(JavacTypes.class, this);
        syms = Symtab.instance(context);
        types = Types.instance(context);
    }
96038
public synchronized static void initConfig(ITestContext context) {
        SeLionLogger.getLogger().entering(context);
        Map<ConfigProperty, String> initialValues = new HashMap<>();
        Map<String, String> testParams = context.getCurrentXmlTest().getLocalParameters();
        if (!testParams.isEmpty()) {
            for (ConfigProperty prop : ConfigProperty.values()) {
                // Check if a selionConfig param resides in the <test>
                String newValue = testParams.get(prop.getName());
                // accept param values that are empty in initialValues.
                if (newValue != null) {
                    initialValues.put(prop, newValue);
                }
            }
        }

        ConfigManager.addConfig(context.getCurrentXmlTest().getName(), new LocalConfig(initialValues));
        SeLionLogger.getLogger().exiting();
    }
197576
public void load( ServletContext servletContext )
    {
        _urlTemplates = new URLTemplates();
        InputStream xmlInputStream = null;
        InputStream xsdInputStream = null;

        try
        {
            xmlInputStream = servletContext.getResourceAsStream( _configFilePath );
            if ( xmlInputStream != null ) {
                /* load the XSD input stream */
                xsdInputStream = SCHEMA_RESOLVER.getInputStream();

                final String W3C_XML_SCHEMA = "http://www.w3.org/2001/XMLSchema";
                final String JAXP_SCHEMA_LANGUAGE = "http://java.sun.com/xml/jaxp/properties/schemaLanguage";
                final String JAXP_SCHEMA_SOURCE = "http://java.sun.com/xml/jaxp/properties/schemaSource";

                DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
                dbf.setValidating(true);
                dbf.setNamespaceAware(true);
                dbf.setAttribute(JAXP_SCHEMA_LANGUAGE, W3C_XML_SCHEMA);
                dbf.setAttribute(JAXP_SCHEMA_SOURCE, xsdInputStream);

                DocumentBuilder db = dbf.newDocumentBuilder();

                /* add an ErrorHandler that just logs validation problems */
                db.setErrorHandler(new ErrorHandler() {
                    public void warning(SAXParseException exception) {
                        _log.info("Validation warning validating config file \"" + _configFilePath + "\" against XML Schema \"" + SCHEMA_RESOLVER.getResourcePath());
                    }

                    public void error(SAXParseException exception) {
                        _log.error("Validation errors occurred parsing the config file \"" + _configFilePath + "\".  Cause: " + exception, exception);
                    }

                    public void fatalError(SAXParseException exception) {
                        _log.error("Validation errors occurred parsing the config file \"" + _configFilePath + "\".  Cause: " + exception, exception);
                    }
                });

                db.setEntityResolver(new EntityResolver() {
                    public InputSource resolveEntity(String publicId, String systemId) {
                        if(systemId.endsWith("/url-template-config.xsd")) {
                            InputStream inputStream = DefaultURLTemplatesFactory.class.getClassLoader().getResourceAsStream(CONFIG_SCHEMA);
                            return new InputSource(inputStream);
                        }
                        else return null;
                    }
                });

                Document document = db.parse(xmlInputStream);
                Element root = document.getDocumentElement();
                loadTemplates( root );
                loadTemplateRefGroups( root );
       }
       else
       {
           if ( _log.isInfoEnabled() )
               _log.info( "Running without URL template descriptor, " + _configFilePath );
       }
   }
   catch ( ParserConfigurationException pce )
   {
       _log.error( "Problem loading URL template descriptor file " + _configFilePath, pce );
   }
   catch ( SAXException se )
   {
       _log.error( "Problem parsing URL template descriptor in " + _configFilePath, se );
   }
   catch ( IOException ioe )
   {
       _log.error( "Problem reading URL template descriptor file " + _configFilePath, ioe );
   }
   finally
   {
       // Close the streams
       try { if ( xmlInputStream != null ) xmlInputStream.close(); } catch ( Exception ignore ) {}
       try { if ( xsdInputStream != null ) xsdInputStream.close(); } catch( IOException ignore ) {}
   }
}
32607
public final void setDataSource(DataSource dataSource) {
		if (this.jdbcTemplate == null || dataSource != this.jdbcTemplate.getDataSource()) {
			this.jdbcTemplate = createJdbcTemplate(dataSource);
			initTemplateConfig();
		}
	}
929779
public void submitContext(final String evaluatorConfiguration, final String contextConfiguration) {
    launchWithConfigurationString(evaluatorConfiguration, contextConfiguration, Optional.<String>empty(),
        Optional.<String>empty());
  }
915034
private void configureDefaultContextPath(DefaultContextPath dcp) {
        String methodName = "configureDefaultContextPath";
        String defaultContextPath = dcp.getValue();

        if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
            Tr.debug(tc, methodName + ": defaultContextPath --> " + defaultContextPath);
        }

        if (defaultContextPath != null && !defaultContextPath.isEmpty()) {
            webAppConfiguration.setDefaultContextPath(defaultContextPath);
        }
    }
162149
public static Resource getConsoleResource(BeanContext context) {
        SlingHttpServletRequest request = context.getRequest();
        ResourceResolver resolver = request.getResourceResolver();
        String path = null;
        // use the resource set by a probably executed 'defineObjects' tag (supports including components)
        Resource resource = context.getAttribute("resource", Resource.class);
        if (resource == null) {
            resource = request.getResource();
        }
        if (resource != null) {
            path = resource.getPath();
        }
        // use the suffix as the resource path if the resource is not defined or references a servlet
        if (StringUtils.isBlank(path) || path.startsWith("/bin/")) {
            RequestPathInfo requestPathInfo = request.getRequestPathInfo();
            path = requestPathInfo.getSuffix();
            resource = null;
        }
        if (resource == null && StringUtils.isNotBlank(path)) {
            resource = resolver.getResource(path);
        }
        if (resource == null) {
            // fallback to the root node if the servlet request has no suffix
            resource = resolver.getResource("/");
        }
        return resource;
    }
124216
protected void configureContext(Context context,
			ServletContextInitializer[] initializers) {
		TomcatStarter starter = new TomcatStarter(initializers);
		if (context instanceof TomcatEmbeddedContext) {
			TomcatEmbeddedContext embeddedContext = (TomcatEmbeddedContext) context;
			embeddedContext.setStarter(starter);
			embeddedContext.setFailCtxIfServletStartFails(true);
		}
		context.addServletContainerInitializer(starter, NO_CLASSES);
		for (LifecycleListener lifecycleListener : this.contextLifecycleListeners) {
			context.addLifecycleListener(lifecycleListener);
		}
		for (Valve valve : this.contextValves) {
			context.getPipeline().addValve(valve);
		}
		for (ErrorPage errorPage : getErrorPages()) {
			new TomcatErrorPage(errorPage).addToContext(context);
		}
		for (MimeMappings.Mapping mapping : getMimeMappings()) {
			context.addMimeMapping(mapping.getExtension(), mapping.getMimeType());
		}
		configureSession(context);
		new DisableReferenceClearingContextCustomizer().customize(context);
		for (TomcatContextCustomizer customizer : this.tomcatContextCustomizers) {
			customizer.customize(context);
		}
	}
401533
private void initConfigPropertyResolver(ServletContext context) {
		String configPropertyResolverClass = getInitParameter("configPropertyResolverClass");
		// Load a custom class to set configPropertyResolver
		configPropResolver = null;
		if (null != configPropertyResolverClass) {
			configPropResolver = (ConfigPropertyResolver) ClassLoaderResourceUtils
					.buildObjectInstance(configPropertyResolverClass);
			if (configPropResolver instanceof ServletContextAware) {
				((ServletContextAware) configPropResolver).setServletContext(context);
			}
		}
	}
880737
@Override
    public void visitClassContext(final ClassContext context) {
        try {
            classContext = context;
            classContext.getJavaClass().accept(this);
        } finally {
            classContext = null;
        }
    }
955421
protected void postProcessApplicationContext(ConfigurableApplicationContext context) {
		if (this.beanNameGenerator != null) {
			context.getBeanFactory().registerSingleton(
					AnnotationConfigUtils.CONFIGURATION_BEAN_NAME_GENERATOR,
					this.beanNameGenerator);
		}
		if (this.resourceLoader != null) {
			if (context instanceof GenericApplicationContext) {
				((GenericApplicationContext) context)
						.setResourceLoader(this.resourceLoader);
			}
			if (context instanceof DefaultResourceLoader) {
				((DefaultResourceLoader) context)
						.setClassLoader(this.resourceLoader.getClassLoader());
			}
		}
		if (this.addConversionService) {
			context.getBeanFactory().setConversionService(
					ApplicationConversionService.getSharedInstance());
		}
	}
81751
public Reader createResource(GeneratorContext context) {
		ServletContext servletContext = context.getServletContext();
		StringBuffer data = null;
		String path = context.getPath();
		if(ENGINE_KEY.equals(path)) {
			data = buildEngineScript(readDWRScript(ENGINE_PATH),servletContext);
		}
		else if(DWR_LIBRARIES.containsKey(path)){
			data = readDWRScript((String)DWR_LIBRARIES.get(path));
		}
		else if(ALL_INTERFACES_KEY.equals(path)) {
			data = new StringBuffer(ENGINE_INIT);
			data.append(getAllPublishedInterfaces(servletContext));
		}
		else {
			data = new StringBuffer(ENGINE_INIT);
			StringTokenizer tk = new StringTokenizer(path,"|");
			while(tk.hasMoreTokens()) {
				data.append(getInterfaceScript(tk.nextToken(),servletContext));
			}
		}
		
		return new StringReader(data.toString());
	}
531144
@Override
	public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
		try {
			HashSet<Class<?>> registeredTypes = new HashSet<>();

			// Get Service Broker
			ServiceBroker broker = applicationContext.getBean(ServiceBroker.class);

			// Find Services in Spring Application Context
			Map<String, Service> serviceMap = applicationContext.getBeansOfType(Service.class);
			if (serviceMap != null && !serviceMap.isEmpty()) {
				String name;
				for (Map.Entry<String, Service> service : serviceMap.entrySet()) {

					// Register Service in Broker
					name = service.getKey();
					registeredTypes.add(service.getClass());
					if (name != null && name.startsWith("$")) {
						broker.createService(name, service.getValue());
						logger.info("Service \"" + name + "\" registered.");
					} else {
						Service instance = service.getValue();
						broker.createService(instance);
						logger.info("Service \"" + instance.getName() + "\" registered.");
					}
				}
			}

			// Add new Services
			if (packagesToScan != null && packagesToScan.length > 0) {
				DefaultListableBeanFactory beanFactory = (DefaultListableBeanFactory) applicationContext
						.getAutowireCapableBeanFactory();
				for (String packageName : packagesToScan) {
					if (!packageName.isEmpty()) {
						LinkedList<String> classNames = scan(packageName);
						for (String className : classNames) {
							if (className.indexOf('$') > -1) {
								continue;
							}
							className = packageName + '.' + className;
							Class<?> type = Class.forName(className);
							if (Service.class.isAssignableFrom(type)) {

								// Check type
								if (!registeredTypes.add(type)) {
									continue;
								}

								// Register Service in Spring
								String name = nameOf(type, false);
								BeanDefinition definition = BeanDefinitionBuilder.genericBeanDefinition(type)
										.setScope(BeanDefinition.SCOPE_SINGLETON)
										.setAutowireMode(DefaultListableBeanFactory.AUTOWIRE_BY_TYPE).setLazyInit(false)
										.getBeanDefinition();
								beanFactory.registerBeanDefinition(name, definition);
								Service service = (Service) beanFactory.createBean(type);

								// Register Service in Broker
								broker.createService(service);

								// Log
								logger.info("Service \"" + name + "\" registered.");
							}
						}
					}
				}
			}
		} catch (Exception cause) {
			throw new FatalBeanException("Unable to define Moleculer Service!", cause);
		}
	}
727685
public InputStream createStreamResource(GeneratorContext context) {
		InputStream is = null;
		try {

			String resourcePath = context.getPath();
			String path = getCompletePath(resourcePath);
			is = ClassLoaderResourceUtils.getResourceAsStream(path, this);
		} catch (FileNotFoundException e) {
			throw new BundlingProcessException(e);
		}
		return is;
	}
753409
public void setDataSourceConnectionSource(ConnectionSource<DataSource, DataSourceSettings> connectionSource) {
        this.dataSourceName = connectionSource.getName();
        DataSource source = connectionSource.getSource();
        getProperties().put(Environment.DATASOURCE, source);
        getProperties().put(Environment.CURRENT_SESSION_CONTEXT_CLASS, GrailsSessionContext.class.getName());
        final ClassLoader contextClassLoader = Thread.currentThread().getContextClassLoader();
        if (contextClassLoader != null && contextClassLoader.getClass().getSimpleName().equalsIgnoreCase("RestartClassLoader")) {
            getProperties().put(AvailableSettings.CLASSLOADERS, contextClassLoader);
        } else {
            getProperties().put(AvailableSettings.CLASSLOADERS, connectionSource.getClass().getClassLoader());
        }
    }