Search in sources :

Example 46 with Namespace

use of org.eclipse.ecf.core.identity.Namespace in project ecf by eclipse.

the class NoRegistryNamespaceTest method testGetNamespace.

public void testGetNamespace() throws Exception {
    Namespace n = IDFactory.getDefault().getNamespaceByName(this.getClass().getName());
    assertNotNull(n);
    assertTrue(n.getName().equals(getClass().getName()));
}
Also used : Namespace(org.eclipse.ecf.core.identity.Namespace)

Example 47 with Namespace

use of org.eclipse.ecf.core.identity.Namespace in project ecf by eclipse.

the class UuIDTest method testGetNamespace.

public void testGetNamespace() throws Exception {
    final ID id = createID();
    final Namespace ns = id.getNamespace();
    assertNotNull(ns);
}
Also used : ID(org.eclipse.ecf.core.identity.ID) UUID(java.util.UUID) Namespace(org.eclipse.ecf.core.identity.Namespace)

Example 48 with Namespace

use of org.eclipse.ecf.core.identity.Namespace in project ecf by eclipse.

the class UuIDTest method testEqualNamespaces.

public void testEqualNamespaces() throws Exception {
    final ID id1 = createID();
    final ID id2 = createID();
    final Namespace ns1 = id1.getNamespace();
    final Namespace ns2 = id2.getNamespace();
    assertTrue(ns1.equals(ns2));
    assertTrue(ns2.equals(ns2));
}
Also used : ID(org.eclipse.ecf.core.identity.ID) UUID(java.util.UUID) Namespace(org.eclipse.ecf.core.identity.Namespace)

Example 49 with Namespace

use of org.eclipse.ecf.core.identity.Namespace in project ecf by eclipse.

the class ServiceInfoFactory method createServiceTypeID.

/**
 * @param endpointDescription endpoint description
 * @param advertiser advertiser
 * @return IServiceTypeID created service type ID
 * @since 3.0
 */
protected IServiceTypeID createServiceTypeID(org.osgi.service.remoteserviceadmin.EndpointDescription endpointDescription, IDiscoveryAdvertiser advertiser) {
    Namespace servicesNamespace = IDFactory.getDefault().getNamespaceByName(// $NON-NLS-1$
    "ecf.namespace.discovery");
    if (advertiser != null) {
        servicesNamespace = advertiser.getServicesNamespace();
    }
    Map props = endpointDescription.getProperties();
    String[] scopes = PropertiesUtil.getStringArrayWithDefault(props, RemoteConstants.DISCOVERY_SCOPE, IServiceTypeID.DEFAULT_SCOPE);
    String[] protocols = PropertiesUtil.getStringArrayWithDefault(props, RemoteConstants.DISCOVERY_PROTOCOLS, IServiceTypeID.DEFAULT_SCOPE);
    String namingAuthority = PropertiesUtil.getStringWithDefault(props, RemoteConstants.DISCOVERY_NAMING_AUTHORITY, IServiceTypeID.DEFAULT_NA);
    return ServiceIDFactory.getDefault().createServiceTypeID(servicesNamespace, new String[] { RemoteConstants.DISCOVERY_SERVICE_TYPE }, scopes, protocols, namingAuthority);
}
Also used : TreeMap(java.util.TreeMap) Map(java.util.Map) Namespace(org.eclipse.ecf.core.identity.Namespace)

Example 50 with Namespace

use of org.eclipse.ecf.core.identity.Namespace 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;
    }
}
Also used : IChatRoomInfo(org.eclipse.ecf.presence.chatroom.IChatRoomInfo) IConnectContext(org.eclipse.ecf.core.security.IConnectContext) ContainerConnectException(org.eclipse.ecf.core.ContainerConnectException) ECFException(org.eclipse.ecf.core.util.ECFException) IChatRoomManager(org.eclipse.ecf.presence.chatroom.IChatRoomManager) Namespace(org.eclipse.ecf.core.identity.Namespace)

Aggregations

Namespace (org.eclipse.ecf.core.identity.Namespace)51 ID (org.eclipse.ecf.core.identity.ID)10 IServiceTypeID (org.eclipse.ecf.discovery.identity.IServiceTypeID)10 IDCreateException (org.eclipse.ecf.core.identity.IDCreateException)9 ContainerConnectException (org.eclipse.ecf.core.ContainerConnectException)5 JSLPNamespace (org.eclipse.ecf.provider.jslp.identity.JSLPNamespace)4 GUID (org.eclipse.ecf.core.identity.GUID)3 UnknownHostException (java.net.UnknownHostException)2 UUID (java.util.UUID)2 IContainer (org.eclipse.ecf.core.IContainer)2 ContainerConnectedEvent (org.eclipse.ecf.core.events.ContainerConnectedEvent)2 ContainerConnectingEvent (org.eclipse.ecf.core.events.ContainerConnectingEvent)2 StringID (org.eclipse.ecf.core.identity.StringID)2 IConnectContext (org.eclipse.ecf.core.security.IConnectContext)2 ECFException (org.eclipse.ecf.core.util.ECFException)2 ServiceTypeID (org.eclipse.ecf.discovery.identity.ServiceTypeID)2 IPresenceContainerAdapter (org.eclipse.ecf.presence.IPresenceContainerAdapter)2 SimpleResolver (org.xbill.DNS.SimpleResolver)2 URI (java.net.URI)1 Map (java.util.Map)1