KickJava   Java API By Example, From Geeks To Geeks.

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


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.ApplicationClientDescriptor;
28 import com.sun.enterprise.deployment.interfaces.DeploymentImplConstants;
29 import com.sun.enterprise.deployment.util.ModuleDescriptor;
30 import com.sun.enterprise.instance.BaseManager;
31 import java.io.File JavaDoc;
32 import java.io.FileNotFoundException JavaDoc;
33 import java.io.IOException JavaDoc;
34 import java.net.URI JavaDoc;
35 import java.net.URISyntaxException JavaDoc;
36
37 /**
38  *Records mappings of paths to content that stem from a single app client.
39  *
40  * @author tjquinn
41  */

42     
43 public class AppclientContentOrigin extends UserContentOrigin {
44
45     /** records the content origin's context root */
46     private String JavaDoc contextRoot;
47
48     /** module descriptor for the content origin */
49     protected ModuleDescriptor moduleDescriptor;
50     
51     /**
52      *Creates a new instance of the appclient content origin.
53      *@param Application object for the appclient (either an artificial wrapper
54      *around a stand-alone app client or the parent ear's Application if this is
55      *an embedded app client)
56      *@param ModuleDescriptor for the specific app client
57      *@param the context root to be used for this app client
58      */

59     public AppclientContentOrigin(Application application, ModuleDescriptor moduleDescriptor, String JavaDoc contextRoot) {
60         super(application);
61         this.moduleDescriptor = moduleDescriptor;
62
63         /*
64          *Make sure the context root is not empty and has a
65          *slash at the beginning. The default value is legal but
66          *a user-supplied one might not be.
67          */

68         if (contextRoot.length() < 2 || ( ! contextRoot.substring(0,1).equals("/") )) {
69             String JavaDoc regName = application.getRegistrationName();
70             throw new IllegalArgumentException JavaDoc("Java Web Start-related context root of '" + contextRoot + "' specified for app client " + regName + " must begin with a slash and contain at least one other character");
71         }
72         this.contextRoot = contextRoot;
73     }
74     
75     /**
76      *Returns the origin's context root.
77      *@return the string value for the context root
78      */

79     public String JavaDoc getContextRoot() {
80         return contextRoot;
81     }
82
83     /**
84      *Returns the display name for the app client.
85      *@return the display name as a String
86      */

87     public String JavaDoc getDisplayName() {
88         return moduleDescriptor.getDescriptor().getDisplayName();
89     }
90     
91     /**
92      *Returns the descriptor for the app client.
93      *@return the descriptor
94      */

95     public String JavaDoc getDescription() {
96         return getApplication().getDescription();
97     }
98     
99     /**
100      *Returns the path, within the virtual namespace provided by the JWS system
101      *servlet, where the app client jar file for this app client resides.
102      *@return the path to the client jar file
103      */

104     public String JavaDoc getAppclientJarPath() {
105         return NamingConventions.TopLevelAppclient.appclientJarPath(this);
106     }
107     
108     
109     protected String JavaDoc getContentKeyPrefix() {
110         return NamingConventions.TopLevelAppclient.contentKeyPrefix(this);
111     }
112     
113     /**
114      *Returns the path to which requests for the virtual path for this origin
115      *should be dispatched so they can be served by the system servlet.
116      *@return the path to which the virtual path should be mapped
117      */

118     protected String JavaDoc getTargetPath() {
119         return NamingConventions.TopLevelAppclient.actualContextRoot(application);
120     }
121     
122     /**
123      *Returns the virtual path users can use to refer to the app client from
124      *this origin. If the developer did not specify one, the default path
125      *is returned.
126      *@return the path by which users can access the app client
127      */

128     public String JavaDoc getVirtualPath() {
129         return NamingConventions.TopLevelAppclient.virtualContextRoot(application, moduleDescriptor);
130     }
131     
132     public String JavaDoc toString() {
133         return super.toString() + ", context root=" + getVirtualPath() + ", module name=" + moduleDescriptor.getName();
134     }
135     
136     public String JavaDoc getVendor() {
137         return ((ApplicationClientDescriptor) moduleDescriptor.getDescriptor()).getJavaWebStartAccessDescriptor().getVendor();
138     }
139
140     public String JavaDoc getName() {
141         return application.getRegistrationName();
142     }
143 }
144
Popular Tags