Revision: 4144
Author:   solomax666
Date:     Tue Aug 30 08:37:47 2011
Log:      - beans are retrieved using getter instead of servlet init method
http://code.google.com/p/openmeetings/source/detail?r=4144

Modified:
/branches/dev/injection/src/app/org/openmeetings/servlet/outputhandler/RTPSharerServlet.java

=======================================
--- /branches/dev/injection/src/app/org/openmeetings/servlet/outputhandler/RTPSharerServlet.java Sun Aug 28 09:53:59 2011 +++ /branches/dev/injection/src/app/org/openmeetings/servlet/outputhandler/RTPSharerServlet.java Tue Aug 30 08:37:47 2011
@@ -5,8 +5,6 @@
 import java.util.HashMap;
 import java.util.Iterator;

-import javax.servlet.ServletConfig;
-import javax.servlet.ServletException;
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;

@@ -20,6 +18,8 @@
 import org.openmeetings.app.rtp.RTPStreamingHandler;
 import org.red5.logging.Red5LoggerFactory;
 import org.slf4j.Logger;
+import org.springframework.context.ApplicationContext;
+import org.springframework.web.context.support.WebApplicationContextUtils;

 /**
  *
@@ -33,18 +33,45 @@
        private static final long serialVersionUID = -3803050458625713769L;
private static final Logger log = Red5LoggerFactory.getLogger(RTPSharerServlet.class, ScopeApplicationAdapter.webAppRootKey);

-       private Sessionmanagement sessionManagement;
-    private Usermanagement userManagement;
-    private RTPStreamingHandler rtpStreamingHandler;
-
-       @Override
-       public void init(ServletConfig config) throws ServletException {
-               super.init(config);
- sessionManagement = (Sessionmanagement)config.getServletContext().getAttribute("sessionManagement"); - userManagement = (Usermanagement)config.getServletContext().getAttribute("userManagement"); - rtpStreamingHandler = (RTPStreamingHandler)config.getServletContext().getAttribute("rtpStreamingHandler");
-       }
-
+    public Sessionmanagement getSessionManagement() {
+               try {
+                       if (ScopeApplicationAdapter.initComplete) {
+                               ApplicationContext context = 
WebApplicationContextUtils
+                                               
.getWebApplicationContext(getServletContext());
+                               return (Sessionmanagement) 
context.getBean("sessionManagement");
+                       }
+               } catch (Exception err) {
+                       log.error("[getSessionManagement]", err);
+               }
+               return null;
+       }
+
+       public Usermanagement getUserManagement() {
+               try {
+                       if (ScopeApplicationAdapter.initComplete) {
+                               ApplicationContext context = 
WebApplicationContextUtils
+                                               
.getWebApplicationContext(getServletContext());
+                               return (Usermanagement) 
context.getBean("userManagement");
+                       }
+               } catch (Exception err) {
+                       log.error("[getUserManagement]", err);
+               }
+               return null;
+       }
+
+       public RTPStreamingHandler getRtpStreamingHandler() {
+               try {
+                       if (ScopeApplicationAdapter.initComplete) {
+                               ApplicationContext context = 
WebApplicationContextUtils
+                                               
.getWebApplicationContext(getServletContext());
+                               return (RTPStreamingHandler) 
context.getBean("rtpStreamingHandler");
+                       }
+               } catch (Exception err) {
+                       log.error("[getRtpStreamingHandler]", err);
+               }
+               return null;
+       }
+
        @Override
        public Template handleRequest(HttpServletRequest httpServletRequest,
                        HttpServletResponse httpServletResponse, Context ctx) {
@@ -58,8 +85,8 @@

                        log.debug("sid: " + sid);

-                       Long users_id = sessionManagement.checkSession(sid);
-                       Long user_level = 
userManagement.getUserLevelByID(users_id);
+                       Long users_id = 
getSessionManagement().checkSession(sid);
+                       Long user_level = 
getUserManagement().getUserLevelByID(users_id);

                        if (user_level > 0) {

@@ -86,7 +113,7 @@
                                String template = "rtp_player_applet.vm";

                                // Retrieve Data from RTPmanager
- RTPScreenSharingSession rsss = rtpStreamingHandler.getSessionForRoom(room, sid, publicSID); + RTPScreenSharingSession rsss = getRtpStreamingHandler().getSessionForRoom(room, sid, publicSID);

                                if(rsss == null){
                                        log.error("no RTPSharingSession available 
for room " + room);

--
You received this message because you are subscribed to the Google Groups 
"OpenMeetings developers" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/openmeetings-dev?hl=en.

Reply via email to