Package javolution.util

Examples of javolution.util.FastMap


    }

    /** Gets a FastMap of request mappings. */
    public static Map loadRequestMap(Element root, URL xml) {
        long startTime = System.currentTimeMillis();
        FastMap map = FastMap.newInstance();
        if (root == null) {
            root = loadDocument(xml);
        }

        if (root == null) return map;

        List includeElementList = UtilXml.childElementList(root, INCLUDE);
        Iterator includeElementIter = includeElementList.iterator();
        while (includeElementIter.hasNext()) {
            Element includeElement = (Element) includeElementIter.next();
            String includeLocation = includeElement.getAttribute(INCLUDE_LOCATION);
            if ((includeLocation != null) && (includeLocation.length() > 0)) {
                try {
                    Map subMap = loadRequestMap(null, FlexibleLocation.resolveLocation(includeLocation));
                    map.putAll(subMap);
                } catch (MalformedURLException mue) {
                    Debug.logError(mue, "Error processing include at [" + includeLocation + "]:" + mue.toString(), module);
                }
            }
        }

        List requestMapElementList = UtilXml.childElementList(root, REQUEST_MAPPING);
        Iterator requestMapElementIter = requestMapElementList.iterator();
        while (requestMapElementIter.hasNext()) {
            Element requestMapElement = (Element) requestMapElementIter.next();
           
            // Create a URI-MAP for each element found.
            FastMap uriMap = FastMap.newInstance();

            // Get the URI info.
            String uri = requestMapElement.getAttribute(REQUEST_URI);
            String edit = requestMapElement.getAttribute(REQUEST_EDIT);

            if (edit == null || edit.equals(""))
                edit = "true";
            if (uri != null) {
                uriMap.put(REQUEST_URI, uri);
                uriMap.put(REQUEST_EDIT, edit);
            }

            // Check for security.
            Element securityElement = UtilXml.firstChildElement(requestMapElement, SECURITY);
            if (securityElement != null) {
                String securityHttps = securityElement.getAttribute(SECURITY_HTTPS);
                String securityAuth = securityElement.getAttribute(SECURITY_AUTH);
                String securityCert = securityElement.getAttribute(SECURITY_CERT);
                String securityExtView = securityElement.getAttribute(SECURITY_EXTVIEW);
                String securityDirectRequest = securityElement.getAttribute(SECURITY_DIRECT);

                // if x509 is required so is https
                if ("true".equalsIgnoreCase(securityCert)) {
                    securityHttps = "true";
                }
               
                uriMap.put(SECURITY_HTTPS, securityHttps);
                uriMap.put(SECURITY_AUTH, securityAuth);
                uriMap.put(SECURITY_CERT, securityCert);              
                uriMap.put(SECURITY_EXTVIEW, securityExtView);
                uriMap.put(SECURITY_DIRECT, securityDirectRequest);
            }

            // Check for an event.
            Element eventElement = UtilXml.firstChildElement(requestMapElement, EVENT);
            if (eventElement != null) {
                String type = eventElement.getAttribute(EVENT_TYPE);
                String path = eventElement.getAttribute(EVENT_PATH);
                String invoke = eventElement.getAttribute(EVENT_METHOD);

                uriMap.put(EVENT_TYPE, type);
                uriMap.put(EVENT_PATH, path);
                uriMap.put(EVENT_METHOD, invoke);
               
                // Check for a global-transaction attribute - default to true
                uriMap.put(EVENT_GLOBAL_TRANSACTION, eventElement.hasAttribute(EVENT_GLOBAL_TRANSACTION) ? eventElement.getAttribute(EVENT_GLOBAL_TRANSACTION) : "true");
            }

            // Check for a description.
            String description = UtilXml.childElementValue(requestMapElement, REQUEST_DESCRIPTION);
            uriMap.put(REQUEST_DESCRIPTION, UtilValidate.isNotEmpty(description) ? description : "");

            // Get the response(s).
            List responseElementList = UtilXml.childElementList(requestMapElement, RESPONSE);
            Iterator responseElementIter = responseElementList.iterator();
            while (responseElementIter.hasNext()) {
                Element responseElement = (Element) responseElementIter.next();
                String name = responseElement.getAttribute(RESPONSE_NAME);
                String type = responseElement.getAttribute(RESPONSE_TYPE);
                String value = responseElement.getAttribute(RESPONSE_VALUE);
                uriMap.put(name, type + ":" + value);
            }

            if (uri != null) {
                map.put(uri, uriMap);
            }
View Full Code Here


    }

    /** Gets a FastMap of view mappings. */
    public static Map loadViewMap(Element root, URL xml) {
        long startTime = System.currentTimeMillis();
        FastMap map = FastMap.newInstance();
        if (root == null) {
            root = loadDocument(xml);
        }

        if (root == null) {
            return map;
        }

        List includeElementList = UtilXml.childElementList(root, INCLUDE);
        Iterator includeElementIter = includeElementList.iterator();
        while (includeElementIter.hasNext()) {
            Element includeElement = (Element) includeElementIter.next();
            String includeLocation = includeElement.getAttribute(INCLUDE_LOCATION);
            if ((includeLocation != null) && (includeLocation.length() > 0)) {
                try {
                    Map subMap = loadViewMap(null, FlexibleLocation.resolveLocation(includeLocation));
                    map.putAll(subMap);
                } catch (MalformedURLException mue) {
                    Debug.logError(mue, "Error processing include at [" + includeLocation + "]:" + mue.toString(), module);
                }
            }
        }

        List viewMapElementList = UtilXml.childElementList(root, VIEW_MAPPING);
        Iterator viewMapElementIter = viewMapElementList.iterator();
        while (viewMapElementIter.hasNext()) {
            Element viewMapElement = (Element) viewMapElementIter.next();
            // Create a URI-MAP for each element found.
            FastMap uriMap = FastMap.newInstance();

            // Get the view info.
            String name = viewMapElement.getAttribute(VIEW_NAME);
            String page = viewMapElement.getAttribute(VIEW_PAGE);
            if (page == null || page.length() == 0) {
                page = name;
            }

            uriMap.put(VIEW_NAME, name);
            uriMap.put(VIEW_PAGE, page);
            uriMap.put(VIEW_TYPE, viewMapElement.getAttribute(VIEW_TYPE));
            uriMap.put(VIEW_INFO, viewMapElement.getAttribute(VIEW_INFO));
            uriMap.put(VIEW_CONTENT_TYPE, viewMapElement.getAttribute(VIEW_CONTENT_TYPE));
            uriMap.put(VIEW_ENCODING, viewMapElement.getAttribute(VIEW_ENCODING));

            // Check for a description.
            String description = UtilXml.childElementValue(viewMapElement, VIEW_DESCRIPTION);
            uriMap.put(VIEW_DESCRIPTION, UtilValidate.isNotEmpty(description) ? description : "");

            if (name != null) map.put(name, uriMap);
        }

        /* Debugging */
 
View Full Code Here

    }

    /** Gets a FastMap of site configuration variables. */
    public static Map loadConfigMap(Element root, URL xml) {
        long startTime = System.currentTimeMillis();
        FastMap map = FastMap.newInstance();
        if (root == null) {
            root = loadDocument(xml);
        }
       
        if (root == null) {
            return map;
        }

        List includeElementList = UtilXml.childElementList(root, INCLUDE);
        Iterator includeElementIter = includeElementList.iterator();
        while (includeElementIter.hasNext()) {
            Element includeElement = (Element) includeElementIter.next();
            String includeLocation = includeElement.getAttribute(INCLUDE_LOCATION);
            if ((includeLocation != null) && (includeLocation.length() > 0)) {
                try {
                    Map subMap = loadConfigMap(null, FlexibleLocation.resolveLocation(includeLocation));
                    map.putAll(subMap);
                } catch (MalformedURLException mue) {
                    Debug.logError(mue, "Error processing include at [" + includeLocation + "]:" + mue.toString(), module);
                }
            }
        }

        // default error page
        String errorpage = UtilXml.childElementValue(root, DEFAULT_ERROR_PAGE);
        if (UtilValidate.isNotEmpty(errorpage)) map.put(DEFAULT_ERROR_PAGE, errorpage);

        // site owner
        String owner = UtilXml.childElementValue(root, SITE_OWNER);
        if (UtilValidate.isNotEmpty(owner)) map.put(SITE_OWNER, owner);

        // security class
        String securityClass = UtilXml.childElementValue(root, SECURITY_CLASS);
        if (UtilValidate.isNotEmpty(securityClass)) map.put(SECURITY_CLASS, securityClass);

        // first visit event
        Element firstvisitElement = UtilXml.firstChildElement(root, FIRSTVISIT);
        if (firstvisitElement != null) {
            List eventList = FastList.newInstance();
            List eventElementList = UtilXml.childElementList(firstvisitElement, EVENT);
            Iterator eventElementIter = eventElementList.iterator();
            while (eventElementIter.hasNext()) {
                Element eventElement = (Element) eventElementIter.next();
                FastMap eventMap = FastMap.newInstance();
                eventMap.put(EVENT_TYPE, eventElement.getAttribute(EVENT_TYPE));
                eventMap.put(EVENT_PATH, eventElement.getAttribute(EVENT_PATH));
                eventMap.put(EVENT_METHOD, eventElement.getAttribute(EVENT_METHOD));
           
                // Check for a global-transaction attribute - default to true
                eventMap.put(EVENT_GLOBAL_TRANSACTION, eventElement.hasAttribute(EVENT_GLOBAL_TRANSACTION) ? eventElement.getAttribute(EVENT_GLOBAL_TRANSACTION) : "true");
                eventList.add(eventMap);
            }
            map.put(FIRSTVISIT, eventList);
        }

        // preprocessor events
        Element preprocessorElement = UtilXml.firstChildElement(root, PREPROCESSOR);
        if (preprocessorElement != null) {
            List eventList = FastList.newInstance();
            List eventElementList = UtilXml.childElementList(preprocessorElement, EVENT);
            Iterator eventElementIter = eventElementList.iterator();
            while (eventElementIter.hasNext()) {
                Element eventElement = (Element) eventElementIter.next();
                FastMap eventMap = FastMap.newInstance();
                eventMap.put(EVENT_TYPE, eventElement.getAttribute(EVENT_TYPE));
                eventMap.put(EVENT_PATH, eventElement.getAttribute(EVENT_PATH));
                eventMap.put(EVENT_METHOD, eventElement.getAttribute(EVENT_METHOD));
           
                // Check for a global-transaction attribute - default to true
                eventMap.put(EVENT_GLOBAL_TRANSACTION, eventElement.hasAttribute(EVENT_GLOBAL_TRANSACTION) ? eventElement.getAttribute(EVENT_GLOBAL_TRANSACTION) : "true");
                eventList.add(eventMap);
            }
            map.put(PREPROCESSOR, eventList);
        }

        // postprocessor events
        Element postprocessorElement = UtilXml.firstChildElement(root, POSTPROCESSOR);
        if (postprocessorElement != null) {
            List eventList = FastList.newInstance();
            List eventElementList = UtilXml.childElementList(postprocessorElement, EVENT);
            Iterator eventElementIter = eventElementList.iterator();
            while (eventElementIter.hasNext()) {
                Element eventElement = (Element) eventElementIter.next();
                FastMap eventMap = FastMap.newInstance();
                eventMap.put(EVENT_TYPE, eventElement.getAttribute(EVENT_TYPE));
                eventMap.put(EVENT_PATH, eventElement.getAttribute(EVENT_PATH));
                eventMap.put(EVENT_METHOD, eventElement.getAttribute(EVENT_METHOD));
           
                // Check for a global-transaction attribute - default to true
                eventMap.put(EVENT_GLOBAL_TRANSACTION, eventElement.hasAttribute(EVENT_GLOBAL_TRANSACTION) ? eventElement.getAttribute(EVENT_GLOBAL_TRANSACTION) : "true");
                eventList.add(eventMap);
            }
            map.put(POSTPROCESSOR, eventList);
        }

        // after-login events
        Element afterLoginElement = UtilXml.firstChildElement(root, "after-login");
        if (afterLoginElement != null) {
            List eventList = FastList.newInstance();
            List eventElementList = UtilXml.childElementList(afterLoginElement, EVENT);
            Iterator eventElementIter = eventElementList.iterator();
            while (eventElementIter.hasNext()) {
                Element eventElement = (Element) eventElementIter.next();
                FastMap eventMap = FastMap.newInstance();
                eventMap.put(EVENT_TYPE, eventElement.getAttribute(EVENT_TYPE));
                eventMap.put(EVENT_PATH, eventElement.getAttribute(EVENT_PATH));
                eventMap.put(EVENT_METHOD, eventElement.getAttribute(EVENT_METHOD));
           
                // Check for a global-transaction attribute - default to true
                eventMap.put(EVENT_GLOBAL_TRANSACTION, eventElement.hasAttribute(EVENT_GLOBAL_TRANSACTION) ? eventElement.getAttribute(EVENT_GLOBAL_TRANSACTION) : "true");
                eventList.add(eventMap);
            }
            map.put("after-login", eventList);
        }

        // before-logout events
        Element beforeLogoutElement = UtilXml.firstChildElement(root, "before-logout");
        if (beforeLogoutElement != null) {
            List eventList = FastList.newInstance();
            List eventElementList = UtilXml.childElementList(beforeLogoutElement, EVENT);
            Iterator eventElementIter = eventElementList.iterator();
            while (eventElementIter.hasNext()) {
                Element eventElement = (Element) eventElementIter.next();
                FastMap eventMap = FastMap.newInstance();
                eventMap.put(EVENT_TYPE, eventElement.getAttribute(EVENT_TYPE));
                eventMap.put(EVENT_PATH, eventElement.getAttribute(EVENT_PATH));
                eventMap.put(EVENT_METHOD, eventElement.getAttribute(EVENT_METHOD));
           
                // Check for a global-transaction attribute - default to true
                eventMap.put(EVENT_GLOBAL_TRANSACTION, eventElement.hasAttribute(EVENT_GLOBAL_TRANSACTION) ? eventElement.getAttribute(EVENT_GLOBAL_TRANSACTION) : "true");
                eventList.add(eventMap);
            }
            map.put("before-logout", eventList);
        }

View Full Code Here

        return controllerConfig != null ? controllerConfig.handlerMap : null;
    }

    public static Map loadHandlerMap(Element root, URL xml) {
        long startTime = System.currentTimeMillis();
        FastMap map = FastMap.newInstance();
        if (root == null) {
            root = loadDocument(xml);
        }
        if (root == null) {
            return map;
        }

        List includeElementList = UtilXml.childElementList(root, INCLUDE);
        Iterator includeElementIter = includeElementList.iterator();
        while (includeElementIter.hasNext()) {
            Element includeElement = (Element) includeElementIter.next();
            String includeLocation = includeElement.getAttribute(INCLUDE_LOCATION);
            if ((includeLocation != null) && (includeLocation.length() > 0)) {
                try {
                    Map subMap = loadHandlerMap(null, FlexibleLocation.resolveLocation(includeLocation));

                    Map newViewHandlerMap = (Map) subMap.get("view");
                    Map viewHandlerMap = (Map) map.get("view");
                    if (viewHandlerMap == null) {
                        map.put("view", newViewHandlerMap);
                    } else {
                        if (newViewHandlerMap != null) {
                            viewHandlerMap.putAll(newViewHandlerMap);
                        }
                    }

                    Map newEventHandlerMap = (Map) subMap.get("event");
                    Map eventHandlerMap = (Map) map.get("event");
                    if (eventHandlerMap == null) {
                        map.put("event", newEventHandlerMap);
                    } else {
                        if (newEventHandlerMap != null) {
                            eventHandlerMap.putAll(newEventHandlerMap);
                        }
                    }
                } catch (MalformedURLException mue) {
                    Debug.logError(mue, "Error processing include at [" + includeLocation + "]:" + mue.toString(), module);
                }
            }
        }

        Map eventMap = FastMap.newInstance();
        Map viewMap = FastMap.newInstance();

        List handlerElementList = UtilXml.childElementList(root, HANDLER);
        Iterator handlerElementIter = handlerElementList.iterator();
        while (handlerElementIter.hasNext()) {
            Element handlerElement = (Element) handlerElementIter.next();
            String hName = checkEmpty(handlerElement.getAttribute(HANDLER_NAME));
            String hClass = checkEmpty(handlerElement.getAttribute(HANDLER_CLASS));
            String hType = checkEmpty(handlerElement.getAttribute(HANDLER_TYPE));
            if (hType.equals("view")) {
                viewMap.put(hName, hClass);
            } else {
                eventMap.put(hName, hClass);
            }
        }

        Map viewHandlerMap = (Map) map.get("view");
        if (viewHandlerMap == null) {
            map.put("view", viewMap);
        } else {
            if (viewMap != null) {
                viewHandlerMap.putAll(viewMap);
            }
        }
        Map eventHandlerMap = (Map) map.get("event");
        if (eventHandlerMap == null) {
            map.put("event", eventMap);
        } else {
            if (eventMap != null) {
                eventHandlerMap.putAll(eventMap);
            }
        }

        /* Debugging */
        if (Debug.verboseOn()) {
            Debug.logVerbose("-------- Handler Mappings --------", module);
            Map debugMap = (Map) map.get("event");

            if (debugMap != null && debugMap.size() > 0) {
                Debug.logVerbose("-------------- EVENT -------------", module);
                Set debugSet = debugMap.keySet();
                Iterator i = debugSet.iterator();
                while (i.hasNext()) {
                    Object o = i.next();
                    String handlerName = (String) o;
                    String className = (String) debugMap.get(o);
                    Debug.logVerbose("[EH] : " + handlerName + " => " + className, module);
                }
            }
            debugMap = (Map) map.get("view");
            if (debugMap != null && debugMap.size() > 0) {
                Debug.logVerbose("-------------- VIEW --------------", module);
                Set debugSet = debugMap.keySet();
                Iterator i = debugSet.iterator();
                while (i.hasNext()) {
                    Object o = i.next();
                    String handlerName = (String) o;
                    String className = (String) debugMap.get(o);
                    Debug.logVerbose("[VH] : " + handlerName + " => " + className, module);
                }
            }
            Debug.logVerbose("------ End Handler Mappings ------", module);
        }

        double totalSeconds = (System.currentTimeMillis() - startTime)/1000.0;
        if (Debug.infoOn()) Debug.logInfo("HandlerMap Created: (" + ((Map) map.get("view")).size() + ") view handlers and (" + ((Map) map.get("event")).size() + ") request/event handlers in " + totalSeconds + "s", module);
        return map;
    }
View Full Code Here

            rootElement = ServiceConfigUtil.getXmlRootElement();
        } catch (GenericConfigException e) {
            Debug.logError(e, "Error getting Service Engine XML root element", module);
        }

        FastMap engineNotifyMap = FastMap.newInstance();

        List nGroups = UtilXml.childElementList(rootElement, "notification-group");
        Iterator i = nGroups.iterator();
        while (i.hasNext()) {
            Element e = (Element) i.next();
            NotificationGroup ng = new NotificationGroup(e);
            engineNotifyMap.put(ng.getName(), ng);
        }

        notificationGroupCache.put(engine, engineNotifyMap);
    }
View Full Code Here

TOP

Related Classes of javolution.util.FastMap

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.