http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/proton-j/src/main/java/org/apache/qpid/proton/codec/transport/EndType.java ---------------------------------------------------------------------- diff --git a/proton-j/src/main/java/org/apache/qpid/proton/codec/transport/EndType.java b/proton-j/src/main/java/org/apache/qpid/proton/codec/transport/EndType.java deleted file mode 100644 index 7945fd4..0000000 --- a/proton-j/src/main/java/org/apache/qpid/proton/codec/transport/EndType.java +++ /dev/null @@ -1,97 +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.codec.transport; - -import java.util.Collections; -import java.util.List; -import org.apache.qpid.proton.amqp.Symbol; -import org.apache.qpid.proton.amqp.UnsignedLong; -import org.apache.qpid.proton.amqp.transport.End; -import org.apache.qpid.proton.amqp.transport.ErrorCondition; -import org.apache.qpid.proton.codec.AbstractDescribedType; -import org.apache.qpid.proton.codec.Decoder; -import org.apache.qpid.proton.codec.DescribedTypeConstructor; -import org.apache.qpid.proton.codec.EncoderImpl; - - -public final class EndType extends AbstractDescribedType<End,List> implements DescribedTypeConstructor<End> -{ - private static final Object[] DESCRIPTORS = - { - UnsignedLong.valueOf(0x0000000000000017L), Symbol.valueOf("amqp:end:list"), - }; - - private static final UnsignedLong DESCRIPTOR = UnsignedLong.valueOf(0x0000000000000017L); - - private EndType(EncoderImpl encoder) - { - super(encoder); - } - - public UnsignedLong getDescriptor() - { - return DESCRIPTOR; - } - - @Override - protected List wrap(End val) - { - ErrorCondition errorCondition = val.getError(); - return errorCondition == null ? Collections.EMPTY_LIST : Collections.singletonList(errorCondition); - } - - - public End newInstance(Object described) - { - List l = (List) described; - - End o = new End(); - - if(!l.isEmpty()) - { - o.setError( (ErrorCondition) l.get( 0 ) ); - } - - - return o; - } - - public Class<End> getTypeClass() - { - return End.class; - } - - - public static void register(Decoder decoder, EncoderImpl encoder) - { - EndType type = new EndType(encoder); - for(Object descriptor : DESCRIPTORS) - { - decoder.register(descriptor, type); - } - encoder.register(type); - } - -} - \ No newline at end of file
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/proton-j/src/main/java/org/apache/qpid/proton/codec/transport/ErrorConditionType.java ---------------------------------------------------------------------- diff --git a/proton-j/src/main/java/org/apache/qpid/proton/codec/transport/ErrorConditionType.java b/proton-j/src/main/java/org/apache/qpid/proton/codec/transport/ErrorConditionType.java deleted file mode 100644 index c8ff939..0000000 --- a/proton-j/src/main/java/org/apache/qpid/proton/codec/transport/ErrorConditionType.java +++ /dev/null @@ -1,147 +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.codec.transport; - -import java.util.AbstractList; -import java.util.List; -import java.util.Map; -import org.apache.qpid.proton.amqp.Symbol; -import org.apache.qpid.proton.amqp.UnsignedLong; -import org.apache.qpid.proton.amqp.transport.ErrorCondition; -import org.apache.qpid.proton.codec.AbstractDescribedType; -import org.apache.qpid.proton.codec.DecodeException; -import org.apache.qpid.proton.codec.Decoder; -import org.apache.qpid.proton.codec.DescribedTypeConstructor; -import org.apache.qpid.proton.codec.EncoderImpl; - - -public final class ErrorConditionType extends AbstractDescribedType<ErrorCondition,List> implements DescribedTypeConstructor<ErrorCondition> -{ - private static final Object[] DESCRIPTORS = - { - UnsignedLong.valueOf(0x000000000000001dL), Symbol.valueOf("amqp:error:list"), - }; - - private static final UnsignedLong DESCRIPTOR = UnsignedLong.valueOf(0x000000000000001dL); - - private ErrorConditionType(EncoderImpl encoder) - { - super(encoder); - } - - public UnsignedLong getDescriptor() - { - return DESCRIPTOR; - } - - @Override - protected List wrap(ErrorCondition val) - { - return new ErrorConditionWrapper(val); - } - - public static class ErrorConditionWrapper extends AbstractList - { - - private ErrorCondition _errorCondition; - - public ErrorConditionWrapper(ErrorCondition errorCondition) - { - _errorCondition = errorCondition; - } - - public Object get(final int index) - { - - switch(index) - { - case 0: - return _errorCondition.getCondition(); - case 1: - return _errorCondition.getDescription(); - case 2: - return _errorCondition.getInfo(); - } - - throw new IllegalStateException("Unknown index " + index); - - } - - public int size() - { - return _errorCondition.getInfo() != null - ? 3 - : _errorCondition.getDescription() != null - ? 2 - : 1; - - } - - } - - public ErrorCondition newInstance(Object described) - { - List l = (List) described; - - ErrorCondition o = new ErrorCondition(); - - if(l.isEmpty()) - { - throw new DecodeException("The condition field cannot be omitted"); - } - - switch(3 - l.size()) - { - - case 0: - o.setInfo( (Map) l.get( 2 ) ); - case 1: - o.setDescription( (String) l.get( 1 ) ); - case 2: - o.setCondition( (Symbol) l.get( 0 ) ); - } - - - return o; - } - - public Class<ErrorCondition> getTypeClass() - { - return ErrorCondition.class; - } - - - - public static void register(Decoder decoder, EncoderImpl encoder) - { - ErrorConditionType type = new ErrorConditionType(encoder); - for(Object descriptor : DESCRIPTORS) - { - decoder.register(descriptor, type); - } - encoder.register(type); - } - -} - \ No newline at end of file http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/proton-j/src/main/java/org/apache/qpid/proton/codec/transport/FlowType.java ---------------------------------------------------------------------- diff --git a/proton-j/src/main/java/org/apache/qpid/proton/codec/transport/FlowType.java b/proton-j/src/main/java/org/apache/qpid/proton/codec/transport/FlowType.java deleted file mode 100644 index f9e91dc..0000000 --- a/proton-j/src/main/java/org/apache/qpid/proton/codec/transport/FlowType.java +++ /dev/null @@ -1,191 +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.codec.transport; - -import java.util.AbstractList; -import java.util.List; -import java.util.Map; -import org.apache.qpid.proton.amqp.Symbol; -import org.apache.qpid.proton.amqp.UnsignedInteger; -import org.apache.qpid.proton.amqp.UnsignedLong; -import org.apache.qpid.proton.amqp.transport.Flow; -import org.apache.qpid.proton.codec.AbstractDescribedType; -import org.apache.qpid.proton.codec.DecodeException; -import org.apache.qpid.proton.codec.Decoder; -import org.apache.qpid.proton.codec.DescribedTypeConstructor; -import org.apache.qpid.proton.codec.EncoderImpl; - - -public final class FlowType extends AbstractDescribedType<Flow,List> implements DescribedTypeConstructor<Flow> -{ - private static final Object[] DESCRIPTORS = - { - UnsignedLong.valueOf(0x0000000000000013L), Symbol.valueOf("amqp:flow:list"), - }; - - private static final UnsignedLong DESCRIPTOR = UnsignedLong.valueOf(0x0000000000000013L); - - private FlowType(EncoderImpl encoder) - { - super(encoder); - } - - public UnsignedLong getDescriptor() - { - return DESCRIPTOR; - } - - @Override - protected List wrap(Flow val) - { - return new FlowWrapper(val); - } - - public static class FlowWrapper extends AbstractList - { - - - private Flow _flow; - - public FlowWrapper(Flow flow) - { - _flow = flow; - } - - public Object get(final int index) - { - - switch(index) - { - case 0: - return _flow.getNextIncomingId(); - case 1: - return _flow.getIncomingWindow(); - case 2: - return _flow.getNextOutgoingId(); - case 3: - return _flow.getOutgoingWindow(); - case 4: - return _flow.getHandle(); - case 5: - return _flow.getDeliveryCount(); - case 6: - return _flow.getLinkCredit(); - case 7: - return _flow.getAvailable(); - case 8: - return _flow.getDrain(); - case 9: - return _flow.getEcho(); - case 10: - return _flow.getProperties(); - } - - throw new IllegalStateException("Unknown index " + index); - - } - - public int size() - { - return _flow.getProperties() != null - ? 11 - : _flow.getEcho() - ? 10 - : _flow.getDrain() - ? 9 - : _flow.getAvailable() != null - ? 8 - : _flow.getLinkCredit() != null - ? 7 - : _flow.getDeliveryCount() != null - ? 6 - : _flow.getHandle() != null - ? 5 - : 4; - - } - } - - public Flow newInstance(Object described) - { - List l = (List) described; - - Flow o = new Flow(); - - if(l.size() <= 3) - { - throw new DecodeException("The outgoing-window field cannot be omitted"); - } - - switch(11 - l.size()) - { - - case 0: - o.setProperties( (Map) l.get( 10 ) ); - case 1: - Boolean echo = (Boolean) l.get(9); - o.setEcho(echo == null ? false : echo); - case 2: - Boolean drain = (Boolean) l.get(8); - o.setDrain(drain == null ? false : drain ); - case 3: - o.setAvailable( (UnsignedInteger) l.get( 7 ) ); - case 4: - o.setLinkCredit( (UnsignedInteger) l.get( 6 ) ); - case 5: - o.setDeliveryCount( (UnsignedInteger) l.get( 5 ) ); - case 6: - o.setHandle( (UnsignedInteger) l.get( 4 ) ); - case 7: - o.setOutgoingWindow( (UnsignedInteger) l.get( 3 ) ); - case 8: - o.setNextOutgoingId( (UnsignedInteger) l.get( 2 ) ); - case 9: - o.setIncomingWindow( (UnsignedInteger) l.get( 1 ) ); - case 10: - o.setNextIncomingId( (UnsignedInteger) l.get( 0 ) ); - } - - - return o; - } - - public Class<Flow> getTypeClass() - { - return Flow.class; - } - - - public static void register(Decoder decoder, EncoderImpl encoder) - { - FlowType type = new FlowType(encoder); - for(Object descriptor : DESCRIPTORS) - { - decoder.register(descriptor, type); - } - encoder.register(type); - } - -} - \ No newline at end of file http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/proton-j/src/main/java/org/apache/qpid/proton/codec/transport/OpenType.java ---------------------------------------------------------------------- diff --git a/proton-j/src/main/java/org/apache/qpid/proton/codec/transport/OpenType.java b/proton-j/src/main/java/org/apache/qpid/proton/codec/transport/OpenType.java deleted file mode 100644 index 21e1205..0000000 --- a/proton-j/src/main/java/org/apache/qpid/proton/codec/transport/OpenType.java +++ /dev/null @@ -1,226 +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.codec.transport; - -import java.util.AbstractList; -import java.util.List; -import java.util.Map; -import org.apache.qpid.proton.amqp.Symbol; -import org.apache.qpid.proton.amqp.UnsignedInteger; -import org.apache.qpid.proton.amqp.UnsignedLong; -import org.apache.qpid.proton.amqp.UnsignedShort; -import org.apache.qpid.proton.amqp.transport.Open; -import org.apache.qpid.proton.codec.AbstractDescribedType; -import org.apache.qpid.proton.codec.DecodeException; -import org.apache.qpid.proton.codec.Decoder; -import org.apache.qpid.proton.codec.DescribedTypeConstructor; -import org.apache.qpid.proton.codec.EncoderImpl; - - -public final class OpenType extends AbstractDescribedType<Open,List> implements DescribedTypeConstructor<Open> -{ - private static final Object[] DESCRIPTORS = - { - UnsignedLong.valueOf(0x0000000000000010L), Symbol.valueOf("amqp:open:list"), - }; - - private static final UnsignedLong DESCRIPTOR = UnsignedLong.valueOf(0x0000000000000010L); - - private OpenType(EncoderImpl encoder) - { - super(encoder); - } - - - public UnsignedLong getDescriptor() - { - return DESCRIPTOR; - } - - @Override - protected List wrap(Open val) - { - return new OpenWrapper(val); - } - - - public static class OpenWrapper extends AbstractList - { - - private Open _open; - - public OpenWrapper(Open open) - { - _open = open; - } - - public Object get(final int index) - { - - switch(index) - { - case 0: - return _open.getContainerId(); - case 1: - return _open.getHostname(); - case 2: - return _open.getMaxFrameSize(); - case 3: - return _open.getChannelMax(); - case 4: - return _open.getIdleTimeOut(); - case 5: - return _open.getOutgoingLocales(); - case 6: - return _open.getIncomingLocales(); - case 7: - return _open.getOfferedCapabilities(); - case 8: - return _open.getDesiredCapabilities(); - case 9: - return _open.getProperties(); - } - - throw new IllegalStateException("Unknown index " + index); - - } - - public int size() - { - return _open.getProperties() != null - ? 10 - : _open.getDesiredCapabilities() != null - ? 9 - : _open.getOfferedCapabilities() != null - ? 8 - : _open.getIncomingLocales() != null - ? 7 - : _open.getOutgoingLocales() != null - ? 6 - : _open.getIdleTimeOut() != null - ? 5 - : (_open.getChannelMax() != null && !_open.getChannelMax().equals(UnsignedShort.MAX_VALUE)) - ? 4 - : (_open.getMaxFrameSize() != null && !_open.getMaxFrameSize().equals(UnsignedInteger.MAX_VALUE)) - ? 3 - : _open.getHostname() != null - ? 2 - : 1; - - } - - } - - public Open newInstance(Object described) - { - List l = (List) described; - - Open o = new Open(); - - if(l.isEmpty()) - { - throw new DecodeException("The container-id field cannot be omitted"); - } - - switch(10 - l.size()) - { - - case 0: - o.setProperties( (Map) l.get( 9 ) ); - case 1: - Object val1 = l.get( 8 ); - if( val1 == null || val1.getClass().isArray() ) - { - o.setDesiredCapabilities( (Symbol[]) val1 ); - } - else - { - o.setDesiredCapabilities( (Symbol) val1 ); - } - case 2: - Object val2 = l.get( 7 ); - if( val2 == null || val2.getClass().isArray() ) - { - o.setOfferedCapabilities( (Symbol[]) val2 ); - } - else - { - o.setOfferedCapabilities( (Symbol) val2 ); - } - case 3: - Object val3 = l.get( 6 ); - if( val3 == null || val3.getClass().isArray() ) - { - o.setIncomingLocales( (Symbol[]) val3 ); - } - else - { - o.setIncomingLocales( (Symbol) val3 ); - } - case 4: - Object val4 = l.get( 5 ); - if( val4 == null || val4.getClass().isArray() ) - { - o.setOutgoingLocales( (Symbol[]) val4 ); - } - else - { - o.setOutgoingLocales( (Symbol) val4 ); - } - case 5: - o.setIdleTimeOut( (UnsignedInteger) l.get( 4 ) ); - case 6: - UnsignedShort channelMax = (UnsignedShort) l.get(3); - o.setChannelMax(channelMax == null ? UnsignedShort.MAX_VALUE : channelMax); - case 7: - UnsignedInteger maxFrameSize = (UnsignedInteger) l.get(2); - o.setMaxFrameSize(maxFrameSize == null ? UnsignedInteger.MAX_VALUE : maxFrameSize); - case 8: - o.setHostname( (String) l.get( 1 ) ); - case 9: - o.setContainerId( (String) l.get( 0 ) ); - } - - - return o; - } - - public Class<Open> getTypeClass() - { - return Open.class; - } - - - public static void register(Decoder decoder, EncoderImpl encoder) - { - OpenType type = new OpenType(encoder); - for(Object descriptor : DESCRIPTORS) - { - decoder.register(descriptor, type); - } - encoder.register(type); - } - -} - \ No newline at end of file http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/proton-j/src/main/java/org/apache/qpid/proton/codec/transport/TransferType.java ---------------------------------------------------------------------- diff --git a/proton-j/src/main/java/org/apache/qpid/proton/codec/transport/TransferType.java b/proton-j/src/main/java/org/apache/qpid/proton/codec/transport/TransferType.java deleted file mode 100644 index 4ddbd49..0000000 --- a/proton-j/src/main/java/org/apache/qpid/proton/codec/transport/TransferType.java +++ /dev/null @@ -1,207 +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.codec.transport; - -import java.util.AbstractList; -import java.util.List; -import org.apache.qpid.proton.amqp.Binary; -import org.apache.qpid.proton.amqp.Symbol; -import org.apache.qpid.proton.amqp.UnsignedByte; -import org.apache.qpid.proton.amqp.UnsignedInteger; -import org.apache.qpid.proton.amqp.UnsignedLong; -import org.apache.qpid.proton.amqp.transport.DeliveryState; -import org.apache.qpid.proton.amqp.transport.ReceiverSettleMode; -import org.apache.qpid.proton.amqp.transport.Transfer; -import org.apache.qpid.proton.codec.AbstractDescribedType; -import org.apache.qpid.proton.codec.DecodeException; -import org.apache.qpid.proton.codec.Decoder; -import org.apache.qpid.proton.codec.DescribedTypeConstructor; -import org.apache.qpid.proton.codec.EncoderImpl; - - -public final class TransferType extends AbstractDescribedType<Transfer,List> implements DescribedTypeConstructor<Transfer> -{ - private static final Object[] DESCRIPTORS = - { - UnsignedLong.valueOf(0x0000000000000014L), Symbol.valueOf("amqp:transfer:list"), - }; - - private static final UnsignedLong DESCRIPTOR = UnsignedLong.valueOf(0x0000000000000014L); - - private TransferType(EncoderImpl encoder) - { - super(encoder); - } - - - public UnsignedLong getDescriptor() - { - return DESCRIPTOR; - } - - @Override - protected List wrap(Transfer val) - { - return new TransferWrapper(val); - } - - - public static class TransferWrapper extends AbstractList - { - - private Transfer _transfer; - - public TransferWrapper(Transfer transfer) - { - _transfer = transfer; - } - - public Object get(final int index) - { - - switch(index) - { - case 0: - return _transfer.getHandle(); - case 1: - return _transfer.getDeliveryId(); - case 2: - return _transfer.getDeliveryTag(); - case 3: - return _transfer.getMessageFormat(); - case 4: - return _transfer.getSettled(); - case 5: - return _transfer.getMore(); - case 6: - return _transfer.getRcvSettleMode() == null ? null : _transfer.getRcvSettleMode().getValue(); - case 7: - return _transfer.getState(); - case 8: - return _transfer.getResume(); - case 9: - return _transfer.getAborted(); - case 10: - return _transfer.getBatchable(); - } - - throw new IllegalStateException("Unknown index " + index); - - } - - public int size() - { - return _transfer.getBatchable() - ? 11 - : _transfer.getAborted() - ? 10 - : _transfer.getResume() - ? 9 - : _transfer.getState() != null - ? 8 - : _transfer.getRcvSettleMode() != null - ? 7 - : _transfer.getMore() - ? 6 - : _transfer.getSettled() != null - ? 5 - : _transfer.getMessageFormat() != null - ? 4 - : _transfer.getDeliveryTag() != null - ? 3 - : _transfer.getDeliveryId() != null - ? 2 - : 1; - - } - - } - - public Transfer newInstance(Object described) - { - List l = (List) described; - - Transfer o = new Transfer(); - - if(l.isEmpty()) - { - throw new DecodeException("The handle field cannot be omitted"); - } - - switch(11 - l.size()) - { - - case 0: - Boolean batchable = (Boolean) l.get(10); - o.setBatchable(batchable == null ? false : batchable); - case 1: - Boolean aborted = (Boolean) l.get(9); - o.setAborted(aborted == null ? false : aborted); - case 2: - Boolean resume = (Boolean) l.get(8); - o.setResume(resume == null ? false : resume); - case 3: - o.setState( (DeliveryState) l.get( 7 ) ); - case 4: - UnsignedByte receiverSettleMode = (UnsignedByte) l.get(6); - o.setRcvSettleMode(receiverSettleMode == null ? null : ReceiverSettleMode.values()[receiverSettleMode.intValue()]); - case 5: - Boolean more = (Boolean) l.get(5); - o.setMore(more == null ? false : more ); - case 6: - o.setSettled( (Boolean) l.get( 4 ) ); - case 7: - o.setMessageFormat( (UnsignedInteger) l.get( 3 ) ); - case 8: - o.setDeliveryTag( (Binary) l.get( 2 ) ); - case 9: - o.setDeliveryId( (UnsignedInteger) l.get( 1 ) ); - case 10: - o.setHandle( (UnsignedInteger) l.get( 0 ) ); - } - - - return o; - } - - public Class<Transfer> getTypeClass() - { - return Transfer.class; - } - - - - - public static void register(Decoder decoder, EncoderImpl encoder) - { - TransferType type = new TransferType(encoder); - for(Object descriptor : DESCRIPTORS) - { - decoder.register(descriptor, type); - } - encoder.register(type); - } - -} - \ No newline at end of file http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/proton-j/src/main/java/org/apache/qpid/proton/driver/Connector.java ---------------------------------------------------------------------- diff --git a/proton-j/src/main/java/org/apache/qpid/proton/driver/Connector.java b/proton-j/src/main/java/org/apache/qpid/proton/driver/Connector.java deleted file mode 100644 index 619b1cf..0000000 --- a/proton-j/src/main/java/org/apache/qpid/proton/driver/Connector.java +++ /dev/null @@ -1,127 +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.driver; - -import java.io.IOException; - -import org.apache.qpid.proton.engine.Connection; -import org.apache.qpid.proton.engine.Sasl; -import org.apache.qpid.proton.engine.Transport; - -/** - * Intermediates between a proton engine {@link Connection} and the I/O - * layer. - * - * The top half of the engine can be access via {@link #getConnection()}. - * The bottom half of the engine is used by {@link #process()}. - * Stores application specific context using {@link #setContext(Object)}. - * - * Implementations are not necessarily thread-safe. - * - * @param <C> application supplied context - * @deprecated Messenger and its connector will be removed from upcoming proton-j releases. - */ -@Deprecated -public interface Connector<C> -{ - /** - * Handle any inbound data, outbound data, or timing events pending on - * the connector. - * Typically, applications repeatedly invoke this method - * during the lifetime of a connection. - */ - boolean process() throws IOException; - - /** - * Access the listener which opened this connector. - * - * @return the listener which created this connector, or null if the - * connector has no listener (e.g. an outbound client - * connection). - */ - @SuppressWarnings("rawtypes") - Listener listener(); - - /** - * Access the Authentication and Security context of the connector. - * - * @return the Authentication and Security context for the connector, - * or null if none. - */ - Sasl sasl(); - - /** - * Access the Transport associated with the connector. - * - */ - - Transport getTransport(); - - /** - * Access the AMQP Connection associated with the connector. - * - * @return the connection context for the connector, or null if none. - */ - Connection getConnection(); - - /** - * Assign the AMQP Connection associated with the connector. - * - * @param connection the connection to associate with the connector. - */ - void setConnection(Connection connection); - - /** - * Access the application context that is associated with the connector. - * - * @return the application context that was passed when creating this - * connector. See - * {@link Driver#createConnector(String, int, Object) - * createConnector(String, int, Object)} and - * {@link Driver#createConnector(java.nio.channels.SelectableChannel, Object) - * createConnector(java.nio.channels.SelectableChannel, Object)}. - */ - C getContext(); - - /** - * Assign a new application context to the connector. - * - * @param context new application context to associate with the connector - */ - void setContext(C context); - - /** - * Close the socket used by the connector. - */ - void close(); - - /** - * Determine if the connector is closed. - */ - boolean isClosed(); - - /** - * Destructor for the given connector. - * - * Assumes the connector's socket has been closed prior to call. - */ - void destroy(); -} http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/proton-j/src/main/java/org/apache/qpid/proton/driver/Driver.java ---------------------------------------------------------------------- diff --git a/proton-j/src/main/java/org/apache/qpid/proton/driver/Driver.java b/proton-j/src/main/java/org/apache/qpid/proton/driver/Driver.java deleted file mode 100644 index 3d8ada3..0000000 --- a/proton-j/src/main/java/org/apache/qpid/proton/driver/Driver.java +++ /dev/null @@ -1,160 +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.driver; - -import java.io.IOException; -import java.nio.channels.SelectableChannel; -import java.nio.channels.ServerSocketChannel; - -import org.apache.qpid.proton.driver.impl.DriverImpl; - -/** - * A driver for the proton engine. - * - * Manages {@link Connector}'s and {@link Listener}'s, which act as intermediaries between - * the proton engine and the network. - * - * Provides methods for the application to access the "top half" of the engine API when the state - * of the engine may have changed due to I/O or timing events - see {@link #connector()}. - * - * Connectors incorporate the SASL engine in order to provide a complete network stack: - * AMQP over SASL over TCP. - * - * Unless otherwise stated, methods on Driver implementations are not necessarily thread-safe. - * - * @deprecated Messenger and its driver will be removed from upcoming proton-j releases. - */ -@Deprecated -public interface Driver -{ - /** - * @deprecated Messenger and its driver will be removed from upcoming proton-j releases. - */ - @Deprecated - public static final class Factory - { - public static Driver create() throws IOException { - return new DriverImpl(); - } - } - - /** - * Force {@link #doWait(long)} to return. - * - * If the driver is not currently waiting then the next invocation of {@link #doWait(long)} - * will return immediately unless the {@link #connector()} method is invoked in the meantime. - * - * Thread-safe. - */ - void wakeup(); - - /** - * Wait for an active connector or listener, or for {@link #wakeup()} to be called. - * - * Thread-safe. - * - * @param timeout maximum time in milliseconds to wait. -1 means wait indefinitely. - * - * @return true if woken up - */ - boolean doWait(long timeout); - - /** - * Get the next listener with pending data in the driver. - * - * @return null if no active listener available - */ - @SuppressWarnings("rawtypes") - Listener listener(); - - /** - * Get the next active connector in the driver. - * - * Returns the next connector with pending inbound data, available capacity - * for outbound data, or pending tick. - * - * Clears the wake-up status that is set by {@link #wakeup()}. - * - * @return null if no active connector available - */ - @SuppressWarnings("rawtypes") - Connector connector(); - - /** - * Destruct the driver and all associated listeners, connectors and other resources. - */ - void destroy(); - - /** - * Construct a listener for the given address. - * - * @param host local host address to listen on - * @param port local port to listen on - * @param context application-supplied, can be accessed via - * {@link Listener#getContext() getContext()} method on a listener. - * @return a new listener on the given host:port, null if error - */ - <C> Listener<C> createListener(String host, int port, C context); - - /** - * Create a listener using the existing channel. - * - * @param c existing SocketChannel for listener to listen on - * @param context application-supplied, can be accessed via - * {@link Listener#getContext() getContext()} method on a listener. - * @return a new listener on the given channel, null if error - */ - <C> Listener<C> createListener(ServerSocketChannel c, C context); - - /** - * Construct a connector to the given remote address. - * - * @param host remote host to connect to. - * @param port remote port to connect to. - * @param context application-supplied, can be accessed via - * {@link Connector#getContext() getContext()} method on a listener. - * - * @return a new connector to the given remote, or null on error. - */ - <C> Connector<C> createConnector(String host, int port, C context); - - /** - * Create a connector using the existing file descriptor. - * - * @param fd existing SocketChannel for listener to listen on - * @param context application-supplied, can be accessed via - * {@link Connector#getContext() getContext()} method on a listener. - * - * @return a new connector to the given host:port, null if error. - */ - <C> Connector<C> createConnector(SelectableChannel fd, C context); - - /** - * Return an iterator over all listeners. - */ - Iterable<Listener> listeners(); - /** - * Return an iterator over all connectors. - */ - Iterable<Connector> connectors(); - -} http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/proton-j/src/main/java/org/apache/qpid/proton/driver/Listener.java ---------------------------------------------------------------------- diff --git a/proton-j/src/main/java/org/apache/qpid/proton/driver/Listener.java b/proton-j/src/main/java/org/apache/qpid/proton/driver/Listener.java deleted file mode 100644 index 7541d4d..0000000 --- a/proton-j/src/main/java/org/apache/qpid/proton/driver/Listener.java +++ /dev/null @@ -1,61 +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.driver; - -/** - * Server API. - * - * @param <C> application supplied context - * @deprecated Messenger and its listener will be removed from upcoming proton-j releases. - */ -@Deprecated -public interface Listener<C> -{ - /** - * Accept a connection that is pending on the listener. - * - * @return a new connector for the remote, or NULL on error. - */ - Connector<C> accept(); - - /** - * Access the application context that is associated with the listener. - * - * @return the application context that was passed when creating this - * listener. See {@link Driver#createListener(String, int, Object) - * createListener(String, int, Object)} and - * {@link Driver#createConnector(java.nio.channels.SelectableChannel, Object) - * createConnector(java.nio.channels.SelectableChannel, Object)} - */ - C getContext(); - - /** - * Set the application context that is associated with this listener. - * - */ - void setContext(C ctx); - - /** - * Close the socket used by the listener. - * - */ - void close() throws java.io.IOException; -} http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/proton-j/src/main/java/org/apache/qpid/proton/driver/impl/ConnectorImpl.java ---------------------------------------------------------------------- diff --git a/proton-j/src/main/java/org/apache/qpid/proton/driver/impl/ConnectorImpl.java b/proton-j/src/main/java/org/apache/qpid/proton/driver/impl/ConnectorImpl.java deleted file mode 100644 index 18cad9a..0000000 --- a/proton-j/src/main/java/org/apache/qpid/proton/driver/impl/ConnectorImpl.java +++ /dev/null @@ -1,280 +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.driver.impl; - -import static org.apache.qpid.proton.driver.impl.ConnectorImpl.ConnectorState.UNINITIALIZED; - -import java.io.IOException; -import java.nio.ByteBuffer; -import java.nio.channels.SelectionKey; -import java.nio.channels.SocketChannel; -import java.util.logging.Level; -import java.util.logging.Logger; - -import org.apache.qpid.proton.Proton; -import org.apache.qpid.proton.driver.Connector; -import org.apache.qpid.proton.driver.Listener; -import org.apache.qpid.proton.engine.Connection; -import org.apache.qpid.proton.engine.Sasl; -import org.apache.qpid.proton.engine.Transport; -import org.apache.qpid.proton.engine.TransportException; - -@SuppressWarnings("deprecation") -class ConnectorImpl<C> implements Connector<C> -{ - private static int DEFAULT_BUFFER_SIZE = 64 * 1024; - private static int readBufferSize = Integer.getInteger - ("pn.receive_buffer_size", DEFAULT_BUFFER_SIZE); - private static int writeBufferSize = Integer.getInteger - ("pn.send_buffer_size", DEFAULT_BUFFER_SIZE); - - enum ConnectorState {UNINITIALIZED, OPENED, EOS, CLOSED}; - - private final DriverImpl _driver; - private final Listener<C> _listener; - private final SocketChannel _channel; - private final Logger _logger = Logger.getLogger("proton.driver"); - private C _context; - - private Connection _connection; - private Transport _transport = Proton.transport(); - private SelectionKey _key; - private ConnectorState _state = UNINITIALIZED; - - private boolean _inputDone = false; - private boolean _outputDone = false; - private boolean _closed = false; - - private boolean _selected = false; - private boolean _readAllowed = false; - - ConnectorImpl(DriverImpl driver, Listener<C> listener, SocketChannel c, C context, SelectionKey key) - { - _driver = driver; - _listener = listener; - _channel = c; - _context = context; - _key = key; - } - - void selected() - { - if (!_selected) { - _selected = true; - _driver.selectConnector(this); - _readAllowed = true; - } - } - - void unselected() - { - _selected = false; - } - - public boolean process() throws IOException - { - if (isClosed() || !_channel.finishConnect()) return false; - - boolean processed = false; - if (!_inputDone) - { - if (read()) { - processed = true; - } - } - - if (!_outputDone) - { - if (write()) { - processed = true; - } - } - - if (_outputDone && _inputDone) - { - close(); - } - - return processed; - } - - private boolean read() throws IOException - { - if (!_readAllowed) return false; - _readAllowed = false; - boolean processed = false; - - int interest = _key.interestOps(); - int capacity = _transport.capacity(); - if (capacity == Transport.END_OF_STREAM) - { - _inputDone = true; - } - else - { - ByteBuffer tail = _transport.tail(); - int bytesRead = _channel.read(tail); - if (bytesRead < 0) { - _transport.close_tail(); - _inputDone = true; - } else if (bytesRead > 0) { - try { - _transport.process(); - } catch (TransportException e) { - _logger.log(Level.SEVERE, this + " error processing input", e); - } - processed = true; - } - } - - capacity = _transport.capacity(); - if (capacity > 0) { - interest |= SelectionKey.OP_READ; - } else { - interest &= ~SelectionKey.OP_READ; - if (capacity < 0) { - _inputDone = true; - } - } - _key.interestOps(interest); - - return processed; - } - - private boolean write() throws IOException - { - boolean processed = false; - - int interest = _key.interestOps(); - boolean writeBlocked = false; - - try { - while (_transport.pending() > 0 && !writeBlocked) - { - ByteBuffer head = _transport.head(); - int wrote = _channel.write(head); - if (wrote > 0) { - processed = true; - _transport.pop(wrote); - } else { - writeBlocked = true; - } - } - - int pending = _transport.pending(); - if (pending > 0) { - interest |= SelectionKey.OP_WRITE; - } else { - interest &= ~SelectionKey.OP_WRITE; - if (pending < 0) { - _outputDone = true; - } - } - } catch (TransportException e) { - _logger.log(Level.SEVERE, this + " error", e); - interest &= ~SelectionKey.OP_WRITE; - _inputDone = true; - _outputDone = true; - } - - _key.interestOps(interest); - - return processed; - } - - public Listener<C> listener() - { - return _listener; - } - - public Sasl sasl() - { - if (_transport != null) - { - return _transport.sasl(); - } - else - { - return null; - } - } - - public Connection getConnection() - { - return _connection; - } - - public void setConnection(Connection connection) - { - _connection = connection; - _transport.bind(_connection); - } - - public Transport getTransport() - { - return _transport; - } - - public C getContext() - { - return _context; - } - - public void setContext(C context) - { - _context = context; - } - - public void close() - { - if (!isClosed()) - { - try - { - _channel.close(); - } - catch (IOException e) - { - _logger.log(Level.SEVERE, "Exception when closing connection",e); - } - finally - { - _closed = true; - selected(); - } - } - } - - public boolean isClosed() - { - return _closed; - } - - public void destroy() - { - close(); // close if not closed already - _driver.removeConnector(this); - } - - @Override - public String toString() - { - StringBuilder builder = new StringBuilder(); - builder.append("ConnectorImpl [_channel=").append(_channel).append("]"); - return builder.toString(); - } -} http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/proton-j/src/main/java/org/apache/qpid/proton/driver/impl/DriverImpl.java ---------------------------------------------------------------------- diff --git a/proton-j/src/main/java/org/apache/qpid/proton/driver/impl/DriverImpl.java b/proton-j/src/main/java/org/apache/qpid/proton/driver/impl/DriverImpl.java deleted file mode 100644 index 6264d7a..0000000 --- a/proton-j/src/main/java/org/apache/qpid/proton/driver/impl/DriverImpl.java +++ /dev/null @@ -1,254 +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.driver.impl; - -import java.io.IOException; -import java.net.InetSocketAddress; -import java.net.ServerSocket; -import java.nio.channels.ClosedChannelException; -import java.nio.channels.SelectableChannel; -import java.nio.channels.SelectionKey; -import java.nio.channels.Selector; -import java.nio.channels.ServerSocketChannel; -import java.nio.channels.SocketChannel; -import java.util.ArrayDeque; -import java.util.Collection; -import java.util.Collections; -import java.util.Iterator; -import java.util.LinkedList; -import java.util.Queue; -import java.util.logging.Level; -import java.util.logging.Logger; - -import org.apache.qpid.proton.driver.Connector; -import org.apache.qpid.proton.driver.Driver; -import org.apache.qpid.proton.driver.Listener; - -@SuppressWarnings("deprecation") -public class DriverImpl implements Driver -{ - private Selector _selector; - private Collection<Listener> _listeners = new LinkedList(); - private Collection<Connector> _connectors = new LinkedList(); - private Logger _logger = Logger.getLogger("proton.driver"); - private Object _wakeupLock = new Object(); - private boolean _woken = false; - private Queue<ConnectorImpl> _selectedConnectors = new ArrayDeque<ConnectorImpl>(); - private Queue<ListenerImpl> _selectedListeners = new ArrayDeque<ListenerImpl>(); - - public DriverImpl() throws IOException - { - _selector = Selector.open(); - } - - public void wakeup() - { - synchronized (_wakeupLock) { - _woken = true; - } - _selector.wakeup(); - } - - public boolean doWait(long timeout) - { - try - { - boolean woken; - synchronized (_wakeupLock) { - woken = _woken; - } - - if (woken || timeout == 0) { - _selector.selectNow(); - } else if (timeout < 0) { - _selector.select(); - } else { - _selector.select(timeout); - } - - synchronized (_wakeupLock) { - woken = woken || _woken; - _woken = false; - } - - for (SelectionKey key : _selector.selectedKeys()) { - if (key.isAcceptable()) { - ListenerImpl l = (ListenerImpl) key.attachment(); - l.selected(); - } else { - ConnectorImpl c = (ConnectorImpl) key.attachment(); - c.selected(); - } - } - - _selector.selectedKeys().clear(); - - return woken; - } - catch (IOException e) - { - _logger.log(Level.SEVERE, "Exception when waiting for IO Event",e); - throw new RuntimeException(e); - } - } - - void selectListener(ListenerImpl l) - { - _selectedListeners.add(l); - } - - public Listener listener() - { - ListenerImpl listener = _selectedListeners.poll(); - if (listener != null) { - listener.unselected(); - } - - return listener; - } - - void selectConnector(ConnectorImpl c) - { - _selectedConnectors.add(c); - } - - public Connector connector() - { - ConnectorImpl connector = _selectedConnectors.poll(); - if (connector != null) { - connector.unselected(); - } - return connector; - } - - public void destroy() - { - try - { - _selector.close(); - } - catch (IOException e) - { - _logger.log(Level.SEVERE, "Exception when closing selector",e); - throw new RuntimeException(e); - } - _listeners.clear(); - _connectors.clear(); - } - - public <C> Listener<C> createListener(String host, int port, C context) - { - try - { - ServerSocketChannel serverSocketChannel = ServerSocketChannel.open(); - ServerSocket serverSocket = serverSocketChannel.socket(); - serverSocket.bind(new InetSocketAddress(host, port)); - serverSocketChannel.configureBlocking(false); - Listener<C> listener = createListener(serverSocketChannel, context); - _logger.fine("Created listener on " + host + ":" + port + ": " + context); - - return listener; - } - catch (ClosedChannelException e) - { - e.printStackTrace(); // TODO - Implement - } - catch (IOException e) - { - e.printStackTrace(); // TODO - Implement - } - return null; - } - - public <C> Listener<C> createListener(ServerSocketChannel c, C context) - { - Listener<C> l = new ListenerImpl<C>(this, c, context); - SelectionKey key = registerInterest(c,SelectionKey.OP_ACCEPT); - key.attach(l); - _listeners.add(l); - return l; - } - - public <C> Connector<C> createConnector(String host, int port, C context) - { - try - { - SocketChannel channel = SocketChannel.open(); - channel.configureBlocking(false); - // Disable the Nagle algorithm on TCP connections. - channel.socket().setTcpNoDelay(true); - channel.connect(new InetSocketAddress(host, port)); - return createConnector(channel, context); - } - catch (IOException e) - { - // TODO Auto-generated catch block - e.printStackTrace(); - throw new RuntimeException(e); - } - } - - public <C> Connector<C> createConnector(SelectableChannel c, C context) - { - SelectionKey key = registerInterest(c, SelectionKey.OP_READ | SelectionKey.OP_WRITE); - Connector<C> co = new ConnectorImpl<C>(this, null, (SocketChannel)c, context, key); - key.attach(co); - _connectors.add(co); - return co; - } - - public <C> void removeConnector(Connector<C> c) - { - _connectors.remove(c); - } - - public Iterable<Listener> listeners() - { - return _listeners; - } - - public Iterable<Connector> connectors() - { - return _connectors; - } - - protected <C> Connector<C> createServerConnector(SelectableChannel c, C context, Listener<C> l) - { - SelectionKey key = registerInterest(c, SelectionKey.OP_READ | SelectionKey.OP_WRITE); - Connector<C> co = new ConnectorImpl<C>(this, l, (SocketChannel)c, context, key); - key.attach(co); - _connectors.add(co); - return co; - } - - private <C> SelectionKey registerInterest(SelectableChannel c, int opKeys) - { - try - { - return c.register(_selector, opKeys); - } - catch (ClosedChannelException e) - { - e.printStackTrace(); // TODO - Implement - throw new RuntimeException(e); - } - } -} http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/proton-j/src/main/java/org/apache/qpid/proton/driver/impl/ListenerImpl.java ---------------------------------------------------------------------- diff --git a/proton-j/src/main/java/org/apache/qpid/proton/driver/impl/ListenerImpl.java b/proton-j/src/main/java/org/apache/qpid/proton/driver/impl/ListenerImpl.java deleted file mode 100644 index a7dd936..0000000 --- a/proton-j/src/main/java/org/apache/qpid/proton/driver/impl/ListenerImpl.java +++ /dev/null @@ -1,93 +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.driver.impl; - -import java.io.IOException; -import java.nio.channels.ServerSocketChannel; -import java.nio.channels.SocketChannel; -import java.util.logging.Level; -import java.util.logging.Logger; - -import org.apache.qpid.proton.driver.Connector; -import org.apache.qpid.proton.driver.Listener; - -@SuppressWarnings("deprecation") -class ListenerImpl<C> implements Listener<C> -{ - private C _context; - private final ServerSocketChannel _channel; - private final DriverImpl _driver; - private final Logger _logger = Logger.getLogger("proton.driver"); - private boolean _selected = false; - - ListenerImpl(DriverImpl driver, ServerSocketChannel c, C context) - { - _driver = driver; - _channel = c; - _context = context; - } - - void selected() - { - if (!_selected) { - _selected = true; - _driver.selectListener(this); - } - } - - void unselected() - { - _selected = false; - } - - public Connector<C> accept() - { - try - { - SocketChannel c = _channel.accept(); - if(c != null) - { - c.configureBlocking(false); - return _driver.createServerConnector(c, null, this); - } - } - catch (IOException e) - { - _logger.log(Level.SEVERE, "Exception when accepting connection",e); - } - return null; //TODO - we should probably throw an exception instead of returning null? - } - - public C getContext() - { - return _context; - } - - public void setContext(C context) - { - _context = context; - } - - public void close() throws IOException - { - _channel.socket().close(); - } -} http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/proton-j/src/main/java/org/apache/qpid/proton/engine/BaseHandler.java ---------------------------------------------------------------------- diff --git a/proton-j/src/main/java/org/apache/qpid/proton/engine/BaseHandler.java b/proton-j/src/main/java/org/apache/qpid/proton/engine/BaseHandler.java deleted file mode 100644 index 2490052..0000000 --- a/proton-j/src/main/java/org/apache/qpid/proton/engine/BaseHandler.java +++ /dev/null @@ -1,240 +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; - -import java.util.Iterator; -import java.util.LinkedHashSet; - - -/** - * BaseHandler - * - */ - -public class BaseHandler implements CoreHandler -{ - - public static Handler getHandler(Record r) { - return r.get(Handler.class, Handler.class); - } - - public static void setHandler(Record r, Handler handler) { - r.set(Handler.class, Handler.class, handler); - } - - public static Handler getHandler(Extendable ext) { - return ext.attachments().get(Handler.class, Handler.class); - } - - public static void setHandler(Extendable ext, Handler handler) { - ext.attachments().set(Handler.class, Handler.class, handler); - } - - private LinkedHashSet<Handler> children = new LinkedHashSet<Handler>(); - - @Override public void onConnectionInit(Event e) { onUnhandled(e); } - @Override public void onConnectionLocalOpen(Event e) { onUnhandled(e); } - @Override public void onConnectionRemoteOpen(Event e) { onUnhandled(e); } - @Override public void onConnectionLocalClose(Event e) { onUnhandled(e); } - @Override public void onConnectionRemoteClose(Event e) { onUnhandled(e); } - @Override public void onConnectionBound(Event e) { onUnhandled(e); } - @Override public void onConnectionUnbound(Event e) { onUnhandled(e); } - @Override public void onConnectionFinal(Event e) { onUnhandled(e); } - - @Override public void onSessionInit(Event e) { onUnhandled(e); } - @Override public void onSessionLocalOpen(Event e) { onUnhandled(e); } - @Override public void onSessionRemoteOpen(Event e) { onUnhandled(e); } - @Override public void onSessionLocalClose(Event e) { onUnhandled(e); } - @Override public void onSessionRemoteClose(Event e) { onUnhandled(e); } - @Override public void onSessionFinal(Event e) { onUnhandled(e); } - - @Override public void onLinkInit(Event e) { onUnhandled(e); } - @Override public void onLinkLocalOpen(Event e) { onUnhandled(e); } - @Override public void onLinkRemoteOpen(Event e) { onUnhandled(e); } - @Override public void onLinkLocalDetach(Event e) { onUnhandled(e); } - @Override public void onLinkRemoteDetach(Event e) { onUnhandled(e); } - @Override public void onLinkLocalClose(Event e) { onUnhandled(e); } - @Override public void onLinkRemoteClose(Event e) { onUnhandled(e); } - @Override public void onLinkFlow(Event e) { onUnhandled(e); } - @Override public void onLinkFinal(Event e) { onUnhandled(e); } - - @Override public void onDelivery(Event e) { onUnhandled(e); } - @Override public void onTransport(Event e) { onUnhandled(e); } - @Override public void onTransportError(Event e) { onUnhandled(e); } - @Override public void onTransportHeadClosed(Event e) { onUnhandled(e); } - @Override public void onTransportTailClosed(Event e) { onUnhandled(e); } - @Override public void onTransportClosed(Event e) { onUnhandled(e); } - - @Override public void onReactorInit(Event e) { onUnhandled(e); } - @Override public void onReactorQuiesced(Event e) { onUnhandled(e); } - @Override public void onReactorFinal(Event e) { onUnhandled(e); } - - @Override public void onTimerTask(Event e) { onUnhandled(e); } - - @Override public void onSelectableInit(Event e) { onUnhandled(e); } - @Override public void onSelectableUpdated(Event e) { onUnhandled(e); } - @Override public void onSelectableReadable(Event e) { onUnhandled(e); } - @Override public void onSelectableWritable(Event e) { onUnhandled(e); } - @Override public void onSelectableExpired(Event e) { onUnhandled(e); } - @Override public void onSelectableError(Event e) { onUnhandled(e); } - @Override public void onSelectableFinal(Event e) { onUnhandled(e); } - - @Override public void onUnhandled(Event event) {} - - @Override - public void add(Handler child) { - children.add(child); - } - - @Override - public Iterator<Handler> children() { - return children.iterator(); - } - - @Override - public void handle(Event e) { - switch (e.getType()) { - case CONNECTION_INIT: - onConnectionInit(e); - break; - case CONNECTION_LOCAL_OPEN: - onConnectionLocalOpen(e); - break; - case CONNECTION_REMOTE_OPEN: - onConnectionRemoteOpen(e); - break; - case CONNECTION_LOCAL_CLOSE: - onConnectionLocalClose(e); - break; - case CONNECTION_REMOTE_CLOSE: - onConnectionRemoteClose(e); - break; - case CONNECTION_BOUND: - onConnectionBound(e); - break; - case CONNECTION_UNBOUND: - onConnectionUnbound(e); - break; - case CONNECTION_FINAL: - onConnectionFinal(e); - break; - case SESSION_INIT: - onSessionInit(e); - break; - case SESSION_LOCAL_OPEN: - onSessionLocalOpen(e); - break; - case SESSION_REMOTE_OPEN: - onSessionRemoteOpen(e); - break; - case SESSION_LOCAL_CLOSE: - onSessionLocalClose(e); - break; - case SESSION_REMOTE_CLOSE: - onSessionRemoteClose(e); - break; - case SESSION_FINAL: - onSessionFinal(e); - break; - case LINK_INIT: - onLinkInit(e); - break; - case LINK_LOCAL_OPEN: - onLinkLocalOpen(e); - break; - case LINK_REMOTE_OPEN: - onLinkRemoteOpen(e); - break; - case LINK_LOCAL_DETACH: - onLinkLocalDetach(e); - break; - case LINK_REMOTE_DETACH: - onLinkRemoteDetach(e); - break; - case LINK_LOCAL_CLOSE: - onLinkLocalClose(e); - break; - case LINK_REMOTE_CLOSE: - onLinkRemoteClose(e); - break; - case LINK_FLOW: - onLinkFlow(e); - break; - case LINK_FINAL: - onLinkFinal(e); - break; - case DELIVERY: - onDelivery(e); - break; - case TRANSPORT: - onTransport(e); - break; - case TRANSPORT_ERROR: - onTransportError(e); - break; - case TRANSPORT_HEAD_CLOSED: - onTransportHeadClosed(e); - break; - case TRANSPORT_TAIL_CLOSED: - onTransportTailClosed(e); - break; - case TRANSPORT_CLOSED: - onTransportClosed(e); - break; - case REACTOR_FINAL: - onReactorFinal(e); - break; - case REACTOR_QUIESCED: - onReactorQuiesced(e); - break; - case REACTOR_INIT: - onReactorInit(e); - break; - case SELECTABLE_ERROR: - onSelectableError(e); - break; - case SELECTABLE_EXPIRED: - onSelectableExpired(e); - break; - case SELECTABLE_FINAL: - onSelectableFinal(e); - break; - case SELECTABLE_INIT: - onSelectableInit(e); - break; - case SELECTABLE_READABLE: - onSelectableReadable(e); - break; - case SELECTABLE_UPDATED: - onSelectableWritable(e); - break; - case SELECTABLE_WRITABLE: - onSelectableWritable(e); - break; - case TIMER_TASK: - onTimerTask(e); - break; - case NON_CORE_EVENT: - onUnhandled(e); - break; - } - } -} http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/proton-j/src/main/java/org/apache/qpid/proton/engine/Collector.java ---------------------------------------------------------------------- diff --git a/proton-j/src/main/java/org/apache/qpid/proton/engine/Collector.java b/proton-j/src/main/java/org/apache/qpid/proton/engine/Collector.java deleted file mode 100644 index 142406e..0000000 --- a/proton-j/src/main/java/org/apache/qpid/proton/engine/Collector.java +++ /dev/null @@ -1,45 +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; - -import org.apache.qpid.proton.engine.impl.CollectorImpl; - -/** - * Collector - * - */ - -public interface Collector -{ - - public static final class Factory - { - public static Collector create() { - return new CollectorImpl(); - } - } - - Event peek(); - - void pop(); - - boolean more(); -} http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/proton-j/src/main/java/org/apache/qpid/proton/engine/Connection.java ---------------------------------------------------------------------- diff --git a/proton-j/src/main/java/org/apache/qpid/proton/engine/Connection.java b/proton-j/src/main/java/org/apache/qpid/proton/engine/Connection.java deleted file mode 100644 index fb4de11..0000000 --- a/proton-j/src/main/java/org/apache/qpid/proton/engine/Connection.java +++ /dev/null @@ -1,137 +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; - -import java.util.EnumSet; -import java.util.Map; - -import org.apache.qpid.proton.amqp.Symbol; -import org.apache.qpid.proton.engine.impl.ConnectionImpl; -import org.apache.qpid.proton.reactor.Reactor; -import org.apache.qpid.proton.reactor.ReactorChild; - - -/** - * Maintains lists of sessions, links and deliveries in a state - * that is interesting to the application. - * - * These are exposed by returning the head of those lists via - * {@link #sessionHead(EnumSet, EnumSet)}, {@link #linkHead(EnumSet, EnumSet)} - * {@link #getWorkHead()} respectively. - */ -public interface Connection extends Endpoint, ReactorChild -{ - - public static final class Factory - { - public static Connection create() { - return new ConnectionImpl(); - } - } - - /** - * Returns a newly created session - * - * TODO does the Connection's channel-max property limit how many sessions can be created, - * or opened, or neither? - */ - public Session session(); - - /** - * Returns the head of the list of sessions in the specified states. - * - * Typically used to discover sessions whose remote state has acquired - * particular values, e.g. sessions that have been remotely opened or closed. - * - * TODO what ordering guarantees on the returned "linked list" are provided? - * - * @see Session#next(EnumSet, EnumSet) - */ - public Session sessionHead(EnumSet<EndpointState> local, EnumSet<EndpointState> remote); - - /** - * Returns the head of the list of links in the specified states. - * - * Typically used to discover links whose remote state has acquired - * particular values, e.g. links that have been remotely opened or closed. - * - * @see Link#next(EnumSet, EnumSet) - */ - public Link linkHead(EnumSet<EndpointState> local, EnumSet<EndpointState> remote); - - /** - * Returns the head of the delivery work list. The delivery work list consists of - * unsettled deliveries whose state has been changed by the other container - * and not yet locally processed. - * - * @see Receiver#recv(byte[], int, int) - * @see Delivery#settle() - * @see Delivery#getWorkNext() - */ - public Delivery getWorkHead(); - - public void setContainer(String container); - - public String getContainer(); - - /** - * Set the name of the host (either fully qualified or relative) to which - * this connection is connecting to. This information may be used by the - * remote peer to determine the correct back-end service to connect the - * client to. This value will be sent in the Open performative. - * - * <b>Note that it is illegal to set the hostname to a numeric IP - * address or include a port number.</b> - * - * @param hostname the RFC1035 compliant host name. - */ - public void setHostname(String hostname); - - public String getHostname(); - - public String getRemoteContainer(); - - public String getRemoteHostname(); - - void setOfferedCapabilities(Symbol[] capabilities); - - void setDesiredCapabilities(Symbol[] capabilities); - - Symbol[] getRemoteOfferedCapabilities(); - - Symbol[] getRemoteDesiredCapabilities(); - - Map<Symbol,Object> getRemoteProperties(); - - void setProperties(Map<Symbol,Object> properties); - - @Override - Object getContext(); - - @Override - void setContext(Object context); - - void collect(Collector collector); - - Transport getTransport(); - - Reactor getReactor(); -} http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/proton-j/src/main/java/org/apache/qpid/proton/engine/CoreHandler.java ---------------------------------------------------------------------- diff --git a/proton-j/src/main/java/org/apache/qpid/proton/engine/CoreHandler.java b/proton-j/src/main/java/org/apache/qpid/proton/engine/CoreHandler.java deleted file mode 100644 index 81c66db..0000000 --- a/proton-j/src/main/java/org/apache/qpid/proton/engine/CoreHandler.java +++ /dev/null @@ -1,71 +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; - -public interface CoreHandler extends Handler { - void onConnectionInit(Event e); - void onConnectionLocalOpen(Event e); - void onConnectionRemoteOpen(Event e); - void onConnectionLocalClose(Event e); - void onConnectionRemoteClose(Event e); - void onConnectionBound(Event e); - void onConnectionUnbound(Event e); - void onConnectionFinal(Event e); - - void onSessionInit(Event e); - void onSessionLocalOpen(Event e); - void onSessionRemoteOpen(Event e); - void onSessionLocalClose(Event e); - void onSessionRemoteClose(Event e); - void onSessionFinal(Event e); - - void onLinkInit(Event e); - void onLinkLocalOpen(Event e); - void onLinkRemoteOpen(Event e); - void onLinkLocalDetach(Event e); - void onLinkRemoteDetach(Event e); - void onLinkLocalClose(Event e); - void onLinkRemoteClose(Event e); - void onLinkFlow(Event e); - void onLinkFinal(Event e); - - void onDelivery(Event e); - void onTransport(Event e); - void onTransportError(Event e); - void onTransportHeadClosed(Event e); - void onTransportTailClosed(Event e); - void onTransportClosed(Event e); - - void onReactorInit(Event e); - void onReactorQuiesced(Event e); - void onReactorFinal(Event e); - - void onTimerTask(Event e); - - void onSelectableInit(Event e); - void onSelectableUpdated(Event e); - void onSelectableReadable(Event e); - void onSelectableWritable(Event e); - void onSelectableExpired(Event e); - void onSelectableError(Event e); - void onSelectableFinal(Event e); - -} http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/proton-j/src/main/java/org/apache/qpid/proton/engine/Delivery.java ---------------------------------------------------------------------- diff --git a/proton-j/src/main/java/org/apache/qpid/proton/engine/Delivery.java b/proton-j/src/main/java/org/apache/qpid/proton/engine/Delivery.java deleted file mode 100644 index c5f6d73..0000000 --- a/proton-j/src/main/java/org/apache/qpid/proton/engine/Delivery.java +++ /dev/null @@ -1,146 +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; - -import org.apache.qpid.proton.amqp.transport.DeliveryState; - -/** - * A delivery of a message on a particular link. - * - * Whilst a message is logically a long-lived object, a delivery is short-lived - it - * is only intended to be used by the application until it is settled and all its data has been read. - */ -public interface Delivery extends Extendable -{ - - public byte[] getTag(); - - public Link getLink(); - - public DeliveryState getLocalState(); - - public DeliveryState getRemoteState(); - - /** - * updates the state of the delivery - * - * @param state the new delivery state - */ - public void disposition(DeliveryState state); - - /** - * Settles this delivery. - * - * Causes the delivery to be removed from the connection's work list (see {@link Connection#getWorkHead()}). - * If this delivery is its link's current delivery, the link's current delivery pointer is advanced. - */ - public void settle(); - - /** - * Returns whether this delivery has been settled. - * - * TODO proton-j and proton-c return the local and remote statuses respectively. Resolve this ambiguity. - * - * @see #settle() - */ - public boolean isSettled(); - - public boolean remotelySettled(); - - /** - * TODO When does an application call this method? Do we really need this? - */ - public void free(); - - /** - * @see Connection#getWorkHead() - */ - public Delivery getWorkNext(); - - public Delivery next(); - - public boolean isWritable(); - - /** - * Returns whether this delivery has data ready to be received. - * - * @see Receiver#recv(byte[], int, int) - */ - public boolean isReadable(); - - public void setContext(Object o); - - public Object getContext(); - - /** - * Returns whether this delivery's state or settled flag has ever remotely changed. - * - * TODO what is the main intended use case for calling this method? - */ - public boolean isUpdated(); - - public void clear(); - - public boolean isPartial(); - - public int pending(); - - public boolean isBuffered(); - - /** - * Configures a default DeliveryState to be used if a - * received delivery is settled/freed without any disposition - * state having been previously applied. - * - * @param state the default delivery state - */ - public void setDefaultDeliveryState(DeliveryState state); - - public DeliveryState getDefaultDeliveryState(); - - /** - * Sets the message-format for this Delivery, representing the 32bit value using an int. - * - * The default value is 0 as per the message format defined in the core AMQP 1.0 specification.<p> - * - * See the following for more details:<br> - * <a href="http://docs.oasis-open.org/amqp/core/v1.0/os/amqp-core-transport-v1.0-os.html#type-transfer"> - * http://docs.oasis-open.org/amqp/core/v1.0/os/amqp-core-transport-v1.0-os.html#type-transfer</a><br> - * <a href="http://docs.oasis-open.org/amqp/core/v1.0/os/amqp-core-transport-v1.0-os.html#type-message-format"> - * http://docs.oasis-open.org/amqp/core/v1.0/os/amqp-core-transport-v1.0-os.html#type-message-format</a><br> - * <a href="http://docs.oasis-open.org/amqp/core/v1.0/os/amqp-core-messaging-v1.0-os.html#section-message-format"> - * http://docs.oasis-open.org/amqp/core/v1.0/os/amqp-core-messaging-v1.0-os.html#section-message-format</a><br> - * <a href="http://docs.oasis-open.org/amqp/core/v1.0/os/amqp-core-messaging-v1.0-os.html#definition-MESSAGE-FORMAT"> - * http://docs.oasis-open.org/amqp/core/v1.0/os/amqp-core-messaging-v1.0-os.html#definition-MESSAGE-FORMAT</a><br> - * - * @param messageFormat the message format - */ - public void setMessageFormat(int messageFormat); - - /** - * Gets the message-format for this Delivery, representing the 32bit value using an int. - * - * @return the message-format - * @see #setMessageFormat(int) - */ - public int getMessageFormat(); - -} http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ccdcf329/proton-j/src/main/java/org/apache/qpid/proton/engine/Endpoint.java ---------------------------------------------------------------------- diff --git a/proton-j/src/main/java/org/apache/qpid/proton/engine/Endpoint.java b/proton-j/src/main/java/org/apache/qpid/proton/engine/Endpoint.java deleted file mode 100644 index d88087b..0000000 --- a/proton-j/src/main/java/org/apache/qpid/proton/engine/Endpoint.java +++ /dev/null @@ -1,80 +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; - - -import org.apache.qpid.proton.amqp.transport.ErrorCondition; - -public interface Endpoint extends Extendable -{ - /** - * @return the local endpoint state - */ - public EndpointState getLocalState(); - - /** - * @return the remote endpoint state (as last communicated) - */ - public EndpointState getRemoteState(); - - /** - * @return the local endpoint error, or null if there is none - */ - public ErrorCondition getCondition(); - - /** - * Set the local error condition - * @param condition - */ - public void setCondition(ErrorCondition condition); - - /** - * @return the remote endpoint error, or null if there is none - */ - public ErrorCondition getRemoteCondition(); - - /** - * free the endpoint and any associated resources - */ - public void free(); - - /** - * transition local state to ACTIVE - */ - void open(); - - /** - * transition local state to CLOSED - */ - void close(); - - /** - * Sets an arbitrary an application owned object on the end-point. This object - * is not used by Proton. - */ - public void setContext(Object o); - - /** - * @see #setContext(Object) - */ - public Object getContext(); - -} --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
