[Red5commits] [1644] 1. Fixed bug with SharedObjects? after ApplicationAdapter? refactoring.2. Fixed

mklishin luke at codegent.com
Wed Jan 24 11:13:40 EST 2007


1. Fixed bug with SharedObjects? after ApplicationAdapter? refactoring.
2. Fixed some documentation typos.
3. Added some in code documentation of low level logic in server initialization.


Timestamp: 01/21/07 18:59:51 EST (3 days ago) 
Change: 1644 
Author: mklishin

Files (see diff or trac for details): 
java/server/trunk/src/org/red5/server/ContextLoader.java
java/server/trunk/src/org/red5/server/JettyLoader.java
java/server/trunk/src/org/red5/server/adapter/ApplicationAdapter.java
java/server/trunk/src/org/red5/server/adapter/StatefulScopeWrappingAdapter.java
java/server/trunk/src/org/red5/server/api/IContext.java
java/server/trunk/src/org/red5/server/jetty/Red5WebPropertiesConfiguration.java


Trac: http://mirror1.cvsdude.com/trac/osflash/red5/changeset/1644

Index: /java/server/trunk/src/org/red5/server/adapter/ApplicationAdapter.java
===================================================================
--- /java/server/trunk/src/org/red5/server/adapter/ApplicationAdapter.java (revision 1630)
+++ /java/server/trunk/src/org/red5/server/adapter/ApplicationAdapter.java (revision 1644)
@@ -133,26 +133,4 @@
 
     /**
-     * Creates new application adapter
-     */
-    public ApplicationAdapter() {
-        sharedObjectService = (ISharedObjectService) getScopeService(
-                scope, ISharedObjectService.class,
-                SharedObjectService.class, false);
-
-        providerService = (IProviderService) getScopeService(scope,
-                IProviderService.class, ProviderService.class);
-
-        vodService = (IOnDemandStreamService) getScopeService(
-                scope, IOnDemandStreamService.class,
-                StreamService.class, false);
-
-        schedulingService = (ISchedulingService) getScopeService(
-                scope, ISchedulingService.class,
-                QuartzSchedulingService.class, false);
-
-        
-    }
-
-    /**
 	 * Register listener that will get notified about application events. Please
 	 * note that return values (e.g. from {@link IApplication#appStart(IScope)})
@@ -629,6 +607,8 @@
 	public boolean createSharedObject(IScope scope, String name,
 			boolean persistent) {
-
-        return sharedObjectService.createSharedObject(scope, name, persistent);
+		ISharedObjectService service = (ISharedObjectService) getScopeService(
+				scope, ISharedObjectService.class,
+				SharedObjectService.class, false);
+		return service.createSharedObject(scope, name, persistent);
     }
 
@@ -643,5 +623,8 @@
 	 */
 	public ISharedObject getSharedObject(IScope scope, String name) {
-		return sharedObjectService.getSharedObject(scope, name);
+		ISharedObjectService service = (ISharedObjectService) getScopeService(
+				scope, ISharedObjectService.class,
+				SharedObjectService.class, false);
+		return service.getSharedObject(scope, name);
 	}
 
@@ -659,5 +642,8 @@
 	public ISharedObject getSharedObject(IScope scope, String name,
 			boolean persistent) {
-		return sharedObjectService.getSharedObject(scope, name, persistent);
+		ISharedObjectService service = (ISharedObjectService) getScopeService(
+				scope, ISharedObjectService.class,
+				SharedObjectService.class, false);
+		return service.getSharedObject(scope, name, persistent);
 	}
 
@@ -669,5 +655,8 @@
 	 */
 	public Set<String> getSharedObjectNames(IScope scope) {
-		return sharedObjectService.getSharedObjectNames(scope);
+		ISharedObjectService service = (ISharedObjectService) getScopeService(
+				scope, ISharedObjectService.class,
+				SharedObjectService.class, false);
+		return service.getSharedObjectNames(scope);
 	}
 
@@ -681,5 +670,8 @@
 	 */
 	public boolean hasSharedObject(IScope scope, String name) {
-		return sharedObjectService.hasSharedObject(scope, name);
+		ISharedObjectService service = (ISharedObjectService) getScopeService(
+				scope, ISharedObjectService.class,
+				SharedObjectService.class, false);
+		return service.hasSharedObject(scope, name);
 	}
 
@@ -688,6 +680,7 @@
 	/** {@inheritDoc} */
     public boolean hasBroadcastStream(IScope scope, String name) {
-
-        return (providerService.getLiveProviderInput(scope, name, false) != null);
+		IProviderService service = (IProviderService) getScopeService(scope,
+				IProviderService.class, ProviderService.class);
+		return (service.getLiveProviderInput(scope, name, false) != null);
 	}
 
@@ -713,5 +706,7 @@
 	 */
 	public List<String> getBroadcastStreamNames(IScope scope) {
-		return providerService.getBroadcastStreamNames(scope);
+		IProviderService service = (IProviderService) getScopeService(scope,
+				IProviderService.class, ProviderService.class);
+		return service.getBroadcastStreamNames(scope);
 	}
 
@@ -728,5 +723,7 @@
 	 */
 	public boolean hasOnDemandStream(IScope scope, String name) {
-		return (providerService.getVODProviderInput(scope, name) != null);
+		IProviderService service = (IProviderService) getScopeService(scope,
+				IProviderService.class, ProviderService.class);
+		return (service.getVODProviderInput(scope, name) != null);
 	}
 
@@ -745,5 +742,8 @@
 	public IOnDemandStream getOnDemandStream(IScope scope, String name) {
 		log.warn("This won't work until the refactoring of the streaming code is complete.");
-        return vodService.getOnDemandStream(scope, name);
+		IOnDemandStreamService service = (IOnDemandStreamService) getScopeService(
+				scope, IOnDemandStreamService.class,
+				StreamService.class, false);
+		return service.getOnDemandStream(scope, name);
 	}
 
@@ -780,5 +780,8 @@
 	 */
 	public String addScheduledJob(int interval, IScheduledJob job) {
-        return schedulingService.addScheduledJob(interval, job);
+		ISchedulingService service = (ISchedulingService) getScopeService(
+				scope, ISchedulingService.class,
+				QuartzSchedulingService.class, false);
+		return service.addScheduledJob(interval, job);
 	}
 
@@ -796,5 +799,8 @@
 	 */
 	public String addScheduledOnceJob(long timeDelta, IScheduledJob job) {
-		return schedulingService.addScheduledOnceJob(timeDelta, job);
+		ISchedulingService service = (ISchedulingService) getScopeService(
+				scope, ISchedulingService.class,
+				QuartzSchedulingService.class, false);
+		return service.addScheduledOnceJob(timeDelta, job);
 	}
 
@@ -811,5 +817,8 @@
 	 */
 	public String addScheduledOnceJob(Date date, IScheduledJob job) {
-		return schedulingService.addScheduledOnceJob(date, job);
+		ISchedulingService service = (ISchedulingService) getScopeService(
+				scope, ISchedulingService.class,
+				QuartzSchedulingService.class, false);
+		return service.addScheduledOnceJob(date, job);
 	}
 
@@ -821,5 +830,8 @@
 	 */
 	public void removeScheduledJob(String name) {
-		schedulingService.removeScheduledJob(name);
+		ISchedulingService service = (ISchedulingService) getScopeService(
+				scope, ISchedulingService.class,
+				QuartzSchedulingService.class, false);
+		service.removeScheduledJob(name);
 	}
 
@@ -830,5 +842,8 @@
 	 */
 	public List<String> getScheduledJobNames() {
-		return schedulingService.getScheduledJobNames();
+		ISchedulingService service = (ISchedulingService) getScopeService(
+				scope, ISchedulingService.class,
+				QuartzSchedulingService.class, false);
+		return service.getScheduledJobNames();
 	}
 
