1 | /*
|
---|
2 | * Copyright 2001-2002,2004-2005 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.util.optional;
|
---|
18 |
|
---|
19 | import java.security.Permission;
|
---|
20 | import org.apache.tools.ant.ExitException;
|
---|
21 |
|
---|
22 | /**
|
---|
23 | * This is intended as a replacement for the default system manager.
|
---|
24 | * The goal is to intercept System.exit calls and make it throw an
|
---|
25 | * exception instead so that a System.exit in a task does not
|
---|
26 | * fully terminate Ant.
|
---|
27 | *
|
---|
28 | * @see ExitException
|
---|
29 | */
|
---|
30 | public class NoExitSecurityManager extends SecurityManager {
|
---|
31 |
|
---|
32 | /**
|
---|
33 | * Override SecurityManager#checkExit.
|
---|
34 | * This throws an ExitException(status) exception.
|
---|
35 | * @param status the exit status
|
---|
36 | */
|
---|
37 | public void checkExit(int status) {
|
---|
38 | throw new ExitException(status);
|
---|
39 | }
|
---|
40 |
|
---|
41 | /**
|
---|
42 | * Override SecurityManager#checkPermission.
|
---|
43 | * This does nothing.
|
---|
44 | * @param perm the requested permission.
|
---|
45 | */
|
---|
46 | public void checkPermission(Permission perm) {
|
---|
47 | // no permission here
|
---|
48 | }
|
---|
49 | }
|
---|