Diff
Modified: trunk/core/src/main/java/org/servicemix/JbiConstants.java (697 => 698)
--- trunk/core/src/main/java/org/servicemix/JbiConstants.java 2005-10-28 13:32:18 UTC (rev 697)
+++ trunk/core/src/main/java/org/servicemix/JbiConstants.java 2005-10-28 14:08:47 UTC (rev 698)
@@ -19,6 +19,14 @@
public interface JbiConstants {
+ String SEND_SYNC = "javax.jbi.messaging.sendSync";
+
+ String PROTOCOL_TYPE = "javax.jbi.protocol.type";
+
+ String PROTOCOL_HEADERS = "javax.jbi.protocol.headers";
+
+ String SECUTIRY_SUBJECT = "javax.jbi.security.subject";
+
String PERSISTENT_PROPERTY_NAME = "org.servicemix.persistent";
}
Modified: trunk/core/src/main/java/org/servicemix/jbi/messaging/DeliveryChannelImpl.java (697 => 698)
--- trunk/core/src/main/java/org/servicemix/jbi/messaging/DeliveryChannelImpl.java 2005-10-28 13:32:18 UTC (rev 697)
+++ trunk/core/src/main/java/org/servicemix/jbi/messaging/DeliveryChannelImpl.java 2005-10-28 14:08:47 UTC (rev 698)
@@ -23,6 +23,7 @@
import org.activemq.util.IdGenerator;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+import org.servicemix.JbiConstants;
import org.servicemix.MessageExchangeListener;
import org.servicemix.jbi.container.ActivationSpec;
import org.servicemix.jbi.container.JBIContainer;
@@ -202,7 +203,7 @@
}
protected MessageExchangeFactoryImpl createMessageExchangeFactory() {
- MessageExchangeFactoryImpl messageExchangeFactory = new MessageExchangeFactoryImpl(idGenerator);
+ MessageExchangeFactoryImpl messageExchangeFactory = new MessageExchangeFactoryImpl(idGenerator, closed);
messageExchangeFactory.setContext(context);
return messageExchangeFactory;
}
@@ -330,6 +331,8 @@
if (this.closed.get()) {
throw new MessagingException("DeliveryChannel is closed");
}
+ // JBI 5.5.2.1.3: set the sendSync property
+ messageExchange.setProperty(JbiConstants.SEND_SYNC, Boolean.TRUE);
MessageExchangeImpl messageExchangeImpl = (MessageExchangeImpl) messageExchange;
autoEnlistInTx(messageExchangeImpl);
try {
@@ -345,6 +348,9 @@
resumeTx(messageExchangeImpl);
return true;
} else {
+ // JBI 5.5.2.1.3: the exchange should be set to ERROR status
+ // TODO: messageExchangeImpl.handleAccept(); ?
+ messageExchangeImpl.setStatus(ExchangeStatus.ERROR);
return false;
}
} catch (InterruptedException e) {
Modified: trunk/core/src/main/java/org/servicemix/jbi/messaging/MessageExchangeFactoryImpl.java (697 => 698)
--- trunk/core/src/main/java/org/servicemix/jbi/messaging/MessageExchangeFactoryImpl.java 2005-10-28 13:32:18 UTC (rev 697)
+++ trunk/core/src/main/java/org/servicemix/jbi/messaging/MessageExchangeFactoryImpl.java 2005-10-28 14:08:47 UTC (rev 698)
@@ -19,6 +19,8 @@
package org.servicemix.jbi.messaging;
+import edu.emory.mathcs.backport.java.util.concurrent.atomic.AtomicBoolean;
+
import org.activemq.util.IdGenerator;
import org.servicemix.jbi.framework.ComponentContextImpl;
@@ -47,15 +49,22 @@
private ServiceEndpoint endpoint;
private IdGenerator idGenerator;
private ComponentContextImpl context;
+ private AtomicBoolean closed;
/**
* Constructor for a factory
* @param idGen
*/
- public MessageExchangeFactoryImpl(IdGenerator idGen){
+ public MessageExchangeFactoryImpl(IdGenerator idGen, AtomicBoolean closed){
this.idGenerator = idGen;
+ this.closed = closed;
}
+ protected void checkClosed() throws MessagingException {
+ if (closed.get()) {
+ throw new MessagingException("DeliveryChannel has been closed.");
+ }
+ }
/**
* Create an exchange from the specified pattern
@@ -65,6 +74,7 @@
* @throws MessagingException
*/
public MessageExchange createExchange(URI pattern) throws MessagingException {
+ checkClosed();
MessageExchange result = null;
if (pattern != null) {
if (pattern.equals(MessageExchangeSupport.IN_ONLY)) {
@@ -93,6 +103,7 @@
* @throws MessagingException
*/
public InOnly createInOnlyExchange() throws MessagingException {
+ checkClosed();
InOnlyImpl result = new InOnlyImpl(getExchangeId());
setDefaults(result);
return result;
@@ -105,6 +116,7 @@
* @throws MessagingException
*/
public RobustInOnly createRobustInOnlyExchange() throws MessagingException {
+ checkClosed();
RobustInOnlyImpl result = new RobustInOnlyImpl(getExchangeId());
setDefaults(result);
return result;
@@ -117,6 +129,7 @@
* @throws MessagingException
*/
public InOut createInOutExchange() throws MessagingException {
+ checkClosed();
InOutImpl result = new InOutImpl(getExchangeId());
setDefaults(result);
return result;
@@ -129,6 +142,7 @@
* @throws MessagingException
*/
public InOptionalOut createInOptionalOutExchange() throws MessagingException {
+ checkClosed();
InOptionalOutImpl result = new InOptionalOutImpl(getExchangeId());
setDefaults(result);
return result;
@@ -145,6 +159,7 @@
* @throws MessagingException
*/
public MessageExchange createExchange(QName serviceName, QName operationName) throws MessagingException {
+ checkClosed();
InOptionalOutImpl me = new InOptionalOutImpl(getExchangeId());
setDefaults(me);
me.setService(serviceName);
Added: trunk/core/src/test/java/org/servicemix/jbi/messaging/DeliveryChannelImplTest.java (697 => 698)
--- trunk/core/src/test/java/org/servicemix/jbi/messaging/DeliveryChannelImplTest.java 2005-10-28 13:32:18 UTC (rev 697)
+++ trunk/core/src/test/java/org/servicemix/jbi/messaging/DeliveryChannelImplTest.java 2005-10-28 14:08:47 UTC (rev 698)
@@ -0,0 +1,67 @@
+/**
+ *
+ * Copyright 2005 LogicBlaze, Inc. http://www.logicblaze.com
+ *
+ * Licensed 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.servicemix.jbi.messaging;
+
+import org.servicemix.examples.SenderComponent;
+import org.servicemix.jbi.container.ActivationSpec;
+import org.servicemix.jbi.container.JBIContainer;
+
+import javax.jbi.messaging.DeliveryChannel;
+import javax.jbi.messaging.InOnly;
+import javax.jbi.messaging.MessageExchangeFactory;
+import javax.jbi.messaging.MessagingException;
+
+import junit.framework.TestCase;
+
+public class DeliveryChannelImplTest extends TestCase {
+
+ protected JBIContainer container;
+ protected DeliveryChannel channel;
+
+ protected void setUp() throws Exception {
+ container = new JBIContainer();
+ container.init();
+ container.start();
+ SenderComponent component = new SenderComponent();
+ container.activateComponent(new ActivationSpec("sender", component));
+ channel = component.getDeliveryChannel();
+ }
+
+ protected void tearDown() throws Exception {
+ container.shutDown();
+ }
+
+ public void testExchangeFactoryOnOpenChannel() throws Exception {
+ MessageExchangeFactory mef = channel.createExchangeFactory();
+ assertNotNull(mef);
+ assertNotNull(mef.createInOnlyExchange());
+ }
+
+ public void testExchangeFactoryOnClosedChannel() throws Exception {
+ channel.close();
+ MessageExchangeFactory mef = channel.createExchangeFactory();
+ assertNotNull(mef);
+ try {
+ mef.createInOnlyExchange();
+ fail("Exchange creation should have failed (JBI: 5.5.2.1.4)");
+ } catch (MessagingException e) {
+ // expected
+ }
+ }
+
+}
Modified: trunk/core/src/test/java/org/servicemix/jbi/messaging/MEPExchangeTest.java (697 => 698)
--- trunk/core/src/test/java/org/servicemix/jbi/messaging/MEPExchangeTest.java 2005-10-28 13:32:18 UTC (rev 697)
+++ trunk/core/src/test/java/org/servicemix/jbi/messaging/MEPExchangeTest.java 2005-10-28 14:08:47 UTC (rev 698)
@@ -17,6 +17,7 @@
**/
package org.servicemix.jbi.messaging;
+import org.servicemix.JbiConstants;
import org.servicemix.components.util.ComponentSupport;
import org.servicemix.jbi.container.JBIContainer;
import org.servicemix.jbi.jaxp.StringSource;
@@ -132,6 +133,7 @@
InOnly mep = (InOnly) provider.getChannel().accept(10000L);
assertNotNull(mep);
assertEquals(ExchangeStatus.ACTIVE, mep.getStatus());
+ assertEquals(Boolean.TRUE, mep.getProperty(JbiConstants.SEND_SYNC));
mep.setStatus(ExchangeStatus.DONE);
provider.getChannel().send(mep);
} catch (Exception e) {