1
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
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 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.getPortletHandle());
71
72 stateChanged();
73 }
74 }
75
76 public PortletContext getPortletContext() {
77 return this.portletContext;
78 }
79
80 public String getParent() {
81 return this.parentHandle;
82 }
83
84 public void setParent(String portletHandle) {
85 this.parentHandle = portletHandle;
86
87 stateChanged();
88 }
89
90 public boolean isConsumerConfigured() {
91
92 return !getParent().equals(portletKey.getPortletHandle());
93 }
94 }