KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > enterprise > appclient > jws > ApplicationContentOrigin


1 /*
2  * The contents of this file are subject to the terms
3  * of the Common Development and Distribution License
4  * (the License). You may not use this file except in
5  * compliance with the License.
6  *
7  * You can obtain a copy of the license at
8  * https://glassfish.dev.java.net/public/CDDLv1.0.html or
9  * glassfish/bootstrap/legal/CDDLv1.0.txt.
10  * See the License for the specific language governing
11  * permissions and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL
14  * Header Notice in each file and include the License file
15  * at glassfish/bootstrap/legal/CDDLv1.0.txt.
16  * If applicable, add the following below the CDDL Header,
17  * with the fields enclosed by brackets [] replaced by
18  * you own identifying information:
19  * "Portions Copyrighted [year] [name of copyright owner]"
20  *
21  * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
22  */

23
24 package com.sun.enterprise.appclient.jws;
25
26 import com.sun.enterprise.deployment.Application;
27 import com.sun.enterprise.deployment.util.ModuleDescriptor;
28 import java.io.IOException JavaDoc;
29 import java.net.URI JavaDoc;
30 import java.util.Iterator JavaDoc;
31 import java.util.Vector JavaDoc;
32
33 /**
34  *Records mappings of paths to content that stem from app clients nested
35  *within a Java EE application or jars in the Java EE app itself.
36
37  * @author tjquinn
38  */

39 public class ApplicationContentOrigin extends UserContentOrigin {
40     
41     /** this application origin's child app client origins */
42     private Vector JavaDoc<AppclientContentOrigin> appclientOrigins;
43     
44     /**
45      *Returns a new instance, representing a single application that is
46      *an origin of served content.
47      *@param the Application descriptor object for the app of interest
48      */

49     public ApplicationContentOrigin(Application application) {
50         super(application);
51         appclientOrigins = new Vector JavaDoc<AppclientContentOrigin>();
52     }
53     
54     /**
55      *Adds an origin representing an embedded app client to the application's
56      *origin.
57      *@param the app client content origin of the embedded app client
58      */

59     public void addNestedOrigin(AppclientContentOrigin origin) {
60         appclientOrigins.add(origin);
61     }
62     
63     /**
64      *Removes the specified child origin and reports if it was present
65      *@param the app client content origin to be removed
66      *@return boolean indicating if the sub-origin was present
67      */

68     public boolean removeNestedOrigin(AppclientContentOrigin origin) {
69         return appclientOrigins.remove(origin);
70     }
71     
72     /**
73      *Returns the embedded app client origins.
74      *@return the sub-origins
75      */

76     public Vector JavaDoc<AppclientContentOrigin> getAppclientOrigins() {
77         return appclientOrigins;
78     }
79
80     /**
81      *Reports the prefix for the content key for all content related to this origin.
82      *<p>
83      *The content key is used as the key when content is stored in any of the maps
84      *@return the content key prefix for any content from this origin
85      */

86     public String JavaDoc getContentKeyPrefix() {
87         return NamingConventions.TopLevelApplication.contentKeyPrefix(this);
88     }
89     /**
90      *Returns the path, within the virtual namespace provided by the JWS system
91      *servlet, where the app client jar file for this application resides.
92      *@return the path to the client jar file
93      */

94     public String JavaDoc getAppclientJarPath() {
95         return NamingConventions.TopLevelApplication.appclientJarPath(this);
96     }
97     
98     public String JavaDoc toString() {
99         StringBuilder JavaDoc sb = new StringBuilder JavaDoc(super.toString());
100         for (AppclientContentOrigin child : appclientOrigins) {
101             sb.append(lineSep).append(" ").append(child.toString());
102         }
103         return sb.toString();
104     }
105     
106     /**
107      *Returns the context root for this origin, as specified by the developer
108      *of the app client or (if missing) as defaulted by us during loading.
109      *@return the context root under which the origin's documents are addressable
110      */

111     public String JavaDoc getContextRoot() {
112         return NamingConventions.TopLevelApplication.contextRoot(application);
113     }
114
115     /**
116      *Returns whether this content origin's appclient is enabled for Java
117      *Web Start access.
118      *@return boolean indicating whether the application is enabled for JWS access
119      */

120     public boolean isEnabled() {
121         try {
122             return AppclientJWSSupportInfo.getInstance().isEnabled(this);
123         } catch (IOException JavaDoc ioe) {
124             /*
125              *An IOException can occur if some infrastructure objects cannot be
126              *located in obtaining the instance. Very unlikely and also logged elsewhere.
127              */

128             return false;
129         } catch (Exception JavaDoc e) {
130             throw new RuntimeException JavaDoc(e);
131         }
132     }
133 }
134
Popular Tags