org.eclipse.ecf.provider.xmpp
Class XMPPContainer

java.lang.Object
  extended by org.eclipse.ecf.core.AbstractContainer
      extended by org.eclipse.ecf.provider.generic.SOContainer
          extended by org.eclipse.ecf.provider.generic.ClientSOContainer
              extended by org.eclipse.ecf.provider.xmpp.XMPPContainer
All Implemented Interfaces:
org.eclipse.core.runtime.IAdaptable, IContainer, IIdentifiable, IReliableContainer, ISharedObjectContainer, ISharedObjectContainerClient, IPresenceContainerAdapter, IPresenceService
Direct Known Subclasses:
XMPPSContainer

public class XMPPContainer
extends ClientSOContainer
implements IPresenceService

Since:
3.0

Field Summary
static java.lang.String CONNECT_NAMESPACE
           
static java.lang.String CONTAINER_HELPER_ID
           
static int DEFAULT_KEEPALIVE
           
protected static java.lang.String GOOGLE_SERVICENAME
           
protected  int keepAlive
           
protected  ID presenceHelperID
           
static java.lang.String XMPP_GOOGLE_OVERRIDE_PROP_NAME
           
 
Fields inherited from class org.eclipse.ecf.provider.generic.ClientSOContainer
CONNECTED, CONNECTING, connection, connectionState, connectLock, connectPolicy, DEFAULT_CONNECT_TIMEOUT, DISCONNECTED, remoteServerID
 
Fields inherited from class org.eclipse.ecf.provider.generic.SOContainer
config, DEFAULT_OBJECT_ARG_KEY, DEFAULT_OBJECT_ARGTYPES_KEY, groupManager, isClosing, loadingThreadGroup, policy, receiver, sharedObjectManager, sharedObjectMessageSerializer, sharedObjectThreadGroup
 
Constructor Summary
  XMPPContainer()
           
  XMPPContainer(int ka)
           
protected XMPPContainer(SOContainerConfig config, int keepAlive)
           
  XMPPContainer(java.lang.String userhost, int ka)
           
 
Method Summary
 void connect(ID remote, IConnectContext joinContext)
          Connect to a target remote process or process group.
protected  Callback[] createAuthorizationCallbacks()
           
protected  java.lang.Object createConnectData(ID target, Callback[] cbs, java.lang.Object data)
           
protected  ISynchAsynchConnection createConnection(ID remoteSpace, java.lang.Object data)
          Create connection instance.
protected  SOContext createSharedObjectContext(SOConfig soconfig, IQueueEnqueue queue)
           
protected  void deliverEvent(Event evt)
           
 void disconnect()
          Disconnect.
 void dispose()
          Dispose this IContainer instance.
 IAccountManager getAccountManager()
          Get interface for managing account
 java.lang.Object getAdapter(java.lang.Class clazz)
          This specialization of IAdaptable.getAdapter() returns additional services supported by this container.
 IChatManager getChatManager()
          Get chat manager for sending and receiving chat messages
 IChatRoomManager getChatRoomManager()
          Get chat room manager for this presence container.
protected  java.lang.Object getConnectData(ID remote, IConnectContext joinContext)
           
 Namespace getConnectNamespace()
          Get the Namespace for creating a targetID suitable for use as the first parameter in subsequent calls to IContainer.connect(ID, IConnectContext).
protected  int getConnectTimeout()
           
 org.eclipse.ecf.internal.provider.xmpp.smack.ECFConnection getECFConnection()
           
protected  org.jivesoftware.smack.Roster getRoster()
           
 IRosterManager getRosterManager()
          Get roster manager for access to roster model.
 IUserSearchManager getUserSearchManager()
          Retrieve interface for search on the provide.
 org.jivesoftware.smack.XMPPConnection getXMPPConnection()
           
protected  boolean handleAsExtension(org.jivesoftware.smack.packet.Packet packet)
           
protected  ID handleConnectResponse(ID originalTarget, java.lang.Object serverData)
           
protected  void handleXMPPMessage(org.jivesoftware.smack.packet.Packet aPacket)
           
protected  boolean isGoogle(ID remoteSpace)
           
protected  void log(java.lang.String msg, java.lang.Throwable e)
           
protected  void processAsynch(AsynchEvent e)
           
protected  void sendMessage(ContainerMessage data)
           
