You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mnemonic.apache.org by ka...@apache.org on 2024/01/07 20:39:48 UTC

(mnemonic) branch master updated: MNEMONIC-809: Refactored and Expanded in Computing Service

This is an automated email from the ASF dual-hosted git repository.

katarina pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mnemonic.git


The following commit(s) were added to refs/heads/master by this push:
     new 86b1b05  MNEMONIC-809: Refactored and Expanded in Computing Service
     new a0fdb17  Merge pull request #369 from katarinaking/809
86b1b05 is described below

commit 86b1b051511cc6292a9dfb404cec4a46b83fb4f5
Author: Katarina <ka...@gmail.com>
AuthorDate: Sun Jan 7 20:38:31 2024 +0000

    MNEMONIC-809: Refactored and Expanded in Computing Service
---
 .../computing/internal/PrintServiceImpl.java       | 77 ++++++++++++----------
 1 file changed, 44 insertions(+), 33 deletions(-)

diff --git a/mnemonic-computing-services/mnemonic-utilities-service/src/main/java/org/apache/mnemonic/service/computing/internal/PrintServiceImpl.java b/mnemonic-computing-services/mnemonic-utilities-service/src/main/java/org/apache/mnemonic/service/computing/internal/PrintServiceImpl.java
index 9563f85..baeea6d 100644
--- a/mnemonic-computing-services/mnemonic-utilities-service/src/main/java/org/apache/mnemonic/service/computing/internal/PrintServiceImpl.java
+++ b/mnemonic-computing-services/mnemonic-utilities-service/src/main/java/org/apache/mnemonic/service/computing/internal/PrintServiceImpl.java
@@ -22,44 +22,55 @@ import org.apache.mnemonic.service.computing.ValueInfo;
 import org.apache.mnemonic.primitives.NativeLibraryLoader;
 
 public class PrintServiceImpl implements GeneralComputingService {
-  static {
-    try {
-      NativeLibraryLoader.loadFromJar("utilitiescomputing");
-    } catch (Exception e) {
-      throw new Error(e);
+
+    // Load the native library when the class is loaded
+    static {
+        try {
+            NativeLibraryLoader.loadFromJar("utilitiescomputing");
+        } catch (Exception e) {
+            // If there's an error loading the native library, throw an Error
+            throw new Error("Failed to load native library", e);
+        }
     }
-  }
 
-  /**
-   * {@inheritDoc}
-   */
-  @Override
-  public String getServiceId() {
-    return "print";
-  }
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public String getServiceId() {
+        // Return the unique identifier for this computing service
+        return "print";
+    }
 
-  /**
-   * {@inheritDoc}
-   */
-  @Override
-  public long[] perform(String mode, ValueInfo[] valinfos) {
-    long[] ret = null;
-    if (null != valinfos) {
-      ret = nperformPrint(valinfos);
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public long[] perform(String mode, ValueInfo[] valinfos) {
+        long[] ret = null;
+        if (valinfos != null) {
+            // Call the native method to perform the print action
+            ret = nperformPrint(valinfos);
+        }
+        return ret;
     }
-    return ret;
-  }
 
-  @Override
-  public long[] perform(String mode, ValueInfo[] valinfos, long dcHandler, long dcSize) {
-    throw new UnsupportedOperationException("Invalid operation for print.");
-  }
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public long[] perform(String mode, ValueInfo[] valinfos, long dcHandler, long dcSize) {
+        // This operation is not supported for print, so throw an UnsupportedOperationException
+        throw new UnsupportedOperationException("Invalid operation for print.");
+    }
 
-  /**
-   * A native function to fulfill the action of print in native level.
-   * @param valinfos an array of value info, some of them could be set as NULL
-   * @return an array of handler returned by native level
-   */
-  protected native long[] nperformPrint(ValueInfo[] valinfos);
+    /**
+     * A native function to fulfill the action of print at the native level.
+     *
+     * @param valinfos an array of value info, some of them could be set as NULL
+     * @return an array of handler returned by native level
+     */
+    protected native long[] nperformPrint(ValueInfo[] valinfos);
 
 }
+