This site contains the documentation that is relevant to older WSO2 product versions and offerings.
For the latest WSO2 documentation, visit https://wso2.com/documentation/.
Accessing Registry Remotely through API
The RemoteRegistry
is a Java API for interacting with a Registry instance. Regardless of where a given Registry instance is located, either locally or remotely, you can still talk to it using RemoteRegistry
.
The RemoteRegistry
is yet another implementation of org.wso2.registry.Registry
interface. However, the difference between the RemoteRegistry
and a standard Registry
is that, the RemoteRegistry
is not an actual registry but a client for interacting with a registry instance.
Communication between the Registry
and the RemoteRegistry
takes place using the Atom Publishing Protocol (APP). When we start the registry server, an atom feed is generated. Thereafter, if you browse https://localhost:9443/registry/atom/ (this address changes depending on your application server settings), you'd be able to see the atom feed from the registry.
How to Create an Instance of the RemoteRegistry
1. Create an instance of the RemoteRegistry
. For that purpose, figure out the URL of a registry. If the root of the registry is http://foo.com/, the URL for the RemoteRegistry
instance would be http://foo.com/registry/atom.
2. Once the URL is figured out, create an instance of the RemoteRegistry
using the following code:
System.setProperty("javax.net.ssl.trustStore", "GREG_HOME/repository/resources/security/client-truststore.jks"); System.setProperty("javax.net.ssl.trustStorePassword", "wso2carbon"); System.setProperty("javax.net.ssl.trustStoreType","JKS"); Â System.setProperty("carbon.repo.write.mode", "true"); RemoteRegistry remote_registry = new RemoteRegistry(new URL("https://localhost:9443/registry"));
Creating an instance of the RemoteRegistry
in this manner, is similar to accessing a registry without login into it with communication taking place as an anonymous user.
If you have a user name and password for the registry, you can pass them along when creating the remote_registry
instance. At that point, all permissions granted for the particular username/password pair will apply to the owner of the remote_registry
instance.
Creating the remote_registry
with user name and the password can be done using:
RemoteRegistry remote_registry = new RemoteRegistry(new URL("https://localhost:9443/registry"), "admin", "admin");
In this example, the remote_registry
instance username with the value "admin" and the password as also "admin".
Using the Registry API
You can learn how to use Registry API from the Basic Registry API Knowledge section.
Importing the Local File System to the Registry
You can use the RemoteRegistry
to export your entire local file system into the Registry.
1. Give the location of the file system and the location where you want to put them in the Registry.
2. Once you do that, inside the registry, it will create the same structure as the file system and upload all files into the Registry. This can be considered as any check-in operation on any kind of version management system.
3. The following code demonstrates how to import a local file system into the Registry:
File file = new File("Path of the file"); RemoteRegistry remote_registry = new RemoteRegistry(new URL("http://localhost:9443/registry"), "admin", "admin"); RegistryClientUtils.importToRegistry(file ,"/myFile/filesystem" ,remote_registry);
Exporting the Registry to a File System
1. To export, select either the entire Registry or a selected node.
2. Depending on the node selected, the remote_registry
instance will create the same structure within the file system. Even if you have the resource with binary data, it will create all of the necessary files in the file system.
For example, to export "/myFile/filesystem" into my local file system then we can use the following code:
File toFile = new File("Path of the new file"); RemoteRegistry remote_registry = new RemoteRegistry(new URL("http://localhost:9443/registry"), "admin", "admin"); RegistryClientUtils.exportFromRegistry( toFile, "/myFile/filesystem" ,remote_registry);