protected  boolean verifySharedObjectMessageTarget(ID containerID)
           
 
Methods inherited from class org.eclipse.ecf.provider.generic.ClientSOContainer
disconnect, forwardExcluding, forwardExcluding, forwardToRemote, getConnectedID, getConnection, getConnectLock, getIDForConnection, getLeaveData, handleLeave, handleLeaveGroupMessage, handleViewChangeMessage, isConnected, isConnecting, isGroupManager, processDisconnect, processSynch, queueContainerMessage, sendCreate, sendCreateMsg, sendCreateResponse, sendCreateResponseSharedObjectMessage, sendCreateSharedObjectMessage, sendDispose, sendDisposeSharedObjectMessage, sendMessage, sendSharedObjectMessage, setConnectInitiatorPolicy
 
Methods inherited from class org.eclipse.ecf.provider.generic.SOContainer
addNewRemoteMember, addSharedObject0, addSharedObjectAndWait, addSharedObjectWrapper, addToLoading, checkRemoteCreate, createContainerPropertiesForSharedObject, createRemoteSharedObjectConfig, createRemoteSharedObjectContext, createRemoteSharedObjectWrapper, createSharedObjectConfig, createSharedObjectWrapper, debug, defaultDeserializeSharedObjectMessage, defaultSerializeSharedObjectMessage, deserializeContainerMessage, deserializeSharedObjectMessage, destroySharedObject, disconnect, fireDelegateContainerEvent, forward, getArgsFromProperties, getArgTypesFromProperties, getClassLoaderForContainer, getClassLoaderForSharedObject, getConfig, getGroupMemberIDs, getGroupMembershipLock, getID, getMaxGroupMembers, getNewSharedObjectThread, getNextSequenceNumber, getOtherMemberIDs, getReceiver, getSharedObject, getSharedObjectIDs, getSharedObjectManager, getSharedObjectMessageSerializer, getSharedObjectWrapper, handleAsynchIOException, handleCreateMessage, handleCreateResponseMessage, handleSharedObjectDisposeMessage, handleSharedObjectMessage, handleUndeliveredSharedObjectMessage, handleUnidentifiedMessage, isClosing, load, moveFromLoadingToActive, notifySharedObjectActivated, notifySharedObjectDeactivated, printToSystemError, removeFromLoading, removeRemoteMember, removeSharedObject, serialize, serializeSharedObjectMessage, setMaxGroupMembers, setRemoteAddPolicy, setSharedObjectMessageSerializer, traceStack, validateContainerMessage, verifyToIDForSharedObjectMessage
 
Methods inherited from class org.eclipse.ecf.core.AbstractContainer
addListener, fireContainerEvent, getPasswordFromConnectContext, removeListener
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.eclipse.ecf.core.IContainer
addListener, removeListener
 

Field Detail

DEFAULT_KEEPALIVE

public static final int DEFAULT_KEEPALIVE
See Also:
Constant Field Values

CONNECT_NAMESPACE

public static final java.lang.String CONNECT_NAMESPACE

CONTAINER_HELPER_ID

public static final java.lang.String CONTAINER_HELPER_ID

GOOGLE_SERVICENAME

protected static final java.lang.String GOOGLE_SERVICENAME
See Also:
Constant Field Values

XMPP_GOOGLE_OVERRIDE_PROP_NAME

public static final java.lang.String XMPP_GOOGLE_OVERRIDE_PROP_NAME
See Also:
Constant Field Values

keepAlive

protected int keepAlive

presenceHelperID

protected ID presenceHelperID
Constructor Detail

XMPPContainer

protected XMPPContainer(SOContainerConfig config,
                        int keepAlive)
                 throws java.lang.Exception
Throws:
java.lang.Exception

XMPPContainer

public XMPPContainer()
              throws java.lang.Exception
Throws:
java.lang.Exception

XMPPContainer

public XMPPContainer(int ka)
              throws java.lang.Exception
Throws:
java.lang.Exception

XMPPContainer

public XMPPContainer(java.lang.String userhost,
                     int ka)
              throws java.lang.Exception
Throws:
java.lang.Exception
Method Detail

verifySharedObjectMessageTarget

protected boolean verifySharedObjectMessageTarget(ID containerID)
Overrides:
verifySharedObjectMessageTarget in class SOContainer
Since:
3.2

sendMessage

