/** * Basic Blackberry HTTP filter, for subclassing * From RIM's HttpFilterRegistry API examples * Their examples were all private classes, though... * * You'll need to copy of subclass this and specify your own URLs. * While you can modify the main() parameters in the * project file, there's no such option for libMain(). * * The Protocol class is what you'll want to mess with, * for creating your own web application engine. You can * subclass mine and avoid a lot of the "empty" methods * needed to satisfy the filter interface. */ package com.jcomeau.blackberry; import net.rim.blackberry.api.browser.Browser; import net.rim.device.api.io.http.HttpFilterRegistry; public class Common { public static String defaultUrl = "test-blackberry.jcomeau.com"; public static String defaultFilter = "com.jcomeau.blackberry"; public static boolean DEBUGGING = true; public static String[] HTMLFILES = { // for Class.getResourceAsStream() "/html", "html", "", // some circumstances require leading /, others no }; /** * Subclass this and add a main() method for the * "application" project for your filter, along * with a 28x28 color PNG icon and a 32x32 black and white for the older * (and/or cheaper) Blackberries. While not strictly necessary -- * people could still launch your application by typing the filtered URL * into the browser -- this gives them a shortcut with a pretty picture. */ /* public static void main(String[] args) { try { launch(args[0]); { } catch (Exception noArgs) { launch(defaultUrl); } */ /* create subprojects for each URL and set main() call parameters */ public static void launch (String url) { System.err.println("Attempting to launch browser with url " + url); Browser.getDefaultSession().displayPage(url); } /* You'll need to add this libMain() to your own library project! public static void libMain(String[] args) { register(Common.defaultUrl, Common.defaultFilter); } */ public static void register(String url, String filterPackage) { HttpFilterRegistry.registerFilter(url, filterPackage); System.err.println(filterPackage + ".Protocol.class registered for" + " url " + url); } public static void debugprintln() { if (DEBUGGING) System.err.println(); } public static void debugprintln(String message) { if (DEBUGGING) System.err.println(message); } public static void debugprint(String message) { if (DEBUGGING) System.err.print(message); } }