Author: richard.opalka(a)jboss.com
Date: 2007-09-18 06:43:43 -0400 (Tue, 18 Sep 2007)
New Revision: 4582
Added:
stack/native/branches/ropalka/trunk/src/main/java/org/jboss/ws/extensions/wsrm/DeliveryAssurance.java
stack/native/branches/ropalka/trunk/src/main/java/org/jboss/ws/extensions/wsrm/DeliveryAssuranceFactory.java
stack/native/branches/ropalka/trunk/src/main/java/org/jboss/ws/extensions/wsrm/DeliveryQuality.java
Log:
adding new classes
Added:
stack/native/branches/ropalka/trunk/src/main/java/org/jboss/ws/extensions/wsrm/DeliveryAssurance.java
===================================================================
---
stack/native/branches/ropalka/trunk/src/main/java/org/jboss/ws/extensions/wsrm/DeliveryAssurance.java
(rev 0)
+++
stack/native/branches/ropalka/trunk/src/main/java/org/jboss/ws/extensions/wsrm/DeliveryAssurance.java 2007-09-18
10:43:43 UTC (rev 4582)
@@ -0,0 +1,45 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+package org.jboss.ws.extensions.wsrm;
+
+/**
+ * Represents message delivery assurance
+ *
+ * @author richard.opalka(a)jboss.com
+ * @see org.jboss.ws.extensions.wsrm.DeliveryAssuranceFactory
+ */
+public interface DeliveryAssurance
+{
+
+ /**
+ * Returns associated message delivery assurance
+ * @return non null delivery assurance object
+ */
+ DeliveryQuality getDeliveryQuality();
+
+ /**
+ * Specifies whether messages are to be delivered in order to the service instance or
client proxy
+ * @return <b>true</b> if in order delivery is required,
<b>false</b> otherwise
+ */
+ boolean inOrder();
+
+}
Property changes on:
stack/native/branches/ropalka/trunk/src/main/java/org/jboss/ws/extensions/wsrm/DeliveryAssurance.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Added:
stack/native/branches/ropalka/trunk/src/main/java/org/jboss/ws/extensions/wsrm/DeliveryAssuranceFactory.java
===================================================================
---
stack/native/branches/ropalka/trunk/src/main/java/org/jboss/ws/extensions/wsrm/DeliveryAssuranceFactory.java
(rev 0)
+++
stack/native/branches/ropalka/trunk/src/main/java/org/jboss/ws/extensions/wsrm/DeliveryAssuranceFactory.java 2007-09-18
10:43:43 UTC (rev 4582)
@@ -0,0 +1,154 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+
+package org.jboss.ws.extensions.wsrm;
+
+/**
+ * Encapsulates generation of reliable messaging quality assurance configurations
+ *
+ * @author richard.opalka(a)jboss.com
+ * @see org.jboss.ws.extensions.wsrm.DeliveryQuality
+ */
+public final class DeliveryAssuranceFactory
+{
+
+ private static final DeliveryAssuranceFactory INSTANCE = new
DeliveryAssuranceFactory();
+ private static final String[] ACCEPTABLE_IN_ORDER_VALUES = { "0",
"1", "false", "true" };
+ private static final DeliveryAssurance EXACTLY_ONCE_WITH_ORDER;
+ private static final DeliveryAssurance EXACTLY_ONCE_WITHOUT_ORDER;
+ private static final DeliveryAssurance AT_MOST_ONCE_WITH_ORDER;
+ private static final DeliveryAssurance AT_MOST_ONCE_WITHOUT_ORDER;
+ private static final DeliveryAssurance AT_LEAST_ONCE_WITH_ORDER;
+ private static final DeliveryAssurance AT_LEAST_ONCE_WITHOUT_ORDER;
+
+ static
+ {
+ EXACTLY_ONCE_WITH_ORDER = new DeliveryAssuranceImpl(DeliveryQuality.EXACTLY_ONCE,
true);
+ EXACTLY_ONCE_WITHOUT_ORDER = new
DeliveryAssuranceImpl(DeliveryQuality.EXACTLY_ONCE, false);
+ AT_MOST_ONCE_WITH_ORDER = new DeliveryAssuranceImpl(DeliveryQuality.AT_MOST_ONCE,
true);
+ AT_MOST_ONCE_WITHOUT_ORDER = new
DeliveryAssuranceImpl(DeliveryQuality.AT_MOST_ONCE, false);
+ AT_LEAST_ONCE_WITH_ORDER = new DeliveryAssuranceImpl(DeliveryQuality.AT_LEAST_ONCE,
true);
+ AT_LEAST_ONCE_WITHOUT_ORDER = new
DeliveryAssuranceImpl(DeliveryQuality.AT_LEAST_ONCE, false);
+ }
+
+ // immutable object instance
+ private static final class DeliveryAssuranceImpl implements DeliveryAssurance
+ {
+
+ private final DeliveryQuality quality;
+ private final boolean inOrder;
+
+ private DeliveryAssuranceImpl(DeliveryQuality quality, boolean inOrder)
+ {
+ this.quality = quality;
+ this.inOrder = inOrder;
+ }
+
+ /*
+ * @see org.jboss.ws.extensions.wsrm.DeliveryAssurance#getDeliveryQuality()
+ */
+ public DeliveryQuality getDeliveryQuality()
+ {
+ return quality;
+ }
+
+ /*
+ * @see org.jboss.ws.extensions.wsrm.DeliveryAssurance#inOrder()
+ */
+ public boolean inOrder()
+ {
+ return inOrder;
+ }
+
+ }
+
+ private DeliveryAssuranceFactory()
+ {
+ // no instances
+ }
+
+ /**
+ * Factory getter
+ * @return factory instance
+ */
+ public static DeliveryAssuranceFactory getInstance()
+ {
+ return INSTANCE;
+ }
+
+ /**
+ * Returns constructed DeliveryAssurance object
+ * @param quality string representing quality value
+ * @param inOrder string representing inOrder value
+ * @return DeliveryAssurance object
+ * @throws IllegalArgumentException if <b>quality</b> or
<b>inOrder</b> are null or contain incorrect values
+ */
+ public static DeliveryAssurance getDeliveryAssurance(String quality, String inOrder)
+ {
+ if ((quality == null) || (inOrder == null))
+ throw new IllegalArgumentException("Neither quality nor inOrder parameter
cannot be null");
+
+ Boolean inOrderBoolean = null;
+ for (int i = 0; i < ACCEPTABLE_IN_ORDER_VALUES.length; i++)
+ {
+ if (ACCEPTABLE_IN_ORDER_VALUES[i].equals(inOrder))
+ {
+ inOrderBoolean = (i % 2 == 0) ? Boolean.FALSE : Boolean.TRUE;
+ break;
+ }
+ }
+
+ if (inOrderBoolean == null)
+ throw new IllegalArgumentException("Incorrect inOrder value: " +
inOrder);
+
+ return getDeliveryAssurance(DeliveryQuality.parseDeliveryQuality(quality),
inOrderBoolean);
+ }
+
+ /**
+ * Returns constructed DeliveryAssurance object
+ * @param quality object representing required quality
+ * @param inOrder string representing required inOrder value
+ * @return DeliveryAssurance object
+ * @throws IllegalArgumentException if <b>quality</b> is null
+ */
+ public static DeliveryAssurance getDeliveryAssurance(DeliveryQuality quality, boolean
inOrder)
+ {
+ if (quality == null)
+ throw new IllegalArgumentException("Quality cannot be null");
+
+ if (inOrder)
+ {
+ if (quality == DeliveryQuality.EXACTLY_ONCE) return EXACTLY_ONCE_WITH_ORDER;
+ if (quality == DeliveryQuality.AT_LEAST_ONCE) return AT_LEAST_ONCE_WITH_ORDER;
+ if (quality == DeliveryQuality.AT_MOST_ONCE) return AT_MOST_ONCE_WITH_ORDER;
+ }
+ else
+ {
+ if (quality == DeliveryQuality.EXACTLY_ONCE) return EXACTLY_ONCE_WITHOUT_ORDER;
+ if (quality == DeliveryQuality.AT_LEAST_ONCE) return
AT_LEAST_ONCE_WITHOUT_ORDER;
+ if (quality == DeliveryQuality.AT_MOST_ONCE) return AT_MOST_ONCE_WITHOUT_ORDER;
+ }
+
+ return null; // never happens
+ }
+
+}
Property changes on:
stack/native/branches/ropalka/trunk/src/main/java/org/jboss/ws/extensions/wsrm/DeliveryAssuranceFactory.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Added:
stack/native/branches/ropalka/trunk/src/main/java/org/jboss/ws/extensions/wsrm/DeliveryQuality.java
===================================================================
---
stack/native/branches/ropalka/trunk/src/main/java/org/jboss/ws/extensions/wsrm/DeliveryQuality.java
(rev 0)
+++
stack/native/branches/ropalka/trunk/src/main/java/org/jboss/ws/extensions/wsrm/DeliveryQuality.java 2007-09-18
10:43:43 UTC (rev 4582)
@@ -0,0 +1,89 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+package org.jboss.ws.extensions.wsrm;
+
+/**
+ * Represents message delivery quality
+ *
+ * @author richard.opalka(a)jboss.com
+ */
+public enum DeliveryQuality
+{
+
+ /**
+ * Each message is to be delivered at most once. The RM Source MAY retry transmission
of
+ * unacknowledged messages, but is NOT REQUIRED to do so. The requirement on the RM
+ * Destination is that it MUST filter out duplicate messages, i.e. that it MUST NOT
+ * deliver a duplicate of a message that has already been delivered.
+ */
+ AT_MOST_ONCE("AtMostOnce"),
+
+ /**
+ * Each message is to be delivered exactly once; if a message cannot be delivered then
an error
+ * MUST be raised by the RM Source and/or RM Destination. The requirement on an RM
Source is
+ * that it SHOULD retry transmission of every message sent by the Application Source
until it
+ * receives an acknowledgement from the RM Destination. The requirement on the RM
Destination
+ * is that it SHOULD retry the transfer to the Application Destination of any message
that it
+ * accepts from the RM Source until that message has been successfully delivered, and
that it
+ * MUST NOT deliver a duplicate of a message that has already been delivered.
+ */
+ AT_LEAST_ONCE("AtLeastOnce"),
+
+ /**
+ * Each message is to be delivered at least once, or else an error MUST be raised by
the RM
+ * Source and/or RM Destination. The requirement on an RM Source is that it SHOULD
retry
+ * transmission of every message sent by the Application Source until it receives an
+ * acknowledgement from the RM Destination. The requirement on the RM Destination is
that it
+ * SHOULD retry the transfer to the Application Destination of any message that it
accepts
+ * from the RM Source, until that message has been successfully delivered. There is
no
+ * requirement for the RM Destination to apply duplicate message filtering.
+ */
+ EXACTLY_ONCE("ExactlyOnce");
+
+ // associated string representation
+ private final String quality;
+
+ DeliveryQuality(String quality)
+ {
+ this.quality = quality;
+ }
+
+ /**
+ * Returns associated constant with passed <b>quality</b> string. Note
this method is case sensitive.
+ * Allowed values are: <b>AtMostOnce</b>, <b>AtLeastOnce</b>,
<b>ExactlyOnce</b>.
+ * @param quality to be parsed
+ * @return associated constant
+ * @throws IllegalArgumentException if <b>quality</b> string has no
associated enumeration value
+ */
+ public static DeliveryQuality parseDeliveryQuality(String quality)
+ {
+ if (AT_MOST_ONCE.quality.equals(quality))
+ return AT_MOST_ONCE;
+ if (AT_LEAST_ONCE.quality.equals(quality))
+ return AT_LEAST_ONCE;
+ if (EXACTLY_ONCE.quality.equals(quality))
+ return EXACTLY_ONCE;
+
+ throw new IllegalArgumentException("Unrecognized string: " + quality);
+ }
+
+}
Property changes on:
stack/native/branches/ropalka/trunk/src/main/java/org/jboss/ws/extensions/wsrm/DeliveryQuality.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF