[Red5commits] [1599] Minor javadocs improvements
mklishin
luke at codegent.com
Wed Jan 24 11:03:25 EST 2007
Minor javadocs improvements
Timestamp: 12/23/06 09:15:00 EST (1 month ago)
Change: 1599
Author: mklishin
Files (see diff or trac for details):
java/server/trunk/src/org/red5/server/AttributeStore.java
java/server/trunk/src/org/red5/server/BasicScope.java
java/server/trunk/src/org/red5/server/ContextLoader.java
java/server/trunk/src/org/red5/server/GlobalScope.java
java/server/trunk/src/org/red5/server/PersistableAttributeStore.java
java/server/trunk/src/org/red5/server/Scope.java
java/server/trunk/src/org/red5/server/adapter/ApplicationAdapter.java
Trac: http://mirror1.cvsdude.com/trac/osflash/red5/changeset/1599
Index: /java/server/trunk/src/org/red5/server/adapter/ApplicationAdapter.java
===================================================================
--- /java/server/trunk/src/org/red5/server/adapter/ApplicationAdapter.java (revision 1592)
+++ /java/server/trunk/src/org/red5/server/adapter/ApplicationAdapter.java (revision 1599)
@@ -221,10 +221,6 @@
if (isApp(scope)) {
return appStart(scope);
- } else if (isRoom(scope)) {
- return roomStart(scope);
- } else {
- return false;
- }
- }
+ } else return isRoom(scope) && roomStart(scope);
+ }
/**
@@ -287,10 +283,6 @@
if (isApp(scope)) {
return appJoin(client, scope);
- } else if (isRoom(scope)) {
- return roomJoin(client, scope);
- } else {
- return false;
- }
- }
+ } else return isRoom(scope) && roomJoin(client, scope);
+ }
/**
@@ -323,6 +315,5 @@
* make it act the way you want.
*
- * @param app
- * Application scope object
+ * @param app Application scope object
* @return <code>true</code> if scope can be started, <code>false</code>
* otherwise
@@ -519,7 +510,6 @@
* Handler method. Called every time client leaves room scope.
*
- * @param client
- * Disconnected client object
- * @param room
+ * @param client Disconnected client object
+ * @param room Room scope
*/
public void roomLeave(IClient client, IScope room) {
@@ -666,5 +656,6 @@
/* Wrapper around the stream interfaces */
- public boolean hasBroadcastStream(IScope scope, String name) {
+ /** {@inheritDoc} */
+ public boolean hasBroadcastStream(IScope scope, String name) {
IProviderService service = (IProviderService) getScopeService(scope,
IProviderService.class, ProviderService.class);
@@ -672,5 +663,6 @@
}
- public IBroadcastStream getBroadcastStream(IScope scope, String name) {
+ /** {@inheritDoc} */
+ public IBroadcastStream getBroadcastStream(IScope scope, String name) {
IStreamService service = (IStreamService) getScopeService(
scope, IStreamService.class,
@@ -680,6 +672,5 @@
IBroadcastScope bs = ((StreamService) service).getBroadcastScope(scope, name);
- IClientBroadcastStream stream = (IClientBroadcastStream) bs.getAttribute(IBroadcastScope.STREAM_ATTRIBUTE);
- return stream;
+ return (IClientBroadcastStream) bs.getAttribute(IBroadcastScope.STREAM_ATTRIBUTE);
}
@@ -876,5 +867,6 @@
}
- public boolean clearSharedObjects(IScope scope, String name) {
+ /** {@inheritDoc} */
+ public boolean clearSharedObjects(IScope scope, String name) {
// TODO Auto-generated method stub
return false;
Index: /java/server/trunk/src/org/red5/server/BasicScope.java
===================================================================
--- /java/server/trunk/src/org/red5/server/BasicScope.java (revision 1590)
+++ /java/server/trunk/src/org/red5/server/BasicScope.java (revision 1599)
@@ -19,8 +19,4 @@
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
-
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.Set;
import org.red5.server.api.IBasicScope;
@@ -29,4 +25,8 @@
import org.red5.server.api.event.IEvent;
import org.red5.server.api.event.IEventListener;
+
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.Set;
/**
@@ -52,5 +52,5 @@
* Scope persistence storate type
*/
- protected String persistenceClass = null;
+ protected String persistenceClass;
/**
@@ -70,6 +70,5 @@
/**
- *
- * @return
+ * {@inheritDoc}
*/
public boolean hasParent() {
@@ -78,6 +77,5 @@
/**
- *
- * @return
+ *{@inheritDoc}
*/
public IScope getParent() {
@@ -86,6 +84,5 @@
/**
- *
- * @return
+ *{@inheritDoc}
*/
public int getDepth() {
@@ -94,6 +91,5 @@
/**
- *
- * @return
+ *{@inheritDoc}
*/
@Override
@@ -133,5 +129,5 @@
/**
* Setter for persistent property
- * @param persistent
+ * @param persistent Persistence flag value
*/
@Override
@@ -152,9 +148,8 @@
/**
- * Noifies listeners on event. To be implemented in subclass realization
+ * Notifies listeners on event. Current implementation is empty. To be implemented in subclass realization
* @param event Event to broadcast
*/
public void notifyEvent(IEvent event) {
- // TODO Auto-generated method stub
}
@@ -176,25 +171,27 @@
* Getter for subscopes list iterator. Returns null because this is a base implementation
*
- * @return
+ * @return Iterator for subscopes
*/
public Iterator<IBasicScope> iterator() {
- // TODO Auto-generated method stub
return null;
}
/**
- *
+ * Iterator for basic scope
*/
public class EmptyBasicScopeIterator implements Iterator<IBasicScope> {
- public boolean hasNext() {
+ /** {@inheritDoc} */
+ public boolean hasNext() {
return false;
}
- public IBasicScope next() {
+ /** {@inheritDoc} */
+ public IBasicScope next() {
return null;
}
- public void remove() {
+ /** {@inheritDoc} */
+ public void remove() {
// nothing
}
Index: /java/server/trunk/src/org/red5/server/GlobalScope.java
===================================================================
--- /java/server/trunk/src/org/red5/server/GlobalScope.java (revision 1590)
+++ /java/server/trunk/src/org/red5/server/GlobalScope.java (revision 1599)
@@ -37,6 +37,6 @@
/**
*
- * @param persistenceClass
- * @throws Exception
+ * @param persistenceClass Persistent class name
+ * @throws Exception Exception
*/
@Override
@@ -68,5 +68,10 @@
}
- public void setServer(IServer server) {
+ /**
+ * Setter for server
+ *
+ * @param server Server
+ */
+ public void setServer(IServer server) {
this.server = server;
}
Index: /java/server/trunk/src/org/red5/server/Scope.java
===================================================================
--- /java/server/trunk/src/org/red5/server/Scope.java (revision 1590)
+++ /java/server/trunk/src/org/red5/server/Scope.java (revision 1599)
@@ -20,21 +20,7 @@
*/
-import java.io.IOException;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.Map;
-import java.util.Set;
-import java.util.concurrent.ConcurrentHashMap;
-
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.red5.server.api.IBasicScope;
-import org.red5.server.api.IClient;
-import org.red5.server.api.IConnection;
-import org.red5.server.api.IContext;
-import org.red5.server.api.IScope;
-import org.red5.server.api.IScopeAware;
-import org.red5.server.api.IScopeHandler;
+import org.red5.server.api.*;
import org.red5.server.api.event.IEvent;
import org.red5.server.api.persistence.IPersistable;
@@ -43,57 +29,74 @@
import org.springframework.core.style.ToStringCreator;
+import java.io.IOException;
+import java.util.*;
+
+/**
+ * The scope object.
+ *
+ * A statefull object shared between a group of clients connected to the same
+ * context path. Scopes are arranged in a hierarchical way, so its possible for
+ * a scope to have a parent. If a client is connect to a scope then they are
+ * also connected to its parent scope. The scope object is used to access
+ * resources, shared object, streams, etc.
+ *
+ * The following are all names for scopes: application, room, place, lobby.
+ *
+ * @author The Red5 Project (red5 at osflash.org)
+ */
public class Scope extends BasicScope implements IScope {
/**
- *
+ * Logger
*/
protected static Log log = LogFactory.getLog(Scope.class.getName());
/**
- *
+ * Unset flag constant
*/
private static final int UNSET = -1;
/**
- *
+ * Scope type constant
*/
private static final String TYPE = "scope";
/**
- *
+ * Scope service handler constant
*/
private static final String SERVICE_HANDLERS = IPersistable.TRANSIENT_PREFIX
+ "_scope_service_handlers";
/**
- *
+ * Scope nesting depth, unset by default
*/
private int depth = UNSET;
/**
- *
+ * Scope context
*/
private IContext context;
/**
- *
+ * Scope handler
*/
private IScopeHandler handler;
/**
- *
+ * Autostart flag
*/
private boolean autoStart = true;
/**
- *
+ * Whether scope is enabled
*/
private boolean enabled = true;
/**
- *
+ * Whether scope is running
*/
private boolean running;
- /**
- *
- */
- private Map<String, IBasicScope> children = new ConcurrentHashMap<String, IBasicScope>();
- /**
- *
- */
- private Map<IClient, Set<IConnection>> clients = new ConcurrentHashMap<IClient, Set<IConnection>>();
-
- /**
- *
+
+ /**
+ * Child scopes map (child scopes are named)
+ */
+ private HashMap<String, IBasicScope> children = new HashMap<String, IBasicScope>();
+ /**
+ * Clients and connection map
+ */
+ private HashMap<IClient, Set<IConnection>> clients = new HashMap<IClient, Set<IConnection>>();
+
+ /**
+ * Creates unnamed scope
*/
public Scope() {
@@ -102,6 +105,6 @@
/**
- *
- * @param name
+ * Creates scope with given name
+ * @param name Scope name
*/
public Scope(String name) {
@@ -110,6 +113,6 @@
/**
- *
- * @return
+ * Check if scope is enabled
+ * @return <code>true</code> if scope is enabled, <code>false</code> otherwise
*/
public boolean isEnabled() {
@@ -118,6 +121,6 @@
/**
- *
- * @param enabled
+ * Enable or disable scope by setting enable flag
+ * @param enabled Enable flag value
*/
public void setEnabled(boolean enabled) {
@@ -126,6 +129,6 @@
/**
- *
- * @return
+ * Check if scope is in running state
+ * @return <code>true</code> if scope is in running state, <code>false</code> otherwise
*/
public boolean isRunning() {
@@ -134,6 +137,6 @@
/**
- *
- * @param autoStart
+ * Setter for autostart flag
+ * @param autoStart Autostart flag value
*/
public void setAutoStart(boolean autoStart) {
@@ -142,6 +145,6 @@
/**
- *
- * @param context
+ * Setter for context
+ * @param context Context object
*/
public void setContext(IContext context) {
@@ -150,6 +153,6 @@
/**
- *
- * @param handler
+ * Setter for scope event handler
+ * @param handler Event handler
*/
public void setHandler(IScopeHandler handler) {
@@ -161,5 +164,5 @@
/**
- *
+ * Initialization actions, start if autostart is set to <code>true</code>
*/
public void init() {
@@ -177,21 +180,13 @@
/**
- *
- * @return
+ * Starts scope
+ * @return <code>true</code> if scope has handler and it's start method returned true, <code>false</code> otherwise
*/
public boolean start() {
- if (enabled && !running) {
- if (hasHandler() && !handler.start(this)) {
- return false;
- } else {
- return true;
- }
- } else {
- return false;
- }
- }
-
- /**
- *
+ return enabled && !running && !(hasHandler() && !handler.start(this));
+ }
+
+ /**
+ * Stops scope
*/
public void stop() {
@@ -199,5 +194,5 @@
/**
- *
+ * Destroys scope
*/
public void destory() {
@@ -212,7 +207,8 @@
/**
+ * Set scope persistence class
*
- * @param persistenceClass
- * @throws Exception
+ * @param persistenceClass Scope's persistence class
+ * @throws Exception Exception
*/
public void setPersistenceClass(String persistenceClass) throws Exception {
@@ -227,7 +223,7 @@
/**
- *
- * @param scope
- * @return
+ * Add child scope to this scope
+ * @param scope Child scope
+ * @return <code>true</code> on success (if scope has handler and it accepts child scope addition), <code>false</code> otherwise
*/
public boolean addChildScope(IBasicScope scope) {
@@ -265,6 +261,6 @@
/**
- *
- * @param pattern
+ * Setter for child load path. Should be implemented in subclasses?
+ * @param pattern Load path pattern
*/
public void setChildLoadPath(String pattern) {
@@ -273,6 +269,6 @@
/**
- *
- * @param scope
+ * Removes child scope
+ * @param scope Child scope to remove
*/
public void removeChildScope(IBasicScope scope) {
@@ -290,7 +286,7 @@
/**
- *
- * @param name
- * @return
+ * Check whether scope has child scope with given name
+ * @param name Child scope name
+ * @return <code>true</code> if scope has child node with given name, <code>false</code> otherwise
*/
public boolean hasChildScope(String name) {
@@ -302,8 +298,8 @@
/**
- *
- * @param type
- * @param name
- * @return
+ * Check whether scope has child scope with given name and type
+ * @param type Child scope type
+ * @param name Child scope name
+ * @return <code>true</code> if scope has child node with given name and type, <code>false</code> otherwise
*/
public boolean hasChildScope(String type, String name) {
@@ -312,6 +308,6 @@
/**
- *
- * @return
+ * Return child scope names iterator
+ * @return Child scope names iterator
*/
public Iterator<String> getScopeNames() {
@@ -321,6 +317,6 @@
/**
- *
- * @return
+ * Return set of clients
+ * @return Set of clients bound to scope
*/
public Set<IClient> getClients() {
@@ -329,6 +325,6 @@
/**
- *
- * @return
+ * Check if scope has a context
+ * @return <code>true</code> if scope has context, <code>false</code> otherwise
*/
public boolean hasContext() {
@@ -337,6 +333,6 @@
/**
- *
- * @return
+ * Return scope context. If scope doesn't have context, parent's context is returns, and so forth.
+ * @return Scope context or parent context
*/
public IContext getContext() {
@@ -351,6 +347,6 @@
/**
- *
- * @return
+ * Return scope context path
+ * @return Scope context path
*/
public String getContextPath() {
@@ -365,6 +361,6 @@
/**
- *
- * @param name
+ * Setter for scope name
+ * @param name Scope name
*/
@Override
@@ -374,6 +370,6 @@
/**
- *
- * @return
+ * Return scope path calculated from parent path and parent scope name
+ * @return Scope path
*/
@Override
@@ -387,6 +383,6 @@
/**
- *
- * @param parent
+ * Setter for parent scope
+ * @param parent Parent scope
*/
public void setParent(IScope parent) {
@@ -395,6 +391,6 @@
/**
- *
- * @return
+ * Check if scope or it's parent has handler
+ * @return <code>true</code> if scope or it's parent scope has a handler, <code>false</code> otherwise
*/
public boolean hasHandler() {
@@ -403,6 +399,6 @@
/**
- *
- * @return
+ * Return scope handler or parent's scope handler if this scope doesn't have one
+ * @return Scope handler (or parent's one)
*/
public IScopeHandler getHandler() {
@@ -417,6 +413,6 @@
/**
- *
- * @return
+ * Return parent scope
+ * @return Parent scope
*/
@Override
@@ -426,6 +422,6 @@
/**
- *
- * @return
+ * Check if scope has parent scope
+ * @return <code>true</code> if scope has parent scope, <code>false</code> otherwise`
*/
@Override
@@ -435,7 +431,7 @@
/**
- *
- * @param conn
- * @return
+ * Connect to scope
+ * @param conn Connection object
+ * @return <code>true</code> on success, <code>false</code> otherwise
*/
public synchronized boolean connect(IConnection conn) {
@@ -444,8 +440,11 @@
/**
+ * Connect to scope with parameters. To successfully connect to scope it must have handler that will accept
+ * this connection with given set of params. Client associated with connection is added to scope clients set,
+ * connection is registred as scope event listener.
*
- * @param conn
- * @param params
- * @return
+ * @param conn Connection object
+ * @param params Params passed with connection
+ * @return <code>true</code> on success, <code>false</code> otherwise
*/
public synchronized boolean connect(IConnection conn, Object[] params) {
@@ -478,6 +477,6 @@
/**
- *
- * @param conn
+ * Disconnect connection from scope
+ * @param conn Connection object
*/
public synchronized void disconnect(IConnection conn) {
@@ -487,5 +486,5 @@
final IClient client = conn.getClient();
if (clients.containsKey(client)) {
- final Set conns = clients.get(client);
+ final Set<IConnection> conns = clients.get(client);
conns.remove(conn);
IScopeHandler handler = null;
@@ -521,6 +520,6 @@
/**
- *
- * @param depth
+ * Set scope depth
+ * @param depth Scope depth
*/
public void setDepth(int depth) {
@@ -529,6 +528,6 @@
/**
- *
- * @return
+ * return scope depth
+ * @return Scope depth
*/
@Override
@@ -545,8 +544,8 @@
/**
- *
- * @param path
- * @return
- * @throws IOException
+ * Return array of resources from path string, usually used with pattern path
+ * @param path Resources path
+ * @return Resources
+ * @throws IOException I/O exception
*/
public Resource[] getResources(String path) throws IOException {
@@ -558,7 +557,7 @@
/**
- *
- * @param path
- * @return
+ * Return resource located at given path
+ * @param path Resource path
+ * @return Resource
*/
public Resource getResource(String path) {
@@ -570,6 +569,6 @@
/**
- *
- * @return
+ * Return connection iterator
+ * @return Connections iterator
*/
public Iterator<IConnection> getConnections() {
@@ -578,7 +577,7 @@
/**
- *
- * @param client
- * @return
+ * Looks up connections for client
+ * @param client Client
+ * @return Connection
*/
public Set<IConnection> lookupConnections(IClient client) {
@@ -586,5 +585,6 @@
}
- @Override
+ /** {@inheritDoc} */
+ @Override
public void dispatchEvent(IEvent event) {
Iterator<IConnection> conns = getConnections();
@@ -599,14 +599,25 @@
/**
- *
+ * Iterator that filters strings by given prefix
*/
class PrefixFilteringStringIterator implements Iterator<String> {
-
+ /**
+ * Iterator
+ */
private Iterator<String> iterator;
-
+ /**
+ * Prefix
+ */
private String prefix;
-
+ /**
+ * Next object
+ */
private String next;
+ /**
+ * Creates prefix filtering string iterator from iterator and prefix
+ * @param iterator Iterator
+ * @param prefix Prefix
+ */
public PrefixFilteringStringIterator(Iterator<String> iterator,
String prefix) {
@@ -615,5 +626,6 @@
}
- public boolean hasNext() {
+ /** {@inheritDoc} */
+ public boolean hasNext() {
if (next != null) {
return true;
@@ -625,5 +637,6 @@
}
- public String next() {
+ /** {@inheritDoc} */
+ public String next() {
if (next != null) {
final String result = next;
@@ -638,5 +651,6 @@
}
- public void remove() {
+ /** {@inheritDoc} */
+ public void remove() {
// not possible
}
@@ -645,22 +659,22 @@
/**
- *
+ * Iterates through connections
*/
class ConnectionIterator implements Iterator<IConnection> {
/**
- *
+ * Set iterator
*/
private Iterator<Set<IConnection>> setIterator;
/**
- *
+ * Connections iterator
*/
private Iterator<IConnection> connIterator;
/**
- *
+ * Current connection
*/
private IConnection current;
/**
- *
+ * Creates connection iterator
*/
public ConnectionIterator() {
@@ -669,6 +683,5 @@
/**
- *
- * @return
+ * {@inheritDoc}
*/
public boolean hasNext() {
@@ -678,6 +691,5 @@
/**
- *
- * @return
+ * {@inheritDoc}
*/
public IConnection next() {
@@ -688,10 +700,11 @@
connIterator = setIterator.next().iterator();
}
- current = (IConnection) connIterator.next();
+ // Always of type IConnection, no need to cast
+ current = connIterator.next();
return current;
}
/**
- *
+ * {@inheritDoc}
*/
public void remove() {
@@ -704,7 +717,7 @@
/**
- *
- * @param name
- * @return
+ * Create child scope with given name
+ * @param name Child scope name
+ * @return <code>true</code> on success, <code>false</code> otherwise
*/
public boolean createChildScope(String name) {
@@ -715,19 +728,18 @@
/**
- *
- * @param event
- * @return
+ * Handles event. To be implemented in subclasses.
+ * @param event Event to handle
+ * @return <code>true</code> on success, <code>false</code> otherwise
*/
@Override
public boolean handleEvent(IEvent event) {
- // TODO Auto-generated method stub
return false;
}
/**
- *
- * @param type
- * @param name
- * @return
+ * Return base scope of given type with given name
+ * @param type Scope type
+ * @param name Scope name
+ * @return Basic scope object
*/
public IBasicScope getBasicScope(String type, String name) {
@@ -736,7 +748,7 @@
/**
- *
- * @param type
- * @return
+ * Return basic scope names iterator
+ * @param type Scope type
+ * @return Iterator
*/
public Iterator<String> getBasicScopeNames(String type) {
@@ -750,7 +762,7 @@
/**
- *
- * @param name
- * @return
+ * Return child scope by name
+ * @param name Scope name
+ * @return Child scope with given name
*/
public IScope getScope(String name) {
@@ -759,6 +771,6 @@
/**
- *
- * @return
+ * Child scopes iterator
+ * @return Child scopes iterator
*/
@Override
@@ -768,6 +780,5 @@
/**
- *
- * @return
+ * {@inheritDoc}
*/
@Override
@@ -778,8 +789,7 @@
}
- /* IServiceHandlerProvider interface */
- /**
- *
- * @return
+ /**
+ * Return map of service handlers
+ * @return Map of service handlers
*/
protected Map<String, Object> getServiceHandlers() {
@@ -789,7 +799,7 @@
/**
- *
- * @param name
- * @param handler
+ * Register service handler by name
+ * @param name Service handler name
+ * @param handler Service handler
*/
public void registerServiceHandler(String name, Object handler) {
@@ -799,6 +809,6 @@
/**
- *
- * @param name
+ * Unregisters service h
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