Loads the context map from the VFS.<p>

@return the context map
@throws Exception if something goes wrong
1765
private Map<String, CmsTemplateContext> initMap() throws Exception {

        Map<String, CmsTemplateContext> result = new LinkedHashMap<String, CmsTemplateContext>();
        String path = getConfigurationPropertyPath();
        CmsResource resource = m_cms.readResource(path);
        CmsFile file = m_cms.readFile(resource);
        String fileContent = new String(file.getContents(), "UTF-8");
        CmsMacroResolver resolver = new CmsMacroResolver();
        resolver.setCmsObject(m_cms);
        for (Map.Entry<String, String> param : m_params.entrySet()) {
            resolver.addMacro(param.getKey(), param.getValue());
        }
        fileContent = resolver.resolveMacros(fileContent);
        JSONTokener tok = new JSONTokener(fileContent);
        tok.setOrdered(true);
        JSONObject root = new JSONObject(tok, true);
        for (String templateContextName : root.keySet()) {
            JSONObject templateContextJson = (JSONObject)(root.opt(templateContextName));
            CmsJsonMessageContainer jsonMessage = new CmsJsonMessageContainer(templateContextJson.opt(A_NICE_NAME));
            String templatePath = (String)templateContextJson.opt(A_PATH);
            JSONObject variantsJson = (JSONObject)templateContextJson.opt(A_VARIANTS);
            List<CmsClientVariant> variants = new ArrayList<CmsClientVariant>();
            if (variantsJson != null) {
                for (String variantName : variantsJson.keySet()) {
                    JSONObject variantJson = (JSONObject)variantsJson.opt(variantName);
                    CmsJsonMessageContainer variantMessage = new CmsJsonMessageContainer(variantJson.opt(A_NICE_NAME));
                    int width = variantJson.optInt(A_WIDTH, 800);
                    int height = variantJson.optInt(A_HEIGHT, 600);
                    CmsClientVariant variant = new CmsClientVariant(
                        variantName,
                        variantMessage,
                        width,
                        height,
                        new HashMap<String, String>());
                    variants.add(variant);
                }
            }
            CmsTemplateContext templateContext = new CmsTemplateContext(
                templateContextName,
                templatePath,
                jsonMessage,
                this,
                variants,
                false);
            result.put(templateContextName, templateContext);

        }
        return result;
    }
856646
public void actionShow() throws Exception {

        // try to load the historical resource
        if (CmsStringUtil.isNotEmpty(getParamVersion())) {
            showHistoricVersion();
        } else {
            String resourceStr = getParamResource();
            // trying to read the resource
            CmsResource resource = readResource(resourceStr);
            if (isDeleted(resource)) {
                // resource has been deleted in offline project
                throw new CmsVfsResourceNotFoundException(Messages.get().container(
                    Messages.ERR_RESOURCE_DELETED_2,
                    resourceStr,
                    getCms().getRequestContext().getCurrentProject().getName()));
            }

            // check for release / expiration time window
            autoTimeWarp(resource);

            // code for display resource after all tests for displayability (exists, not deleted)
            //            if (CmsResourceTypeXmlContainerPage.isContainerPage(resource)) {
            //                // if we have a container page look for the first sitemap entry
            //                // and use that to display the container page
            //                List<CmsInternalSitemapEntry> entries = OpenCms.getSitemapManager().getEntriesForStructureId(
            //                    getJsp().getCmsObject(),
            //                    resource.getStructureId());
            //                if (!entries.isEmpty()) {
            //                    CmsInternalSitemapEntry entry = entries.get(0);
            //                    resourceStr = entry.getRootPath();
            //                }
            //            }
            if (OpenCms.getSiteManager().isSharedFolder(getCms().getRequestContext().getSiteRoot())) {
                if (!OpenCms.getSiteManager().startsWithShared(resourceStr)) {
                    resourceStr = CmsStringUtil.joinPaths(OpenCms.getSiteManager().getSharedFolder(), resourceStr);
                }
            }
            String url = getJsp().link(resourceStr);
            // if in online project
            if ((url.indexOf("://") < 0) && getCms().getRequestContext().getCurrentProject().isOnlineProject()) {
                url = prependSiteRoot(url);
            }
            getJsp().getResponse().sendRedirect(url);
        }
    }
