001: /*
002: * Copyright 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: package org.apache.ws.scout.registry;
018:
019: import java.util.ArrayList;
020: import java.util.Collection;
021: import java.util.LinkedHashSet;
022:
023: import javax.xml.registry.BulkResponse;
024: import javax.xml.registry.JAXRException;
025:
026: /**
027: * Implements JAXR BulkResponse Interface.
028: * For futher details, look into the JAXR API Javadoc.
029: *
030: * @author <a href="mailto:anil@apache.org">Anil Saldhana</a>
031: * @author <a href="mailto:geirm@apache.org">Geir Magnusson Jr.</a>
032: */
033: public class BulkResponseImpl extends JAXRResponseImpl implements
034: BulkResponse {
035: private boolean partialResponse = false;
036:
037: private Collection<Exception> exceptions = new ArrayList<Exception>();
038: private Collection<? extends Object> collection = new ArrayList<Object>();
039:
040: /**
041: * Creates a new instance of BulkResponseImpl
042: */
043: public BulkResponseImpl() {
044: }
045:
046: BulkResponseImpl(LinkedHashSet<? extends Object> collection) {
047: this .collection = collection;
048: }
049:
050: /**
051: * Get Collection of RegistryObjects *
052: */
053: public Collection<? extends Object> getCollection()
054: throws JAXRException {
055: return this .collection;
056: }
057:
058: /**
059: * The javadoc is unclear. it says for getExceptions() :
060: * "Get the Collection of RegistryException instances in case of partial
061: * commit. Caller thread will block here if result is not yet available.
062: * Return null if result is available and there is no RegistryException(s)."
063: * Yet the return javadoc says :
064: * "Collection of RegistryException instances. The Collection may be empty but not null."
065: *
066: * So my interpretation is return null if result avail, and empty collection otherwise
067: *
068: * @return
069: * @throws JAXRException
070: */
071: public Collection<Exception> getExceptions() throws JAXRException {
072: return (this .exceptions.size() == 0 ? null : exceptions);
073: }
074:
075: public boolean isPartialResponse() throws JAXRException {
076: if (exceptions.size() > 0) {
077: this .partialResponse = true;
078: }
079: return this .partialResponse;
080: }
081:
082: public void setPartialResponse(boolean b) throws JAXRException {
083: this .partialResponse = b;
084: }
085:
086: public void setCollection(Collection<? extends Object> coll)
087: throws JAXRException {
088: this .collection = coll;
089: }
090:
091: /**
092: * Setter for property exceptions.
093: *
094: * @param exceptions New value of property exceptions.
095: */
096: public void setExceptions(Collection<Exception> exceptions) {
097: this.exceptions = exceptions;
098: }
099:
100: }
|