org.cometd.common
Class AbstractTransport

java.lang.Object
  extended by org.cometd.common.AbstractTransport
All Implemented Interfaces:
Transport

public class AbstractTransport
extends Object
implements Transport


Constructor Summary
protected AbstractTransport(String name, Map<String,Object> options)
           
 
Method Summary
 String getName()
           
 Object getOption(String name)
          Get an option value.
 boolean getOption(String option, boolean dftValue)
          Get option or default value.
 int getOption(String option, int dftValue)
          Get option or default value.
 long getOption(String option, long dftValue)
          Get option or default value.
 String getOption(String option, String dftValue)
          Get option or default value.
 Set<String> getOptionNames()
           
 String getOptionPrefix()
           
 void setOption(String name, Object value)
           
 void setOptionPrefix(String prefix)
          Set the option name prefix segment.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AbstractTransport

protected AbstractTransport(String name,
                            Map<String,Object> options)
Method Detail

getName

public String getName()
Specified by:
getName in interface Transport

getOption

public Object getOption(String name)
Get an option value. Get an option value by searching the option name tree. The option map obtained by calling BayeuxServerImpl#getOptions() is searched for the option name with the most specific prefix. If this transport was initialised with calls:
   addPrefix("long-polling");
   addPrefix("jsonp");
 
then a call to getOption("foobar") will look for the most specific value with names:
   long-polling.json.foobar
   long-polling.foobar
   foobar
 

Specified by:
getOption in interface Transport

setOption

public void setOption(String name,
                      Object value)
Parameters:
name -
value -

getOptionPrefix

public String getOptionPrefix()
Specified by:
getOptionPrefix in interface Transport

setOptionPrefix

public void setOptionPrefix(String prefix)
Set the option name prefix segment.

Normally this is called by the super class constructors to establish a naming hierarchy for options and iteracts with the setOption(String, Object) method to create a naming hierarchy for options. For example the following sequence of calls:

   setOption("foo","x");
   setOption("bar","y");
   setOptionPrefix("long-polling");
   setOption("foo","z");
   setOption("whiz","p");
   setOptionPrefix("long-polling.jsonp");
   setOption("bang","q");
   setOption("bar","r");
 
will establish the following option names and values:
   foo: x
   bar: y
   long-polling.foo: z
   long-polling.whiz: p
   long-polling.jsonp.bang: q
   long-polling.jsonp.bar: r
 
The various getOption(String) methods will search this name tree for the most specific match.

Parameters:
segment - name
Throws:
IllegalArgumentException - if the new prefix is not prefixed by the old prefix.

getOptionNames

public Set<String> getOptionNames()
Specified by:
getOptionNames in interface Transport
See Also:
getOptionNames()

getOption

public String getOption(String option,
                        String dftValue)
Get option or default value.

Parameters:
option - The option name.
dftValue - The default value.
Returns:
option or default value
See Also:
getOption(String)

getOption

public long getOption(String option,
                      long dftValue)
Get option or default value.

Parameters:
option - The option name.
dftValue - The default value.
Returns:
option or default value
See Also:
getOption(String)

getOption

public int getOption(String option,
                     int dftValue)
Get option or default value.

Parameters:
option - The option name.
dftValue - The default value.
Returns:
option or default value
See Also:
getOption(String)

getOption

public boolean getOption(String option,
                         boolean dftValue)
Get option or default value.

Parameters:
option - The option name.
dftValue - The default value.
Returns:
option or default value
See Also:
getOption(String)


Copyright © 2008-2011 Dojo Foundation. All Rights Reserved.