KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > sape > carbon > services > config > jar > JarFolderFactory


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.jar;
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 import org.sape.carbon.core.util.jar.EnhancedJarFile;
25
26 /**
27  * Factory for create folder nodes
28  *
29  * Copyright 2002 Sapient
30  * @since carbon 1.0
31  * @author Douglas Voet, April 2002
32  * @version $Revision: 1.2 $($Author: dvoet $ / $Date: 2003/05/05 21:21:09 $)
33  */

34 public class JarFolderFactory
35     implements NodeFactory {
36
37     /**
38      * Only creates sub folders of other FileFolders
39      *
40      * @param parent the parent node of the folder to be loaded
41      * @param name the name of the jar folder to load
42      * @return the newly loaded node
43      * @throws InvalidParameterException if parent is not assignable
44      * from FileFolder
45      * @throws NodeCreationException indicates an error creating the node
46      *
47      * @see NodeFactory#getInstance
48      */

49     public Node getInstance(Node parent, String JavaDoc name)
50         throws NodeCreationException {
51
52         JarFolder parentJarFolder;
53         try {
54             parentJarFolder = (JarFolder) parent;
55         } catch (ClassCastException JavaDoc cce) {
56             throw new InvalidParameterException(
57                 this.getClass(),
58                 "parent is not assignable from JarFolder", cce);
59         }
60
61         if (name == null) {
62             throw new InvalidParameterException(
63                 this.getClass(),
64                 "name cannot be null");
65         }
66         String JavaDoc entryName =
67             parentJarFolder.getInternalJarEntryName() + name
68                 + EnhancedJarFile.JAR_DELIMETER;
69
70         return new JarFolder(
71             parent,
72             name,
73             parentJarFolder.getSubFolderFactory(),
74             parentJarFolder.getConfigurationDocumentFactory(),
75             parentJarFolder.getLinkNodeFactory(),
76             parentJarFolder.getReadWriteLock(),
77             parentJarFolder.getInternalJarFile(),
78             entryName);
79     }
80 }
Popular Tags