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 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 super();
55 }
56
57 public CompositeResouceWrapper(Resource delegate)
58 {
59 super();
60 this._delegate = delegate;
61 setResourceName(delegate.getResourceName());
62 setLibraryName(delegate.getLibraryName());
63 setContentType(delegate.getContentType());
64 }
65
66
67 public InputStream getInputStream() throws IOException
68 {
69 return getWrapped().getInputStream();
70 }
71
72 public String getRequestPath()
73 {
74 return getWrapped().getRequestPath();
75 }
76
77 public Map<String, String> getResponseHeaders()
78 {
79 return getWrapped().getResponseHeaders();
80 }
81
82 public URL getURL()
83 {
84 return getWrapped().getURL();
85 }
86
87 public boolean userAgentNeedsUpdate(FacesContext context)
88 {
89 return getWrapped().userAgentNeedsUpdate(context);
90 }
91
92 public Resource getWrapped()
93 {
94 if (_delegate == null)
95 {
96 _delegate = FacesContext.getCurrentInstance().getApplication().
97 getResourceHandler().createResource(
98 getResourceName(),
99 getLibraryName(),
100 getContentType());
101 }
102 return _delegate;
103 }
104
105 public void readExternal(ObjectInput in) throws IOException,
106 ClassNotFoundException
107 {
108 setResourceName((String) in.readObject());
109 setLibraryName((String) in.readObject());
110 setContentType((String) in.readObject());
111 }
112
113 public void writeExternal(ObjectOutput out) throws IOException
114 {
115 out.writeObject(getResourceName());
116 out.writeObject(getLibraryName());
117 out.writeObject(getContentType());
118 }
119
120 @Override
121 public String toString()
122 {
123
124
125
126 return ( (getLibraryName() != null) ? getLibraryName() : "") + ":"+
127 ( (getResourceName() != null) ? getResourceName() : "") ;
128 }
129 }