protected void sendMessage(ContainerMessage data)
                    throws java.io.IOException
Overrides:
sendMessage in class ClientSOContainer
Throws:
java.io.IOException
Since:
3.2

getRosterManager

public IRosterManager getRosterManager()
Description copied from interface: IPresenceContainerAdapter
Get roster manager for access to roster model. If null is returned roster manager unavailable for this adapter.

Specified by:
getRosterManager in interface IPresenceContainerAdapter
Returns:
IRosterManager if available for this adapter. Will be null if not available for for the implementing provider.

getUserSearchManager

public IUserSearchManager getUserSearchManager()
Description copied from interface: IPresenceContainerAdapter
Retrieve interface for search on the provide. The returned IUserSearchManager (if not null) can be used to search users related to the same provider.

Specified by:
getUserSearchManager in interface IPresenceContainerAdapter
Returns:
IUserSearchManager. null if no search available for this provider.
Since:
3.0

getAccountManager

public IAccountManager getAccountManager()
Description copied from interface: IPresenceContainerAdapter
Get interface for managing account

Specified by:
getAccountManager in interface IPresenceContainerAdapter
Returns:
IAccountManger. Will be null if no account manager available

getChatRoomManager

public IChatRoomManager getChatRoomManager()
Description copied from interface: IPresenceContainerAdapter
Get chat room manager for this presence container. If returns null, no chat room facilities are available

Specified by:
getChatRoomManager in interface IPresenceContainerAdapter
Returns:
a chat room manager instance if chat room facilities are available for this presence container If no such facilities are available, returns null.

getChatManager

public IChatManager getChatManager()
Description copied from interface: IPresenceContainerAdapter
Get chat manager for sending and receiving chat messages

Specified by:
getChatManager in interface IPresenceContainerAdapter
Returns:
IChatManager for this presence container adapter. Will be null if no chat manager available for given provider.

getConnectNamespace

public Namespace getConnectNamespace()
Description copied from interface: IContainer
Get the Namespace for creating a targetID suitable for use as the first parameter in subsequent calls to IContainer.connect(ID, IConnectContext). If this method returns null, then it means that null is expected as a valid parameter in subsequent calls to IContainer.connect(ID, IConnectContext). If this method returns a non-null Namespace, then the targetID parameter in IContainer.connect(ID, IConnectContext) must be non-null instance created of the returned Namespace.

Specified by:
getConnectNamespace in interface IContainer
Overrides:
getConnectNamespace in class SOContainer
Returns:
Namespace the namespace associated with subsequent calls to IContainer.connect(ID, IConnectContext). If null, then the targetID instances passed to IContainer.connect(ID, IConnectContext) may be null. If not null, then targetID instances passed to IContainer.connect(ID, IConnectContext) must be instances of the returned Namespace.

connect

public void connect(ID remote,
                    IConnectContext joinContext)
             throws ContainerConnectException
Description copied from interface: IContainer
Connect to a target remote process or process group. The target identified by the first parameter (targetID) is connected the implementation class. If authentication information is required, the required information is given via via the second parameter (connectContext). Callers note that depending upon the provider implementation this method may block. It is suggested that callers use a separate thread to call this method. This method provides an implementation independent way for container implementations to connect, authenticate, and communicate with a remote service or group of services. Providers are responsible for implementing this operation in a way appropriate to the given remote service (or group) via expected protocol.

Specified by:
connect in interface IContainer
Overrides:
connect in class ClientSOContainer
Parameters:
remote - the ID of the remote server or group to connect to. See IContainer.getConnectNamespace() for a explanation of the constraints upon this parameter.
joinContext - any required context to allow this container to authenticate. May be null if underlying provider does not have any authentication requirements for connection.
Throws:
ContainerConnectException - thrown if communication cannot be established with remote service. Causes can include network connection failure, authentication failure, server error, or if container is already connected.

disconnect

public void disconnect()
Description copied from interface: IContainer
Disconnect. This operation will disconnect the local container instance from any previously joined target or group. Subsequent calls to getConnectedID() will return null.

Specified by:
disconnect in interface IContainer
Overrides:
disconnect in class ClientSOContainer

dispose

public void dispose()
Description copied from interface: IContainer
Dispose this IContainer instance. The container instance will be made inactive after the completion of this method and will be unavailable for subsequent usage.

