Package com.sun.appserv.web.cache.mapping

Examples of com.sun.appserv.web.cache.mapping.CacheMapping


        // cache-mappings are ordered by the associated filter name
        Iterator filterNames = cacheMappings.keySet().iterator();
        while(filterNames.hasNext()) {
            String name = (String) filterNames.next();
            CacheMapping mapping = (CacheMapping)cacheMappings.get(name);

            String helperNameRef = mapping.getHelperNameRef();
            CacheHelper helper;
            if (helperNameRef == null || helperNameRef.equals("default")) {
                helper = defaultHelper;
            } else {
                helper = (CacheHelper) cacheHelpers.get(helperNameRef);
View Full Code Here


     *  the request; all key field names must be found in the appropriate scope.
     */
    public String getCacheKey(HttpServletRequest request) {

        // cache mapping associated with the request
        CacheMapping mapping = lookupCacheMapping(request);

        if (isKeyGeneratorChecked == false && attrKeyGenerator != null) {
            try {
                keyGenerator = (CacheKeyGenerator)
                                context.getAttribute(attrKeyGenerator);
            } catch (ClassCastException cce){
                _logger.log(Level.WARNING, "cache.defaultHelp.illegalKeyGenerator", cce);
            }

            isKeyGeneratorChecked = true;
        }

        if (keyGenerator != null) {
            String key = keyGenerator.getCacheKey(context, request);
            if (key != null)
                return key;
        }

        StringBuffer sb = new StringBuffer(128);

        /** XXX: the StringBuffer append is a (uncontended) synchronized method.
         *  performance hit?
         */
        sb.append(request.getServletPath());

        // append the key fields
        Field[] keys = mapping.getKeyFields();
        for (int i = 0; i < keys.length; i++) {
            Object value = keys[i].getValue(context, request);

            // all defined key field must be present
            if (value == null) {
View Full Code Here

     */
    public boolean isCacheable(HttpServletRequest request) {
        boolean result = false;

        // cache mapping associated with the request
        CacheMapping mapping = lookupCacheMapping(request);

        // check if the method is in the allowed methods list
        if (mapping.findMethod(request.getMethod())) {
            result = true;

            ConstraintField fields[] = mapping.getConstraintFields();
            // apply all the constraints
            for (int i = 0; i < fields.length; i++) {
                if (!fields[i].applyConstraints(context, request)) {
                    result = false;
                    break;
View Full Code Here

     */
    public boolean isRefreshNeeded(HttpServletRequest request) {
        boolean result = false;

        // cache mapping associated with the request
        CacheMapping mapping = lookupCacheMapping(request);
        Field field = mapping.getRefreshField();
        if (field != null) {
            Object value = field.getValue(context, request);
            // the field's string representation must be "true" or "false"
            if (value != null && "true".equals(value.toString())) {
                result = true;
View Full Code Here

     *  fields. If not specified, get the timeout defined for the
     *  cache element.
     */
    public int getTimeout(HttpServletRequest request) {
        // cache mapping associated with the request
        CacheMapping mapping = lookupCacheMapping(request);

        // get the statically configured value, if any
        int result = mapping.getTimeout();

        // if the field is not defined, return the configured value
        Field field = mapping.getTimeoutField();
        if (field != null) {
            Object value = field.getValue(context, request);
            if (value != null) {
                try {
                    // Integer type timeout object
View Full Code Here

        // for each cache-mapping, create CacheMapping, setup the filter
        for (int i = 0; i < cacheConfig.sizeCacheMapping(); i++) {
            com.sun.enterprise.deployment.runtime.web.CacheMapping
                            mapConfig = cacheConfig.getCacheMapping(i);
           
            CacheMapping mapping = new CacheMapping();
            configureCacheMapping(mapConfig, mapping, logger);

            // use filter's name to refer to setup the filter
            String filterName = CACHING_FILTER_CLASSNAME + i;

            /**
             * all cache-mapings are indexed by the unique filter-name;
             * DefaultCacheHelper uses this name to access the mapping.
             */
            manager.addCacheMapping(filterName, mapping);

            // setup the ias CachingFilter definition with the context
            FilterDef filterDef = new FilterDef();
            filterDef.setFilterName(filterName);
            filterDef.setFilterClass(CACHING_FILTER_CLASSNAME);

            filterDef.addInitParameter("servletName", mapping.getServletName());
            filterDef.addInitParameter("URLPattern", mapping.getURLPattern());
            app.addFilterDef(filterDef);

            // setup the mapping for the specified servlet-name or url-pattern
            FilterMap filterMap = new FilterMap();
            filterMap.setServletName(mapping.getServletName());
            filterMap.setURLPattern(mapping.getURLPattern());
            String[] dispatchers = mapConfig.getDispatcher();
            for (int j=0; dispatchers!=null && j<dispatchers.length; j++) {
                // calls to FilterMap.setDispatcher are cumulative
                filterMap.setDispatcher(dispatchers[j]);
            }
            filterMap.setFilterName(filterName);
            app.addFilterMap(filterMap);

            if (logger.isLoggable(Level.FINE)) {
                logger.fine("added a caching filter for servlet-name = " + mapping.getServletName() + " url-pattern = " + mapping.getURLPattern());
            }
        }
       
        manager.setServletContext(app.getServletContext());
        return manager;
View Full Code Here

        // for each cache-mapping, create CacheMapping, setup the filter
        for (int i = 0; i < cacheConfig.sizeCacheMapping(); i++) {
            org.glassfish.web.deployment.runtime.CacheMapping
                            mapConfig = cacheConfig.getCacheMapping(i);
           
            CacheMapping mapping = new CacheMapping();
            configureCacheMapping(mapConfig, mapping, logger);

            // use filter's name to refer to setup the filter
            String filterName = CACHING_FILTER_CLASSNAME + i;

            /**
             * all cache-mapings are indexed by the unique filter-name;
             * DefaultCacheHelper uses this name to access the mapping.
             */
            manager.addCacheMapping(filterName, mapping);

            // setup the ias CachingFilter definition with the context
            FilterDef filterDef = new FilterDef();
            filterDef.setFilterName(filterName);
            filterDef.setFilterClassName(CACHING_FILTER_CLASSNAME);

            if (mapping.getServletName() != null) {
                filterDef.addInitParameter("servletName",
                                           mapping.getServletName());
            }
            if (mapping.getURLPattern() != null) {
                filterDef.addInitParameter("URLPattern",
                                           mapping.getURLPattern());
            }

            app.addFilterDef(filterDef);

            // setup the mapping for the specified servlet-name or url-pattern
            FilterMap filterMap = new FilterMap();
            filterMap.setServletName(mapping.getServletName());
            filterMap.setURLPattern(mapping.getURLPattern());
            String[] dispatchers = mapConfig.getDispatcher();
            if (dispatchers != null) {
                EnumSet<DispatcherType> dispatcherTypes = null;
                for (String dispatcher : dispatchers) {
                    // calls to FilterMap.setDispatcher are cumulative
                    if (dispatcherTypes == null) {
                        dispatcherTypes = EnumSet.of(
                            Enum.valueOf(DispatcherType.class, dispatcher));
                    } else {
                        dispatcherTypes.add(
                            Enum.valueOf(DispatcherType.class, dispatcher));
                    }
                }
                filterMap.setDispatcherTypes(dispatcherTypes);
            }
            filterMap.setFilterName(filterName);
            app.addFilterMap(filterMap);

            if (logger.isLoggable(Level.FINE)) {
                logger.log(Level.FINE,
                        CACHING_FILTER_ADDED,
                        new Object[] {mapping.getServletName(), mapping.getURLPattern()});
            }
        }
       
        manager.setServletContext(app.getServletContext());
        return manager;
View Full Code Here

     *  the request; all key field names must be found in the appropriate scope.
     */
    public String getCacheKey(HttpServletRequest request) {

        // cache mapping associated with the request
        CacheMapping mapping = lookupCacheMapping(request);

        if (isKeyGeneratorChecked == false && attrKeyGenerator != null) {
            try {
                keyGenerator = (CacheKeyGenerator)
                                context.getAttribute(attrKeyGenerator);
            } catch (ClassCastException cce){
                _logger.log(Level.WARNING, CACHE_DEFAULT_HELP_ILLEGAL_KET_GENERATOR, cce);
            }

            isKeyGeneratorChecked = true;
        }

        if (keyGenerator != null) {
            String key = keyGenerator.getCacheKey(context, request);
            if (key != null)
                return key;
        }

        StringBuilder sb = new StringBuilder(128);
        sb.append(request.getServletPath());

        // append the key fields
        Field[] keys = mapping.getKeyFields();
        for (int i = 0; i < keys.length; i++) {
            Object value = keys[i].getValue(context, request);

            // all defined key field must be present
            if (value == null) {
View Full Code Here

     */
    public boolean isCacheable(HttpServletRequest request) {
        boolean result = false;

        // cache mapping associated with the request
        CacheMapping mapping = lookupCacheMapping(request);

        // check if the method is in the allowed methods list
        if (mapping.findMethod(request.getMethod())) {
            result = true;

            ConstraintField fields[] = mapping.getConstraintFields();
            // apply all the constraints
            for (int i = 0; i < fields.length; i++) {
                if (!fields[i].applyConstraints(context, request)) {
                    result = false;
                    break;
View Full Code Here

     */
    public boolean isRefreshNeeded(HttpServletRequest request) {
        boolean result = false;

        // cache mapping associated with the request
        CacheMapping mapping = lookupCacheMapping(request);
        Field field = mapping.getRefreshField();
        if (field != null) {
            Object value = field.getValue(context, request);
            // the field's string representation must be "true" or "false"
            if (value != null && "true".equals(value.toString())) {
                result = true;
View Full Code Here

TOP

Related Classes of com.sun.appserv.web.cache.mapping.CacheMapping

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.