code reuse on server side, use one registrar
authorEugene.Petrenko <eugene.petrenko@gmail.com>
Tue, 23 Aug 2011 16:55:02 +0000 (18:55 +0200)
committerEugene.Petrenko <eugene.petrenko@gmail.com>
Tue, 23 Aug 2011 16:55:02 +0000 (18:55 +0200)
nuget-server/src/META-INF/build-server-plugin-nuget-install-runner.xml
nuget-server/src/META-INF/build-server-plugin-nuget-pack-runner.xml
nuget-server/src/META-INF/build-server-plugin-nuget-publish-runner.xml
nuget-server/src/META-INF/build-server-plugin-nuget.xml
nuget-server/src/jetbrains/buildServer/nuget/server/runner/NuGetRunType.java [new file with mode: 0644]
nuget-server/src/jetbrains/buildServer/nuget/server/runner/NuGetRunTypesRegistrar.java [moved from nuget-server/src/jetbrains/buildServer/nuget/server/runner/pack/PackRunTypeRegistrar.java with 64% similarity]
nuget-server/src/jetbrains/buildServer/nuget/server/runner/install/PackageInstallerRunTypeRegistrar.java [deleted file]
nuget-server/src/jetbrains/buildServer/nuget/server/runner/install/PackagesInstallerRunType.java
nuget-server/src/jetbrains/buildServer/nuget/server/runner/pack/PackRunType.java
nuget-server/src/jetbrains/buildServer/nuget/server/runner/publish/PublishRunType.java
nuget-server/src/jetbrains/buildServer/nuget/server/runner/publish/PublishRunTypeRegistrar.java [deleted file]

index dd0dff4c066769c58cc3e021fc4ce3aafa3b3bc2..516da6aaa5882126110451bc6e98bef6f8798ff0 100644 (file)
@@ -4,6 +4,5 @@
        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd"\r
        default-autowire="constructor">\r
 \r
-  <bean class="jetbrains.buildServer.nuget.server.runner.install.PackageInstallerRunTypeRegistrar"/>\r
   <bean class="jetbrains.buildServer.nuget.server.runner.install.PackagesInstallerRunType"/>\r
 </beans>
\ No newline at end of file
index b49cb980ed959f038c125aea4411477fa6a028b9..e4b317dc912234b0c5873296b47c23eac8490140 100644 (file)
@@ -5,6 +5,5 @@
        default-autowire="constructor">\r
 \r
 \r
-  <bean class="jetbrains.buildServer.nuget.server.runner.pack.PackRunTypeRegistrar"/>\r
   <bean class="jetbrains.buildServer.nuget.server.runner.pack.PackRunType"/>\r
 </beans>
\ No newline at end of file
index b99bd43954ad52f4974ed3ac85e73150e3b65bf8..dfd0cec3be95cbd06a0b8b585f596fbf96528751 100644 (file)
@@ -4,7 +4,6 @@
        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd"\r
        default-autowire="constructor">\r
 \r
-  <bean class="jetbrains.buildServer.nuget.server.runner.publish.PublishRunTypeRegistrar"/>\r
   <bean class="jetbrains.buildServer.nuget.server.runner.publish.PublishRunType"/>\r
 \r
 </beans>
\ No newline at end of file
index efbbe19afe831e8630e500fe94b54ac7c8985820..335dad55e8d8f5f30ea0311efb6bc4bf5cbca109 100644 (file)
@@ -22,4 +22,6 @@
 \r
   <bean class="jetbrains.buildServer.nuget.server.show.NuGetDownloadedPackagesTab"/>\r
 \r
+\r
+  <bean class="jetbrains.buildServer.nuget.server.runner.NuGetRunTypesRegistrar"/>\r
 </beans>
\ No newline at end of file
diff --git a/nuget-server/src/jetbrains/buildServer/nuget/server/runner/NuGetRunType.java b/nuget-server/src/jetbrains/buildServer/nuget/server/runner/NuGetRunType.java
new file mode 100644 (file)
index 0000000..d0578de
--- /dev/null
@@ -0,0 +1,84 @@
+/*\r
+ * Copyright 2000-2011 JetBrains s.r.o.\r
+ *\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ */\r
+\r
+package jetbrains.buildServer.nuget.server.runner;\r
+\r
+import jetbrains.buildServer.nuget.common.DotNetConstants;\r
+import jetbrains.buildServer.requirements.Requirement;\r
+import jetbrains.buildServer.requirements.RequirementType;\r
+import jetbrains.buildServer.serverSide.PropertiesProcessor;\r
+import jetbrains.buildServer.serverSide.RunType;\r
+import jetbrains.buildServer.web.openapi.PluginDescriptor;\r
+import org.jetbrains.annotations.NotNull;\r
+\r
+import java.util.ArrayList;\r
+import java.util.List;\r
+import java.util.Map;\r
+\r
+/**\r
+ * @author Eugene Petrenko (eugene.petrenko@gmail.com)\r
+ *         Date: 23.08.11 18:47\r
+ */\r
+public abstract class NuGetRunType extends RunType {\r
+  private final PluginDescriptor myDescriptor;\r
+\r
+  protected NuGetRunType(PluginDescriptor descriptor) {\r
+    myDescriptor = descriptor;\r
+  }\r
+\r
+  @NotNull\r
+  @Override\r
+  public abstract String getType();\r
+\r
+  @Override\r
+  public abstract String getDisplayName();\r
+\r
+  @Override\r
+  public abstract String getDescription();\r
+\r
+  @Override\r
+  @NotNull\r
+  public abstract PropertiesProcessor getRunnerPropertiesProcessor();\r
+\r
+  @NotNull\r
+  protected abstract String getEditJsp();\r
+\r
+  @NotNull\r
+  protected abstract String getViewJsp();\r
+\r
+  @NotNull\r
+  public final String getEditRunnerParamsJspFilePath() {\r
+    return myDescriptor.getPluginResourcesPath(getEditJsp());\r
+  }\r
+\r
+  @Override\r
+  @NotNull\r
+  public String getViewRunnerParamsJspFilePath() {\r
+    return myDescriptor.getPluginResourcesPath(getViewJsp());\r
+  }\r
+\r
+  @NotNull\r
+  @Override\r
+  public abstract String describeParameters(@NotNull Map<String, String> parameters);\r
+\r
+\r
+  @Override\r
+  public List<Requirement> getRunnerSpecificRequirements(@NotNull Map<String, String> runParameters) {\r
+    List<Requirement> list = new ArrayList<Requirement>(super.getRunnerSpecificRequirements(runParameters));\r
+    list.add(new Requirement(DotNetConstants.DOT_NET_FRAMEWORK_4_x86, null, RequirementType.EXISTS));\r
+    return list;\r
+  }\r
+}\r
similarity index 64%
rename from nuget-server/src/jetbrains/buildServer/nuget/server/runner/pack/PackRunTypeRegistrar.java
rename to nuget-server/src/jetbrains/buildServer/nuget/server/runner/NuGetRunTypesRegistrar.java
index e47ccb852e34840c10e35f83563ca6f751cebae4..849cb13a0dd9907f81f4f2da49ee6b3da3a51fec 100644 (file)
  * limitations under the License.\r
  */\r
 \r
-package jetbrains.buildServer.nuget.server.runner.pack;\r
+package jetbrains.buildServer.nuget.server.runner;\r
 \r
 import jetbrains.buildServer.serverSide.RunTypeRegistry;\r
 import org.jetbrains.annotations.NotNull;\r
 \r
+import java.util.Collection;\r
+\r
 /**\r
  * @author Eugene Petrenko (eugene.petrenko@gmail.com)\r
- *         Date: 22.08.11 21:13\r
+ *         Date: 23.08.11 18:52\r
  */\r
-public class PackRunTypeRegistrar {\r
-  public PackRunTypeRegistrar(@NotNull final PackRunType rt,\r
-                              @NotNull final RunTypeRegistry reg) {\r
-    reg.registerRunType(rt);\r
+public class NuGetRunTypesRegistrar {\r
+  public NuGetRunTypesRegistrar(@NotNull final RunTypeRegistry registry,\r
+                                @NotNull final Collection<NuGetRunType> types) {\r
+    for (NuGetRunType type : types) {\r
+      registry.registerRunType(type);\r
+    }\r
   }\r
-\r
 }\r
diff --git a/nuget-server/src/jetbrains/buildServer/nuget/server/runner/install/PackageInstallerRunTypeRegistrar.java b/nuget-server/src/jetbrains/buildServer/nuget/server/runner/install/PackageInstallerRunTypeRegistrar.java
deleted file mode 100644 (file)
index 8e5ad02..0000000
+++ /dev/null
@@ -1,31 +0,0 @@
-/*\r
- * Copyright 2000-2011 JetBrains s.r.o.\r
- *\r
- * Licensed under the Apache License, Version 2.0 (the "License");\r
- * you may not use this file except in compliance with the License.\r
- * You may obtain a copy of the License at\r
- *\r
- * http://www.apache.org/licenses/LICENSE-2.0\r
- *\r
- * Unless required by applicable law or agreed to in writing, software\r
- * distributed under the License is distributed on an "AS IS" BASIS,\r
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * See the License for the specific language governing permissions and\r
- * limitations under the License.\r
- */\r
-\r
-package jetbrains.buildServer.nuget.server.runner.install;\r
-\r
-import jetbrains.buildServer.serverSide.RunTypeRegistry;\r
-import org.jetbrains.annotations.NotNull;\r
-\r
-/**\r
- * Created by Eugene Petrenko (eugene.petrenko@gmail.com)\r
- * Date: 09.07.11 12:08\r
- */\r
-public class PackageInstallerRunTypeRegistrar {\r
-  public PackageInstallerRunTypeRegistrar(@NotNull final PackagesInstallerRunType rt,\r
-                                          @NotNull final RunTypeRegistry reg) {\r
-    reg.registerRunType(rt);\r
-  }\r
-}\r
index 5a45889675932aa8167359d2dd3429eb5350b8e2..8488d88a2976108cb4dcae389618de0df514db90 100644 (file)
 \r
 package jetbrains.buildServer.nuget.server.runner.install;\r
 \r
-import jetbrains.buildServer.nuget.common.DotNetConstants;\r
-import jetbrains.buildServer.requirements.Requirement;\r
-import jetbrains.buildServer.requirements.RequirementType;\r
+import jetbrains.buildServer.nuget.server.runner.NuGetRunType;\r
 import jetbrains.buildServer.serverSide.InvalidProperty;\r
 import jetbrains.buildServer.serverSide.PropertiesProcessor;\r
-import jetbrains.buildServer.serverSide.RunType;\r
 import jetbrains.buildServer.util.StringUtil;\r
 import jetbrains.buildServer.web.openapi.PluginDescriptor;\r
 import org.jetbrains.annotations.NotNull;\r
@@ -34,11 +31,9 @@ import static jetbrains.buildServer.nuget.common.PackagesConstants.*;
  * Created by Eugene Petrenko (eugene.petrenko@gmail.com)\r
  * Date: 08.07.11 20:45\r
  */\r
-public class PackagesInstallerRunType extends RunType {\r
-  private final PluginDescriptor myDescriptor;\r
-\r
+public class PackagesInstallerRunType extends NuGetRunType {\r
   public PackagesInstallerRunType(@NotNull final PluginDescriptor descriptor) {\r
-    myDescriptor = descriptor;\r
+    super(descriptor);\r
   }\r
 \r
   @NotNull\r
@@ -57,6 +52,7 @@ public class PackagesInstallerRunType extends RunType {
     return "Installs and updates missing NuGet packages";\r
   }\r
 \r
+  @NotNull\r
   @Override\r
   public PropertiesProcessor getRunnerPropertiesProcessor() {\r
     return new PropertiesProcessor() {\r
@@ -85,21 +81,16 @@ public class PackagesInstallerRunType extends RunType {
     return "Solution: " + parameters.get(SLN_PATH);\r
   }\r
 \r
+  @NotNull\r
   @Override\r
-  public List<Requirement> getRunnerSpecificRequirements(@NotNull Map<String, String> runParameters) {\r
-    List<Requirement> list = new ArrayList<Requirement>(super.getRunnerSpecificRequirements(runParameters));\r
-    list.add(new Requirement(DotNetConstants.DOT_NET_FRAMEWORK_4_x86, null, RequirementType.EXISTS));\r
-    return list;\r
-  }\r
-\r
-  @Override\r
-  public String getEditRunnerParamsJspFilePath() {\r
-    return myDescriptor.getPluginResourcesPath("install/editInstallPackage.jsp");\r
+  protected String getEditJsp() {\r
+    return "install/editInstallPackage.jsp";\r
   }\r
 \r
+  @NotNull\r
   @Override\r
-  public String getViewRunnerParamsJspFilePath() {\r
-    return myDescriptor.getPluginResourcesPath("install/viewInstallPackage.jsp");\r
+  protected String getViewJsp() {\r
+    return "install/viewInstallPackage.jsp";\r
   }\r
 \r
   @Override\r
index 9d321b005bc452b31a9c2bbf56a67ae4c81745c6..312841595a688559d390649db6e19225344cc969 100644 (file)
 package jetbrains.buildServer.nuget.server.runner.pack;\r
 \r
 import jetbrains.buildServer.agent.ServerProvidedProperties;\r
-import jetbrains.buildServer.nuget.common.DotNetConstants;\r
 import jetbrains.buildServer.nuget.common.PackagesConstants;\r
+import jetbrains.buildServer.nuget.server.runner.NuGetRunType;\r
 import jetbrains.buildServer.nuget.server.util.BasePropertiesProcessor;\r
 import jetbrains.buildServer.parameters.ReferencesResolverUtil;\r
-import jetbrains.buildServer.requirements.Requirement;\r
-import jetbrains.buildServer.requirements.RequirementType;\r
 import jetbrains.buildServer.serverSide.InvalidProperty;\r
 import jetbrains.buildServer.serverSide.PropertiesProcessor;\r
-import jetbrains.buildServer.serverSide.RunType;\r
 import jetbrains.buildServer.web.openapi.PluginDescriptor;\r
 import org.jetbrains.annotations.NotNull;\r
 \r
-import java.util.*;\r
+import java.util.Collection;\r
+import java.util.HashMap;\r
+import java.util.Map;\r
 \r
 import static jetbrains.buildServer.nuget.common.PackagesConstants.*;\r
 \r
@@ -37,11 +36,9 @@ import static jetbrains.buildServer.nuget.common.PackagesConstants.*;
  * @author Eugene Petrenko (eugene.petrenko@gmail.com)\r
  *         Date: 22.08.11 21:05\r
  */\r
-public class PackRunType extends RunType {\r
-  private final PluginDescriptor myDescriptor;\r
-\r
+public class PackRunType extends NuGetRunType {\r
   public PackRunType(@NotNull final PluginDescriptor descriptor) {\r
-    myDescriptor = descriptor;\r
+    super(descriptor);\r
   }\r
 \r
   @NotNull\r
@@ -70,6 +67,7 @@ public class PackRunType extends RunType {
     return sb.toString();\r
   }\r
 \r
+  @NotNull\r
   @Override\r
   public PropertiesProcessor getRunnerPropertiesProcessor() {\r
     return new BasePropertiesProcessor() {\r
@@ -88,14 +86,16 @@ public class PackRunType extends RunType {
     };\r
   }\r
 \r
+  @NotNull\r
   @Override\r
-  public String getEditRunnerParamsJspFilePath() {\r
-    return myDescriptor.getPluginResourcesPath("pack/editPack.jsp");\r
+  protected String getEditJsp() {\r
+    return "pack/editPack.jsp";\r
   }\r
 \r
+  @NotNull\r
   @Override\r
-  public String getViewRunnerParamsJspFilePath() {\r
-    return myDescriptor.getPluginResourcesPath("pack/viewPack.jsp");\r
+  protected String getViewJsp() {\r
+    return "pack/viewPack.jsp";\r
   }\r
 \r
   @Override\r
@@ -104,11 +104,4 @@ public class PackRunType extends RunType {
       put(PackagesConstants.NUGET_PACK_VERSION, "%" + ServerProvidedProperties.BUILD_NUMBER_PROP + "%");\r
     }};\r
   }\r
-\r
-  @Override\r
-  public List<Requirement> getRunnerSpecificRequirements(@NotNull Map<String, String> runParameters) {\r
-    List<Requirement> list = new ArrayList<Requirement>(super.getRunnerSpecificRequirements(runParameters));\r
-    list.add(new Requirement(DotNetConstants.DOT_NET_FRAMEWORK_4_x86, null, RequirementType.EXISTS));\r
-    return list;\r
-  }\r
 }\r
index 6ffa8568911a9038e65792d571b9490e62263d02..022f5e242d83232ad5c40448f9c8a6a237cd7b36 100644 (file)
 \r
 package jetbrains.buildServer.nuget.server.runner.publish;\r
 \r
-import jetbrains.buildServer.nuget.common.DotNetConstants;\r
 import jetbrains.buildServer.nuget.common.PackagesConstants;\r
-import jetbrains.buildServer.requirements.Requirement;\r
-import jetbrains.buildServer.requirements.RequirementType;\r
+import jetbrains.buildServer.nuget.server.runner.NuGetRunType;\r
 import jetbrains.buildServer.serverSide.InvalidProperty;\r
 import jetbrains.buildServer.serverSide.PropertiesProcessor;\r
-import jetbrains.buildServer.serverSide.RunType;\r
 import jetbrains.buildServer.util.StringUtil;\r
 import jetbrains.buildServer.web.openapi.PluginDescriptor;\r
 import org.jetbrains.annotations.NotNull;\r
@@ -35,11 +32,9 @@ import static jetbrains.buildServer.nuget.common.PackagesConstants.*;
  * Created by Eugene Petrenko (eugene.petrenko@gmail.com)\r
  * Date: 21.07.11 14:15\r
  */\r
-public class PublishRunType extends RunType {\r
-  private final PluginDescriptor myDescriptor;\r
-\r
+public class PublishRunType extends NuGetRunType {\r
   public PublishRunType(@NotNull final PluginDescriptor descriptor) {\r
-    myDescriptor = descriptor;\r
+    super(descriptor);\r
   }\r
 \r
   @NotNull\r
@@ -58,6 +53,7 @@ public class PublishRunType extends RunType {
     return "Pushes and publishes NuGet package to a given feed";\r
   }\r
 \r
+  @NotNull\r
   @Override\r
   public PropertiesProcessor getRunnerPropertiesProcessor() {\r
     return new PropertiesProcessor() {\r
@@ -81,14 +77,16 @@ public class PublishRunType extends RunType {
     };\r
   }\r
 \r
+  @NotNull\r
   @Override\r
-  public String getEditRunnerParamsJspFilePath() {\r
-    return myDescriptor.getPluginResourcesPath("publish/editPublish.jsp");\r
+  protected String getEditJsp() {\r
+    return "publish/editPublish.jsp";\r
   }\r
 \r
+  @NotNull\r
   @Override\r
-  public String getViewRunnerParamsJspFilePath() {\r
-    return myDescriptor.getPluginResourcesPath("publish/viewPublish.jsp");\r
+  protected String getViewJsp() {\r
+    return "publish/viewPublish.jsp";\r
   }\r
 \r
   @Override\r
@@ -96,13 +94,6 @@ public class PublishRunType extends RunType {
     return Collections.emptyMap();\r
   }\r
 \r
-  @Override\r
-  public List<Requirement> getRunnerSpecificRequirements(@NotNull Map<String, String> runParameters) {\r
-    List<Requirement> list = new ArrayList<Requirement>(super.getRunnerSpecificRequirements(runParameters));\r
-    list.add(new Requirement(DotNetConstants.DOT_NET_FRAMEWORK_4_x86, null, RequirementType.EXISTS));\r
-    return list;\r
-  }\r
-\r
   @NotNull\r
   @Override\r
   public String describeParameters(@NotNull Map<String, String> parameters) {\r
diff --git a/nuget-server/src/jetbrains/buildServer/nuget/server/runner/publish/PublishRunTypeRegistrar.java b/nuget-server/src/jetbrains/buildServer/nuget/server/runner/publish/PublishRunTypeRegistrar.java
deleted file mode 100644 (file)
index ef58ed7..0000000
+++ /dev/null
@@ -1,31 +0,0 @@
-/*\r
- * Copyright 2000-2011 JetBrains s.r.o.\r
- *\r
- * Licensed under the Apache License, Version 2.0 (the "License");\r
- * you may not use this file except in compliance with the License.\r
- * You may obtain a copy of the License at\r
- *\r
- * http://www.apache.org/licenses/LICENSE-2.0\r
- *\r
- * Unless required by applicable law or agreed to in writing, software\r
- * distributed under the License is distributed on an "AS IS" BASIS,\r
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * See the License for the specific language governing permissions and\r
- * limitations under the License.\r
- */\r
-\r
-package jetbrains.buildServer.nuget.server.runner.publish;\r
-\r
-import jetbrains.buildServer.serverSide.RunTypeRegistry;\r
-import org.jetbrains.annotations.NotNull;\r
-\r
-/**\r
- * Created by Eugene Petrenko (eugene.petrenko@gmail.com)\r
- * Date: 21.07.11 14:20\r
- */\r
-public class PublishRunTypeRegistrar {\r
-  public PublishRunTypeRegistrar(@NotNull final PublishRunType rt,\r
-                                 @NotNull final RunTypeRegistry reg) {\r
-    reg.registerRunType(rt);\r
-  }\r
-}\r