KickJava   Java API By Example, From Geeks To Geeks.

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


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.admin.common.exception.IllegalStateException;
27 import com.sun.enterprise.deployment.Application;
28 import com.sun.enterprise.deployment.util.ModuleDescriptor;
29
30 /**
31  *Represents a nested (embedded) app client as an origin of content.
32  *
33  * @author tjquinn
34  */

35 public class NestedAppclientContentOrigin extends AppclientContentOrigin {
36   
37     /** the origin corresponding to the embedded app client's enclosing parent application */
38     private ApplicationContentOrigin parent;
39     
40     /** unique identifier for this embedded app client within its parent */
41     private String JavaDoc name;
42     
43     /**
44      *Creates a new instance of NestedAppclientContentOrigin
45      *@param the parent ApplicationContentOrigin object
46      *@param the ModuleDescriptor for this embedded app client
47      *@param the context root by which this app client's content is to be addressable
48      */

49     public NestedAppclientContentOrigin(ApplicationContentOrigin parent, ModuleDescriptor moduleDescr, String JavaDoc contextRoot) {
50         super(parent.getApplication(), moduleDescr, contextRoot);
51         this.parent = parent;
52         this.name = NamingConventions.NestedAppclient.archiveURIToName(moduleDescr.getArchiveUri());
53     }
54     
55     /**
56      *Returns whether this nested app client's parent application is currently
57      *enabled for Java Web Start access.
58      */

59     public boolean isEnabled() {
60         return parent.isEnabled();
61     }
62     
63     /**
64      *Returns the registration name for the top-level module associated with this
65      *nested app client.
66      *<p>
67      *This method is primarily used to get a name to use in checking whether
68      *the relevant module has been enabled or disabled for Java Web Start access.
69      *This implementation returns the name from the parent, whereas top-level
70      *app clients return their own reg. name.
71      *@return the parent's registration name
72      */

73     public String JavaDoc getTopLevelRegistrationName() {
74         return parent.getApplication().getRegistrationName();
75     }
76     
77     /**
78      *Returns the parent origin of this nested app client origin.
79      *@return the parent ApplicationContentOrigin
80      */

81     public ApplicationContentOrigin getParent() {
82         return parent;
83     }
84     
85     /**
86      *This method should not be called. To prevent the superclass's method
87      *from gaining control in case of an inadvertent invocation, throw an
88      *exception.
89      *@return the path to the client jar file
90      */

91     public String JavaDoc getAppclientJarPath() {
92         throw new RuntimeException JavaDoc("Unexpected invocation");
93     }
94     
95     public String JavaDoc toString() {
96         return super.toString() + lineSep + ", parent=" + getTopLevelRegistrationName();
97     }
98     
99     /**
100      *Returns the prefix for the content map key that is common to all content from this origin.
101      *@return the common content key prefix
102      */

103     public String JavaDoc getContentKeyPrefix() {
104         return NamingConventions.NestedAppclient.contentKeyPrefix(this);
105     }
106     
107     public String JavaDoc getVirtualPath() {
108         return NamingConventions.NestedAppclient.virtualContextRoot(parent.application, moduleDescriptor);
109     }
110     
111     /**
112      *Returns the unique name for this embedded app client within its containing application.
113      *@return the app client's name
114      */

115     public String JavaDoc getName() {
116         return name;
117     }
118
119     protected String JavaDoc getTargetPath() {
120         return NamingConventions.NestedAppclient.actualContextRoot(this);
121     }
122 }
123
Popular Tags