001: /*
002: * Copyright 2000-2001,2004 The Apache Software Foundation.
003: *
004: * Licensed under the Apache License, Version 2.0 (the "License");
005: * you may not use this file except in compliance with the License.
006: * You may obtain a copy of the License at
007: *
008: * http://www.apache.org/licenses/LICENSE-2.0
009: *
010: * Unless required by applicable law or agreed to in writing, software
011: * distributed under the License is distributed on an "AS IS" BASIS,
012: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013: * See the License for the specific language governing permissions and
014: * limitations under the License.
015: */
016:
017: /*
018:
019: */
020:
021: package org.apache.wsrp4j.producer.provider.driver;
022:
023: import java.util.Collection;
024: import java.util.HashSet;
025:
026: /**
027: * This class collects the porlet handles for a registered consumer and
028: * is used for persistence purpose.
029: *
030: * @author <a href="mailto:Ralf.Altrichter@de.ibm.com">Ralf Altrichter</a>
031: *
032: * @version 1.0
033: */
034: public class ConsumerPortletRegistrationImpl {
035:
036: // the registrationHandle of the consumer
037: private String _registrationHandle = null;
038:
039: // collects all portletHandles for this registrationHandle
040: private HashSet _portletHandles = new HashSet();
041:
042: /**
043: * Default Constructor
044: */
045: public ConsumerPortletRegistrationImpl() {
046:
047: }
048:
049: /**
050: * Sets the registration handle for a specific consumer
051: *
052: * @param regHandle, consumer registration handle
053: */
054: public void setRegistrationHandle(String regHandle) {
055: _registrationHandle = regHandle;
056: }
057:
058: /**
059: * Returns the registration handle for a specific consumer
060: *
061: * @return registrationHandle
062: */
063: public String getRegistrationHandle() {
064: return _registrationHandle;
065: }
066:
067: /**
068: * Add a portlet handle to the current registration
069: *
070: * @param portletHandle
071: */
072: public void addPortletHandle(String portletHandle) {
073: _portletHandles.add(portletHandle);
074: }
075:
076: /**
077: * Returns true, if the portletHandle is associated to the
078: * current registration.
079: *
080: * @return true on success, otherwise false
081: */
082: public boolean containsPortletHandle(String portletHandle) {
083: return _portletHandles.contains(portletHandle);
084: }
085:
086: /**
087: * Removes a portlet handle from the current registration
088: *
089: * @param portletHandle
090: */
091: public void deletePortletHandle(String portletHandle) {
092: _portletHandles.remove(portletHandle);
093: }
094:
095: /**
096: * Sets a collection of portlet handles for this registration
097: *
098: * @param collection
099: */
100: public void setPortletHandles(Collection collection) {
101: _portletHandles = (HashSet) collection;
102: }
103:
104: /**
105: * Returns a collection of portlet handles for this registration
106: *
107: * @return collection
108: */
109: public Collection getPortletHandles() {
110: return _portletHandles;
111: }
112:
113: /**
114: * @return true, if no portlet handles are assigned to this registration
115: * false, if at least one portlet handle is assigned to his registration
116: */
117: public boolean isEmpty() {
118: boolean retVal = false;
119:
120: if (_portletHandles.size() == 0) {
121: retVal = true;
122: }
123: return retVal;
124: }
125: }
|