1179980
public Map<String, CmsDefaultSet<String>> getAllowedContextMap(CmsObject cms) {

        Map<String, CmsDefaultSet<String>> result = new HashMap<String, CmsDefaultSet<String>>();
        for (I_CmsResourceType resType : getResourceTypes()) {
            if (resType instanceof CmsResourceTypeXmlContent) {
                String schema = null;
                try {
                    schema = ((CmsResourceTypeXmlContent)resType).getSchema();
                    if (schema != null) {
                        CmsXmlContentDefinition contentDefinition = CmsXmlContentDefinition.unmarshal(cms, schema);

                        CmsDefaultSet<String> allowedContexts = contentDefinition.getContentHandler().getAllowedTemplates();
                        result.put(resType.getTypeName(), allowedContexts);
                    } else {
                        LOG.info(
                            "No schema for XML type " + resType.getTypeName() + " / " + resType.getClass().getName());
                    }
                } catch (Exception e) {
                    LOG.error(
                        "Error in getAllowedContextMap, schema="
                            + schema
                            + ", type="
                            + resType.getTypeName()
                            + ", "
                            + e.getLocalizedMessage(),
                        e);
                }
            }
        }
        return result;
    }
1093317
public void configureWebApp() throws Exception
    {
        Set tlds = new HashSet();
        
        // Find tld's from web.xml
        // When the XMLConfigurator (or other configurator) parsed the web.xml,
        // It should have created aliases for all TLDs.  So search resources aliases
        // for aliases ending in tld
        if (_context.getResourceAliases()!=null)
        {
            Iterator iter=_context.getResourceAliases().values().iterator();
            while(iter.hasNext())
            {
                String location = (String)iter.next();
                if (location!=null && location.toLowerCase().endsWith(".tld"))
                {
                    if (!location.startsWith("/"))
                        location="/WEB-INF/"+location;
                    Resource l=_context.getBaseResource().addPath(location);
                    tlds.add(l);
                }
            }
        }
        
        // Look for any tlds in WEB-INF directly.
        if (_context.getWebInf()!=null)
        {
            String[] contents = _context.getWebInf().list();
            for (int i=0;i<contents.length;i++)
            {
                if (contents[i]!=null && contents[i].toLowerCase().endsWith(".tld"))
                {
                    Resource l=_context.getWebInf().addPath(contents[i]);
                    tlds.add(l);
                }
                
            }

            // Look for any tlds in the META-INF of included jars
            Resource lib=_context.getWebInf().addPath("lib/");
            if (lib.exists() && lib.isDirectory())
            {
                contents = lib.list();
                for (int i=0;i<contents.length;i++)
                {
                    if (contents[i]!=null && contents[i].toLowerCase().endsWith(".jar"))
                    {
                        Resource l=lib.addPath(contents[i]);
                        Resource meta=Resource.newResource("jar:"+l+"!/META-INF/");
                        if (meta.exists())
                        {
                            String[] meta_contents=meta.list();
                            
                            for (int j=0;j<meta_contents.length;j++)
                            {
                                if (meta_contents[j]!=null && meta_contents[j].toLowerCase().endsWith(".tld"))
                                {
                                    Resource t=meta.addPath(meta_contents[j]);
                                    tlds.add(t);
                                }
                            }
                        }
                    }
                }
            }
        }
        
        // Create a TLD parser
        XmlParser parser = new XmlParser(false);
        
        parser.redirectEntity("web-jsptaglibrary_1_1.dtd",WebApplicationContext.class.getResource("/javax/servlet/jsp/resources/web-jsptaglibrary_1_1.dtd"));
        parser.redirectEntity("web-jsptaglibrary_1_2.dtd",WebApplicationContext.class.getResource("/javax/servlet/jsp/resources/web-jsptaglibrary_1_2.dtd"));
        parser.redirectEntity("web-jsptaglibrary_2_0.xsd",WebApplicationContext.class.getResource("/javax/servlet/jsp/resources/web-jsptaglibrary_2_0.xsd"));
        parser.setXpath("/taglib/listener/listener-class");
        // Parse all the discovered TLDs
        Iterator iter = tlds.iterator();
        while (iter.hasNext())
        {
            try
            {
                Resource tld = (Resource)iter.next();
                if (log.isDebugEnabled()) log.debug("TLD="+tld);
                
                XmlParser.Node root = parser.parse(tld.getURL());
                
                for (int i=0;i<root.size();i++)
                {
                    Object o=root.get(i);
                    if (o instanceof XmlParser.Node)
                    {
                        XmlParser.Node node = (XmlParser.Node)o;
                        if ("listener".equals(node.getTag()))
                        {
                            String className=node.getString("listener-class",false,true);
                            if (log.isDebugEnabled()) log.debug("listener="+className);
                            
                            try
                            {
                                Class listenerClass=getWebApplicationContext().loadClass(className);
                                EventListener l=(EventListener)listenerClass.newInstance();
                                _context.addEventListener(l);
                            }
                            catch(Exception e)
                            {
                                log.warn("Could not instantiate listener "+className,e);
                            }
                        }
                    }
                }
            }
            catch(Exception e)
            {
                log.warn(e);
            }
        }
    }
