Maven Repo & Dependencies
<repository>
<id>wso2-nexus</id>
<name>WSO2 internal Repository</name>
<url>http://maven.wso2.org/nexus/content/groups/wso2-public/</url>
<releases>
<enabled>true</enabled>
<updatePolicy>daily</updatePolicy>
<checksumPolicy>fail</checksumPolicy>
</releases>
</repository>
<dependency>
<groupId>org.wso2.carbon</groupId>
<artifactId>org.wso2.carbon.registry.api</artifactId>
<version>4.3.0</version>
</dependency>
<dependency>
<groupId>org.wso2.carbon</groupId>
<artifactId>org.wso2.carbon.registry.core</artifactId>
<version>4.3.0</version>
</dependency>
Import these Classes
import org.wso2.carbon.context.CarbonContext; import org.wso2.carbon.context.RegistryType; import org.wso2.carbon.registry.api.Registry; import org.wso2.carbon.registry.api.RegistryException; import org.wso2.carbon.registry.api.Resource;
try {
CarbonContext cCtx = CarbonContext.getThreadLocalCarbonContext();
Registry registry = cCtx.getRegistry(RegistryType.LOCAL_REPOSITORY);
Resource resource = registry.get("/c1/c2/r1");
Object content = resource.getContent();
String output = new String((byte[]) content);
System.out.println(output);
} catch (RegistryException e) {
e.printStackTrace();
}
Adding a Resource
try {
CarbonContext cCtx = CarbonContext.getThreadLocalCarbonContext();
Registry registry = cCtx.getRegistry(RegistryType.LOCAL_REPOSITORY);
Resource resource = registry.newResource();
String str = "My File Content";
resource.setContent(str.getBytes());
registry.put("/c1/c2/r1", resource);
}
catch (RegistryException e) {
e.printStackTrace();
}