Package net.sf.jportlet.portlet.descriptor

Examples of net.sf.jportlet.portlet.descriptor.CacheDescriptor


                                  PortletResponseImpl response )
        throws PortletException,
                   IOException
    {
        boolean             debug = _log.isDebugEnabled(  );
        CacheDescriptor     cache = _descriptor.getCacheDescriptor( request.getMode(  ) );
        String              id = getCacheableId( cache, request, response );
        PortletResponseImpl response2 = new PortletResponseImpl( this, request, response.getHttpResponse(  ) );
        String              body = null;
        CacheRegion         region = null;
        Cacheable           cacheable;

        /* Load the body from the cache */
        if ( id != null )
        {
            if ( debug )
            {
                _log.debug( "Loading portlet body from the cache.id=" + id );
            }

            region    = getCacheRegion(  );
            cacheable = region.get( id );
            if ( cacheable != null )
            {
                if ( !isDirty( request ) )
                {
                    if ( debug )
                    {
                        _log.debug( "...Portlet body found in the cache" );
                    }

                    body = ( String ) cacheable.getData(  );
                }
                else
                {
                    if ( debug )
                    {
                        _log.debug( "...Portlet dirty. expiring the portlet body" );
                    }

                    cacheable.expire(  );
                    body = null;
                }
            }
        }
        else
        {
            if ( debug )
            {
                _log.debug( "Caching not supported" );
            }
        }

        if ( body == null )
        {
            /* Generate the body */
            if ( debug )
            {
                _log.debug( "Generating the portlet body" );
            }

            _portlet.service( request, response2 );
            body = response2.getBuffer(  ).toString(  );

            /* Cache the body */
            if ( region != null )
            {
                if ( debug )
                {
                    _log.debug( "...Caching the portlet body" );
                }

                cacheable = new CacheableImpl( id, body, 1000 * cache.getExpires(  ) );
                _cacheRegion.put( cacheable );
            }
        }

        /* Bye */
 
View Full Code Here


        if ( id != null )
        {
            PortletResponseImpl resp = ( PortletResponseImpl ) response;
            PortletDescriptor   descr = proxy.getDescriptor(  );
            CacheDescriptor     cache = descr.getCacheDescriptor( request.getMode(  ) );
            CacheRegion         region = getCacheService( proxy ).getRegion( descr.getName(  ), true );
            CacheableImpl       cacheable = new CacheableImpl( id, resp.getBuffer(  ).toString(  ), 1000 * cache.getExpires(  ) );

            if ( debug )
            {
                __log.debug( "Caching portlet content:" + id );
            }
View Full Code Here

    {
        /* No caching */
        StringBuffer      id = new StringBuffer(  );
        PortletDescriptor descr = proxy.getDescriptor(  );
        Portlet.Mode      mode = request.getMode(  );
        CacheDescriptor   cache = descr.getCacheDescriptor( mode );
        if ( ( cache == null ) || ( cache.getExpires(  ) == 0 ) )
        {
            return null;
        }

        id.append( '/' ).append( mode ).append( '/' ).append( request.getWindow(  ).getState(  ) );

        if ( !cache.isShared(  ) )
        {
            User usr = request.getUser(  );
            if ( usr == null )
            {
                id.append( '/' ).append( ANONYMOUS_ID );
View Full Code Here

        lang = portlet.getLanguageDescriptor( Locale.FRENCH );
        assertNotNull( "lang[fr]", lang );
        assertEquals( "lang[fr].title", "Portlet No1", lang.getTitle(  ) );

        /* Cache */
        CacheDescriptor cache = portlet.getCacheDescriptor( Portlet.Mode.VIEW );
        assertNotNull( "cache[view]", cache );
        assertEquals( "cache[view].expires", 300, cache.getExpires(  ) );
        assertFalse( "cache[view].shared", cache.isShared(  ) );

        cache = portlet.getCacheDescriptor( Portlet.Mode.HELP );
        assertNotNull( "cache[help]", cache );
        assertEquals( "cache[help].expires", -1, cache.getExpires(  ) );
        assertTrue( "cache[help].shared", cache.isShared(  ) );

        /* auth */
        AuthConstraintDescriptor auth = portlet.getAuthConstraintDescriptor( Portlet.Mode.VIEW );
        assertNotNull( "auth[view]", auth );
        assertTrue( "auth[view].allowAnonymous", auth.isAllowAnonymous(  ) );
View Full Code Here

TOP

Related Classes of net.sf.jportlet.portlet.descriptor.CacheDescriptor

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.