1217520
protected Context getContext() {
        if (context == null) {
            context = getTomcat().addContext(getConfig().getContextPath(),
                    getConfig().getContextRootDirectory().getAbsolutePath());
        }
        return context;
    }
611873
private Context getContext() {
        Context context = mContext.get();
        if (context == null) {
            throw new IllegalStateException("Context used by the instance has been destroyed.");
        }
        return context;
    }
20541
@Pure
	public static Class<?> getContextClass() throws AndroidException {
		try {
			final ClassLoader loader = ClassLoaderFinder.findClassLoader();
			return Class.forName("android.content.Context", true, loader); //$NON-NLS-1$
		} catch (Throwable e) {
			throw new AndroidException(e);
		}
	}
318028
public static final Map<String, Object> getContext() {
        Map<String, Object> ctx = CTX_HOLDER.get();
        if (ctx == null) {
            return null;
        }
        return ctx;
    }
1231110
@SuppressWarnings("unchecked")
    private static Map<String, String> loadData() {
        final String filePath = "data/cwe.hashmap.serialized";
        try (InputStream input = FileUtils.getResourceAsStream(filePath);
                ObjectInputStream oin = new ObjectInputStream(input)) {
            return (HashMap<String, String>) oin.readObject();
        } catch (ClassNotFoundException ex) {
            LOGGER.warn("Unable to load CWE data. This should not be an issue.");
            LOGGER.debug("", ex);
        } catch (IOException ex) {
            LOGGER.warn("Unable to load CWE data due to an IO Error. This should not be an issue.");
            LOGGER.debug("", ex);
        }
        return null;
    }
352303
public static Map<String, String> getKeywordMap(ApplicationContext context) {
        Map<String, String> keywordToBeanMap = new HashMap<String, String>();

        // Retrieve beans implementing the Keyword interface.
        String[] beanNames = context.getBeanNamesForType(Keyword.class);

        for (String beanName : beanNames) {
            Object bean = context.getBean(beanName);

            // Retrieve keyword information
            KeywordInfo keywordInfo = AnnotationUtils.findAnnotation(bean.getClass(), KeywordInfo.class);

            // Set keyword name as specified in the keyword info, or if information is not available, use bean name.
            String keywordName = keywordInfo != null ? keywordInfo.name() : beanName;

            if (keywordToBeanMap.put(keywordName, beanName) != null) {
                // If map already contains the keyword name, throw an exception. Keywords should be unique.
                throw new RuntimeException("Multiple definitions for keyword '" + keywordName + "' exists.");
            }
        }

        return keywordToBeanMap;
    }
