Chapter 2 describes using the Flash Remoting for J2EE installer to install Flash Remoting. Be sure to use the latest update from Macromedia, which at the time of this writing is the Flash Remoting MX for J2EE Updater 1. The updater is available in ZIP archive format from http://www.macromedia.com/support/flash_remoting/updaters.html.
The updater provides several different distributions of Flash Remoting:
WAR archive with no examples
WAR archive with examples
EAR archive with no examples
EAR archive with examples
If you want to run the examples in a servlet container, install the WAR archive with examples. If you want to run the examples in a servlet and EJB container, install the EAR archive with examples. The installation procedure is described under Section 2.1.3.
To install Flash Remoting for use in your own application, place the JAR archive, flashgateway.jar, in your web application's WEB-INF/lib directory and add the following servlet definition and mapping to your web application's WEB-INF/web.xml file:
<servlet> <servlet-name>FlashGatewayServlet</servlet-name> <servlet-class>flashgateway.controller.GatewayServlet</servlet-class> </servlet> <servlet-mapping> <servlet-name>FlashGatewayServlet</servlet-name> <url-pattern>/gateway</url-pattern> </servlet-mapping>
The servlet definition maps the Flash Remoting gateway servlet to the /gateway URL within your web application. If your web application context root is /mywebapp and viewable at http://localhost/mywebapp/, the Flash Remoting gateway URL that Flash clients will connect to is http://localhost/mywebapp/gateway.
It is important to install Flash Remoting as a servlet in your web application so that it can find your classes. If you install Flash Remoting using the WAR or EAR archives provided by Macromedia, the classes in your web application will not be visible to the gateway servlet configured in those archives.
Once you have installed the Remoting gateway, you need to put the Flash Remoting license file, frconfig.txt, in your web application's classpath, such as in WEB-INF/classes, so that the Remoting gateway can find it. If you are using Flash Remoting for multiple web applications, you can put a single copy of frconfig.txt in your application server's classpath so that it will found by the Remoting gateway in each of your web applications.
For application servers with an enabled Java security manager, you may need to edit the Java security policy to allow Flash Remoting to access your services. Refer to Section 7.12.2 later in this chapter for a discussion of Java security and Flash Remoting.
When you configure the Remoting gateway in your web.xml file, you can configure the log level of the gateway:
<servlet> <servlet-name>FlashGatewayServlet</servlet-name> <servlet-class>flashgateway.controller.GatewayServlet</servlet-class> <init-param> <param-name>LOG_LEVEL</param-name> <param-value>ERROR</param-value> </init-param> </servlet>
The options for the LOG_LEVEL parameter are ERROR, WARNING, INFO, DEBUG, and NONE.
The gateway logs messages to System.err and System.out, which will appear in your application server's logs. In development, set the log level to DEBUG to see the services being invoked by the Remoting gateway and the results of each invocation.