CVS: TapestryBook/examples-library/src/java/bannerads/library BannerAds.library,NONE,1.1 BannerService.java,NONE,1.1 BannerAd.jwc,NONE,1.1 IBanner.java,NONE,1.1 IBannerSource.java,NONE,1.1
Howard Lewis Ship <[email protected]> Sun, 13 Jul 2003 15:42:17 -0700
| Newsgroups | gmane.comp.java.tapestry.cvs |
|---|---|
| Message-ID | <[email protected]> |
Update of /cvsroot/tapestry/TapestryBook/examples-library/src/java/bannerads/library
In directory sc8-pr-cvs1:/tmp/cvs-serv3466/examples-library/src/java/bannerads/library
Added Files:
BannerAds.library BannerService.java BannerAd.jwc IBanner.java
IBannerSource.java
Log Message:
Move the examples and bannerads libraries into a new examples-library subproject.
--- NEW FILE: BannerAds.library ---
<?xml version="1.0"?>
<!-- $Id: BannerAds.library,v 1.1 2003/07/13 22:42:14 hship Exp $ -->
<!DOCTYPE library-specification PUBLIC
"-//Apache Software Foundation//Tapestry Specification 3.0//EN"
"http://jakarta.apache.org/tapestry/dtd/Tapestry_3_0.dtd">
<library-specification>
<service name="bannerads.banner" class="bannerads.library.BannerService"/>
</library-specification>
--- NEW FILE: BannerService.java ---
package bannerads.library;
import java.io.IOException;
import javax.servlet.ServletException;
import org.apache.tapestry.IComponent;
import org.apache.tapestry.IRequestCycle;
import org.apache.tapestry.RedirectException;
import org.apache.tapestry.engine.AbstractService;
import org.apache.tapestry.engine.IEngineServiceView;
import org.apache.tapestry.engine.ILink;
import org.apache.tapestry.request.ResponseOutputStream;
public class BannerService extends AbstractService
{
public static final String SERVICE_NAME = "bannerads.banner";
/**
* The lone parameter should be the banner id.
*/
public ILink getLink(IRequestCycle cycle, IComponent component, Object[] parameters)
{
return constructLink(cycle, SERVICE_NAME, null, parameters, false);
}
public void service(
IEngineServiceView engine,
IRequestCycle cycle,
ResponseOutputStream output)
throws ServletException, IOException
{
IBannerSource source =
(IBannerSource) engine.getSpecification().getExtension(
IBannerSource.BANNER_SOURCE_EXTENSION_NAME,
IBannerSource.class);
source.initialize(cycle);
Object[] parameters = getParameters(cycle);
String bannerId = (String) parameters[0];
IBanner banner = source.getBanner(bannerId);
source.recordClickthru(bannerId);
throw new RedirectException(banner.getClickThruURL());
}
public String getName()
{
return SERVICE_NAME;
}
}
--- NEW FILE: BannerAd.jwc ---
<?xml version="1.0"?>
<!-- $Id: BannerAd.jwc,v 1.1 2003/07/13 22:42:14 hship Exp $ -->
<!DOCTYPE component-specification PUBLIC
"-//Apache Software Foundation//Tapestry Specification 3.0//EN"
"http://jakarta.apache.org/tapestry/dtd/Tapestry_3_0.dtd">
<component-specification class="bannerads.library.components.BannerAd"
allow-body="no"
allow-informal-parameters="yes">
<reserved-parameter name="href"/>
</component-specification>
--- NEW FILE: IBanner.java ---
package bannerads.library;
public interface IBanner
{
/**
* Returns the unique identifier for this banner ad, used to track
* impressions and click-thrus.
*/
public String getId();
/**
* Returns the URL for the banner image.
*/
public String getImageURL();
/**
* Returns the width of the image.
*/
public int getWidth();
/**
* Returns the height of the image.
*/
public int getHeight();
/**
* Returns the click-thru URL for the banner ad.
*/
public String getClickThruURL();
/**
* Returns the title (alt text) for the banner.
*
*/
public String getTitle();
}
--- NEW FILE: IBannerSource.java ---
package bannerads.library;
import java.util.List;
import org.apache.tapestry.IRequestCycle;
public interface IBannerSource
{
/**
* Name ("<code>bannerads.banner-source</code>")
* of an application extension that implements
* {@link bannerads.IBannerSource}.
*/
public static final String BANNER_SOURCE_EXTENSION_NAME = "bannerads.banner-source";
/**
* Invoked to ensure the source is initialized. This
* must always be invoked before any other methods.
*
*/
public void initialize(IRequestCycle cycle);
/**
* Gets a random banner instance.
*/
public IBanner getRandomBanner();
/**
* Gets a specific banner instance.
*/
public IBanner getBanner(String bannerId);
/**
* Records an impression (that is, notes that a particular
* banner was displayed on a page.
*/
public void recordImpression(String bannerId);
/**
* Records a clickthru, indicating the user clicked on
* the banner ad and was redirected to the banner site.
*/
public void recordClickthru(String bannerId);
/**
* Returns the ids of all banners as a List of
* String. The List is not sorted, but may
* be freely modified by the caller.
*/
public List getBannerIds();
}
-------------------------------------------------------
This SF.Net email sponsored by: Parasoft
Error proof Web apps, automate testing & more.
Download & eval WebKing and get a free book.
www.parasoft.com/bulletproofapps1