882119
protected Configuration[] loadConfigurations() throws Exception
    {
        String[] names = _configurationClassNames;
        
        //if this webapp does not have its own set of configurators, use the defaults
        if (null==names)
            names = ((Server)getHttpServer()).getWebApplicationConfigurationClassNames();
        
        if (null!=names)
        {
            //instantiate instances for each
            Object[] nullArgs = new Object[0];
            Configuration[] configurations = new Configuration[names.length];
            for (int i=0; i< names.length; i++)
            {
                configurations[i] =
                    (Configuration)Loader.loadClass(WebApplicationContext.class, names[i]).getConstructors()[0].newInstance(nullArgs);
                if (log.isDebugEnabled()){log.debug("Loaded instance of "+names[i]);};
            }
            return configurations;
        }
        else
            return new Configuration[0];
    }
861181
public Object getObject() throws Exception {
        if (ldapOperations==null) {
            throw new FactoryBeanNotInitializedException("contextSource ldapOperations property has not been set");
        }
        if (managedClasses==null) {        
            throw new FactoryBeanNotInitializedException("managedClasses property has not been set");
        }
        if (converterManager==null) {        
            throw new FactoryBeanNotInitializedException("converterManager property has not been set");
        }
        
        return new OdmManagerImpl(converterManager, ldapOperations, managedClasses);
    }
121786
public ServletContext getCurrentServletContext() {
        final ClassLoader cl = getContextClassLoader();
        if (cl == null) {
            return null;
        }
        return servletContexts.get(cl);
    }
512340
protected Map<String, Map<String, Object>> getContexts() {
        Map<String, Map<String, Object>> contexts = new HashMap<>();
        Map<String, Object> deviceMap = new HashMap<>();
        Map<String, Object> osMap     = new HashMap<>();
        Map<String, Object> appMap    = new HashMap<>();
        contexts.put("os",     osMap);
        contexts.put("device", deviceMap);
        contexts.put("app", appMap);

        // Device
        deviceMap.put("manufacturer",          Build.MANUFACTURER);
        deviceMap.put("brand",                 Build.BRAND);
        deviceMap.put("model",                 Build.MODEL);
        deviceMap.put("family",                getFamily());
        deviceMap.put("model_id",              Build.ID);
        deviceMap.put("battery_level",         getBatteryLevel(ctx));
        deviceMap.put("orientation",           getOrientation(ctx));
        deviceMap.put("simulator",             IS_EMULATOR);
        deviceMap.put("arch",                  Build.CPU_ABI);
        deviceMap.put("storage_size",          getTotalInternalStorage());
        deviceMap.put("free_storage",          getUnusedInternalStorage());
        deviceMap.put("external_storage_size", getTotalExternalStorage());
        deviceMap.put("external_free_storage", getUnusedExternalStorage());
        deviceMap.put("charging",              isCharging(ctx));
        deviceMap.put("online",                isConnected(ctx));

        DisplayMetrics displayMetrics = getDisplayMetrics(ctx);
        if (displayMetrics != null) {
            int largestSide   = Math.max(displayMetrics.widthPixels, displayMetrics.heightPixels);
            int smallestSide  = Math.min(displayMetrics.widthPixels, displayMetrics.heightPixels);
            String resolution = Integer.toString(largestSide) + "x" + Integer.toString(smallestSide);
            deviceMap.put("screen_resolution", resolution);
            deviceMap.put("screen_density",    displayMetrics.density);
            deviceMap.put("screen_dpi",        displayMetrics.densityDpi);
        }

        ActivityManager.MemoryInfo memInfo = getMemInfo(ctx);
        if (memInfo != null) {
            deviceMap.put("free_memory", memInfo.availMem);
            if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
                deviceMap.put("memory_size", memInfo.totalMem);
            }
            deviceMap.put("low_memory",  memInfo.lowMemory);
        }

        // Operating System
        osMap.put("name",           "Android");
        osMap.put("version",        Build.VERSION.RELEASE);
        osMap.put("build",          Build.DISPLAY);
        osMap.put("kernel_version", KERNEL_VERSION);
        osMap.put("rooted",         isRooted());

        // App
        PackageInfo packageInfo = getPackageInfo(ctx);
        if (packageInfo != null) {
            appMap.put("app_version", packageInfo.versionName);
            appMap.put("app_build", packageInfo.versionCode);
            appMap.put("app_identifier", packageInfo.packageName);
        }

        appMap.put("app_name", getApplicationName(ctx));
        appMap.put("app_start_time", stringifyDate(new Date()));

        return contexts;
    }
