public class StandardHubProfile extends java.lang.Object implements HubProfile
| Modifier and Type | Field and Description |
|---|---|
private HubXmlRpcHandler |
hubHandler_ |
private java.io.File |
lockfile_ |
private LockInfo |
lockInfo_ |
private java.net.URL |
lockUrl_ |
private static java.util.logging.Logger |
logger_ |
private static java.util.Random |
random_ |
private java.lang.String |
secret_ |
private SampXmlRpcServer |
server_ |
private SampXmlRpcClientFactory |
xClientFactory_ |
private SampXmlRpcServerFactory |
xServerFactory_ |
| Constructor and Description |
|---|
StandardHubProfile()
Constructs a hub profile with default configuration.
|
StandardHubProfile(SampXmlRpcClientFactory xClientFactory,
SampXmlRpcServerFactory xServerFactory,
java.io.File lockfile,
java.lang.String secret)
Constructs a hub profile with given configuration information.
|
| Modifier and Type | Method and Description |
|---|---|
static java.lang.String |
createSecret()
Returns a string suitable for use as a Standard Profile Secret.
|
LockInfo |
getLockInfo()
Returns the lockfile information associated with this object.
|
MessageRestriction |
getMessageRestriction()
Returns a MessageRestriction object which controls what messages
may be sent by clients registering under ths profile.
|
java.lang.String |
getProfileName()
Returns the name of this profile.
|
private static boolean |
isHubAlive(SampXmlRpcClientFactory xClientFactory,
java.io.File lockfile)
Attempts to determine whether a given lockfile corresponds to a hub
which is still alive.
|
boolean |
isRunning()
Indicates whether this profile is currently running.
|
java.net.URL |
publishLockfile()
Returns an HTTP URL at which the lockfile for this hub can be found.
|
private static LockInfo |
readLockFile(java.io.File lockFile)
Reads lockinfo from a file.
|
void |
start(ClientProfile profile)
Starts this profile's activity allowing access to a given supplier of
hub connections.
|
void |
stop()
Ends this profile's activity on behalf of the hub.
|
private static void |
writeLockInfo(LockInfo info,
java.io.OutputStream out)
Writes lockfile information to a given output stream.
|
private final SampXmlRpcClientFactory xClientFactory_
private final SampXmlRpcServerFactory xServerFactory_
private final java.io.File lockfile_
private final java.lang.String secret_
private java.net.URL lockUrl_
private SampXmlRpcServer server_
private volatile HubXmlRpcHandler hubHandler_
private LockInfo lockInfo_
private static final java.util.logging.Logger logger_
private static final java.util.Random random_
public StandardHubProfile(SampXmlRpcClientFactory xClientFactory, SampXmlRpcServerFactory xServerFactory, java.io.File lockfile, java.lang.String secret)
lockfile is null, no lockfile will
be written at hub startup.xClientFactory - XML-RPC client factory implementationxServerFactory - XML-RPC server implementationlockfile - location to use for hub lockfile, or nullsecret - value for samp.secret lockfile keypublic StandardHubProfile()
throws java.io.IOException
java.io.IOExceptionpublic java.lang.String getProfileName()
HubProfilegetProfileName in interface HubProfilegetProfileName in interface ProfileTokenpublic MessageRestriction getMessageRestriction()
ProfileTokengetMessageRestriction in interface ProfileTokenpublic void start(ClientProfile profile) throws java.io.IOException
HubProfilestart in interface HubProfileprofile - object which can provide hub connectionsjava.io.IOExceptionpublic boolean isRunning()
HubProfileisRunning in interface HubProfilepublic void stop()
HubProfilestop in interface HubProfilepublic LockInfo getLockInfo()
public java.net.URL publishLockfile()
throws java.io.IOException
Use this with care; publishing your lockfile means that other people can connect to your hub and potentially do disruptive things.
java.io.IOExceptionpublic static java.lang.String createSecret()
private static boolean isHubAlive(SampXmlRpcClientFactory xClientFactory, java.io.File lockfile)
xClientFactory - XML-RPC client factory implementationlockfile - lockfile locationlockfile appears
to be alive and wellprivate static LockInfo readLockFile(java.io.File lockFile) throws java.io.IOException
lockFile - filejava.io.IOExceptionprivate static void writeLockInfo(LockInfo info, java.io.OutputStream out) throws java.io.IOException
info - lock info to writeout - destination streamjava.io.IOException