1. /*
  2. * Copyright 2001-2004 The Apache Software Foundation
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License");
  5. * you may not use this file except in compliance with the License.
  6. * You may obtain a copy of the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS,
  12. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. * See the License for the specific language governing permissions and
  14. * limitations under the License.
  15. *
  16. */
  17. package org.apache.tools.ant.taskdefs.optional.ide;
  18. /**
  19. * Super class for all VAJ tasks. Contains common
  20. * attributes (remoteServer) and util methods
  21. *
  22. */
  23. import org.apache.tools.ant.Task;
  24. public class VAJTask extends Task {
  25. /**
  26. * Adaption of VAJLocalUtil to Task context.
  27. */
  28. class VAJLocalToolUtil extends VAJLocalUtil {
  29. public void log(String msg, int level) {
  30. VAJTask.this.log(msg, level);
  31. }
  32. }
  33. // server name / port of VAJ remote tool api server
  34. protected String remoteServer = null;
  35. // holds the appropriate VAJUtil implementation
  36. private VAJUtil util = null;
  37. // checks if this task throws BuildException on error
  38. protected boolean haltOnError = true;
  39. /**
  40. * returns the VAJUtil implementation
  41. */
  42. protected VAJUtil getUtil() {
  43. if (util == null) {
  44. if (remoteServer == null) {
  45. util = new VAJLocalToolUtil();
  46. } else {
  47. util = new VAJRemoteUtil(this, remoteServer);
  48. }
  49. }
  50. return util;
  51. }
  52. /**
  53. * Name and port of a remote tool server, optiona.
  54. * Format: <servername>:<port no>.
  55. * If this attribute is set, the tasks will be executed on the specified tool
  56. * server.
  57. */
  58. public void setRemote(String remoteServer) {
  59. this.remoteServer = remoteServer;
  60. }
  61. /**
  62. * Flag to control behaviour in case of VAJ errors.
  63. * If this attribute is set errors will be ignored
  64. * (no BuildException will be thrown) otherwise
  65. * VAJ errors will be wrapped into a BuildException and
  66. * stop the build.
  67. */
  68. public void setHaltonerror(boolean newHaltOnError) {
  69. haltOnError = newHaltOnError;
  70. }
  71. }