I figured it out :)... Just thought I'd post the solution:

Add this to the class:

protected Application myApplication;

Then add this:

myApplication = (Application) webAppCtx.getBean("web.handler");

After this:

if (webAppCtx != null) {

Then you can access public elements of your Application.

-Luke

On Aug 17, 2007, at 9:07 PM, Luke Scott wrote:

> Ok... Lets say I had this gateway servlet:
>
> package org.red5.server.webapp.test;
> import javax.servlet.ServletException;
> import java.io.IOException;
> import
> org.springframework.web.context.support.WebApplicationContextUtils;
> import org.springframework.web.context.WebApplicationContext;
> import javax.servlet.http.HttpServlet;
> import javax.servlet.http.HttpServletRequest;
> import javax.servlet.http.HttpServletResponse;
> import org.red5.server.api.IContext;
>
> public class UploadServlet extends HttpServlet {
>       protected WebApplicationContext webAppCtx;
>       protected IContext webContext;
>
>       public void init() throws ServletException {
>               webAppCtx = WebApplicationContextUtils.getWebApplicationContext
> (getServletContext());
>               if (webAppCtx != null) {
>                               webContext = (IContext) 
> webAppCtx.getBean("web.context");
>               }
>       }
>
>       public void service(HttpServletRequest req, HttpServletResponse
> resp) throws ServletException, IOException {
>       
>       }
> }
>
> And I used this to load it (in web.xml):
>
> ...
>      <servlet>
>          <servlet-name>gateway</servlet-name>
>          <servlet-class>org.red5.server.webapp.test.UploadServlet</
> servlet-class>
>      </servlet>
>
>      <servlet-mapping>
>          <servlet-name>gateway</servlet-name>
>          <url-pattern>/gateway/*</url-pattern>
>      </servlet-mapping>
> </web-app>
>
> And this was my Red5 application:
>
> package org.red5.server.webapp.test;
> import org.red5.server.adapter.ApplicationAdapter;
>
> public class Application extends ApplicationAdapter {
>       public int counter = 0;
>       
>       public int add()
>       {               
>               counter++;
>               return counter;
>       }
> }
>
> If I connected to my Red5 app (Application extends
> ApplicationAdapter) with NetConnect (Flash) and called "add" three
> times "counter" should be "3". Now... how would I access "counter"
> from my "UploadServlet extends HttpServlet" gateway?
>
> Thanks,
>
> -Luke
>
> _______________________________________________
> Red5 mailing list
> [email protected]
> http://osflash.org/mailman/listinfo/red5_osflash.org


_______________________________________________
Red5 mailing list
[email protected]
http://osflash.org/mailman/listinfo/red5_osflash.org

Reply via email to