Skip to content

Commit

Permalink
Convert sodVariables to describable
Browse files Browse the repository at this point in the history
  • Loading branch information
timja committed Jun 21, 2019
1 parent 742e1e4 commit 9c9a98c
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 100 deletions.
81 changes: 4 additions & 77 deletions src/main/java/com/sonyericsson/jenkins/plugins/bfa/PluginImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -44,21 +44,18 @@
import hudson.security.Permission;
import hudson.security.PermissionGroup;
import hudson.util.CopyOnWriteList;
import java.io.File;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.annotation.Nonnull;
import jenkins.model.GlobalConfiguration;
import jenkins.model.Jenkins;
import net.sf.json.JSONObject;
import org.jenkinsci.Symbol;
import org.kohsuke.accmod.Restricted;
import org.kohsuke.accmod.restrictions.NoExternalUse;
import org.kohsuke.stapler.DataBoundConstructor;
import org.kohsuke.stapler.DataBoundSetter;
import org.kohsuke.stapler.StaplerRequest;

import javax.annotation.Nonnull;
import java.io.File;
import java.util.logging.Level;
import java.util.logging.Logger;

/**
* The main thing.
*
Expand Down Expand Up @@ -240,76 +237,6 @@ public ScanOnDemandVariables getSodVariables() {
return sodVariables;
}

/**
* Used by jelly for loading the view, it can't seem to handle retrieving from the nested field.
*
* @return minimum sod worker threads
*/
@Restricted(NoExternalUse.class)
public int getMinimumSodWorkerThreads() {
if (sodVariables == null) {
return ScanOnDemandVariables.DEFAULT_MINIMUM_SOD_WORKER_THREADS;
}

return sodVariables.getMinimumSodWorkerThreads();
}

/**
* Used by jelly for loading the view, it can't seem to handle retrieving from the nested field.
*
* @return maximum sod worker threads
*/
@Restricted(NoExternalUse.class)
public int getMaximumSodWorkerThreads() {
if (sodVariables == null) {
return ScanOnDemandVariables.DEFAULT_MAXIMUM_SOD_WORKER_THREADS;
}

return sodVariables.getMaximumSodWorkerThreads();
}

/**
* Used by jelly for loading the view, it can't seem to handle retrieving from the nested field.
*
* @return sod thread keep alive time
*/
@Restricted(NoExternalUse.class)
public int getSodThreadKeepAliveTime() {
if (sodVariables == null) {
return ScanOnDemandVariables.DEFAULT_SOD_THREADS_KEEP_ALIVE_TIME;
}

return sodVariables.getSodThreadKeepAliveTime();
}

/**
* Used by jelly for loading the view, it can't seem to handle retrieving from the nested field.
*
* @return sod wait for job shutdown timeout
*/
@Restricted(NoExternalUse.class)
public int getSodWaitForJobShutdownTimeout() {
if (sodVariables == null) {
return ScanOnDemandVariables.DEFAULT_SOD_WAIT_FOR_JOBS_SHUTDOWN_TIMEOUT;
}

return sodVariables.getSodWaitForJobShutdownTimeout();
}

/**
* Used by jelly for loading the view, it can't seem to handle retrieving from the nested field.
*
* @return sod core pool number of threads
*/
@Restricted(NoExternalUse.class)
public int getSodCorePoolNumberOfThreads() {
if (sodVariables == null) {
return ScanOnDemandVariables.DEFAULT_SOD_COREPOOL_THREADS;
}

return sodVariables.getSodCorePoolNumberOfThreads();
}

/**
* Returns the base relative URI for static images packaged in webapp.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@
*/
package com.sonyericsson.jenkins.plugins.bfa.sod;

import hudson.Extension;
import hudson.model.AbstractDescribableImpl;
import hudson.model.Descriptor;
import org.kohsuke.stapler.DataBoundConstructor;
import org.kohsuke.stapler.DataBoundSetter;

Expand All @@ -31,7 +34,7 @@
*
* @author Shemeer S <shemeer.x.sulaiman@sonymobile.com>
*/
public class ScanOnDemandVariables {
public class ScanOnDemandVariables extends AbstractDescribableImpl<ScanOnDemandVariables> {

/**
* Minimum number of worker threads.
Expand Down Expand Up @@ -182,4 +185,11 @@ public int getSodWaitForJobShutdownTimeout() {
return sodWaitForJobShutdownTimeout;
}

/**
* Descriptor for {@link ScanOnDemandVariables}.
*/
@Extension
public static class DescriptorImpl extends Descriptor<ScanOnDemandVariables> {

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
~ THE SOFTWARE.
-->
<?jelly escape-by-default='true'?>
<j:jelly xmlns:j="jelly:core" xmlns:f="/lib/form" xmlns:st="jelly:stapler" xmlns:l="/lib/layout">
<j:jelly xmlns:j="jelly:core" xmlns:f="/lib/form" xmlns:st="jelly:stapler">
<f:section title="${%Build failure analyzer}">
<f:entry title="${%Enabled}"
description="${%If builds should be scanned or not.}">
Expand Down Expand Up @@ -68,27 +68,10 @@
</f:block>
</f:section>
<f:advanced>
<f:section title="${%Scan non-scanned builds}" name="sodVariables">
<f:entry title="${%Minimum number of Worker Threads}"
description="${%Minimum number of worker threads allotted for failure scan options}">
<f:number field="minimumSodWorkerThreads" />
</f:entry>
<f:entry title="${%Maximum number of Worker Threads}"
description="${%Maximum number of worker threads allotted for failure scan options}">
<f:number field="maximumSodWorkerThreads" />
</f:entry>
<f:entry title="${%Thread keep alive time}"
description="${%Thread keep alive time for failure scan options}">
<f:number field="sodThreadKeepAliveTime" />
</f:entry>
<f:entry title="${%Wait for job shutdown timeout}"
description="${%Wait for job shutdown timeout for failure scan options}">
<f:number field="sodWaitForJobShutdownTimeout" />
</f:entry>
<f:entry title="${%Corepool number of Threads}"
description="${%Corepool number of worker threads allotted for failure scan options}">
<f:number field="sodCorePoolNumberOfThreads" />
</f:entry>
<f:section title="${%Scan non-scanned builds}">
<f:property field="sodVariables">
<st:include page="config.jelly" />
</f:property>
</f:section>
<f:entry title="${%Do not analyze aborted jobs}"
help="/plugin/build-failure-analyzer/help/help-doNotAnalyzeAbortedJobs.html">
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?jelly escape-by-default='true'?>
<j:jelly xmlns:j="jelly:core" xmlns:f="/lib/form">
<f:entry title="${%Minimum number of Worker Threads}"
description="${%Minimum number of worker threads allotted for failure scan options}">
<f:number field="minimumSodWorkerThreads"/>
</f:entry>
<f:entry title="${%Maximum number of Worker Threads}"
description="${%Maximum number of worker threads allotted for failure scan options}">
<f:number field="maximumSodWorkerThreads"/>
</f:entry>
<f:entry title="${%Thread keep alive time}"
description="${%Thread keep alive time for failure scan options}">
<f:number field="sodThreadKeepAliveTime"/>
</f:entry>
<f:entry title="${%Wait for job shutdown timeout}"
description="${%Wait for job shutdown timeout for failure scan options}">
<f:number field="sodWaitForJobShutdownTimeout"/>
</f:entry>
<f:entry title="${%Corepool number of Threads}"
description="${%Corepool number of worker threads allotted for failure scan options}">
<f:number field="sodCorePoolNumberOfThreads"/>
</f:entry>
</j:jelly>

0 comments on commit 9c9a98c

Please sign in to comment.