Specified by:
dispose in interface IContainer
Overrides:
dispose in class ClientSOContainer

getAdapter

public java.lang.Object getAdapter(java.lang.Class clazz)
Description copied from interface: IContainer
This specialization of IAdaptable.getAdapter() returns additional services supported by this container. A container that supports additional services over and above the methods on IContainer should return them using this method. It is recommended that clients use this method rather than instanceof checks and downcasts to find out about the capabilities of a specific container.

Typically, after obtaining an IContainer, a client would use this method as a means to obtain a more meaningful interface to the container. This interface may or may not extend IContainer. For example, a client could use the following code to obtain an instance of ISharedObjectContainer:

 IContainer newContainer = ContainerFactory.createContainer(type);
 ISharedObjectContainer soContainer = (ISharedObjectContainer) newContainer
                .getAdapter(ISharedObjectContainer.class);
 if (soContainer == null)
        throw new ContainerCreateException(message);
 

Implementations of this method should delegate to IAdapterManager.loadAdapter() if the service cannot be provided directly to ensure extensibility by third-party plug-ins.

Specified by:
getAdapter in interface org.eclipse.core.runtime.IAdaptable
Specified by:
getAdapter in interface IContainer
Overrides:
getAdapter in class SOContainer
Parameters:
clazz - the service type to look up
Returns:
the service instance castable to the given class, or null if this container does not support the given service

handleConnectResponse

protected ID handleConnectResponse(ID originalTarget,
                                   java.lang.Object serverData)
                            throws java.lang.Exception
Overrides:
handleConnectResponse in class ClientSOContainer
Throws:
java.lang.Exception

createConnection

protected ISynchAsynchConnection createConnection(ID remoteSpace,
                                                  java.lang.Object data)
                                           throws ConnectionCreateException
Description copied from class: ClientSOContainer
Create connection instance. This method is called by ClientSOContainer.connect(ID, IConnectContext). Following a return from this method, the new ISynchAsynchConnection instance's IConnection.connect(ID, Object, int) method is subsequently called.

Specified by:
createConnection in class ClientSOContainer
Parameters:
remoteSpace - the targetID to connect to. The value is the same as that passed into ClientSOContainer.connect(ID, IConnectContext).
data - and data provided to the connection via the IConnectContext passed into the ClientSOContainer.connect(ID, IConnectContext) call.
Returns:
ISynchAsynchConnection a connection instance. Will not be null.
Throws:
ConnectionCreateException - thrown if the connection cannot be created.

isGoogle

protected boolean isGoogle(ID remoteSpace)

getConnectData

protected java.lang.Object getConnectData(ID remote,
                                          IConnectContext joinContext)
                                   throws java.io.IOException,
                                          UnsupportedCallbackException
Overrides:
getConnectData in class ClientSOContainer
Throws:
java.io.IOException
UnsupportedCallbackException

createConnectData

protected java.lang.Object createConnectData(ID target,
                                             Callback[] cbs,
                                             java.lang.Object data)

createAuthorizationCallbacks

protected Callback[] createAuthorizationCallbacks()
Overrides:
createAuthorizationCallbacks in class ClientSOContainer

getConnectTimeout

protected int getConnectTimeout()
Overrides:
getConnectTimeout in class ClientSOContainer

getRoster

protected org.jivesoftware.smack.Roster getRoster()
                                           throws java.io.IOException
Throws:
java.io.IOException

deliverEvent

protected void deliverEvent(Event evt)

handleXMPPMessage

protected void handleXMPPMessage(org.jivesoftware.smack.packet.Packet aPacket)
                          throws java.io.IOException
Throws:
java.io.IOException

handleAsExtension

protected boolean handleAsExtension(org.jivesoftware.smack.packet.Packet packet)

createSharedObjectContext

protected SOContext createSharedObjectContext(SOConfig soconfig,
                                              IQueueEnqueue queue)
Overrides:
createSharedObjectContext in class SOContainer

processAsynch

protected void processAsynch(AsynchEvent e)
Overrides:
processAsynch in class ClientSOContainer

getECFConnection

public org.eclipse.ecf.internal.provider.xmpp.smack.ECFConnection getECFConnection()

getXMPPConnection

public org.jivesoftware.smack.XMPPConnection getXMPPConnection()

log

protected void log(java.lang.String msg,
                   java.lang.Throwable e)