%line | %branch | |||||||||
---|---|---|---|---|---|---|---|---|---|---|
org.apache.turbine.services.servlet.TurbineServlet |
|
|
1 | package org.apache.turbine.services.servlet; |
|
2 | ||
3 | /* |
|
4 | * Copyright 2001-2005 The Apache Software Foundation. |
|
5 | * |
|
6 | * Licensed under the Apache License, Version 2.0 (the "License") |
|
7 | * you may not use this file except in compliance with the License. |
|
8 | * You may obtain a copy of the License at |
|
9 | * |
|
10 | * http://www.apache.org/licenses/LICENSE-2.0 |
|
11 | * |
|
12 | * Unless required by applicable law or agreed to in writing, software |
|
13 | * distributed under the License is distributed on an "AS IS" BASIS, |
|
14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|
15 | * See the License for the specific language governing permissions and |
|
16 | * limitations under the License. |
|
17 | */ |
|
18 | ||
19 | import java.io.InputStream; |
|
20 | import java.net.URL; |
|
21 | import javax.servlet.ServletConfig; |
|
22 | import javax.servlet.ServletContext; |
|
23 | ||
24 | import org.apache.turbine.services.TurbineServices; |
|
25 | ||
26 | /** |
|
27 | * Simple static accessor to the EngineContextService |
|
28 | * |
|
29 | * @author <a href="mailto:burton@apache.org">Kevin A. Burton</a> |
|
30 | * @author <a href="mailto:raphael@apache.org">Raphaƫl Luta</a> |
|
31 | * @author <a href="mailto:ekkerbj@netscape.net">Jeff Brekke</a> |
|
32 | * @author <a href="mailto:jvanzyl@periapt.com">Jason van Zyl</a> |
|
33 | * @version $Id: TurbineServlet.java 278958 2005-09-06 09:35:39Z henning $ |
|
34 | */ |
|
35 | 0 | public class TurbineServlet |
36 | { |
|
37 | /** |
|
38 | * Utility method for accessing the service |
|
39 | * implementation |
|
40 | * |
|
41 | * @return a ServletService implementation instance |
|
42 | */ |
|
43 | protected static ServletService getService() |
|
44 | { |
|
45 | 34 | return (ServletService) TurbineServices |
46 | .getInstance().getService(ServletService.SERVICE_NAME); |
|
47 | } |
|
48 | ||
49 | /** |
|
50 | * Returns an URL object for a given URI string. |
|
51 | * This URI is considered relative to the context. |
|
52 | * |
|
53 | * @param uri the URI to resolve as an URL |
|
54 | * @return an URL object or null is the uri is malformed or can't be resolved |
|
55 | */ |
|
56 | public static URL getResource(String uri) |
|
57 | { |
|
58 | 0 | return getService().getResource(uri); |
59 | } |
|
60 | ||
61 | /** |
|
62 | * Same as getResource except that it returns an InputStream |
|
63 | * |
|
64 | * @see javax.servlet.ServletContext#getResourceAsStream |
|
65 | * @param uri the URI to resolve |
|
66 | * @return an InputStream on the URI content or null |
|
67 | */ |
|
68 | public static InputStream getResourceAsStream(String uri) |
|
69 | { |
|
70 | 34 | return getService().getResourceAsStream(uri); |
71 | } |
|
72 | ||
73 | /** |
|
74 | * Returns the complete filesystem path for a |
|
75 | * given URI |
|
76 | * |
|
77 | * @see javax.servlet.ServletContext#getRealPath |
|
78 | * @param uri the URI to resolve |
|
79 | * @return the full system path of this URI |
|
80 | */ |
|
81 | public static String getRealPath(String path) |
|
82 | { |
|
83 | 0 | return getService().getRealPath(path); |
84 | } |
|
85 | ||
86 | /** |
|
87 | * Returns the servlet config used by this |
|
88 | * Turbine web application. |
|
89 | * |
|
90 | * @return turbine servlet config |
|
91 | */ |
|
92 | public static ServletConfig getServletConfig() |
|
93 | { |
|
94 | 0 | return getService().getServletConfig(); |
95 | } |
|
96 | ||
97 | /** |
|
98 | * Returns the servlet context used by this |
|
99 | * Turbine web application. |
|
100 | * |
|
101 | * @return turbine servlet context |
|
102 | */ |
|
103 | public static ServletContext getServletContext() |
|
104 | { |
|
105 | 0 | return getService().getServletContext(); |
106 | } |
|
107 | ||
108 | /** |
|
109 | * Returns the server scheme for this |
|
110 | * Turbine application. This will either |
|
111 | * be http or https. |
|
112 | * |
|
113 | * @return String |
|
114 | */ |
|
115 | public static String getServerScheme() |
|
116 | { |
|
117 | 0 | return getService().getServerScheme(); |
118 | } |
|
119 | ||
120 | /** |
|
121 | * Returns the server name that this |
|
122 | * Turbine application is running |
|
123 | * on. |
|
124 | * |
|
125 | * @return String |
|
126 | */ |
|
127 | public static String getServerName() |
|
128 | { |
|
129 | 0 | return getService().getServerName(); |
130 | } |
|
131 | ||
132 | /** |
|
133 | * Returns the port that this Turbine |
|
134 | * application is running through |
|
135 | * on the server. |
|
136 | * |
|
137 | * @return String |
|
138 | */ |
|
139 | public static String getServerPort() |
|
140 | { |
|
141 | 0 | return getService().getServerPort(); |
142 | } |
|
143 | ||
144 | /** |
|
145 | * Returns the context path for this |
|
146 | * Turbine application. |
|
147 | * |
|
148 | * @return String |
|
149 | */ |
|
150 | public static String getContextPath() |
|
151 | { |
|
152 | 0 | return getService().getContextPath(); |
153 | } |
|
154 | } |
This report is generated by jcoverage, Maven and Maven JCoverage Plugin. |