Commit 9d57faa1 authored by afreyssin's avatar afreyssin
Browse files

Use DestinationConstants shared definition.

parent e0252d5e
......@@ -27,6 +27,7 @@ import java.util.Properties;
import org.objectweb.joram.client.jms.Destination;
import org.objectweb.joram.client.jms.Queue;
import org.objectweb.joram.shared.DestinationConstants;
/**
* The <code>RestAcquisitionQueue</code> class allows administrators to create REST
......@@ -39,30 +40,30 @@ public class RestAcquisitionQueue {
/**
* Class name of handler allowing to acquire messages to a foreign REST provider.
*/
public final static String RESTAcquisition = "com.scalagent.joram.mom.dest.rest.RESTAcquisitionDaemon";
// public final static String RESTAcquisition = "com.scalagent.joram.mom.dest.rest.RESTAcquisitionDaemon";
public final static String RESTAcquisition = "com.scalagent.joram.mom.dest.rest.RestAcquisitionAsync";
private String hostName = "localhost";
private String host = "localhost";
private int port = 8989;
private String userName = "anonymous";
private String username = "anonymous";
private String password = "anonymous";
private int nbMaxMsgByPeriode = 100;
private boolean mediaTypeJson = true;;
private long timeout = 500;
private int acquisitionPeriod = 100;
private long timeout = 10000;
private int acquisitionPeriod = 100; // TODO (AF):
private long idleTimeout;
/**
* @return the hostName
*/
public String getHostName() {
return hostName;
public String getHost() {
return host;
}
/**
* @param hostName the hostName to set
*/
public RestAcquisitionQueue setHostName(String hostName) {
this.hostName = hostName;
public RestAcquisitionQueue setHost(String host) {
this.host = host;
return this;
}
......@@ -84,15 +85,15 @@ public class RestAcquisitionQueue {
/**
* @return the userName
*/
public String getUserName() {
return userName;
public String getUsername() {
return username;
}
/**
* @param userName the userName to set
*/
public RestAcquisitionQueue setUserName(String userName) {
this.userName = userName;
public RestAcquisitionQueue setUsername(String userName) {
this.username = userName;
return this;
}
......@@ -111,21 +112,6 @@ public class RestAcquisitionQueue {
return this;
}
/**
* @return the nbMaxMsgByPeriode
*/
public int getNbMaxMsgByPeriode() {
return nbMaxMsgByPeriode;
}
/**
* @param nbMaxMsgByPeriode the nbMaxMsgByPeriode to set
*/
public RestAcquisitionQueue setNbMaxMsgByPeriode(int nbMaxMsgByPeriode) {
this.nbMaxMsgByPeriode = nbMaxMsgByPeriode;
return this;
}
/**
* @return the mediaTypeJson
*/
......@@ -170,6 +156,15 @@ public class RestAcquisitionQueue {
this.acquisitionPeriod = acquisitionPeriod;
return this;
}
public long getIdleTimeout() {
return idleTimeout;
}
public RestAcquisitionQueue setIdleTimeout(long idleTimeout) {
this.idleTimeout = idleTimeout;
return this;
}
/**
* Administration method creating and deploying a REST acquisition queue on the local server.
......@@ -276,25 +271,25 @@ public class RestAcquisitionQueue {
if (props == null)
props = new Properties();
props.setProperty("acquisition.className", RESTAcquisition);
if (!props.containsKey("rest.hostName"))
props.setProperty("rest.hostName", hostName);
if (!props.containsKey("rest.port"))
props.setProperty("rest.port", ""+port);
if (!props.containsKey("rest.userName"))
props.setProperty("rest.userName", userName);
if (!props.containsKey("rest.password"))
props.setProperty("rest.password", password);
if (!props.containsKey("rest.nbMaxMsgByPeriode"))
props.setProperty("rest.nbMaxMsgByPeriode", ""+nbMaxMsgByPeriode);
if (!props.containsKey("rest.mediaTypeJson"))
props.setProperty("rest.mediaTypeJson", ""+mediaTypeJson);
if (!props.containsKey("rest.timeout"))
props.setProperty("rest.timeout", ""+timeout);
if (!props.containsKey("acquisition.period"))
props.setProperty("acquisition.period", ""+acquisitionPeriod);
props.setProperty(DestinationConstants.ACQUISITION_CLASS_NAME, RESTAcquisition);
if (!props.containsKey(DestinationConstants.REST_HOST_PROP))
props.setProperty(DestinationConstants.REST_HOST_PROP, host);
if (!props.containsKey(DestinationConstants.REST_PORT_PROP))
props.setProperty(DestinationConstants.REST_PORT_PROP, ""+port);
if (!props.containsKey(DestinationConstants.REST_USERNAME_PROP))
props.setProperty(DestinationConstants.REST_USERNAME_PROP, username);
if (!props.containsKey(DestinationConstants.REST_PASSWORD_PROP))
props.setProperty(DestinationConstants.REST_PASSWORD_PROP, password);
if (!props.containsKey(DestinationConstants.MEDIA_TYPE_JSON_PROP))
props.setProperty(DestinationConstants.MEDIA_TYPE_JSON_PROP, ""+mediaTypeJson);
if (!props.containsKey(DestinationConstants.TIMEOUT_PROP))
props.setProperty(DestinationConstants.TIMEOUT_PROP, ""+timeout);
if (!props.containsKey(DestinationConstants.IDLETIMEOUT_PROP))
props.setProperty(DestinationConstants.IDLETIMEOUT_PROP, ""+ idleTimeout);
if (!props.containsKey(DestinationConstants.ACQUISITION_PERIOD))
props.setProperty(DestinationConstants.ACQUISITION_PERIOD, ""+ acquisitionPeriod);
props.setProperty("jms.destination", dest);
props.setProperty(DestinationConstants.DESTINATION_NAME_PROP, dest);
return Queue.create(serverId, name, Destination.ACQUISITION_QUEUE, props);
}
......
......@@ -27,6 +27,7 @@ import java.util.Properties;
import org.objectweb.joram.client.jms.Destination;
import org.objectweb.joram.client.jms.Queue;
import org.objectweb.joram.shared.DestinationConstants;
/**
* The <code>RestDistributionQueue</code> class allows administrators to create REST
......@@ -45,8 +46,10 @@ public class RestDistributionQueue {
private int port = 8989;
private String userName = "anonymous";
private String password = "anonymous";
private boolean batch = true;
private boolean batch = false;
private boolean async = true;
private int period = 1000;
private long idleTimeout;
/**
* @return the hostName
......@@ -108,15 +111,16 @@ public class RestDistributionQueue {
return this;
}
/**
* @return the batch
* Gets the batch parameter.
* @return the batch parameter
*/
public boolean isBatch() {
return batch;
}
/**
* Sets the batch parameter.
* @param batch the batch to set
*/
public RestDistributionQueue setBatch(boolean batch) {
......@@ -124,6 +128,23 @@ public class RestDistributionQueue {
return this;
}
/**
* Gets the async parameter.
* @return the async parameter
*/
public boolean isAsync() {
return async;
}
/**
* Sets the async parameter.
* @param async the batch to set
*/
public RestDistributionQueue setAsync(boolean async) {
this.async = async;
return this;
}
/**
* @return the period
*/
......@@ -138,6 +159,15 @@ public class RestDistributionQueue {
this.period = period;
return this;
}
public long getIdleTimeout() {
return idleTimeout;
}
public RestDistributionQueue setIdleTimeout(long idleTimeout) {
this.idleTimeout = idleTimeout;
return this;
}
/**
* Administration method creating and deploying a REST distribution queue on the local server.
......@@ -214,7 +244,8 @@ public class RestDistributionQueue {
* message, regardless of distribution errors. This can lead to the loss of message ordering, but will
* prevent a blocking message from blocking every following message. When set to false, the distribution
* process will stop on the first error. Default is false.</li>
* <li>distribution.async - If set to true, the messages are asynchronously forwarded through a daemon.</li>
* <li>distribution.async - If set to true, the messages are asynchronously forwarded through a daemon.
* Default is true.</li>
* </ul>
* The request fails if the target server does not belong to the platform,
* or if the destination deployment fails server side.
......@@ -237,21 +268,25 @@ public class RestDistributionQueue {
if (props == null)
props = new Properties();
props.setProperty("distribution.className", RESTDistribution);
if (!props.containsKey("rest.hostName"))
props.setProperty("rest.hostName", hostName);
if (!props.containsKey("rest.port"))
props.setProperty("rest.port", ""+port);
if (!props.containsKey("rest.userName"))
props.setProperty("rest.userName", userName);
if (!props.containsKey("rest.password"))
props.setProperty("rest.password", password);
if (!props.containsKey("distribution.batch"))
props.setProperty("distribution.batch", ""+batch);
if (!props.containsKey(DestinationConstants.REST_HOST_PROP))
props.setProperty(DestinationConstants.REST_HOST_PROP, hostName);
if (!props.containsKey(DestinationConstants.REST_PORT_PROP))
props.setProperty(DestinationConstants.REST_PORT_PROP, ""+port);
if (!props.containsKey(DestinationConstants.REST_USERNAME_PROP))
props.setProperty(DestinationConstants.REST_USERNAME_PROP, userName);
if (!props.containsKey(DestinationConstants.REST_PASSWORD_PROP))
props.setProperty(DestinationConstants.REST_PASSWORD_PROP, password);
if (!props.containsKey(DestinationConstants.ASYNC_DISTRIBUTION_OPTION))
props.setProperty(DestinationConstants.ASYNC_DISTRIBUTION_OPTION, ""+async);
if (!props.containsKey(DestinationConstants.BATCH_DISTRIBUTION_OPTION))
props.setProperty(DestinationConstants.BATCH_DISTRIBUTION_OPTION, ""+batch);
if (!props.containsKey(DestinationConstants.IDLETIMEOUT_PROP))
props.setProperty(DestinationConstants.IDLETIMEOUT_PROP, ""+ idleTimeout);
if (!props.containsKey("period"))
props.setProperty("period", ""+period);
props.setProperty("jms.destination", dest);
props.setProperty("period", ""+period);
props.setProperty(DestinationConstants.DESTINATION_NAME_PROP, dest);
return Queue.create(serverId, name, Destination.DISTRIBUTION_QUEUE, props);
}
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment