PageRenderTime 56ms CodeModel.GetById 21ms RepoModel.GetById 0ms app.codeStats 0ms

/jboss-as-7.1.1.Final/controller-client/src/main/java/org/jboss/as/controller/client/helpers/domain/impl/ServerGroupDeploymentPlanBuilderImpl.java

#
Java | 85 lines | 47 code | 10 blank | 28 comment | 4 complexity | f80d8ae9277ba0865a9aa9632b10bf29 MD5 | raw file
Possible License(s): LGPL-2.1, Apache-2.0
  1. /*
  2. * JBoss, Home of Professional Open Source.
  3. * Copyright 2010, Red Hat, Inc., and individual contributors
  4. * as indicated by the @author tags. See the copyright.txt file in the
  5. * distribution for a full listing of individual contributors.
  6. *
  7. * This is free software; you can redistribute it and/or modify it
  8. * under the terms of the GNU Lesser General Public License as
  9. * published by the Free Software Foundation; either version 2.1 of
  10. * the License, or (at your option) any later version.
  11. *
  12. * This software is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  15. * Lesser General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU Lesser General Public
  18. * License along with this software; if not, write to the Free
  19. * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
  20. * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
  21. */
  22. package org.jboss.as.controller.client.helpers.domain.impl;
  23. import static org.jboss.as.controller.client.ControllerClientMessages.MESSAGES;
  24. import org.jboss.as.controller.client.helpers.domain.DeploymentSetPlan;
  25. import org.jboss.as.controller.client.helpers.domain.RollbackDeploymentPlanBuilder;
  26. import org.jboss.as.controller.client.helpers.domain.ServerGroupDeploymentPlan;
  27. import org.jboss.as.controller.client.helpers.domain.ServerGroupDeploymentPlanBuilder;
  28. /**
  29. * Variant of a {@link DeploymentPlanBuilderImpl} that exposes
  30. * directives that are only applicable when controlling how a {@link DeploymentSetPlan}
  31. * should be applied to one or more server groups.
  32. *
  33. * @author Brian Stansberry
  34. */
  35. class ServerGroupDeploymentPlanBuilderImpl extends InitialDeploymentSetBuilderImpl implements ServerGroupDeploymentPlanBuilder {
  36. ServerGroupDeploymentPlanBuilderImpl(DeploymentPlanBuilderImpl existing, DeploymentSetPlanImpl setPlan) {
  37. super(existing, setPlan);
  38. }
  39. @Override
  40. public RollbackDeploymentPlanBuilder withRollback() {
  41. DeploymentSetPlanImpl setPlan = getCurrentDeploymentSetPlan();
  42. ServerGroupDeploymentPlan groupPlan = setPlan.getLatestServerGroupDeploymentPlan();
  43. if (groupPlan == null) {
  44. throw MESSAGES.notConfigured(ServerGroupDeploymentPlan.class.getSimpleName());
  45. }
  46. groupPlan = groupPlan.createRollback();
  47. setPlan = setPlan.storeServerGroup(groupPlan);
  48. return new RollbackDeploymentPlanBuilderImpl(this, setPlan);
  49. }
  50. @Override
  51. public ServerGroupDeploymentPlanBuilder rollingToServers() {
  52. DeploymentSetPlanImpl setPlan = getCurrentDeploymentSetPlan();
  53. ServerGroupDeploymentPlan groupPlan = setPlan.getLatestServerGroupDeploymentPlan();
  54. if (groupPlan == null) {
  55. throw MESSAGES.notConfigured(ServerGroupDeploymentPlan.class.getSimpleName());
  56. }
  57. groupPlan = groupPlan.createRollingToServers();
  58. setPlan = setPlan.storeServerGroup(groupPlan);
  59. return new ServerGroupDeploymentPlanBuilderImpl(this, setPlan);
  60. }
  61. @Override
  62. public ServerGroupDeploymentPlanBuilder rollingToServerGroup(String serverGroupName) {
  63. DeploymentSetPlanImpl setPlan = getCurrentDeploymentSetPlan();
  64. ServerGroupDeploymentPlan groupPlan = new ServerGroupDeploymentPlan(serverGroupName);
  65. setPlan = setPlan.storeRollToServerGroup(groupPlan);
  66. return new ServerGroupDeploymentPlanBuilderImpl(this, setPlan);
  67. }
  68. @Override
  69. public ServerGroupDeploymentPlanBuilder toServerGroup(String serverGroupName) {
  70. DeploymentSetPlanImpl setPlan = getCurrentDeploymentSetPlan();
  71. ServerGroupDeploymentPlan groupPlan = new ServerGroupDeploymentPlan(serverGroupName);
  72. setPlan = setPlan.storeServerGroup(groupPlan);
  73. return new ServerGroupDeploymentPlanBuilderImpl(this, setPlan);
  74. }
  75. }