001 /*
002 * Licensed to the Apache Software Foundation (ASF) under one or more
003 * contributor license agreements. See the NOTICE file distributed with
004 * this work for additional information regarding copyright ownership.
005 * The ASF licenses this file to You under the Apache License, Version 2.0
006 * (the "License"); you may not use this file except in compliance with
007 * the License. You may obtain a copy of the License at
008 *
009 * http://www.apache.org/licenses/LICENSE-2.0
010 *
011 * Unless required by applicable law or agreed to in writing, software
012 * distributed under the License is distributed on an "AS IS" BASIS,
013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014 * See the License for the specific language governing permissions and
015 * limitations under the License.
016 */
017 package org.apache.servicemix.wsn.client;
018
019 import java.math.BigInteger;
020 import java.util.List;
021
022 import javax.jbi.JBIException;
023 import javax.xml.bind.JAXBException;
024
025 import org.apache.servicemix.client.ServiceMixClient;
026 import org.apache.servicemix.jbi.container.JBIContainer;
027 import org.oasis_open.docs.wsn.b_2.DestroyPullPoint;
028 import org.oasis_open.docs.wsn.b_2.GetMessages;
029 import org.oasis_open.docs.wsn.b_2.GetMessagesResponse;
030 import org.oasis_open.docs.wsn.b_2.NotificationMessageHolderType;
031 import org.w3._2005._08.addressing.EndpointReferenceType;
032
033 public class PullPoint extends AbstractWSAClient {
034
035 public PullPoint(EndpointReferenceType pullPoint, ServiceMixClient client) {
036 super(pullPoint, client);
037 }
038
039 public PullPoint(EndpointReferenceType pullPoint, JBIContainer container) throws JBIException, JAXBException {
040 super(pullPoint, createJaxbClient(container));
041 }
042
043 public List<NotificationMessageHolderType> getMessages(int max) throws JBIException {
044 GetMessages getMessages = new GetMessages();
045 getMessages.setMaximumNumber(BigInteger.valueOf(max));
046 GetMessagesResponse response = (GetMessagesResponse) request(getMessages);
047 return response.getNotificationMessage();
048 }
049
050 public void destroy() throws JBIException {
051 request(new DestroyPullPoint());
052 }
053
054 }