| ConsumerEnvironmentImpl.java |
1 /**
2 * Copyright (c) 2000-2009 Liferay, Inc. All rights reserved.
3 *
4 * The contents of this file are subject to the terms of the Liferay Enterprise
5 * Subscription License ("License"). You may not use this file except in
6 * compliance with the License. You can obtain a copy of the License by
7 * contacting Liferay, Inc. See the License for the specific language governing
8 * permissions and limitations under the License, including but not limited to
9 * distribution rights of the Software.
10 *
11 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
12 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
13 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
14 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
15 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
16 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
17 * SOFTWARE.
18 */
19
20 package com.liferay.portlet.wsrp;
21
22 import oasis.names.tc.wsrp.v1.types.StateChange;
23
24 import org.apache.wsrp4j.consumer.driver.GenericConsumerEnvironment;
25 import org.apache.wsrp4j.consumer.driver.PortletDriverRegistryImpl;
26 import org.apache.wsrp4j.consumer.driver.URLRewriterImpl;
27 import org.apache.wsrp4j.consumer.util.ConsumerConstants;
28 import org.apache.wsrp4j.util.Constants;
29 import org.apache.wsrp4j.util.Modes;
30 import org.apache.wsrp4j.util.WindowStates;
31
32 /**
33 * <a href="ConsumerEnvironmentImpl.java.html"><b><i>View Source</i></b></a>
34 *
35 * @author Michael Young
36 *
37 */
38 public class ConsumerEnvironmentImpl extends GenericConsumerEnvironment {
39
40 public ConsumerEnvironmentImpl() {
41
42 // set the name of the consumer agent
43 setConsumerAgent(CONSUMER_AGENT);
44
45 // define the locales the consumer supports
46 String[] supportedLocales = new String[2];
47 supportedLocales[0] = Constants.LOCALE_EN_US;
48 supportedLocales[1] = Constants.LOCALE_DE_DE;
49 setSupportedLocales(supportedLocales);
50
51 // define the modes the consumer supports
52 String[] supportedModes = new String[3];
53 supportedModes[0] = Modes._view;
54 supportedModes[1] = Modes._help;
55 supportedModes[2] = Modes._edit;
56 setSupportedModes(supportedModes);
57
58 // define the window states the consumer supports
59 String[] supportedWindowStates = new String[3];
60 supportedWindowStates[0] = WindowStates._normal;
61 supportedWindowStates[1] = WindowStates._maximized;
62 supportedWindowStates[2] = WindowStates._minimized;
63 setSupportedWindowStates(supportedWindowStates);
64
65 // define portlet state change behaviour
66 setPortletStateChange(StateChange.readWrite);
67
68 // define the mime types the consumer supports
69 setMimeTypes(new String[] { Constants.MIME_TYPE_HTML });
70
71 // define the character sets the consumer supports
72 setCharacterEncodingSet(new String[] { Constants.UTF_8 });
73
74 // set the authentication method the consumer uses
75 setUserAuthentication(ConsumerConstants.NONE);
76
77 // set consumer components
78 setUserRegistry(UserRegistryImpl.getInstance());
79 setSessionHandler(SessionHandlerImpl.getInstance(this));
80
81 setPortletRegistry(PortletRegistryImpl.getInstance());
82 setTemplateComposer(URLTemplateComposerImpl.getInstance());
83 setURLRewriter(URLRewriterImpl.getInstance());
84 setPortletDriverRegistry(PortletDriverRegistryImpl.getInstance(this));
85 setProducerRegistry(ProducerRegistryImpl.getInstance());
86 }
87
88 private static final String CONSUMER_AGENT = "Liferay WSRP Consumer";
89
90 }