com.googlecode.fascinator.portal.services.impl
Class VelocityServiceImpl

java.lang.Object
  extended by com.googlecode.fascinator.portal.services.impl.VelocityServiceImpl
All Implemented Interfaces:
VelocityService

public class VelocityServiceImpl
extends Object
implements VelocityService

Velocity service implementation with skinning support.

Author:
Oliver Lucido

Constructor Summary
VelocityServiceImpl(PortalManager portalManager, DynamicPageCache pageCache)
          Construct and configure the Velocity service.
 
Method Summary
 InputStream getResource(String resourcePath)
          Gets a Velocity resource.
 InputStream getResource(String portalId, String resourceName)
          Gets a Velocity resource.
 void renderTemplate(String portalId, String templateName, org.apache.velocity.context.Context context, Writer writer)
          Renders a Velocity template with the given context.
 String resourceExists(String portalId, String resourceName)
          Resolves the given resource to a valid Velocity resource if possible.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

VelocityServiceImpl

public VelocityServiceImpl(PortalManager portalManager,
                           DynamicPageCache pageCache)
Construct and configure the Velocity service.

Parameters:
portalManager - PortalManager instance
pageCache - DynamicPageCache instance
Method Detail

getResource

public InputStream getResource(String resourcePath)
Gets a Velocity resource.

Specified by:
getResource in interface VelocityService
Parameters:
resourcePath - valid Velocity resource path
Returns:
resource stream or null if not found

getResource

public InputStream getResource(String portalId,
                               String resourceName)
Gets a Velocity resource. The resourcePath is resolved given the portalId and resourceName, as well as taking into account the skin priority.

Specified by:
getResource in interface VelocityService
Parameters:
portalId - the portal to get the resource from
resourceName - the resource to get
Returns:
resource stream or null if not found

resourceExists

public String resourceExists(String portalId,
                             String resourceName)
Resolves the given resource to a valid Velocity resource if possible.

Specified by:
resourceExists in interface VelocityService
Parameters:
portalId - the portal to get the resource from
resourceName - the resource to check
Returns:
a valid Velocity resource path or null if not found

renderTemplate

public void renderTemplate(String portalId,
                           String templateName,
                           org.apache.velocity.context.Context context,
                           Writer writer)
                    throws Exception
Renders a Velocity template with the given context.

Specified by:
renderTemplate in interface VelocityService
Parameters:
portalId - the portal to render the resource from
templateName - the template to render
context - the Velocity context to render
writer - a writer to output the render result to
Throws:
Exception - if an error occurred while rendering the template


Copyright © 2009-2011. All Rights Reserved.