use of org.eclipse.ecf.core.ContainerConnectException in project ecf by eclipse.
the class TrivialContainer method connect.
/*
* (non-Javadoc)
*
* @see org.eclipse.ecf.core.IContainer#connect(org.eclipse.ecf.core.identity.ID,
* org.eclipse.ecf.core.security.IConnectContext)
*/
public void connect(ID targetID, IConnectContext connectContext) throws ContainerConnectException {
if (!targetID.getNamespace().getName().equals(getConnectNamespace().getName()))
throw new ContainerConnectException("targetID not of appropriate Namespace");
fireContainerEvent(new ContainerConnectingEvent(getID(), targetID));
// XXX connect to remote service here
this.targetID = targetID;
fireContainerEvent(new ContainerConnectedEvent(getID(), targetID));
}
use of org.eclipse.ecf.core.ContainerConnectException in project ecf by eclipse.
the class IRCChannelContainer method connect.
/*
* (non-Javadoc)
*
* @see
* org.eclipse.ecf.core.IContainer#connect(org.eclipse.ecf.core.identity.ID,
* org.eclipse.ecf.core.security.IConnectContext)
*/
public void connect(ID connectID, IConnectContext connectContext) throws ContainerConnectException {
// Actually do join here
if (connectID == null)
throw new ContainerConnectException(Messages.IRCChannelContainer_Exception_TargetID_Null);
if (connectWaiting)
throw new ContainerConnectException(Messages.IRCChannelContainer_Exception_Connecting);
// Get channel name
String channelName = connectID.getName();
fireContainerEvent(new ContainerConnectingEvent(this.getID(), connectID, connectContext));
// Get password via callback in connectContext
String pw = getPasswordFromConnectContext(connectContext);
synchronized (connectLock) {
connectWaiting = true;
try {
rootContainer.doJoinChannel(channelName, pw);
long timeout = CONNECT_TIMEOUT + System.currentTimeMillis();
while (connectWaiting && timeout > System.currentTimeMillis()) {
connectLock.wait(2000);
}
if (connectWaiting)
throw new TimeoutException(NLS.bind(Messages.IRCChannelContainer_Exception_Connect_Timeout, connectID.getName()), CONNECT_TIMEOUT);
this.targetID = connectID;
fireContainerEvent(new ContainerConnectedEvent(this.getID(), this.targetID));
} catch (Exception e) {
this.targetID = null;
throw new ContainerConnectException(NLS.bind(Messages.IRCChannelContainer_Exception_Connect_Failed, connectID.getName()), e);
} finally {
connectWaiting = false;
}
}
}
use of org.eclipse.ecf.core.ContainerConnectException in project ecf by eclipse.
the class AbstractClientContainer method connect.
// IContainer implementation methods
public void connect(ID targetID, IConnectContext connectContext1) throws ContainerConnectException {
if (targetID == null)
// $NON-NLS-1$
throw new ContainerConnectException("targetID cannot be null");
Namespace targetNamespace = targetID.getNamespace();
Namespace connectNamespace = getConnectNamespace();
if (connectNamespace == null)
// $NON-NLS-1$
throw new ContainerConnectException("targetID namespace cannot be null");
if (!(targetNamespace.getName().equals(connectNamespace.getName())))
// $NON-NLS-1$
throw new ContainerConnectException("targetID of incorrect type");
fireContainerEvent(new ContainerConnectingEvent(containerID, targetID));
synchronized (connectLock) {
if (connectedID == null) {
connectedID = targetID;
this.connectContext = connectContext1;
} else if (!connectedID.equals(targetID))
// $NON-NLS-1$
throw new ContainerConnectException("Already connected to " + connectedID.getName());
}
fireContainerEvent(new ContainerConnectedEvent(containerID, targetID));
}
use of org.eclipse.ecf.core.ContainerConnectException in project ecf by eclipse.
the class ChatRoomBot method connect.
public synchronized void connect() throws ECFException {
fireInitBot();
try {
Namespace namespace = null;
if (container == null) {
container = ContainerFactory.getDefault().createContainer(bot.getContainerFactoryName());
namespace = container.getConnectNamespace();
} else
// $NON-NLS-1$
throw new ContainerConnectException("Already connected");
targetID = IDFactory.getDefault().createID(namespace, bot.getConnectID());
IChatRoomManager manager = (IChatRoomManager) container.getAdapter(IChatRoomManager.class);
if (manager == null)
// $NON-NLS-1$
throw new ECFException("No chat room manager available");
firePreConnect();
String password = bot.getPassword();
IConnectContext context = (password == null) ? null : ConnectContextFactory.createPasswordConnectContext(password);
container.connect(targetID, context);
String[] roomNames = bot.getChatRooms();
String[] roomPasswords = bot.getChatRoomPasswords();
for (int i = 0; i < roomNames.length; i++) {
IChatRoomInfo room = manager.getChatRoomInfo(roomNames[i]);
roomContainer = room.createChatRoomContainer();
roomID = room.getRoomID();
firePreRoomConnect();
roomContainer.addMessageListener(this);
IConnectContext roomContext = (roomPasswords[i] == null) ? null : ConnectContextFactory.createPasswordConnectContext(roomPasswords[i]);
roomContainer.connect(roomID, roomContext);
}
} catch (ECFException e) {
if (container != null) {
if (container.getConnectedID() != null) {
container.disconnect();
}
container.dispose();
}
container = null;
throw e;
}
}
use of org.eclipse.ecf.core.ContainerConnectException in project ecf by eclipse.
the class XMPPChatRoomContainer method connect.
public void connect(String groupName) throws ContainerConnectException {
ID targetID = null;
try {
targetID = createChatRoomID(groupName);
} catch (final IDCreateException e) {
throw new ContainerConnectException(Messages.XMPPChatRoomContainer_EXCEPTION_CREATING_ROOM_ID, e);
}
this.connect(targetID, null);
}
Aggregations