KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jboss > deployers > spi > deployer > DeploymentUnit


1 /*
2 * JBoss, Home of Professional Open Source
3 * Copyright 2006, JBoss Inc., and individual contributors as indicated
4 * by the @authors tag. See the copyright.txt in the distribution for a
5 * full listing of individual contributors.
6 *
7 * This is free software; you can redistribute it and/or modify it
8 * under the terms of the GNU Lesser General Public License as
9 * published by the Free Software Foundation; either version 2.1 of
10 * the License, or (at your option) any later version.
11 *
12 * This software is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
16 *
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this software; if not, write to the Free
19 * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
20 * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
21 */

22 package org.jboss.deployers.spi.deployer;
23
24 import java.util.List JavaDoc;
25 import java.util.Set JavaDoc;
26
27 import org.jboss.deployers.spi.DeploymentException;
28 import org.jboss.deployers.spi.attachments.Attachments;
29 import org.jboss.deployers.spi.classloader.ClassLoaderFactory;
30 import org.jboss.deployers.spi.structure.DeploymentContext;
31 import org.jboss.virtual.VirtualFile;
32
33 /**
34  * DeploymentUnit.<p>
35  *
36  * A deployment unit represents a single unit
37  * that deployers work with.
38  *
39  * @author <a HREF="adrian@jboss.com">Adrian Brock</a>
40  * @author Scott.Stark@jboss.org
41  * @version $Revision: 1.1 $
42  */

43 public interface DeploymentUnit extends Attachments
44 {
45    /**
46     * Get the deployment units name
47     *
48     * @return the name;
49     */

50    String JavaDoc getName();
51
52    /**
53     * Get the simple vfs name of the deployment unit. This is the simple
54     * name of the virtual file .
55     *
56     * vfs path ------------------- simple name
57     * deploy/some.ear "some.ear"
58     * deploy/some.ear/x.ejb "x.ejb"
59     * deploy/some.ear/y.sar "y.sar"
60     * deploy/some.ear/y.sar/z.rar "z.rar"
61     * deploy/complexwithappxml.ear/module-mbean1.sar/submbean.sar submbean.sar
62     * @return the deployment unit simple path
63     */

64    public String JavaDoc getSimpleName();
65
66    /**
67     * Get the path of this deployment relative to the top of the
68     * deployment based on the vfs paths. For example, an ear:
69     *
70     * vfs path ------------------- relative path
71     * deploy/some.ear ""
72     * deploy/some.ear/x.ejb "/x.ejb"
73     * deploy/some.ear/y.sar "/y.sar"
74     * deploy/some.ear/y.sar/z.rar "/y.sar/z.rar"
75     * deploy/complexwithappxml.ear/module-mbean1.sar/submbean.sar /module-mbean1.sar/submbean.sar
76     *
77     * @return the top-level deployment relative path
78     */

79    public String JavaDoc getRelativePath();
80
81    /**
82     * Gets a metadata file. This is a file located under the deployment metadata
83     * context(s).
84     *
85     * @param name the name to exactly match
86     * @return the virtual file or null if not found
87     * @throws IllegalArgumentException for a null name
88     */

89    VirtualFile getMetaDataFile(String JavaDoc name);
90    
91    /**
92     * Gets the metadata files for this deployment unit
93     *
94     * @param name the name to exactly match
95     * @param suffix the suffix to partially match
96     * @return the virtual files that match
97     * @throws IllegalArgumentException if both the name and suffix are null
98     */

99    List JavaDoc<VirtualFile> getMetaDataFiles(String JavaDoc name, String JavaDoc suffix);
100
101    /**
102     * Get a file in the deployment. To get the deployment root use "" as the file
103     * name.
104     *
105     * @param name - the path name of the file relative to the deployment root.
106     * @return the file if found, null otherwise.
107     */

108    VirtualFile getFile(String JavaDoc name);
109
110    /**
111     * Gets the classloader for this deployment unit
112     *
113     * @return the classloader
114     */

115    ClassLoader JavaDoc getClassLoader();
116
117    /**
118     * Create the classloader
119     *
120     * @param factory the classloader factory
121     * @return false if the classloader already exists
122     * @throws IllegalArgumentException for a null factory
123     * @throws DeploymentException for any error
124     */

125    boolean createClassLoader(ClassLoaderFactory factory) throws DeploymentException;
126    
127    /**
128     * Get the managed objects
129     *
130     * @return the managed objects
131     */

132    Attachments getTransientManagedObjects();
133    
134    /**
135     * Get all the metadata for the expected type
136     *
137     * @param <T> the type to get
138     * @param unit the unit
139     * @param type the type
140     * @return a set of metadata matching the type
141     * @throws IllegalArgumentException if the type is null
142     */

143    <T> Set JavaDoc<? extends T> getAllMetaData(Class JavaDoc<T> type);
144
145    /**
146     * Add a component
147     *
148     * @param name the name
149     * @return the new deployment unit
150     * @throws IllegalArgumentException for a null name
151     */

152    DeploymentUnit addComponent(String JavaDoc name);
153    
154    /**
155     * Remove a component
156     *
157     * @param name the name
158     * @return true when removed
159     * @throws IllegalArgumentException for a null name
160     */

161    boolean removeComponent(String JavaDoc name);
162    
163    /**
164     * Get the deployment contxt
165     *
166     * @return the deployment context
167     */

168    @Deprecated JavaDoc // If you are using this, then think about it.
169
DeploymentContext getDeploymentContext();
170 }
171
Popular Tags