http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/e57c2a52/proton-j/engine/src/org/apache/qpid/proton/engine/impl/TransportImpl.java ---------------------------------------------------------------------- diff --git a/proton-j/engine/src/org/apache/qpid/proton/engine/impl/TransportImpl.java b/proton-j/engine/src/org/apache/qpid/proton/engine/impl/TransportImpl.java deleted file mode 100644 index 5937c56..0000000 --- a/proton-j/engine/src/org/apache/qpid/proton/engine/impl/TransportImpl.java +++ /dev/null @@ -1,736 +0,0 @@ -/** - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.qpid.proton.engine.impl; - -import org.apache.qpid.proton.codec.DecoderImpl; -import org.apache.qpid.proton.codec.EncoderImpl; -import org.apache.qpid.proton.engine.Accepted; -import org.apache.qpid.proton.engine.Connection; -import org.apache.qpid.proton.engine.DeliveryState; -import org.apache.qpid.proton.engine.EndpointState; -import org.apache.qpid.proton.engine.Transport; -import org.apache.qpid.proton.type.AMQPDefinedTypes; -import org.apache.qpid.proton.type.Binary; -import org.apache.qpid.proton.type.DescribedType; -import org.apache.qpid.proton.type.UnsignedInteger; -import org.apache.qpid.proton.type.UnsignedShort; -import org.apache.qpid.proton.type.messaging.Source; -import org.apache.qpid.proton.type.messaging.Target; -import org.apache.qpid.proton.type.transport.Attach; -import org.apache.qpid.proton.type.transport.Begin; -import org.apache.qpid.proton.type.transport.Close; -import org.apache.qpid.proton.type.transport.Detach; -import org.apache.qpid.proton.type.transport.Disposition; -import org.apache.qpid.proton.type.transport.End; -import org.apache.qpid.proton.type.transport.Flow; -import org.apache.qpid.proton.type.transport.FrameBody; -import org.apache.qpid.proton.type.transport.Open; -import org.apache.qpid.proton.type.transport.Role; -import org.apache.qpid.proton.type.transport.Transfer; - -import java.nio.ByteBuffer; -import java.util.HashMap; -import java.util.Map; - -public class TransportImpl extends EndpointImpl implements Transport, FrameBody.FrameBodyHandler<Integer> -{ - public static final byte[] HEADER = new byte[8]; - public static final org.apache.qpid.proton.type.messaging.Accepted ACCEPTED = - new org.apache.qpid.proton.type.messaging.Accepted(); - - static - { - HEADER[0] = (byte) 'A'; - HEADER[1] = (byte) 'M'; - HEADER[2] = (byte) 'Q'; - HEADER[3] = (byte) 'P'; - HEADER[4] = 0; - HEADER[5] = 1; - HEADER[6] = 0; - HEADER[7] = 0; - } - - private ConnectionImpl _connectionEndpoint; - - private boolean _isOpenSent; - private boolean _isCloseSent; - - private int _headerWritten; - private TransportSession[] _remoteSessions; - private TransportSession[] _localSessions; - - private final FrameParser _frameParser; - - private Map<SessionImpl, TransportSession> _transportSessionState = new HashMap<SessionImpl, TransportSession>(); - private Map<LinkImpl, TransportLink> _transportLinkState = new HashMap<LinkImpl, TransportLink>(); - - - private DecoderImpl _decoder = new DecoderImpl(); - private EncoderImpl _encoder = new EncoderImpl(_decoder); - - private int _maxFrameSize = 16 * 1024; - - { - AMQPDefinedTypes.registerAllTypes(_decoder); - } - - public TransportImpl(Connection connectionEndpoint) - { - _connectionEndpoint = (ConnectionImpl) connectionEndpoint; - _localSessions = new TransportSession[_connectionEndpoint.getMaxChannels()]; - _remoteSessions = new TransportSession[_connectionEndpoint.getMaxChannels()]; - _frameParser = new FrameParser(this); - } - - public int input(byte[] bytes, int offset, int length) - { - return _frameParser.input(bytes, offset, length); - } - - //================================================================================================================== - // Process model state to generate output - - public int output(byte[] bytes, final int offset, final int size) - { - - int written = 0; - - written += processHeader(bytes, offset); - written += processOpen(bytes, offset + written, size - written); - written += processBegin(bytes, offset + written, size - written); - written += processAttach(bytes, offset + written, size - written); - written += processReceiverFlow(bytes, offset + written, size - written); - written += processReceiverDisposition(bytes, offset + written, size - written); - written += processMessageData(bytes, offset + written, size - written); - written += processSenderDisposition(bytes, offset + written, size - written); - written += processSenderFlow(bytes, offset + written, size - written); - written += processDetach(bytes, offset + written, size - written); - written += processEnd(bytes, offset+written, size-written); - written += processClose(bytes, offset+written, size-written); - - if(size - written > _maxFrameSize) - { - clearInterestList(); - clearTransportWorkList(); - } - - return written; - } - - private void clearTransportWorkList() - { - DeliveryImpl delivery = _connectionEndpoint.getTransportWorkHead(); - while(delivery != null) - { - DeliveryImpl transportWorkNext = delivery.getTransportWorkNext(); - delivery.clearTransportWork(); - delivery = transportWorkNext; - } - } - - private int processDetach(byte[] bytes, int offset, int length) - { - EndpointImpl endpoint = _connectionEndpoint.getTransportHead(); - int written = 0; - while(endpoint != null && length >= _maxFrameSize) - { - - if(endpoint instanceof LinkImpl) - { - - LinkImpl link = (LinkImpl) endpoint; - TransportLink transportLink = getTransportState(link); - if(link.getLocalState() == EndpointState.CLOSED - && transportLink.isLocalHandleSet()) - { - - SessionImpl session = link.getSession(); - TransportSession transportSession = getTransportState(session); - UnsignedInteger localHandle = transportLink.getLocalHandle(); - transportLink.clearLocalHandle(); - transportSession.freeLocalHandle(localHandle); - - - Detach detach = new Detach(); - detach.setHandle(localHandle); - - - int frameBytes = writeFrame(bytes, offset, length, transportSession.getLocalChannel(), detach, null); - written += frameBytes; - offset += frameBytes; - length -= frameBytes; - } - - } - endpoint = endpoint.getNext(); - } - return written; - } - - private int processSenderFlow(byte[] bytes, int offset, int length) - { - return 0; //TODO - Implement - } - - private int processSenderDisposition(byte[] bytes, int offset, int length) - { - return 0; //TODO - Implement - } - - private int processMessageData(byte[] bytes, int offset, int length) - { - DeliveryImpl delivery = _connectionEndpoint.getTransportWorkHead(); - int written = 0; - while(delivery != null && length >= _maxFrameSize) - { - if((delivery.getLink() instanceof SenderImpl)) - { - SenderImpl sender = (SenderImpl) delivery.getLink(); - - - - TransportLink transportLink = sender.getTransportLink(); - UnsignedInteger deliveryId = transportLink.getDeliveryCount(); - transportLink.setDeliveryCount(deliveryId.add(UnsignedInteger.ONE)); - TransportDelivery transportDelivery = new TransportDelivery(deliveryId, delivery, transportLink); - - - Transfer transfer = new Transfer(); - transfer.setDeliveryId(deliveryId); - transfer.setDeliveryTag(new Binary(delivery.getTag())); - transfer.setHandle(transportLink.getLocalHandle()); - transfer.setMessageFormat(UnsignedInteger.ZERO); - - int frameBytes = writeFrame(bytes, offset, length, - sender.getSession().getTransportSession().getLocalChannel(), - transfer, null); - written += frameBytes; - offset += frameBytes; - length -= frameBytes; - - } - delivery = delivery.getTransportWorkNext(); - } - return written; - } - - private int processReceiverDisposition(byte[] bytes, int offset, int length) - { - DeliveryImpl delivery = _connectionEndpoint.getTransportWorkHead(); - int written = 0; - while(delivery != null && length >= _maxFrameSize) - { - if((delivery.getLink() instanceof ReceiverImpl) && delivery.isLocalStateChange()) - { - TransportDelivery transportDelivery = delivery.getTransportDelivery(); - Disposition disposition = new Disposition(); - disposition.setFirst(transportDelivery.getDeliveryId()); - disposition.setLast(transportDelivery.getDeliveryId()); - disposition.setRole(Role.RECEIVER); - disposition.setSettled(delivery.isSettled()); - DeliveryState deliveryState = delivery.getLocalState(); - if(deliveryState == Accepted.getInstance()) - { - disposition.setState(ACCEPTED); - } - else - { - // TODO - } - int frameBytes = writeFrame(bytes, offset, length, delivery.getLink().getSession() - .getTransportSession().getLocalChannel(), - disposition, null); - written += frameBytes; - offset += frameBytes; - length -= frameBytes; - } - delivery = delivery.getTransportWorkNext(); - } - return written; - } - - private int processReceiverFlow(byte[] bytes, int offset, int length) - { - EndpointImpl endpoint = _connectionEndpoint.getTransportHead(); - int written = 0; - while(endpoint != null && length >= _maxFrameSize) - { - - if(endpoint instanceof ReceiverImpl) - { - - ReceiverImpl receiver = (ReceiverImpl) endpoint; - TransportLink transportLink = getTransportState(receiver); - TransportSession transportSession = getTransportState(receiver.getSession()); - - if(receiver.getLocalState() == EndpointState.ACTIVE) - { - int credits = receiver.clearCredits(); - if(credits != 0) - { - transportLink.addCredit(credits); - Flow flow = new Flow(); - flow.setHandle(transportLink.getLocalHandle()); - flow.setIncomingWindow(transportSession.getIncomingWindowSize()); - flow.setOutgoingWindow(transportSession.getOutgoingWindowSize()); - flow.setDeliveryCount(transportLink.getDeliveryCount()); - flow.setLinkCredit(transportLink.getLinkCredit()); - - int frameBytes = writeFrame(bytes, offset, length, transportSession.getLocalChannel(), flow, null); - written += frameBytes; - offset += frameBytes; - length -= frameBytes; - } - } - } - endpoint = endpoint.getNext(); - } - return written; - } - - private int processAttach(byte[] bytes, int offset, int length) - { - EndpointImpl endpoint = _connectionEndpoint.getTransportHead(); - int written = 0; - while(endpoint != null && length >= _maxFrameSize) - { - - if(endpoint instanceof LinkImpl) - { - - LinkImpl link = (LinkImpl) endpoint; - TransportLink transportLink = getTransportState(link); - if(link.getLocalState() == EndpointState.ACTIVE) - { - - if( (link.getRemoteState() == EndpointState.ACTIVE - && !transportLink.isLocalHandleSet()) || link.getRemoteState() == EndpointState.UNINITIALIZED) - { - - SessionImpl session = link.getSession(); - TransportSession transportSession = getTransportState(session); - UnsignedInteger localHandle = transportSession.allocateLocalHandle(); - transportLink.setLocalHandle(localHandle); - - if(link.getRemoteState() == EndpointState.UNINITIALIZED) - { - transportSession.addHalfOpenLink(transportLink); - } - - Attach attach = new Attach(); - attach.setHandle(localHandle); - attach.setName(transportLink.getName()); - - if(link.getLocalSourceAddress() != null) - { - Source source = new Source(); - source.setAddress(link.getLocalSourceAddress()); - attach.setSource(source); - } - - if(link.getLocalTargetAddress() != null) - { - Target target = new Target(); - target.setAddress(link.getLocalTargetAddress()); - attach.setTarget(target); - } - - attach.setRole(endpoint instanceof ReceiverImpl ? Role.RECEIVER : Role.SENDER); - - if(link instanceof SenderImpl) - { - attach.setInitialDeliveryCount(UnsignedInteger.ZERO); - } - - int frameBytes = writeFrame(bytes, offset, length, transportSession.getLocalChannel(), attach, null); - written += frameBytes; - offset += frameBytes; - length -= frameBytes; - } - } - - } - endpoint = endpoint.getNext(); - } - return written; - } - - private void clearInterestList() - { - EndpointImpl endpoint = _connectionEndpoint.getTransportHead(); - while(endpoint != null) - { - endpoint.clearModified(); - endpoint = endpoint.transportNext(); - } - } - - private int processHeader(byte[] bytes, int offset) - { - int headerWritten = 0; - while(_headerWritten < HEADER.length) - { - bytes[offset+(headerWritten++)] = HEADER[_headerWritten++]; - } - return headerWritten; - } - - private int processOpen(byte[] bytes, int offset, int length) - { - if(_connectionEndpoint.getLocalState() != EndpointState.UNINITIALIZED && !_isOpenSent) - { - Open open = new Open(); - - // TODO - populate; - - _isOpenSent = true; - - return writeFrame(bytes, offset, length, 0, open, null); - - } - return 0; - } - - private int processBegin(byte[] bytes, final int offset, final int length) - { - EndpointImpl endpoint = _connectionEndpoint.getTransportHead(); - int written = 0; - while(endpoint != null && length >= _maxFrameSize) - { - if(endpoint instanceof SessionImpl) - { - SessionImpl session = (SessionImpl) endpoint; - TransportSession transportSession = getTransportState(session); - if(session.getLocalState() == EndpointState.ACTIVE - && session.getRemoteState() == EndpointState.ACTIVE - && !transportSession.isLocalChannelSet()) - { - int channelId = allocateLocalChannel(); - transportSession.setLocalChannel(channelId); - _localSessions[channelId] = transportSession; - - Begin begin = new Begin(); - - begin.setRemoteChannel(UnsignedShort.valueOf((short) transportSession.getRemoteChannel())); - begin.setHandleMax(transportSession.getHandleMax()); - begin.setIncomingWindow(transportSession.getIncomingWindowSize()); - begin.setOutgoingWindow(transportSession.getOutgoingWindowSize()); - begin.setNextOutgoingId(transportSession.getNextOutgoingId()); - - written += writeFrame(bytes, offset, length, channelId, begin, null); - } - } - endpoint = endpoint.transportNext(); - } - return written; - } - - private TransportSession getTransportState(SessionImpl session) - { - TransportSession transportSession = _transportSessionState.get(session); - if(transportSession == null) - { - transportSession = new TransportSession(session); - session.setTransportSession(transportSession); - _transportSessionState.put(session, transportSession); - } - return transportSession; - } - - private TransportLink getTransportState(LinkImpl link) - { - TransportLink transportLink = _transportLinkState.get(link); - if(transportLink == null) - { - transportLink = TransportLink.createTransportLink(link); - _transportLinkState.put(link, transportLink); - } - return transportLink; - } - - private int allocateLocalChannel() - { - return 0; //TODO - Implement - } - - private int processEnd(byte[] bytes, int offset, int length) - { - EndpointImpl endpoint = _connectionEndpoint.getTransportHead(); - int written = 0; - while(endpoint != null && length >= _maxFrameSize) - { - - if(endpoint instanceof SessionImpl) - { - - SessionImpl session = (SessionImpl) endpoint; - TransportSession transportSession = session.getTransportSession(); - if(session.getLocalState() == EndpointState.CLOSED - && transportSession.isLocalChannelSet()) - { - - int channel = transportSession.getLocalChannel(); - transportSession.freeLocalChannel(); - _localSessions[channel] = null; - - - End end = new End(); - - int frameBytes = writeFrame(bytes, offset, length, channel, end, null); - written += frameBytes; - offset += frameBytes; - length -= frameBytes; - } - - } - endpoint = endpoint.getNext(); - } - return written; - } - - private int processClose(byte[] bytes, final int offset, final int length) - { - if(_connectionEndpoint.getLocalState() == EndpointState.CLOSED && !_isCloseSent) - { - Close close = new Close(); - - // TODO - populate; - - _isCloseSent = true; - - return writeFrame(bytes, offset, length, 0, close, null); - - } - return 0; - - } - - - - private int writeFrame(byte[] bytes, int offset, int size, int channel, DescribedType frameBody, ByteBuffer payload) - { - ByteBuffer buf = ByteBuffer.wrap(bytes, offset+8, size-8); - int oldPosition = buf.position(); - _encoder.setByteBuffer(buf); - _encoder.writeDescribedType(frameBody); - - int frameSize = 8 + buf.position() - oldPosition; - bytes[offset] = (byte) ((frameSize>>24) & 0xFF); - bytes[offset+1] = (byte) ((frameSize>>16) & 0xFF); - bytes[offset+2] = (byte) ((frameSize>>8) & 0xFF); - bytes[offset+3] = (byte) (frameSize & 0xFF); - bytes[offset+4] = (byte) 2; - bytes[offset+6] = (byte) ((channel>>8) & 0xFF); - bytes[offset+7] = (byte) (channel & 0xFF); - - - return frameSize; - } - - //================================================================================================================== - - @Override - protected ConnectionImpl getConnectionImpl() - { - return _connectionEndpoint; - } - - public void destroy() - { - super.destroy(); - _connectionEndpoint.clearTransport(); - } - - //================================================================================================================== - // handle incoming amqp data - - - public void handleOpen(Open open, Binary payload, Integer channel) - { - System.out.println("CH["+channel+"] : " + open); - _connectionEndpoint.handleOpen(open); - } - - public void handleBegin(Begin begin, Binary payload, Integer channel) - { - System.out.println("CH["+channel+"] : " + begin); - // TODO - check channel < max_channel - TransportSession transportSession = _remoteSessions[channel]; - if(transportSession != null) - { - // TODO - fail due to begin on begun session - } - else - { - SessionImpl session; - if(begin.getRemoteChannel() == null) - { - session = _connectionEndpoint.session(); - transportSession = getTransportState(session); - } - else - { - // TODO check null - transportSession = _localSessions[begin.getRemoteChannel().intValue()]; - session = transportSession.getSession(); - - } - transportSession.setRemoteChannel(channel); - session.setRemoteState(EndpointState.ACTIVE); - _remoteSessions[channel] = transportSession; - - - } - - } - - public void handleAttach(Attach attach, Binary payload, Integer channel) - { - System.out.println("CH["+channel+"] : " + attach); - TransportSession transportSession = _remoteSessions[channel]; - if(transportSession == null) - { - // TODO - fail due to attach on non-begun session - } - else - { - SessionImpl session = transportSession.getSession(); - TransportLink transportLink = transportSession.getLinkFromRemoteHandle(attach.getHandle()); - LinkImpl link = null; - - if(transportLink != null) - { - // TODO - fail - attempt attach on a handle which is in use - } - else - { - transportLink = transportSession.resolveHalfOpenLink(attach.getName()); - if(transportLink == null) - { - - link = (attach.getRole() == Role.RECEIVER) - ? session.sender(attach.getName()) - : session.receiver(attach.getName()); - transportLink = getTransportState(link); - } - - link.setRemoteState(EndpointState.ACTIVE); - Source source = (Source) attach.getSource(); - if(source != null) - { - link.setRemoteSourceAddress(source.getAddress()); - } - Target target = (Target) attach.getTarget(); - if(target != null) - { - link.setRemoteTargetAddress(target.getAddress()); - } - - transportLink.setName(attach.getName()); - transportLink.setRemoteHandle(attach.getHandle()); - transportSession.addLinkRemoteHandle(transportLink, attach.getHandle()); - - } - } - } - - public void handleFlow(Flow flow, Binary payload, Integer channel) - { - System.out.println("CH["+channel+"] : " + flow); - TransportSession transportSession = _remoteSessions[channel]; - if(transportSession == null) - { - // TODO - fail due to attach on non-begun session - } - else - { - transportSession.handleFlow(flow); - } - - } - - public void handleTransfer(Transfer transfer, Binary payload, Integer channel) - { - System.out.println("CH["+channel+"] : " + transfer); - // TODO - check channel < max_channel - TransportSession transportSession = _remoteSessions[channel]; - if(transportSession != null) - { - transportSession.handleTransfer(transfer, payload); - } - else - { - // TODO - fail due to begin on begun session - } - } - - public void handleDisposition(Disposition disposition, Binary payload, Integer context) - { - //To change body of implemented methods use File | Settings | File Templates. - } - - public void handleDetach(Detach detach, Binary payload, Integer channel) - { - System.out.println("CH["+channel+"] : " + detach); - TransportSession transportSession = _remoteSessions[channel]; - if(transportSession == null) - { - // TODO - fail due to attach on non-begun session - } - else - { - TransportLink transportLink = transportSession.getLinkFromRemoteHandle(detach.getHandle()); - - if(transportLink != null) - { - LinkImpl link = transportLink.getLink(); - transportSession.freeRemoteHandle(transportLink.getRemoteHandle()); - link.setRemoteState(EndpointState.CLOSED); - - } - else - { - // TODO - fail - attempt attach on a handle which is in use - } - } - } - - public void handleEnd(End end, Binary payload, Integer channel) - { - System.out.println("CH["+channel+"] : " + end); - TransportSession transportSession = _remoteSessions[channel]; - if(transportSession == null) - { - // TODO - fail due to attach on non-begun session - } - else - { - _remoteSessions[channel] = null; - - transportSession.getSession().setRemoteState(EndpointState.CLOSED); - - } - } - - public void handleClose(Close close, Binary payload, Integer channel) - { - System.out.println("CH["+channel+"] : " + close); - _connectionEndpoint.setRemoteState(EndpointState.CLOSED); - } - -} \ No newline at end of file
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/e57c2a52/proton-j/engine/src/org/apache/qpid/proton/engine/impl/TransportLink.java ---------------------------------------------------------------------- diff --git a/proton-j/engine/src/org/apache/qpid/proton/engine/impl/TransportLink.java b/proton-j/engine/src/org/apache/qpid/proton/engine/impl/TransportLink.java deleted file mode 100644 index 33c1dd6..0000000 --- a/proton-j/engine/src/org/apache/qpid/proton/engine/impl/TransportLink.java +++ /dev/null @@ -1,126 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ - -package org.apache.qpid.proton.engine.impl; - -import org.apache.qpid.proton.type.UnsignedInteger; -import org.apache.qpid.proton.type.transport.Flow; - -class TransportLink<T extends LinkImpl> -{ - private UnsignedInteger _localHandle; - private String _name; - private UnsignedInteger _remoteHandle; - private UnsignedInteger _deliveryCount = UnsignedInteger.ZERO; - private UnsignedInteger _linkCredit = UnsignedInteger.ZERO; - private T _link; - private UnsignedInteger _remoteDeliveryCount; - private UnsignedInteger _remoteLinkCredit; - - protected TransportLink(T link) - { - _link = link; - } - - static <L extends LinkImpl> TransportLink<L> createTransportLink(L link) - { - return (TransportLink<L>) (link instanceof ReceiverImpl - ? new TransportReceiver((ReceiverImpl)link) - : new TransportSender((SenderImpl)link)); - } - - public UnsignedInteger getLocalHandle() - { - return _localHandle; - } - - public void setLocalHandle(UnsignedInteger localHandle) - { - _localHandle = localHandle; - } - - public boolean isLocalHandleSet() - { - return _localHandle != null; - } - - public String getName() - { - return _name; - } - - public void setName(String name) - { - _name = name; - } - - public void clearLocalHandle() - { - _localHandle = null; - } - - public UnsignedInteger getRemoteHandle() - { - return _remoteHandle; - } - - public void setRemoteHandle(UnsignedInteger remoteHandle) - { - _remoteHandle = remoteHandle; - } - - public UnsignedInteger getDeliveryCount() - { - return _deliveryCount; - } - - public UnsignedInteger getLinkCredit() - { - return _linkCredit; - } - - public void addCredit(int credits) - { - _linkCredit = UnsignedInteger.valueOf(_linkCredit.intValue() + credits); - } - - public T getLink() - { - return _link; - } - - void handleFlow(Flow flow) - { - _remoteDeliveryCount = flow.getDeliveryCount(); - _remoteLinkCredit = flow.getLinkCredit(); - - } - - void setLinkCredit(UnsignedInteger linkCredit) - { - _linkCredit = linkCredit; - } - - public void setDeliveryCount(UnsignedInteger deliveryCount) - { - _deliveryCount = deliveryCount; - } -} http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/e57c2a52/proton-j/engine/src/org/apache/qpid/proton/engine/impl/TransportReceiver.java ---------------------------------------------------------------------- diff --git a/proton-j/engine/src/org/apache/qpid/proton/engine/impl/TransportReceiver.java b/proton-j/engine/src/org/apache/qpid/proton/engine/impl/TransportReceiver.java deleted file mode 100644 index bdd480f..0000000 --- a/proton-j/engine/src/org/apache/qpid/proton/engine/impl/TransportReceiver.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ - -package org.apache.qpid.proton.engine.impl; - -import org.apache.qpid.proton.type.transport.Flow; - -class TransportReceiver extends TransportLink<ReceiverImpl> -{ - - - TransportReceiver(ReceiverImpl link) - { - super(link); - link.setTransportLink(this); - } - - public ReceiverImpl getReceiver() - { - return getLink(); - } - - @Override - void handleFlow(Flow flow) - { - super.handleFlow(flow); - } -} http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/e57c2a52/proton-j/engine/src/org/apache/qpid/proton/engine/impl/TransportSender.java ---------------------------------------------------------------------- diff --git a/proton-j/engine/src/org/apache/qpid/proton/engine/impl/TransportSender.java b/proton-j/engine/src/org/apache/qpid/proton/engine/impl/TransportSender.java deleted file mode 100644 index 111f1c4..0000000 --- a/proton-j/engine/src/org/apache/qpid/proton/engine/impl/TransportSender.java +++ /dev/null @@ -1,52 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ - -package org.apache.qpid.proton.engine.impl; - -import org.apache.qpid.proton.type.UnsignedInteger; -import org.apache.qpid.proton.type.transport.Flow; - -class TransportSender extends TransportLink<SenderImpl> -{ - private boolean _drain; - - TransportSender(SenderImpl link) - { - super(link); - link.setTransportLink(this); - } - - @Override - void handleFlow(Flow flow) - { - super.handleFlow(flow); - _drain = flow.getDrain(); - UnsignedInteger transferLimit = flow.getLinkCredit().add(getDeliveryCount()); - UnsignedInteger linkCredit = transferLimit.subtract(getDeliveryCount()); - getLink().setCredit(linkCredit.intValue()); - - DeliveryImpl current = getLink().current(); - getLink().getConnectionImpl().workUpdate(current); - setLinkCredit(linkCredit); - } - - -} http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/e57c2a52/proton-j/engine/src/org/apache/qpid/proton/engine/impl/TransportSession.java ---------------------------------------------------------------------- diff --git a/proton-j/engine/src/org/apache/qpid/proton/engine/impl/TransportSession.java b/proton-j/engine/src/org/apache/qpid/proton/engine/impl/TransportSession.java deleted file mode 100644 index 692d2d5..0000000 --- a/proton-j/engine/src/org/apache/qpid/proton/engine/impl/TransportSession.java +++ /dev/null @@ -1,255 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ - -package org.apache.qpid.proton.engine.impl; - -import org.apache.qpid.proton.type.Binary; -import org.apache.qpid.proton.type.UnsignedInteger; -import org.apache.qpid.proton.type.transport.Flow; -import org.apache.qpid.proton.type.transport.Transfer; - -import java.util.HashMap; -import java.util.Map; - -class TransportSession -{ - private final SessionImpl _session; - private int _localChannel = -1; - private int _remoteChannel = -1; - private boolean _openSent; - private UnsignedInteger _handleMax = UnsignedInteger.valueOf(1024); - private UnsignedInteger _incomingWindowSize = UnsignedInteger.valueOf(1024); - private UnsignedInteger _outgoingWindowSize = UnsignedInteger.valueOf(1024); - private UnsignedInteger _nextOutgoingId = UnsignedInteger.ONE; - private TransportLink[] _remoteHandleMap = new TransportLink[1024]; - private TransportLink[] _localHandleMap = new TransportLink[1024]; - private Map<String, TransportLink> _halfOpenLinks = new HashMap<String, TransportLink>(); - - - private UnsignedInteger _currentDeliveryId; - private UnsignedInteger _remoteIncomingWindow; - private UnsignedInteger _remoteOutgoingWindow; - private UnsignedInteger _remoteNextIncomingId; - private UnsignedInteger _remoteNextOutgoingId; - - public TransportSession(SessionImpl session) - { - _session = session; - } - - public SessionImpl getSession() - { - return _session; - } - - public int getLocalChannel() - { - return _localChannel; - } - - public void setLocalChannel(int localChannel) - { - _localChannel = localChannel; - } - - public int getRemoteChannel() - { - return _remoteChannel; - } - - public void setRemoteChannel(int remoteChannel) - { - _remoteChannel = remoteChannel; - } - - public boolean isOpenSent() - { - return _openSent; - } - - public void setOpenSent(boolean openSent) - { - _openSent = openSent; - } - - public boolean isRemoteChannelSet() - { - return _remoteChannel != -1; - } - - public boolean isLocalChannelSet() - { - return _localChannel != -1; - } - - public void unsetLocalChannel() - { - _localChannel = -1; - } - - public void unsetRemoteChannel() - { - _remoteChannel = -1; - } - - - public UnsignedInteger getHandleMax() - { - return _handleMax; - } - - public UnsignedInteger getIncomingWindowSize() - { - return _incomingWindowSize; - } - - public UnsignedInteger getOutgoingWindowSize() - { - return _outgoingWindowSize; - } - - public UnsignedInteger getNextOutgoingId() - { - return _nextOutgoingId; - } - - public TransportLink getLinkFromRemoteHandle(UnsignedInteger handle) - { - return _remoteHandleMap[handle.intValue()]; - } - - public UnsignedInteger allocateLocalHandle() - { - for(int i = 0; i < _localHandleMap.length; i++) - { - if(_localHandleMap[i] == null) - { - return UnsignedInteger.valueOf(i); - } - } - // TODO - error - return UnsignedInteger.MAX_VALUE; - } - - public void addLinkRemoteHandle(TransportLink link, UnsignedInteger remoteHandle) - { - _remoteHandleMap[remoteHandle.intValue()] = link; - } - - public void addLinkLocalHandle(TransportLink link, UnsignedInteger localhandle) - { - _localHandleMap[localhandle.intValue()] = link; - } - - public void freeLocalHandle(UnsignedInteger handle) - { - _localHandleMap[handle.intValue()] = null; - } - - public void freeRemoteHandle(UnsignedInteger handle) - { - _remoteHandleMap[handle.intValue()] = null; - } - - public TransportLink resolveHalfOpenLink(String name) - { - return _halfOpenLinks.remove(name); - } - - public void addHalfOpenLink(TransportLink link) - { - _halfOpenLinks.put(link.getName(), link); - } - - public void handleTransfer(Transfer transfer, Binary payload) - { - - if(transfer.getDeliveryId() == null || transfer.getDeliveryId().equals(_currentDeliveryId)) - { - - // TODO - handle large messages - } - else - { - // TODO - check deliveryId has been incremented by one - _currentDeliveryId = transfer.getDeliveryId(); - // TODO - check link handle valid and a receiver - TransportReceiver transportReceiver = (TransportReceiver) getLinkFromRemoteHandle(transfer.getHandle()); - ReceiverImpl receiver = transportReceiver.getReceiver(); - Binary deliveryTag = transfer.getDeliveryTag(); - DeliveryImpl delivery = receiver.delivery(deliveryTag.getArray(), deliveryTag.getArrayOffset(), - deliveryTag.getLength()); - TransportDelivery transportDelivery = new TransportDelivery(_currentDeliveryId, delivery, transportReceiver); - delivery.setTransportDelivery(transportDelivery); - delivery.addIOWork(); - - - } - - if(!(transfer.getMore() || transfer.getAborted())) - { - _incomingWindowSize = _incomingWindowSize.subtract(UnsignedInteger.ONE); - } - - } - - public void freeLocalChannel() - { - _localChannel = -1; - } - - private void setRemoteIncomingWindow(UnsignedInteger incomingWindow) - { - _remoteIncomingWindow = incomingWindow; - } - - private void setRemoteOutgoingWindow(UnsignedInteger outgoingWindow) - { - _remoteOutgoingWindow = outgoingWindow; - } - - void handleFlow(Flow flow) - { - setRemoteIncomingWindow(flow.getIncomingWindow()); - setRemoteOutgoingWindow(flow.getOutgoingWindow()); - setRemoteNextIncomingId(flow.getNextIncomingId()); - setRemoteNextOutgoingId(flow.getNextOutgoingId()); - - if(flow.getHandle() != null) - { - TransportLink transportLink = getLinkFromRemoteHandle(flow.getHandle()); - transportLink.handleFlow(flow); - - - } - - } - - private void setRemoteNextOutgoingId(UnsignedInteger nextOutgoingId) - { - _remoteNextOutgoingId = nextOutgoingId; - } - - private void setRemoteNextIncomingId(UnsignedInteger remoteNextIncomingId) - { - _remoteNextIncomingId = remoteNextIncomingId; - } -} http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/e57c2a52/proton-j/module.xml ---------------------------------------------------------------------- diff --git a/proton-j/module.xml b/proton-j/module.xml deleted file mode 100644 index ca7715b..0000000 --- a/proton-j/module.xml +++ /dev/null @@ -1,886 +0,0 @@ -<!-- - - - - Licensed to the Apache Software Foundation (ASF) under one - - or more contributor license agreements. See the NOTICE file - - distributed with this work for additional information - - regarding copyright ownership. The ASF licenses this file - - to you under the Apache License, Version 2.0 (the - - "License"); you may not use this file except in compliance - - with the License. You may obtain a copy of the License at - - - - http://www.apache.org/licenses/LICENSE-2.0 - - - - Unless required by applicable law or agreed to in writing, - - software distributed under the License is distributed on an - - "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - - KIND, either express or implied. See the License for the - - specific language governing permissions and limitations - - under the License. - - - --> -<project name="module" xmlns:artifact="antlib:org.apache.maven.artifact.ant"> - - <import file="common.xml"/> - - <path id="maven-ant-tasks.classpath" path="${project.root}/lib/maven-ant-tasks-2.1.1.jar" /> - <typedef resource="org/apache/maven/artifact/ant/antlib.xml" - uri="antlib:org.apache.maven.artifact.ant" - classpathref="maven-ant-tasks.classpath" /> - - <map property="module" value="${basedir}" split="${path.separator}"> - <globmapper from="${project.root}${file.separator}*" to="*"/> - </map> - - <map property="module.name" value="${module}"> - <filtermapper> - <replacestring from="${file.separator}" to="-"/> - </filtermapper> - </map> - - <echo message="Running ant for module : ${module}" level="info"/> - - <property file="${project.root}/build.deps"/> - - <property name="module.build" location="${build.scratch}/${module}"/> - <property name="module.classes" location="${module.build}/classes"/> - <property name="module.instrumented" location="${module.build}/classes-instrumented"/> - <property name="module.precompiled" location="${module.build}/src"/> - <property name="module.api" location="${build.api}/${module}/"/> - <property name="module.test.api" location="${build.test.api}/${module}"/> - <property name="module.test.classes" location="${module.build}/test/classes"/> - <property name="module.results" location="${build.results}/${module}"/> - <property name="module.failed" location="${module.results}/FAILED"/> - <property name="module.src" location="src"/> - <property name="module.test.src" location="test"/> - <property name="module.bin" location="bin"/> - <property name="module.etc" location="etc"/> - - <property name="module.namever" value="${project.name}-${module.name}-${project.version}"/> - <property name="module.namever.osgi" value="${project.name}-${module.name}_${project.version}.0.osgi"/> - <property name="module.release.base" value="${basedir}/release"/> - <property name="module.release" value="${module.release.base}/${module.namever}"/> - <property name="module.release.lib" value="${module.release}/lib"/> - <property name="module.release.zip" location="${module.release.base}/${module.namever}.zip"/> - <property name="module.release.tar" location="${module.release.base}/${module.namever}.tar"/> - <property name="module.release.tgz" location="${module.release.base}/${module.namever}.tar.gz"/> - <property name="module.release.bz2" location="${module.release}/${module.namever}.tar.bz2"/> - - <property name="module.genpom.args" value=""/> - <property name="maven.remote.repo" value="file://${module.release.base}/maven"/> - - <property name="broker.log.prefix" value="BROKER: "/> - <property name="broker.log.interleave" value="true"/> - - <property name="module.qpid.jar" location="${module.release.lib}/qpid-all.jar"/> - <basename property="qpid.jar.name" file="${module.qpid.jar}"/> - - <property name="module.coverage" location="${module.build}/coverage"/> - <property name="cobertura.datafile" location="${module.instrumented}/cobetura.ser"/> - - - <available property="module.test.src.exists" file="${module.test.src}"/> - <available property="module.etc.exists" file="${module.etc}"/> - <available property="module.bin.exists" file="${module.bin}"/> - - <property name="module.source.jar" - location="${build.lib}/${project.name}-${module.name}-${project.version}-sources.jar"/> - - <!-- module.depends and module.test.depends are supplied by the importing file --> - <property name="module.depends" value=""/> - <property name="module.test.depends" value=""/> - <property name="module.test.excludes" value=""/> - - <map property="module.depends.path" value="${module.depends}" join="${path.separator}"> - <globmapper from="*" to="${build.scratch}/*/classes"/> - </map> - - <map property="module.test.depends.path" value="${module.test.depends}" join="${path.separator}"> - <globmapper from="*" to="${build.scratch}/*/classes"/> - </map> - - - <!-- Add depenencies dependencies to path --> - <map property="module.depends.libs" value="${module.depends}" join=" "> - <chainedmapper> - <filtermapper> - <replacestring from="${file.separator}" to="-"/> - </filtermapper> - <propertymapper from="*" to="*.libs"/> - </chainedmapper> - </map> - <condition property="module.depends.libs.includes" value="__EMPTY__" else="${module.depends.libs}"> - <equals trim="true" arg1="${module.depends.libs}" arg2=""/> - </condition> - - - <!-- Add depenencies test dependencies to path --> - <map property="module.test.depends.libs" value="${module.test.depends}" join=" "> - <chainedmapper> - <filtermapper> - <replacestring from="${file.separator}" to="-"/> - </filtermapper> - <propertymapper from="*" to="*.libs"/> - </chainedmapper> - </map> - <condition property="module.test.depends.libs.includes" value="__EMPTY__" else="${module.test.depends.libs}"> - <equals trim="true" arg1="${module.test.depends.libs}" arg2=""/> - </condition> - - - <indirect name="module.libs" variable="${module.name}.libs"/> - <condition property="module.libs.includes" value="__EMPTY__" else="${module.libs}"> - <equals trim="true" arg1="${module.libs}" arg2=""/> - </condition> - - <indirect name="module.test.libs" variable="${module.name}.test.libs"/> - <condition property="module.test.libs.includes" value="__EMPTY__" else="${module.test.libs}"> - <equals trim="true" arg1="${module.test.libs}" arg2=""/> - </condition> - - <path id="module.libs"> - <fileset dir="${project.root}" includes="${module.libs.includes}"/> - <fileset dir="${project.root}" includes="${module.depends.libs.includes}"/> - </path> - - <path id="module.test.libs"> - <fileset dir="${project.root}" includes="${module.test.libs.includes}"/> - <fileset dir="${project.root}" includes="${module.test.depends.libs.includes}"/> - </path> - - <path id="module.src.path"> - <pathelement location="${module.src}"/> - <pathelement location="${module.precompiled}"/> - </path> - - <path id="module.test.src.path"> - <pathelement location="${module.test.src}"/> - </path> - - <condition property="module.jar" - value="${build.plugins}/${project.name}-${module.name}-${project.version}.jar" - else="${build.lib}/${project.name}-${module.name}-${project.version}.jar"> - <and> - <isset property="module.plugin"/> - <istrue value="${module.plugin}"/> - </and> - </condition> - - <property name="module.test.jar" - location="${build.lib}/${project.name}-${module.name}-tests-${project.version}.jar"/> - - <path id="module.class.path"> - <pathelement location="${module.classes}"/> - <pathelement path="${module.depends.path}"/> - <path refid="module.libs"/> - </path> - - <path id="module.test.path"> - <pathelement path="${module.test.classes}"/> - <path refid="module.class.path"/> - <pathelement path="${module.test.depends.path}"/> - <path refid="module.test.libs"/> - </path> - - <property name="javac.deprecation" value="off"/> - - <target name="debug"> - <echo-prop name="basedir"/> - <echo-prop name="project.root"/> - <echo-prop name="module"/> - <echo-prop name="module.libs"/> - <echo-prop name="module.test.libs"/> - <echo-prop name="module.name"/> - <echo-prop name="module.jar"/> - <echo-prop name="module.depends"/> - <echo-prop name="module.depends.path"/> - <echo-prop name="module.test.depends"/> - <echo-prop name="module.test.depends.path"/> - <echo-prop name="module.depends.libs"/> - <echo-prop name="module.test.depends.libs"/> - <echo-path refid="module.src.path"/> - <echo-path refid="module.class.path"/> - <echo-path refid="module.test.path"/> - </target> - - <target name="prepare"> - <mkdir dir="${build.bin}"/> - <mkdir dir="${build.etc}"/> - <mkdir dir="${build.lib}"/> - <mkdir dir="${build.results}"/> - <mkdir dir="${build.plugins}"/> - <mkdir dir="${module.classes}"/> - <mkdir dir="${module.precompiled}"/> - <mkdir dir="${module.api}"/> - <mkdir dir="${module.test.api}"/> - <mkdir dir="${module.test.classes}"/> - <mkdir dir="${module.results}"/> - </target> - - <target name="pom" depends="prepare" if="module.genpom"> - <jython path="${mllib.dir}"> - <args> - <arg line='"${project.root}/genpom"'/> - <arg line='-s "${project.root}/lib/poms"'/> - <arg line='-o "${build.scratch}/qpid-${module.name}.pom"'/> - <arg line="-u ${project.url}"/> - <arg line="-g ${project.groupid}"/> - <arg line="-v ${project.version}${maven.version.suffix}"/> - <arg line="-p qpid"/> - <arg line='-m "${module.depends}"'/> - <arg line="-a ${module.name}"/> - <arg line="${module.genpom.args}"/> - <arg line="${module.libs}"/> - </args> - </jython> - </target> - - <target name="release-mvn" depends="pom" if="module.genpom" description="Install the artifacts into the local repository and prepare the release"> - <antcall target="build"/> - - <artifact:pom id="module.pom" file="${build.scratch}/qpid-${module.name}.pom"/> - - <artifact:install file="${module.jar}" pomRefId="module.pom" settingsFile="${maven.settings.xml}"> - <localRepository path="${maven.local.repo}"/> - </artifact:install> - - <artifact:deploy file="${module.jar}" pomRefId="module.pom" uniqueVersion="${maven.unique.version}" settingsFile="${maven.settings.xml}"> - <attach file="${module.source.jar}" classifier="sources"/> - <localRepository path="${maven.local.repo}"/> - <remoteRepository url="${maven.remote.repo}"/> - </artifact:deploy> - </target> - - <target name="precompile"/> - - <target name="compile" depends="prepare,precompile" description="compile sources"> - - <echo message="Targeting : ${java.target}" level="info"/> - - <javac source="${java.source}" target="${java.target}" - destdir="${module.classes}" debug="on" debuglevel="lines,vars,source" includeantruntime="false" - deprecation="${javac.deprecation}"> - <compilerarg line="${javac.compiler.args}"/> - <src refid="module.src.path"/> - <classpath refid="module.class.path"/> - </javac> - - <!-- copy any non java src files into the build tree, e.g. properties files --> - <copy todir="${module.classes}" verbose="true"> - <fileset dir="${module.src}"> - <exclude name="**/*.java"/> - <exclude name="**/package.html"/> - </fileset> - </copy> - </target> - - <target name="precompile-tests" if="module.test.src.exists"/> - - <target name="compile-tests" depends="compile,precompile-tests" if="module.test.src.exists" - description="compilte unit tests"> - <javac target="${java.target}" source="${java.source}" - destdir="${module.test.classes}" debug="on" - deprecation="${javac.deprecation}" - srcdir="${module.test.src}" - includeantruntime="false"> - <classpath refid="module.test.path"/> - </javac> - - <!-- copy any non java src files into the build tree, e.g. properties files --> - <copy todir="${module.test.classes}" verbose="true"> - <fileset dir="${module.test.src}"> - <exclude name="**/*.java"/> - <exclude name="**/package.html"/> - </fileset> - </copy> - </target> - - - <delete file="${build.scratch}/test-${profile}.properties" quiet="true"/> - <concat destfile="${build.scratch}/test-${profile}.properties" force="no" fixlastline="yes"> - <filelist dir="${test.profiles}" files="testprofile.defaults"/> - <filelist dir="${test.profiles}" files="${_profile_files}"/> - </concat> - <property file="${build.scratch}/test-${profile}.properties"/> - - <map property="test.excludefiles" value="${test.excludes}"> - <globmapper from="*" to="${test.profiles}/*;"/> - </map> - - <condition property="dontruntest" value="dontruntest" else="runtest"> - <contains substring="${module.name}" string="${exclude.modules}" /> - </condition> - - <property name="jvm.args" value=""/> - <property name="broker.existing.qpid.work" value=""/> - - <target name="test" depends="build,compile-tests" if="module.test.src.exists" - unless="${dontruntest}" description="execute unit tests"> - - <delete file="${module.failed}"/> - - <echo message="Using profile:${profile}" level="info"/> - <junit fork="yes" forkmode="once" maxmemory="${test.mem}" reloading="no" - haltonfailure="${haltonfailure}" haltonerror="${haltonerror}" - failureproperty="test.failures" printsummary="on" timeout="6000000" - dir="${project.root}" > - - <jvmarg line="${jvm.args}" /> - - <sysproperty key="amqj.logging.level" value="${amqj.logging.level}"/> - <sysproperty key="amqj.server.logging.level" value="${amqj.server.logging.level}"/> - <sysproperty key="amqj.protocol.logging.level" value="${amqj.protocol.logging.level}"/> - <sysproperty key="log4j.debug" value="${log4j.debug}"/> - <sysproperty key="root.logging.level" value="${root.logging.level}"/> - <sysproperty key="log4j.configuration" value="${log4j.configuration}"/> - <sysproperty key="java.naming.factory.initial" value="${java.naming.factory.initial}"/> - <sysproperty key="java.naming.provider.url" value="${java.naming.provider.url}"/> - <sysproperty key="messagestore.class.name" value="${messagestore.class.name}" /> - <sysproperty key="test.output" value="${module.results}"/> - <sysproperty key="qpid.amqp.version" value="${qpid.amqp.version}"/> - - <syspropertyset> - <propertyref prefix="test"/> - </syspropertyset> - <syspropertyset> - <propertyref prefix="profile"/> - </syspropertyset> - <syspropertyset> - <propertyref prefix="javax.net.ssl"/> - </syspropertyset> - <syspropertyset> - <propertyref prefix="broker"/> - </syspropertyset> - - <sysproperty key="max_prefetch" value ="${max_prefetch}"/> - <sysproperty key="qpid.dest_syntax" value ="${qpid.dest_syntax}"/> - - <sysproperty key="example.plugin.target" value="${project.root}/build/lib/plugins"/> - <sysproperty key="QPID_EXAMPLE_HOME" value="${qpid.home}"/> - <sysproperty key="QPID_HOME" value="${qpid.home}"/> - <sysproperty key="QPID_WORK" value="${qpid.work}"/> - - <formatter type="plain"/> - <formatter type="xml"/> - - <classpath refid="module.test.path"/> - - <batchtest todir="${module.results}"> - <fileset dir="${module.test.src}" excludes="${module.test.excludes}"> - <include name="**/${test}.java"/> - </fileset> - </batchtest> - </junit> - - <antcall target="touch-failed"/> - - <condition property="failed"> - <and> - <isfalse value="${test.failures.ignore}"/> - <available file="${module.failed}"/> - </and> - </condition> - - <fail if="failed" message="TEST SUITE FAILED"/> - - </target> - - <target name="report-module" description="generate junit reports for each module"> - <junitreport todir="${module.results}"> - <fileset dir="${module.results}"> - <include name="TEST-*.xml"/> - </fileset> - <report format="frames" todir="${module.results}/report/html"/> - </junitreport> - </target> - - <target name="touch-failed" if="test.failures"> - <touch file="${module.failed}"/> - <touch file="${build.failed}"/> - </target> - - <target name="copy-bin" if="module.bin.exists" description="copy bin directory if it exists to build tree"> - <copy todir="${build.bin}" failonerror="false"> - <fileset dir="${module.bin}"/> - </copy> - <chmod dir="${build.bin}" perm="ugo+rx" includes="**/*"/> - </target> - - <target name="copy-bin-release" if="module.bin.exists" description="copy dependencies into module release"> - <copy todir="${module.release}/bin" failonerror="true"> - <fileset dir="${module.bin}" /> - </copy> - <chmod dir="${module.release}/bin" perm="ugo+rx" includes="**/*"/> - </target> - - <target name="copy-etc" if="module.etc.exists" description="copy etc directory if it exists to build tree"> - <copy todir="${build.etc}" failonerror="false"> - <fileset dir="${module.etc}"/> - </copy> - </target> - - <target name="copy-etc-release" if="module.etc.exists" description="copy etc directory if it exists to build tree"> - <copy todir="${module.release}/etc" failonerror="false" flatten="true"> - <fileset dir="${module.etc}"/> - </copy> - </target> - - <target name="postbuild" description="run after a build"/> - - <target name="build" depends="jar,jar-tests,jar-sources,libs,copy-bin,copy-etc,postbuild" description="compile and copy resources into build tree"/> - <target name="jar.manifest" depends="compile" if="module.manifest"> - <jar destfile="${module.jar}" basedir="${module.classes}" manifest="${module.manifest}"/> - </target> - - <target name="jar.nomanifest" depends="compile" unless="module.manifest"> - <jar destfile="${module.jar}" basedir="${module.classes}"> - <metainf dir="${project.root}/resources/" /> - </jar> - </target> - - <target name="jar" depends="jar.manifest,jar.nomanifest" description="create jar"/> - - <target name="jar-tests" depends="compile-tests" description="create unit test jar"> - <jar destfile="${module.test.jar}" basedir="${module.test.classes}"/> - </target> - - <target name="jar-sources" depends="prepare" description="create sources jar"> - <jar destfile="${module.source.jar}"> - <fileset dir="${project.root}/resources"> - <include name="LICENSE"/> - <include name="NOTICE"/> - </fileset> - <fileset dir="${module.src}" includes="**/*.java"/> - <fileset dir="${module.precompiled}" includes="**/*.java"/> - </jar> - </target> - - <target name="libs" description="copy dependencies into build tree"> - <copylist todir="${build.lib}" dir="${project.root}" files="${module.libs}"/> - </target> - - <map property="module.depends.jars" value="${module.depends}" join=","> - <globmapper from="*" to="${project.name}-*-${project.version}.jar"/> - <filtermapper> - <replacestring from="/" to="-"/> - </filtermapper> - </map> - - - <target name="libs-release" description="copy dependencies into module release"> - <!-- Copy the module dependencies --> - <echo message="${module.libs}"/> - <copylist todir="${module.release}/lib" dir="${project.root}" files="${module.libs}"/> - <copylist todir="${module.release}/lib" dir="${project.root}" files="${module.depends.libs}"/> - - <!-- Copy the jar for this module --> - <copy todir="${module.release}/lib" failonerror="true"> - <fileset file="${module.jar}"/> - <fileset dir="${build.lib}" includes="${module.depends.jars}"/> - </copy> - </target> - - <target name="resources" description="copy resources into build tree"> - <copy todir="${build}" failonerror="false" flatten="true"> - <fileset dir="${basedir}${file.separator}.." includes="${resources}"/> - </copy> - </target> - - <target name="resources-release" description="copy resources into module release"> - <copy todir="${module.release}" failonerror="false" flatten="true"> - <fileset dir="${resources}" excludes="META-INF"/> - </copy> - </target> - - <uptodate property="doc.done" targetfile="${module.api}/index.html"> - <srcfiles dir="${module.src}" includes="**/*.java"/> - </uptodate> - - <property name="module.doc.access" value="package"/> - <target name="doc" depends="prepare" unless="doc.done" description="generate api-doc"> - <javadoc access="${module.doc.access}" destdir="${module.api}" author="false" version="true" use="true" - windowtitle="${project.name} - ${module.name} - API Documentation" - sourcepathref="module.src.path" classpathref="module.class.path" packagenames="*"> - <arg value="-J-Dhttp.proxyHost=${http.proxyHost}"/> - <arg value="-J-Dhttp.proxyPort=${http.proxyPort}"/> - <bottom><![CDATA[<em><a href="http://www.apache.org/licenses/LICENSE-2.0">Licensed to the Apache Software Foundation</a></em>]]></bottom> - <link href="http://java.sun.com/j2se/1.5.0/docs/api/"/> - <link href="http://download.oracle.com/docs/cd/E17477_01/javaee/5/api/"/> - <link href="http://commons.apache.org/configuration/apidocs/"/> - <tag name="todo" scope="all" description="Todo:" /> - </javadoc> - </target> - - <uptodate property="test-doc.done" targetfile="${module.test.api}/index.html"> - <srcfiles dir="${module.test.src}" includes="**/*.java"/> - </uptodate> - - <property name="module.test.doc.access" value="public"/> - <target name="test-doc" depends="prepare" unless="testdoc.done" if="module.test.src.exists" description="generate test api-doc"> - <javadoc access="${module.test.doc.access}" destdir="${module.test.api}" author="false" version="true" use="true" - windowtitle="${project.name} - ${module.name} - Test API Documentation" - sourcepathref="module.test.src.path" classpathref="module.test.path" packagenames="*"> - <arg value="-J-Dhttp.proxyHost=${http.proxyHost}"/> - <arg value="-J-Dhttp.proxyPort=${http.proxyPort}"/> - <bottom><![CDATA[<em><a href="http://www.apache.org/licenses/LICENSE-2.0">Licensed to the Apache Software Foundation</a></em>]]></bottom> - <link href="http://java.sun.com/j2se/1.5.0/docs/api/"/> - <link href="http://download.oracle.com/docs/cd/E17477_01/javaee/5/api/"/> - <link href="http://commons.apache.org/configuration/apidocs/"/> - <tag name="todo" scope="all" description="Todo:" /> - </javadoc> - </target> - - <target name="release-bin-prepare"> - <mkdir dir="${module.release}"/> - <available property="module.release.exists" file="${module.release}"/> - </target> - - <target name="check-module-manifest"> - <uptodate property="module-manifest.done" targetfile="${qpid.jar}"> - <srcfiles dir="${build.lib}" includes="**/*.jar" excludes="**/${qpid.jar.name}"/> - </uptodate> - </target> - - <target name="module-manifest" depends="check-module-manifest" unless="module-manifest.done"> - <path id="class.path"> - <fileset dir="${module.release.lib}" > - <include name="*.jar"/> - <exclude name="${qpid.jar.name}"/> - </fileset> - </path> - <pathconvert property="qpid.jar.classpath" pathsep=" " dirsep="/"> - <path refid="class.path"/> - <globmapper from="${module.release.lib}${file.separator}*" to="*"/> - </pathconvert> - - <jar destfile="${module.qpid.jar}"> - <manifest> - <attribute name="Class-Path" value="${qpid.jar.classpath}"/> - </manifest> - <metainf dir="${project.root}/resources/"/> - </jar> - - <touch file="${module.qpid.jar}"/> - </target> - - - <target name="zip-release" depends="build-release-bin" description="build module release archive"> - <zip destfile="${module.release.zip}"> - <zipfileset dir="${module.release}" prefix="${module.namever}" filemode="755"> - <include name="bin/*"/> - <exclude name="bin/*.txt"/> - </zipfileset> - - <zipfileset dir="${module.release}" prefix="${module.namever}" filemode="644"> - <include name="bin/*.txt"/> - </zipfileset> - - <zipfileset dir="${module.release}" prefix="${module.namever}" excludes="${module.release.excludes}" filemode="644" dirmode="755"> - <exclude name="bin/**"/> - <exclude name="**/*.class"/> - </zipfileset> - </zip> - </target> - - <target name="bundle" description="Build module osgi artifact. Override and depend on bundle-tasks to use"/> - - <target name="bundle-tasks" depends="jar"> - <taskdef resource="aQute/bnd/ant/taskdef.properties" classpath="${project.root}/lib/bnd-0.0.384.jar"/> - <echo message="Bundling ${build}/lib/${module.namever}.jar with ${module.src}/${module.name}.bnd"/> - <bnd - classpath="${build}/lib/${module.namever}.jar" - eclipse="false" - failok="false" - exceptions="true" - output="${build}/lib/${module.namever.osgi}.jar" - files="${module.src}/${module.name}.bnd"/> - </target> - - <target name="tar-release" depends="zip-release" description="build release archive"> - <tar destfile="${module.release.tar}" longfile="gnu" > - <zipfileset src="${module.release.zip}"/> - </tar> - </target> - - <target name="gzip-release" depends="tar-release" description="build release archive"> - <gzip src="${module.release.tar}" destfile="${module.release.tgz}"/> - </target> - - <target name="bzip2-release" depends="tar-release" description="build release archive"> - <bzip2 src="${module.release.tar}" destfile="${module.release.bz2}"/> - </target> - - <target name="doc-release" description="no-op override if a doc step is requried "/> - - - <target name="build-release-bin" depends="release-bin-prepare,libs-release,copy-bin-release, - copy-etc-release,doc-release,resources-release,release-bin-other,module-manifest" - description="Task that includes all tasks required to create a module binary release"/> - - <!-- ,zip-release,gzip-release --> - <target name="release-bin-tasks" depends="gzip-release" description="build all release archives except .bz2"/> - - <target name="release-bin-all-tasks" depends="bzip2-release" description="build all release archives"/> - - <!-- Dummy targets to no-op for most modules. Override if a module package is required --> - <target name="release-bin-other" description="Override if there is tasks required for the module bin release to occur last"/> - <target name="release-bin" description="Override and depend on release-bin-tasks to generate"/> - <target name="release-bin-all" description="Override and depend on release-bin-tasks to generate"/> - - <target name="clean" description="remove build artifacts"> - <delete dir="${module.build}"/> - <delete dir="${module.results}"/> - <delete dir="${module.release.base}"/> - <delete dir="${module.instrumented}"/> - </target> - - <target name="instrument" depends="cobertura-init"> - <cobertura-instrument todir="${module.instrumented}" - datafile="${cobertura.datafile}"> - <fileset dir="${module.classes}"> - <include name="**/*.class"/> - </fileset> - </cobertura-instrument> - </target> - - <target name="cover-test" depends="instrument"> - - <mkdir dir="${build.coveragereport}" /> - <junit fork="yes" forkmode="once" maxmemory="${test.mem}" reloading="no" - haltonfailure="${haltonfailure}" haltonerror="${haltonerror}" - failureproperty="test.failures" printsummary="on" timeout="600000" - dir="${project.root}" > - - <sysproperty key="amqj.logging.level" value="${amqj.logging.level}"/> - <sysproperty key="amqj.protocol.logging.level" value="${amqj.protocol.logging.level}"/> - <sysproperty key="log4j.debug" value="${log4j.debug}"/> - <sysproperty key="root.logging.level" value="${root.logging.level}"/> - <sysproperty key="log4j.configuration" value="${log4j.configuration}"/> - <sysproperty key="java.naming.factory.initial" value="${java.naming.factory.initial}"/> - <sysproperty key="java.naming.provider.url" value="${java.naming.provider.url}"/> - <sysproperty key="broker" value="${broker}"/> - <sysproperty key="broker.version" value="${broker.version}"/> - <sysproperty key="broker.ready" value="${broker.ready}" /> - <sysproperty key="test.output" value="${module.results}"/> - - <syspropertyset> - <propertyref prefix="test"/> - </syspropertyset> - <syspropertyset> - <propertyref prefix="broker"/> - </syspropertyset> - - <sysproperty key="max_prefetch" value ="${max_prefetch}"/> - <sysproperty key="example.plugin.target" value="${project.root}/build/lib/plugins"/> - <sysproperty key="QPID_EXAMPLE_HOME" value="${project.root}/build"/> - <sysproperty key="QPID_HOME" value="${project.root}/build"/> - - <sysproperty key="net.sourceforge.cobertura.datafile" - file="${cobertura.datafile}" /> - - <formatter type="plain"/> - <formatter type="xml"/> - - <classpath path="${module.instrumented}"/> - <classpath> - <fileset dir="${build}"> - <include name="**/classes-instrumented/*.class"/> - </fileset> - </classpath> - <classpath refid="module.test.path"/> - <classpath refid="cobertura.classpath"/> - - <batchtest todir="${module.results}"> - <fileset dir="${module.test.src}" excludes="${module.test.excludes}"> - <include name="**/${test}.java"/> - </fileset> - </batchtest> - </junit> - </target> - - <target name="coverage-report" depends="cobertura-init"> - <echo message="${cobertura.datafile}"/> - <cobertura-report format="html" - destdir="${module.coverage}" - datafile="${cobertura.datafile}"> - <fileset dir="${module.src}" includes="**/*.java" /> - </cobertura-report> - </target> - - <property name="version.file" location="${module.classes}/qpidversion.properties"/> - <property file="${version.file}" prefix="old."/> - - <target name="check-version"> - <exec executable="svnversion" spawn="false" failifexecutionfails="false" - dir="${project.root}" outputproperty="svnversion.output"> - <arg line="."/> - </exec> - <condition property="version.stale"> - <not> - <equals arg1="${svnversion.output}" arg2="${old.qpid.svnversion}"/> - </not> - </condition> - </target> - - <target name="create-version" depends="check-version" if="version.stale"> - <!-- Write the version.properties out.--> - <!-- Echos exactly as shown, so leave no spaces before/after lines --> - <echo file="${version.file}" append="false">qpid.version=${project.version} -qpid.svnversion=${svnversion.output} -qpid.name=${project.name} -</echo> - </target> - - <!-- Additions to perform LogMessage generation - To activate for your plugin add the following to your plugin build.xml - - <target name="precompile" depends="gen_logging"/> - - --> - - <property name="gentools.home" location="${project.root}/../gentools" /> - <property name="generated.dir" location="${module.precompiled}" /> - <property name="velocity.compile.dir" value="${build.scratch}/broker/velocity"/> - <property name="velocity.timestamp" location="${generated.dir}/velocity.timestamp" /> - - <target name="compile_velocity" > - <mkdir dir="${velocity.compile.dir}" /> - <!-- Compile LogMessages Velocity Generator --> - <javac source="${java.source}" target="${java.target}" - destdir="${velocity.compile.dir}" debug="on" includeantruntime="false" - deprecation="${javac.deprecation}" - srcdir="${project.root}/broker/src/velocity/java" > - <classpath> - <pathelement path="${gentools.home}/lib/velocity-1.4.jar" /> - </classpath> - <compilerarg line="${javac.compiler.args}"/> - </javac> - </target> - - - <target name="check_velocity_deps"> - <uptodate property="velocity.notRequired" targetfile="${velocity.timestamp}"> - <srcfiles dir="${module.src}" includes="**/*_logmessages.properties" /> - <srcfiles dir="${project.root}/broker/src/velocity/" includes="**/*.java **/*.vm" /> - </uptodate> - </target> - - - <target name="gen_logging" depends="compile_velocity,check_velocity_deps" unless="velocity.notRequired"> - <mkdir dir="${generated.dir}"/> - - <path id="logmessages.path"> - <fileset dir="${module.src}"> - <include name="**/*_logmessages.properties"/> - </fileset> - </path> - - <pathconvert property="logmessages" - refid="logmessages.path" - pathsep="' '"/> - - <echo message="logmessages is ${logmessages}"/> - - <java classname="org.apache.qpid.server.logging.GenerateLogMessages" fork="true" dir="${gentools.home}/src" failonerror="true"> - <arg line="'${logmessages}'"/> - <arg value="-j"/> - <arg value="-o"/> - <arg value="${generated.dir}"/> - <arg value="-t"/> - <arg value="${project.root}/broker/src/velocity/templates/org/apache/qpid/server/logging/messages"/> - <arg value="-s"/> - <arg value="${module.src}"/> - - - <classpath> - <pathelement path="${module.src}"/> - <pathelement path="${velocity.compile.dir}" /> - <fileset dir="${project.root}/lib"> - <include name="**/*.jar"/> - </fileset> - <pathelement path="${gentools.home}/lib/velocity-1.4.jar" /> - </classpath> - </java> - <touch file="${velocity.timestamp}" /> - </target> - - <target name="eclipse" depends="eclipse-setup,eclipse-project,eclipse-source-only,eclipse-source-and-test"/> - - <target name="eclipse-setup"> - <taskdef name="eclipse" classname="prantl.ant.eclipse.EclipseTask" /> - - <!-- Build set of directories representing the dependencies --> - - <dirset id="eclipse.required.projectdirs.path" dir="${project.root}" includes="${module.depends} ${module.test.depends} neverBeEmpty"> - <!-- Select only those projects from module.depends that contain a build.xml. This serves to exclude dependencies that - don't become Eclipse projects e.g. broker-plugins and common-tests --> - <present targetdir="${project.root}"> - <mapper type="glob" from="*" to="*/build.xml"/> - </present> - </dirset> - - <!-- Convert from the set of directories into Eclipse project names proceeded by forward slashes --> - - <pathconvert property="eclipse.required.projectnames" refid="eclipse.required.projectdirs.path" pathsep=" " dirsep="-"> - <map from="${project.root}${file.separator}" to=''/> - </pathconvert> - <map property="eclipse.required.slashedprojectnames" value="${eclipse.required.projectnames}" join="${path.separator}"> - <globmapper from="*" to="/*"/> - </map> - - <echo message="Ant module dependencies : ${module.depends} ${module.test.depends} converted to Eclipse required project(s): ${eclipse.required.slashedprojectnames}"/> - <path id="eclipse.required.slashedprojectnames.path"> - <pathelement path="${eclipse.required.slashedprojectnames}"/> - </path> - </target> - - <!-- Create the Eclipse .project --> - <target name="eclipse-project"> - <eclipse updatealways="${eclipse.updatealways}"> - <project name="${module.name}"/> - - <!-- If the Eclipse task were to ever support the generation of - linked resources, we would configure it to generate - the following: - - scratch_src -> ${module.precompiled} - - in each project. This would avoid the 'linked sources' - manual step documented on the Wiki. - --> - </eclipse> - </target> - - <!-- Create the Eclipse .classpath --> - <target name="eclipse-source-only" unless="module.test.src.exists"> - <eclipse updatealways="${eclipse.updatealways}"> - <settings> - <jdtcore compilercompliance="${eclipse.compilercompliance}" /> - </settings> - <classpath> - <container path="${eclipse.container}" /> - <source path="${module.src}" /> - <source pathref="eclipse.required.slashedprojectnames.path" /> - <library pathref="module.libs"/> - <output path="classes" /> - </classpath> - </eclipse> - </target> - - <!-- Create the Eclipse .classpath --> - <target name="eclipse-source-and-test" if="module.test.src.exists"> - <eclipse updatealways="${eclipse.updatealways}"> - <settings> - <jdtcore compilercompliance="${eclipse.compilercompliance}" /> - </settings> - <classpath> - <container path="${eclipse.container}" /> - <source path="${module.src}" /> - <source path="${module.test.src}" /> - <source pathref="eclipse.required.slashedprojectnames.path" /> - <library pathref="module.libs"/> - <library pathref="module.test.libs"/> - <output path="classes" /> - </classpath> - </eclipse> - </target> -</project> http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/e57c2a52/proton-j/tasks/src/org/apache/qpid/tasks/BaseTask.java ---------------------------------------------------------------------- diff --git a/proton-j/tasks/src/org/apache/qpid/tasks/BaseTask.java b/proton-j/tasks/src/org/apache/qpid/tasks/BaseTask.java deleted file mode 100644 index be604b1..0000000 --- a/proton-j/tasks/src/org/apache/qpid/tasks/BaseTask.java +++ /dev/null @@ -1,74 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ -package org.apache.qpid.tasks; - -import org.apache.tools.ant.BuildException; -import org.apache.tools.ant.Task; - -import java.util.HashSet; -import java.util.Set; - -/** - * BaseTask -- an abstract base task for blaze specific tasks. - **/ - -public abstract class BaseTask extends Task { - - private static Set EMPTY = new HashSet(); - { - EMPTY.add(0); - EMPTY.add(""); - } - - public static class Validator { - - private String name; - private Object value; - - private Validator(String name, Object value) { - this.name = name; - this.value = value; - } - - public Validator required() { - if (value == null) { - error("value is required"); - } - return this; - } - - public Validator nonempty() { - if (EMPTY.contains(value)) { - error("value is empty"); - } - return this; - } - - private void error(String msg) { - throw new BuildException(name + ": " + msg); - } - } - - public Validator validate(String name, Object value) { - return new Validator(name, value); - } - -} http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/e57c2a52/proton-j/tasks/src/org/apache/qpid/tasks/Foreach.java ---------------------------------------------------------------------- diff --git a/proton-j/tasks/src/org/apache/qpid/tasks/Foreach.java b/proton-j/tasks/src/org/apache/qpid/tasks/Foreach.java deleted file mode 100644 index 91b8a25..0000000 --- a/proton-j/tasks/src/org/apache/qpid/tasks/Foreach.java +++ /dev/null @@ -1,84 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ -package org.apache.qpid.tasks; - -import org.apache.tools.ant.BuildException; -import org.apache.tools.ant.Task; -import org.apache.tools.ant.TaskContainer; - -import java.util.ArrayList; -import java.util.List; - -/** - * Foreach -- an ant task that allows iteration. - **/ - -public class Foreach extends BaseTask implements TaskContainer { - - private String property; - private String list; - private String delim = "\\s+"; - private String stop; - private List<Task> tasks = new ArrayList<Task>(); - - public void setProperty(String p) { - property = p; - } - - public void setList(String l) { - list = l; - } - - public void setDelim(String d) { - delim = d; - } - - public void setStop(String s) { - stop = s; - } - - public void addTask(Task t) { - tasks.add(t); - } - - public void execute() { - validate("property", property).required().nonempty(); - validate("list", property).required(); - - if (list.length() == 0) { - return; - } - - String[] values = list.split(delim); - for (int i = 0; i < values.length; i++) { - String value = values[i]; - if (stop != null && stop.length() > 0 && - value.equals(stop)) { - break; - } - getProject().setProperty(property, value); - for (Task t : tasks) { - t.perform(); - } - } - } - -} --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
