KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > nanocontainer > script > groovy > buildernodes > GrantNode


1 /*****************************************************************************
2  * Copyright (C) NanoContainer Organization. All rights reserved. *
3  * ------------------------------------------------------------------------- *
4  * The software in this package is published under the terms of the BSD *
5  * style license a copy of which has been included with this distribution in *
6  * the LICENSE.txt file. *
7  * *
8  * Original code by James Strachan *
9  *****************************************************************************/

10
11 package org.nanocontainer.script.groovy.buildernodes;
12
13 import java.util.Map JavaDoc;
14 import java.security.Permission JavaDoc;
15
16 import org.nanocontainer.ClassPathElement;
17 import org.nanocontainer.script.NanoContainerMarkupException;
18
19 /**
20  * @author Paul Hammant
21  * @version $Revision: 2695 $
22  */

23 public class GrantNode extends AbstractBuilderNode {
24
25     public static final String JavaDoc NODE_NAME = "grant";
26
27     public GrantNode() {
28         super(NODE_NAME);
29     }
30
31
32
33     public Object JavaDoc createNewNode(Object JavaDoc current, Map JavaDoc attributes) {
34
35         Permission JavaDoc perm = (Permission JavaDoc) attributes.remove("class");
36
37         if (!(current instanceof ClassPathElement)) {
38             throw new NanoContainerMarkupException("Don't know how to create a 'grant' child of a '" + current.getClass() + "' parent");
39         }
40
41         ClassPathElement cpe = (ClassPathElement) current;
42
43         return cpe.grantPermission(perm);
44     }
45
46 }
47
Popular Tags