01: /*
02: * Copyright 2000-2001,2004 The Apache Software Foundation.
03: *
04: * Licensed under the Apache License, Version 2.0 (the "License");
05: * you may not use this file except in compliance with the License.
06: * You may obtain a copy of the License at
07: *
08: * http://www.apache.org/licenses/LICENSE-2.0
09: *
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:
17: package org.apache.wsrp4j.consumer.driver;
18:
19: import oasis.names.tc.wsrp.v1.types.PortletContext;
20:
21: import org.apache.wsrp4j.consumer.PortletKey;
22: import org.apache.wsrp4j.consumer.WSRPPortlet;
23: import org.apache.wsrp4j.util.StateChangedServiceImpl;
24:
25: /**
26: * Implements the portlet interface
27: **/
28: public class WSRPPortletImpl extends StateChangedServiceImpl implements
29: WSRPPortlet {
30:
31: private PortletKey portletKey = null;
32:
33: private PortletContext portletContext = null;
34:
35: private String parentHandle = null;
36:
37: // for castor persistence
38: public WSRPPortletImpl() {
39: }
40:
41: public WSRPPortletImpl(PortletKey portletKey) {
42: this .portletKey = portletKey;
43: this .parentHandle = portletKey.getPortletHandle();
44: }
45:
46: public PortletKey getPortletKey() {
47: return this .portletKey;
48: }
49:
50: public void setPortletKey(PortletKey portletKey) {
51: if (portletKey != null) {
52: this .portletKey = portletKey;
53:
54: if (this .portletContext != null) {
55: this .portletContext.setPortletHandle(portletKey
56: .getPortletHandle());
57: }
58:
59: if (parentHandle == null) {
60: parentHandle = portletKey.getPortletHandle();
61: }
62:
63: stateChanged();
64: }
65: }
66:
67: public void setPortletContext(PortletContext portletContext) {
68: if (portletContext != null) {
69: this .portletContext = portletContext;
70: this .portletKey.setPortletHandle(portletContext
71: .getPortletHandle());
72:
73: stateChanged();
74: }
75: }
76:
77: public PortletContext getPortletContext() {
78: return this .portletContext;
79: }
80:
81: public String getParent() {
82: return this .parentHandle;
83: }
84:
85: public void setParent(String portletHandle) {
86: this .parentHandle = portletHandle;
87:
88: stateChanged();
89: }
90:
91: public boolean isConsumerConfigured() {
92:
93: return !getParent().equals(portletKey.getPortletHandle());
94: }
95: }
|