sijie commented on a change in pull request #2578: Add support for schema 
extraction from a jar
URL: https://github.com/apache/incubator-pulsar/pull/2578#discussion_r218168735
 
 

 ##########
 File path: 
pulsar-client-tools/src/main/java/org/apache/pulsar/admin/cli/CmdSchemas.java
 ##########
 @@ -83,4 +88,44 @@ void run() throws Exception {
         }
     }
 
+    @Parameters(commandDescription = "Provide the schema via a topic")
+    private class PojoSchema extends CliCommand {
+        @Parameter(description = "persistent://tenant/namespace/topic", 
required = true)
+        private java.util.List<String> params;
+
+        @Parameter(names = { "-j", "--jar" }, description = "jar filepath", 
required = true)
+        private String jarFilePath;
+
+        @Parameter(names = { "-t", "--type" }, description = "type avro or 
json", required = true)
+        private String type;
+
+        @Parameter(names = { "-c", "--class-name" }, description = "class name 
of pojo", required = true)
+        private String className;
+
+        @Override
+        void run() throws Exception {
+            String topic = validateTopicName(params);
+
+            File file  = new File(jarFilePath);
+            ClassLoader cl = new URLClassLoader(new URL[]{ 
file.toURI().toURL() });
+
+            Class cls = cl.loadClass(className);
+
+            PostSchemaPayload input = new PostSchemaPayload();
+
+            if (type.toLowerCase().equals("avro")) {
+                input.setType("avro");
+                
input.setSchema(SchemaExtractor.getAvroSchemaInfo(cls).toString());
 
 Review comment:
   it should be `new String(SchemaInfo#getSchema(), UTF_8)`

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

Reply via email to