KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > cocoon > portal > wsrp > consumer > ProducerDescription


1 /*
2  * Copyright 2005 The Apache Software Foundation.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */

16 package org.apache.cocoon.portal.wsrp.consumer;
17
18 import oasis.names.tc.wsrp.v1.types.RegistrationData;
19
20 import org.apache.avalon.framework.configuration.Configuration;
21 import org.apache.avalon.framework.configuration.ConfigurationException;
22 import org.apache.cocoon.portal.wsrp.adapter.WSRPAdapter;
23 import org.apache.wsrp4j.consumer.ConsumerEnvironment;
24
25 /**
26  * Describes and creates producers.<br/>
27  * If the registration interface url is set (not null) this implies
28  * that the producer requires a registration. If the producer does
29  * not require a registration, set the registration interface url
30  * to null<br/>
31  *
32  * @author <a HREF="mailto:cziegeler@s-und-n.de">Carsten Ziegeler</a>
33  * @author <a HREF="mailto:malessandrini@s-und-n.de">Michel Alessandrini</a>
34  *
35  * @version $Id: ProducerDescription.java 264755 2005-08-30 10:29:21Z cziegeler $
36  **/

37 public class ProducerDescription {
38
39     /** Unique string of the producer */
40     protected String JavaDoc id;
41
42     /** The wsrp makup-interface-url (required) */
43     protected String JavaDoc markupInterfaceUrl;
44
45     /** The wsrp service-description-interface-url (required) */
46     protected String JavaDoc serviceDescriptionInterfaceUrl;
47
48     /** The wsrp registration-interface-url (optional) */
49     protected String JavaDoc registrationInterfaceUrl;
50
51     /** The wsrp portlet-management-interface-url (optional) */
52     protected String JavaDoc portletManagementInterfaceUrl;
53     
54     /** name of the producer */
55     protected String JavaDoc name;
56     
57     /** description of the producer */
58     protected String JavaDoc description;
59
60     /** The registration data. */
61     protected RegistrationData registrationData;
62
63     /**
64      * Default constructor
65      */

66     public ProducerDescription() {
67         this(null);
68     }
69
70     /**
71      * Constructor<br/>
72      *
73      * @param id of the producer
74      */

75     public ProducerDescription(String JavaDoc id) {
76         this(id, null, null);
77     }
78
79     /**
80      * Constructor<br/>
81      *
82      * @param id of the producer
83      * @param markupUrl markup-interface-url
84      * @param sdUrl service-description-interface-url
85      */

86     public ProducerDescription(String JavaDoc id, String JavaDoc markupUrl, String JavaDoc sdUrl) {
87         this(id, markupUrl, sdUrl, null, null);
88     }
89
90     /**
91      * Constructor<br/>
92      *
93      * @param id of the producer
94      * @param markupUrl markup-interface-url
95      * @param sdUrl service-description-interface-url
96      * @param regUrl registration-interface-url
97      * @param pmUrl portlet-management-interface-url
98      */

99     public ProducerDescription(String JavaDoc id,
100                                String JavaDoc markupUrl,
101                                String JavaDoc sdUrl,
102                                String JavaDoc regUrl,
103                                String JavaDoc pmUrl) {
104         this.id = id;
105         this.markupInterfaceUrl = markupUrl;
106         this.serviceDescriptionInterfaceUrl = sdUrl;
107         this.registrationInterfaceUrl = regUrl;
108         this.portletManagementInterfaceUrl = pmUrl;
109     }
110
111     /**
112      * @return producer-id
113      */

114     public String JavaDoc getId() {
115         return id;
116     }
117
118     /**
119      * set the producer-id<br/>
120      *
121      * @param id
122      */

123     public void setId(String JavaDoc id) {
124         this.id = id;
125     }
126
127     /**
128      * @return markup-interface-url
129      */

130     public String JavaDoc getMarkupInterfaceUrl() {
131         return markupInterfaceUrl;
132     }
133
134     /**
135      * set the markup-interface-url<br/>
136      *
137      * @param markupInterfaceUrl
138      */

139     public void setMarkupInterfaceUrl(String JavaDoc markupInterfaceUrl) {
140         this.markupInterfaceUrl = markupInterfaceUrl;
141     }
142
143     /**
144      * @return portlet-management-interface-url
145      */

146     public String JavaDoc getPortletManagementInterfaceUrl() {
147         return portletManagementInterfaceUrl;
148     }
149
150     /**
151      * Set the portlet-management-interface-url<br/>
152      *
153      * @param portletManagementInterfaceUrl
154      */

155     public void setPortletManagementInterfaceUrl(String JavaDoc portletManagementInterfaceUrl) {
156         this.portletManagementInterfaceUrl = portletManagementInterfaceUrl;
157     }
158
159     /**
160      * @return registration-interface-url
161      */

162     public String JavaDoc getRegistrationInterfaceUrl() {
163         return registrationInterfaceUrl;
164     }
165
166     /**
167      * Set the registration-interface-url<br/>
168      *
169      * @param registrationInterfaceUrl
170      */

171     public void setRegistrationInterfaceUrl(String JavaDoc registrationInterfaceUrl) {
172         this.registrationInterfaceUrl = registrationInterfaceUrl;
173     }
174
175     /**
176      * @return service-description-interface-url
177      */

178     public String JavaDoc getServiceDescriptionInterfaceUrl() {
179         return serviceDescriptionInterfaceUrl;
180     }
181
182     /**
183      * Set the service-description-interface-url<br/>
184      *
185      * @param serviceDescriptionInterfaceUrl
186      */

187     public void setServiceDescriptionInterfaceUrl(String JavaDoc serviceDescriptionInterfaceUrl) {
188         this.serviceDescriptionInterfaceUrl = serviceDescriptionInterfaceUrl;
189     }
190
191     /**
192      * Create a producer description from a configuration<br/>
193      *
194      * @param config
195      * @return the producer-description
196      * @throws ConfigurationException
197      */

198     public static ProducerDescription fromConfiguration(Configuration config, ConsumerEnvironment env)
199     throws ConfigurationException {
200         final String JavaDoc producerId = config.getAttribute("id");
201         final ProducerDescription desc = new ProducerDescription(producerId);
202
203         desc.setMarkupInterfaceUrl(config.getChild("markup-interface-url").getValue());
204         desc.setServiceDescriptionInterfaceUrl(config.getChild("service-description-interface-url").getValue());
205         desc.setRegistrationInterfaceUrl(config.getChild("registration-interface-url").getValue(null));
206         desc.setPortletManagementInterfaceUrl(config.getChild("portlet-management-interface-url").getValue(null));
207         boolean registrationRequired;
208         if ( desc.getRegistrationInterfaceUrl() != null ) {
209             registrationRequired = config.getChild("registration-interface-url").getAttributeAsBoolean("registration-required", true);
210         } else {
211             registrationRequired = false;
212         }
213         if ( registrationRequired == false ) {
214             desc.setRegistrationInterfaceUrl(null);
215         } else {
216             // get the registration data
217
desc.setRegistrationData(createRegistrationData(config.getChild("registration-data"), env));
218         }
219
220         // optional information
221
desc.setName(config.getChild("name").getValue(null));
222         desc.setDescription(config.getChild("description").getValue(null));
223
224         return desc;
225     }
226
227     public static RegistrationData createRegistrationData(Configuration config,
228                                                           ConsumerEnvironment env) {
229         RegistrationData registrationData = new RegistrationData(
230                 env.getConsumerAgent(),
231                 env.getSupportedModes(),
232                 WSRPAdapter.CONSUMER_URL, //consumer-name
233
null, //consumerUserScopes
234
env.getSupportedWindowStates(),
235                 null, //customUserProfileData
236
null, //extensions
237
false, //methodGetSupported
238
null //registrationProperties
239
);
240         return registrationData;
241     }
242
243     /**
244      * @return the producer-description as string
245      */

246     public String JavaDoc getDescription() {
247         return description;
248     }
249
250     /**
251      * Set the producer-description<br/>
252      *
253      * @param description
254      */

255     public void setDescription(String JavaDoc description) {
256         this.description = description;
257     }
258
259     /**
260      * @return name of the producer
261      */

262     public String JavaDoc getName() {
263         return name;
264     }
265
266     /**
267      * Set the producer-name<br/>
268      *
269      * @param name
270      */

271     public void setName(String JavaDoc name) {
272         this.name = name;
273     }
274
275     public RegistrationData getRegistrationData() {
276         return registrationData;
277     }
278
279     public void setRegistrationData(RegistrationData registrationData) {
280         this.registrationData = registrationData;
281     }
282 }
283
Popular Tags