diff options
author | Endi S. Dewata <edewata@redhat.com> | 2017-03-24 03:42:55 +0100 |
---|---|---|
committer | Endi S. Dewata <edewata@redhat.com> | 2017-03-28 01:08:20 +0200 |
commit | a6b64e4f45348011885f268db92beab0d563ff22 (patch) | |
tree | 2eee74ef64ea133d3f12af3e32c420d7f901b52d /base/java-tools/src/com/netscape | |
parent | 18412763e4ec09f4892c2a7b502d72ebfd9fec2a (diff) | |
download | pki-a6b64e4f45348011885f268db92beab0d563ff22.tar.gz pki-a6b64e4f45348011885f268db92beab0d563ff22.tar.xz pki-a6b64e4f45348011885f268db92beab0d563ff22.zip |
Refactored ActivityCLI.
The ActivityCLI and its submodules have been modified to use lazy
initialization to get the PKIClient object.
Diffstat (limited to 'base/java-tools/src/com/netscape')
3 files changed, 12 insertions, 5 deletions
diff --git a/base/java-tools/src/com/netscape/cmstools/logging/ActivityCLI.java b/base/java-tools/src/com/netscape/cmstools/logging/ActivityCLI.java index f53e68700..f0f125edd 100644 --- a/base/java-tools/src/com/netscape/cmstools/logging/ActivityCLI.java +++ b/base/java-tools/src/com/netscape/cmstools/logging/ActivityCLI.java @@ -20,6 +20,7 @@ package com.netscape.cmstools.logging; import org.jboss.resteasy.plugins.providers.atom.Link; +import com.netscape.certsrv.client.PKIClient; import com.netscape.certsrv.logging.ActivityClient; import com.netscape.certsrv.logging.ActivityData; import com.netscape.cmstools.cli.CLI; @@ -38,12 +39,14 @@ public class ActivityCLI extends CLI { addModule(new ActivityShowCLI(this)); } - public void execute(String[] args) throws Exception { + public ActivityClient getActivityClient() throws Exception { - client = parent.getClient(); + if (activityClient != null) return activityClient; + + PKIClient client = getClient(); activityClient = (ActivityClient)parent.getClient("activity"); - super.execute(args); + return activityClient; } public static void printActivity(ActivityData activity, boolean showAll) { diff --git a/base/java-tools/src/com/netscape/cmstools/logging/ActivityFindCLI.java b/base/java-tools/src/com/netscape/cmstools/logging/ActivityFindCLI.java index 9e31795b4..75c635bdc 100644 --- a/base/java-tools/src/com/netscape/cmstools/logging/ActivityFindCLI.java +++ b/base/java-tools/src/com/netscape/cmstools/logging/ActivityFindCLI.java @@ -24,6 +24,7 @@ import java.util.Collection; import org.apache.commons.cli.CommandLine; import org.apache.commons.cli.Option; +import com.netscape.certsrv.logging.ActivityClient; import com.netscape.certsrv.logging.ActivityCollection; import com.netscape.certsrv.logging.ActivityData; import com.netscape.cmstools.cli.CLI; @@ -75,7 +76,8 @@ public class ActivityFindCLI extends CLI { s = cmd.getOptionValue("size"); Integer size = s == null ? null : Integer.valueOf(s); - ActivityCollection result = activityCLI.activityClient.findActivities(filter, start, size); + ActivityClient activityClient = activityCLI.getActivityClient(); + ActivityCollection result = activityClient.findActivities(filter, start, size); MainCLI.printMessage(result.getTotal() + " entries matched"); if (result.getTotal() == 0) return; diff --git a/base/java-tools/src/com/netscape/cmstools/logging/ActivityShowCLI.java b/base/java-tools/src/com/netscape/cmstools/logging/ActivityShowCLI.java index bae172c79..e31cbf6ab 100644 --- a/base/java-tools/src/com/netscape/cmstools/logging/ActivityShowCLI.java +++ b/base/java-tools/src/com/netscape/cmstools/logging/ActivityShowCLI.java @@ -22,6 +22,7 @@ import java.util.Arrays; import org.apache.commons.cli.CommandLine; +import com.netscape.certsrv.logging.ActivityClient; import com.netscape.certsrv.logging.ActivityData; import com.netscape.cmstools.cli.CLI; import com.netscape.cmstools.cli.MainCLI; @@ -59,7 +60,8 @@ public class ActivityShowCLI extends CLI { String activityID = args[0]; - ActivityData activityData = activityCLI.activityClient.getActivity(activityID); + ActivityClient activityClient = activityCLI.getActivityClient(); + ActivityData activityData = activityClient.getActivity(activityID); MainCLI.printMessage("Activity \"" + activityID + "\""); |