KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > sape > carbon > services > config > classloader > ClassloaderFolderFactory


1 /*
2  * The contents of this file are subject to the Sapient Public License
3  * Version 1.0 (the "License"); you may not use this file except in compliance
4  * with the License. You may obtain a copy of the License at
5  * http://carbon.sf.net/License.html.
6  *
7  * Software distributed under the License is distributed on an "AS IS" basis,
8  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for
9  * the specific language governing rights and limitations under the License.
10  *
11  * The Original Code is The Carbon Component Framework.
12  *
13  * The Initial Developer of the Original Code is Sapient Corporation
14  *
15  * Copyright (C) 2003 Sapient Corporation. All Rights Reserved.
16  */

17
18 package org.sape.carbon.services.config.classloader;
19
20 import org.sape.carbon.core.config.node.Node;
21 import org.sape.carbon.core.config.node.NodeCreationException;
22 import org.sape.carbon.core.config.node.NodeFactory;
23 import org.sape.carbon.core.exception.InvalidParameterException;
24
25 /**
26  * Factory for creating folder nodes
27  *
28  * Copyright 2003 Sapient
29  * @since carbon 2.0
30  * @author Greg Hinkle, April 2003
31  * @version $Revision: 1.4 $($Author: dvoet $ / $Date: 2003/11/11 21:19:58 $)
32  */

33 public class ClassloaderFolderFactory
34     implements NodeFactory {
35
36     /**
37      * Only creates sub folders of other ClassloaderFolders
38      *
39      * @throws InvalidParameterException if parent is not assignable
40      * from ClassloaderFolder
41      * @see NodeFactory#getInstance
42      */

43     public Node getInstance(Node parent, String JavaDoc name)
44         throws NodeCreationException {
45
46         ClassloaderFolder parentFolder;
47         try {
48             parentFolder = (ClassloaderFolder) parent;
49         } catch(ClassCastException JavaDoc cce) {
50             throw new InvalidParameterException(
51                 this.getClass(),
52                 "parent is not assignable from ClassloaderFolder", cce);
53         }
54
55         if (name == null) {
56             throw new InvalidParameterException(
57                 this.getClass(),
58                 "name cannot be null");
59         }
60         String JavaDoc resourcePath =
61             parentFolder.getResourcePath() + name +
62             ClassloaderFolder.CLASSLOADER_DELIMETER;
63
64         return new ClassloaderFolder(
65             parent,
66             name,
67             parentFolder.getSubFolderFactory(),
68             parentFolder.getConfigurationDocumentFactory(),
69             parentFolder.getLinkNodeFactory(),
70             resourcePath,
71             parentFolder.getConfigSource());
72     }
73 }
Popular Tags