| 1 | /* |
| 2 | * Copyright (c) 2001-2004 Ant-Contrib project. All rights reserved. |
| 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 | package net.sf.antcontrib.antserver.server; |
| 17 | |
| 18 | import org.apache.tools.ant.BuildException; |
| 19 | import org.apache.tools.ant.Task; |
| 20 | |
| 21 | |
| 22 | /**************************************************************************** |
| 23 | * Place class description here. |
| 24 | * |
| 25 | * @author <a href='mailto:[email protected]'>Matthew Inger</a> |
| 26 | * @author <additional author> |
| 27 | * |
| 28 | * @since |
| 29 | * |
| 30 | ****************************************************************************/ |
| 31 | |
| 32 | |
| 33 | public class ServerTask |
| 34 | extends Task |
| 35 | { |
| 36 | private Server server; |
| 37 | private int port = 17000; |
| 38 | |
| 39 | public ServerTask() |
| 40 | { |
| 41 | super(); |
| 42 | } |
| 43 | |
| 44 | |
| 45 | public void setPort(int port) |
| 46 | { |
| 47 | this.port = port; |
| 48 | } |
| 49 | |
| 50 | |
| 51 | public void shutdown() |
| 52 | { |
| 53 | server.stop(); |
| 54 | } |
| 55 | |
| 56 | public void execute() |
| 57 | { |
| 58 | try |
| 59 | { |
| 60 | server = new Server(this, port); |
| 61 | server.start(); |
| 62 | } |
| 63 | catch (InterruptedException e) |
| 64 | { |
| 65 | throw new BuildException(e); |
| 66 | } |
| 67 | } |
| 68 | } |