Namespace creation is a complex process. Therefore, a factory is used for this purpose, the namespace factory. This factory is registered as a service in the service registry.

Get the factory

The factory is fetched as a singleton from the service registry:

final INamespaceFactory nf = CServiceRegistry.getInstance()

As always, make sure that the service starter of your package has a dependency on the INamespaceFactory to ensure that the factory already exists.

The creation of namespaces

To create a namespace, we need a namespace ID that has not yet been assigned and a short description of the new namespace.

@NotNull INamespace createAndRegisterNamespace(@NotNull IId aNID,
                                               @NotNull String aDescription) throws CException;


final IId nid = CIdFactory.fromObject("MyLovelyNamespace");
final INamespace ns = namespaceFactory.createAndRegisterNamespace(nid,

By the way, if a namespace with this ID already exists, it will simply be returned.

The deletion of a namespace

There is likewise a method for deleting a namespace. In addition to the namespace, all threads, targets and nano services that belong to the namespace are also destroyed.

void deleteNamespace(@NotNull IId aNID) throws CException;

Fetching a namespace

You can also just fetch a namespace with the namespace factory. If it does not exist, null is returned. - Innovative Distributed System