KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > tools > ant > util > optional > NoExitSecurityManager


1 /*
2  * Licensed to the Apache Software Foundation (ASF) under one or more
3  * contributor license agreements. See the NOTICE file distributed with
4  * this work for additional information regarding copyright ownership.
5  * The ASF licenses this file to You under the Apache License, Version 2.0
6  * (the "License"); you may not use this file except in compliance with
7  * the License. You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  *
17  */

18 package org.apache.tools.ant.util.optional;
19
20 import java.security.Permission JavaDoc;
21 import org.apache.tools.ant.ExitException;
22
23 /**
24  * This is intended as a replacement for the default system manager.
25  * The goal is to intercept System.exit calls and make it throw an
26  * exception instead so that a System.exit in a task does not
27  * fully terminate Ant.
28  *
29  * @see ExitException
30  */

31 public class NoExitSecurityManager extends SecurityManager JavaDoc {
32
33     /**
34      * Override SecurityManager#checkExit.
35      * This throws an ExitException(status) exception.
36      * @param status the exit status
37      */

38     public void checkExit(int status) {
39         throw new ExitException(status);
40     }
41
42     /**
43      * Override SecurityManager#checkPermission.
44      * This does nothing.
45      * @param perm the requested permission.
46      */

47     public void checkPermission(Permission JavaDoc perm) {
48         // no permission here
49
}
50 }
51
Popular Tags