1 | |
|
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
|
10 | |
|
11 | |
|
12 | |
|
13 | |
|
14 | |
|
15 | |
|
16 | |
|
17 | |
|
18 | |
|
19 | |
package org.apache.myfaces.view.facelets.tag.composite; |
20 | |
|
21 | |
import java.io.Externalizable; |
22 | |
import java.io.IOException; |
23 | |
import java.io.InputStream; |
24 | |
import java.io.ObjectInput; |
25 | |
import java.io.ObjectOutput; |
26 | |
import java.net.URL; |
27 | |
import java.util.Map; |
28 | |
|
29 | |
import javax.faces.FacesWrapper; |
30 | |
import javax.faces.application.Resource; |
31 | |
import javax.faces.context.FacesContext; |
32 | |
|
33 | |
|
34 | |
|
35 | |
|
36 | |
|
37 | |
|
38 | |
|
39 | |
|
40 | |
|
41 | |
|
42 | 0 | public final class CompositeResouceWrapper extends Resource |
43 | |
implements FacesWrapper<Resource>, Externalizable |
44 | |
{ |
45 | |
|
46 | |
|
47 | |
|
48 | |
private static final long serialVersionUID = 8067930634887545843L; |
49 | |
|
50 | |
private transient Resource _delegate; |
51 | |
|
52 | |
public CompositeResouceWrapper() |
53 | |
{ |
54 | 0 | super(); |
55 | 0 | } |
56 | |
|
57 | |
public CompositeResouceWrapper(Resource delegate) |
58 | |
{ |
59 | 0 | super(); |
60 | 0 | this._delegate = delegate; |
61 | 0 | setResourceName(delegate.getResourceName()); |
62 | 0 | setLibraryName(delegate.getLibraryName()); |
63 | 0 | setContentType(delegate.getContentType()); |
64 | 0 | } |
65 | |
|
66 | |
|
67 | |
public InputStream getInputStream() throws IOException |
68 | |
{ |
69 | 0 | return getWrapped().getInputStream(); |
70 | |
} |
71 | |
|
72 | |
public String getRequestPath() |
73 | |
{ |
74 | 0 | return getWrapped().getRequestPath(); |
75 | |
} |
76 | |
|
77 | |
public Map<String, String> getResponseHeaders() |
78 | |
{ |
79 | 0 | return getWrapped().getResponseHeaders(); |
80 | |
} |
81 | |
|
82 | |
public URL getURL() |
83 | |
{ |
84 | 0 | return getWrapped().getURL(); |
85 | |
} |
86 | |
|
87 | |
public boolean userAgentNeedsUpdate(FacesContext context) |
88 | |
{ |
89 | 0 | return getWrapped().userAgentNeedsUpdate(context); |
90 | |
} |
91 | |
|
92 | |
public Resource getWrapped() |
93 | |
{ |
94 | 0 | if (_delegate == null) |
95 | |
{ |
96 | 0 | _delegate = FacesContext.getCurrentInstance().getApplication(). |
97 | |
getResourceHandler().createResource( |
98 | |
getResourceName(), |
99 | |
getLibraryName(), |
100 | |
getContentType()); |
101 | |
} |
102 | 0 | return _delegate; |
103 | |
} |
104 | |
|
105 | |
public void readExternal(ObjectInput in) throws IOException, |
106 | |
ClassNotFoundException |
107 | |
{ |
108 | 0 | setResourceName((String) in.readObject()); |
109 | 0 | setLibraryName((String) in.readObject()); |
110 | 0 | setContentType((String) in.readObject()); |
111 | 0 | } |
112 | |
|
113 | |
public void writeExternal(ObjectOutput out) throws IOException |
114 | |
{ |
115 | 0 | out.writeObject(getResourceName()); |
116 | 0 | out.writeObject(getLibraryName()); |
117 | 0 | out.writeObject(getContentType()); |
118 | 0 | } |
119 | |
|
120 | |
@Override |
121 | |
public String toString() |
122 | |
{ |
123 | |
|
124 | |
|
125 | |
|
126 | 0 | return ( (getLibraryName() != null) ? getLibraryName() : "") + ":"+ |
127 | |
( (getResourceName() != null) ? getResourceName() : "") ; |
128 | |
} |
129 | |
} |