@@ -843,5 +858,7 @@
 	 */
 	public double getStreamLength(String name) {
-		File file = providerService.getVODProviderFile(scope, name);
+		IProviderService provider = (IProviderService) getScopeService(scope,
+				IProviderService.class, ProviderService.class);
+		File file = provider.getVODProviderFile(scope, name);
 		if (file == null) {
 			return 0;
@@ -872,5 +889,12 @@
 	/** {@inheritDoc} */
     public boolean clearSharedObjects(IScope scope, String name) {
-		return sharedObjectService.clearSharedObjects( scope, name );
+		ISharedObjectService service = (ISharedObjectService) getScopeService(
+                scope,
+                ISharedObjectService.class,
+                SharedObjectService.class,
+                false
+        );
+
+        return service.clearSharedObjects(scope, name);
     }
 
Index: /java/server/trunk/src/org/red5/server/adapter/StatefulScopeWrappingAdapter.java
===================================================================
--- /java/server/trunk/src/org/red5/server/adapter/StatefulScopeWrappingAdapter.java (revision 1628)
+++ /java/server/trunk/src/org/red5/server/adapter/StatefulScopeWrappingAdapter.java (revision 1644)
@@ -37,5 +37,8 @@
 		implements IScopeAware, IAttributeStore {
 
-	protected IScope scope;
+    /**
+     * Wrapped scope
+     */
+    protected IScope scope;
 
 	/** {@inheritDoc} */
Index: /java/server/trunk/src/org/red5/server/jetty/Red5WebPropertiesConfiguration.java
===================================================================
--- /java/server/trunk/src/org/red5/server/jetty/Red5WebPropertiesConfiguration.java (revision 1607)
+++ /java/server/trunk/src/org/red5/server/jetty/Red5WebPropertiesConfiguration.java (revision 1644)
@@ -88,13 +88,19 @@
     public void configureWebApp() throws Exception {
 		log.debug("Configuring Jetty webapp");
-		WebAppContext context = getWebAppContext();
-		if (context.isStarted()) {
+
+        // Get context
+        WebAppContext context = getWebAppContext();
+
+        // If app is already started...
+        if (context.isStarted()) {
 			log.debug("Cannot configure webapp after it is started");
 			return;
 		}
 
-		Resource webInf = context.getWebInf();
+        // Get WEB_INF directory
+        Resource webInf = context.getWebInf();
 		if (webInf != null && webInf.isDirectory()) {
-			Resource config = webInf.addPath("red5-web.properties");
+            // Get properties file with virtualHosts and context path
+            Resource config = webInf.addPath("red5-web.properties");
 			if (config.exists()) {
 				log.debug("Configuring red5-web.properties");
@@ -102,4 +108,5 @@
                 Properties props = new Properties();
 				props.load(config.getInputStream());
+
                 // Get context path and virtual hosts
                 String contextPath = props.getProperty("webapp.contextPath");
Index: /java/server/trunk/src/org/red5/server/ContextLoader.java
===================================================================
--- /java/server/trunk/src/org/red5/server/ContextLoader.java (revision 1599)
+++ /java/server/trunk/src/org/red5/server/ContextLoader.java (revision 1644)
@@ -89,5 +89,6 @@
      */
 	public void init() throws Exception {
-		Properties props = new Properties();
+        // Load properties bundle
+        Properties props = new Properties();
 		Resource res = applicationContext.getResource(contextsConfig);
 		if (!res.exists()) {
Index: /java/server/trunk/src/org/red5/server/JettyLoader.java
===================================================================
--- /java/server/trunk/src/org/red5/server/JettyLoader.java (revision 1590)
+++ /java/server/trunk/src/org/red5/server/JettyLoader.java (revision 1644)
@@ -20,6 +20,4 @@
  */
 
-import java.io.IOException;
-
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
@@ -34,4 +32,6 @@
 import org.springframework.context.ApplicationContextAware;
 import org.springframework.context.support.ClassPathXmlApplicationContext;
+
+import java.io.IOException;
 
 /**
@@ -65,7 +65,7 @@
 
     /**
-     *
-     * @param context
-     * @throws BeansException
+     * App context
+     * @param context           App context
+     * @throws BeansException   Bean exception
      */
 	public void setApplicationContext(ApplicationContext context)
@@ -75,6 +75,6 @@
 
     /**
-     *
-     * @return
+     * Return app context
+     * @return                  App context
      */
 	public static ApplicationContext getApplicationContext() {
@@ -103,6 +103,7 @@
 
 			log.info("Starting jetty servlet engine");
-			
-			String webAppRoot = System.getProperty("red5.webapp.root");
+
+            // Get Red5 applications directory
+            String webAppRoot = System.getProperty("red5.webapp.root");
 			String[] handlersArr = new String[]{"org.mortbay.jetty.webapp.WebInfConfiguration", 
 					"org.mortbay.jetty.webapp.WebXmlConfiguration", 
Index: /java/server/trunk/src/org/red5/server/api/IContext.java
===================================================================
--- /java/server/trunk/src/org/red5/server/api/IContext.java (revision 1609)
+++ /java/server/trunk/src/org/red5/server/api/IContext.java (revision 1644)
@@ -39,5 +39,5 @@
      * @return  Application context
      */
-    public ApplicationContext getApplicationContext();
+    ApplicationContext getApplicationContext();
 
 	// public IScopeResolver getScopeResolver();
@@ -48,5 +48,5 @@
 	 * @return	Client registry object
 	 */
-	public IClientRegistry getClientRegistry();
+    IClientRegistry getClientRegistry();
 
 	/**
@@ -56,5 +56,5 @@
 	 * @return		Service invoker object
 	 */
-	public IServiceInvoker getServiceInvoker();
+    IServiceInvoker getServiceInvoker();
 
 	/**
@@ -64,5 +64,5 @@
 	 * @return	Persistence store object
 	 */
-	public IPersistenceStore getPersistanceStore();
+    IPersistenceStore getPersistanceStore();
 
 	/**
@@ -74,5 +74,5 @@
 	 * @return		Scope handler
 	 */
-	public IScopeHandler lookupScopeHandler(String path);
+    IScopeHandler lookupScopeHandler(String path);
 
 	/**
@@ -85,5 +85,5 @@
 	 * @return		IScope object
 	 */
-	public IScope resolveScope(String path);
+    IScope resolveScope(String path);
 
 	/**
@@ -92,5 +92,5 @@
 	 * @return	global scope reference
 	 */
-	public IScope getGlobalScope();
+    IScope getGlobalScope();
 
 	/**
@@ -101,5 +101,5 @@
 	 * @return				Service object
 	 */
-	public Object lookupService(String serviceName);
+    Object lookupService(String serviceName);
 
 	/**
@@ -110,5 +110,5 @@
 	 * @return			Given bean instance
 	 */
-	public Object getBean(String beanId);
+    Object getBean(String beanId);
 
 	/**
@@ -119,5 +119,5 @@
 	 * @return			Core service
 	 */
-	public Object getCoreService(String beanId);
+    Object getCoreService(String beanId);
 
 	/**


Note:
Diffs are chopped if more than 25k.
This is to get past the limit on the mailing list.



More information about the Red5commits mailing list