1093159
protected Map<String, RabbitmqClusterContext> initContextMap(
            List<RabbitmqClusterContext> contextList) throws RabbitmqCommunicateException
    {
        if (contextList.size() == 0)
        {
            String message = "RabbitMqClusterContext is empty.";
            throw new RabbitmqCommunicateException(message);
        }

        Map<String, RabbitmqClusterContext> contextMap = new HashMap<String, RabbitmqClusterContext>();

        for (RabbitmqClusterContext context : contextList)
        {
            for (String queueName : context.getQueueList())
            {
                //定義したキュー名が一意でない場合、エラーを出力する。
                if (contextMap.containsKey(queueName))
                {
                    String messageFmt = "QueueName is not unique. QueueName={0}";
                    String message = MessageFormat.format(messageFmt, queueName);
                    throw new RabbitmqCommunicateException(message);
                }

                contextMap.put(queueName, context);
            }
        }
        return contextMap;
    }
855633
public ContextItems getMarshaledContext() {
        ContextItems marshaledContext = new ContextItems();

        for (IManagedContext<?> managedContext : managedContexts) {
            marshaledContext.addItems(managedContext.getContextItems(false));
        }

        return marshaledContext;
    }
754368
protected void loadCacheMapping() {
		File f = new File(getCacheFilePath());
		if (f.exists()) {
			try(InputStream is = new FileInputStream(f); BufferedReader rd = new BufferedReader(new FileReader(f))) {
				cacheProperties.load(is);
				for (Enumeration<?> properyNames = cacheProperties.propertyNames(); properyNames.hasMoreElements();) {
					String propName = (String) properyNames.nextElement();
					if (propName.startsWith(JAWR_MAPPING_PREFIX)) {

						String value = cacheProperties.getProperty(propName);

						String resourceMapping = propName.substring(JAWR_MAPPING_PREFIX.length());
						String[] mappings = value.split(SEMICOLON);
						List<FilePathMapping> fMappings = new CopyOnWriteArrayList<>();

						// TODO check the use of mappingModified
						boolean mappingModified = true;
						for (String fmapping : mappings) {
							String[] mapping = fmapping.split(MAPPING_TIMESTAMP_SEPARATOR);
							long lastModified = Long.parseLong(mapping[1]);
							String filePath = mapping[0];
							if (rsHandler.getLastModified(filePath) != lastModified) {
								mappingModified = false;
								break;
							}
							FilePathMapping fmap = new FilePathMapping(filePath, lastModified);
							fMappings.add(fmap);
						}

						if (mappingModified) {
							linkedResourceMap.put(resourceMapping, fMappings);
						}
					}
				}

			} catch (IOException e) {
				throw new BundlingProcessException("Unable to initialize " + getName() + " Generator cache", e);
			}
		}
	}