Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
joram
joram
Commits
db2e6b3a
Commit
db2e6b3a
authored
Jul 27, 2017
by
afreyssin
Browse files
Use DestinationConstants shared definition.
Many improvements following the recovery tests.
parent
9d57faa1
Changes
4
Expand all
Hide whitespace changes
Inline
Side-by-side
joram/joram/mom/extensions/restbridge/src/main/java/com/scalagent/joram/mom/dest/rest/RESTAcquisition.java
View file @
db2e6b3a
...
...
@@ -44,8 +44,8 @@ import javax.ws.rs.core.UriBuilder;
import
org.glassfish.jersey.client.ClientConfig
;
import
org.objectweb.joram.mom.dest.AcquisitionHandler
;
import
org.objectweb.joram.mom.dest.AcquisitionModule
;
import
org.objectweb.joram.mom.dest.ReliableTransmitter
;
import
org.objectweb.joram.shared.DestinationConstants
;
import
org.objectweb.joram.shared.excepts.MessageValueException
;
import
org.objectweb.joram.shared.messages.ConversionHelper
;
import
org.objectweb.joram.shared.messages.Message
;
...
...
@@ -64,15 +64,6 @@ public class RESTAcquisition implements AcquisitionHandler {
private
static
final
Logger
logger
=
Debug
.
getLogger
(
RESTAcquisition
.
class
.
getName
());
private
static
final
String
HOST_PROP
=
"rest.hostName"
;
private
static
final
String
PORT_PROP
=
"rest.port"
;
private
static
final
String
USER_NAME_PROP
=
"rest.userName"
;
private
static
final
String
PASSWORD_PROP
=
"rest.password"
;
private
static
final
String
TIMEOUT_PROP
=
"rest.timeout"
;
private
static
final
String
NB_MAX_MSG_PROP
=
"rest.nbMaxMsgByPeriode"
;
private
static
final
String
MEDIA_TYPE_JSON_PROP
=
"rest.mediaTypeJson"
;
private
static
final
String
DESTINATION_NAME_PROP
=
"jms.destination"
;
private
String
hostName
=
"localhost"
;
private
int
port
=
8989
;
private
Client
client
;
...
...
@@ -90,38 +81,39 @@ public class RESTAcquisition implements AcquisitionHandler {
private
URI
uriCloseConsumer
;
public
void
init
(
Properties
properties
)
{
destName
=
properties
.
getProperty
(
DESTINATION_NAME_PROP
);
destName
=
properties
.
getProperty
(
DestinationConstants
.
DESTINATION_NAME_PROP
);
if
(
destName
==
null
)
{
throw
new
IllegalArgumentException
(
"Missing Destination JNDI name."
);
}
if
(
properties
.
containsKey
(
HOST_PROP
))
{
hostName
=
properties
.
getProperty
(
HOST_PROP
);
if
(
properties
.
containsKey
(
DestinationConstants
.
REST_
HOST_PROP
))
{
hostName
=
properties
.
getProperty
(
DestinationConstants
.
REST_
HOST_PROP
);
}
if
(
properties
.
containsKey
(
PORT_PROP
))
{
if
(
properties
.
containsKey
(
DestinationConstants
.
REST_
PORT_PROP
))
{
try
{
port
=
Integer
.
parseInt
(
properties
.
getProperty
(
PORT_PROP
));
port
=
Integer
.
parseInt
(
properties
.
getProperty
(
DestinationConstants
.
REST_
PORT_PROP
));
}
catch
(
NumberFormatException
nfe
)
{
logger
.
log
(
BasicLevel
.
ERROR
,
"Property "
+
PORT_PROP
logger
.
log
(
BasicLevel
.
ERROR
,
"Property "
+
DestinationConstants
.
REST_
PORT_PROP
+
" could not be parsed properly, use default value."
,
nfe
);
}
}
if
(
properties
.
containsKey
(
USER
_
NAME_PROP
))
{
userName
=
properties
.
getProperty
(
USER
_
NAME_PROP
);
if
(
properties
.
containsKey
(
DestinationConstants
.
REST_
USERNAME_PROP
))
{
userName
=
properties
.
getProperty
(
DestinationConstants
.
REST_
USERNAME_PROP
);
}
if
(
properties
.
containsKey
(
PASSWORD_PROP
))
{
password
=
properties
.
getProperty
(
PASSWORD_PROP
);
if
(
properties
.
containsKey
(
DestinationConstants
.
REST_
PASSWORD_PROP
))
{
password
=
properties
.
getProperty
(
DestinationConstants
.
REST_
PASSWORD_PROP
);
}
if
(
properties
.
containsKey
(
TIMEOUT_PROP
))
{
if
(
properties
.
containsKey
(
DestinationConstants
.
TIMEOUT_PROP
))
{
try
{
timeout
=
Long
.
parseLong
(
properties
.
getProperty
(
TIMEOUT_PROP
));
timeout
=
Long
.
parseLong
(
properties
.
getProperty
(
DestinationConstants
.
TIMEOUT_PROP
));
}
catch
(
NumberFormatException
exc
)
{
}
}
if
(
properties
.
containsKey
(
NB_MAX_MSG_PROP
))
{
if
(
properties
.
containsKey
(
DestinationConstants
.
NB_MAX_MSG_PROP
))
{
try
{
nbMaxMsg
=
Integer
.
parseInt
(
properties
.
getProperty
(
NB_MAX_MSG_PROP
));
nbMaxMsg
=
Integer
.
parseInt
(
properties
.
getProperty
(
DestinationConstants
.
NB_MAX_MSG_PROP
));
}
catch
(
NumberFormatException
exc
)
{
}
}
// init client and target
if
(
client
==
null
)
{
ClientConfig
config
=
new
ClientConfig
();
...
...
@@ -136,8 +128,8 @@ public class RESTAcquisition implements AcquisitionHandler {
client
.
target
(
uriCloseConsumer
).
request
().
accept
(
MediaType
.
TEXT_PLAIN
).
delete
();
uriCreateConsumer
=
null
;
}
if
(
properties
.
containsKey
(
MEDIA_TYPE_JSON_PROP
))
{
mediaTypeJson
=
Boolean
.
parseBoolean
(
properties
.
getProperty
(
MEDIA_TYPE_JSON_PROP
));
if
(
properties
.
containsKey
(
DestinationConstants
.
MEDIA_TYPE_JSON_PROP
))
{
mediaTypeJson
=
Boolean
.
parseBoolean
(
properties
.
getProperty
(
DestinationConstants
.
MEDIA_TYPE_JSON_PROP
));
}
createConsumer
();
}
...
...
@@ -227,7 +219,7 @@ public class RESTAcquisition implements AcquisitionHandler {
}
if
(
jsonMessageHeader
.
containsKey
(
"CorrelationIDAsBytes"
))
{
// TODO "CorrelationIDAsBytes"
// TODO "CorrelationIDAsBytes"
if
(
logger
.
isLoggable
(
BasicLevel
.
WARN
))
logger
.
log
(
BasicLevel
.
WARN
,
"-- TODO CorrelationIDAsBytes"
);
}
...
...
@@ -483,9 +475,9 @@ public class RESTAcquisition implements AcquisitionHandler {
if
(
logger
.
isLoggable
(
BasicLevel
.
DEBUG
))
logger
.
log
(
BasicLevel
.
DEBUG
,
"RESTAcquisition.setProperties properties = "
+
properties
);
if
(
properties
.
containsKey
(
AcquisitionModule
.
PERSISTENT
_PROPERTY
))
{
if
(
properties
.
containsKey
(
DestinationConstants
.
ACQUISITION_
PERSISTENT
))
{
try
{
persistent
=
ConversionHelper
.
toBoolean
(
properties
.
get
(
AcquisitionModule
.
PERSISTENT
_PROPERTY
));
persistent
=
ConversionHelper
.
toBoolean
(
properties
.
get
(
DestinationConstants
.
ACQUISITION_
PERSISTENT
));
}
catch
(
MessageValueException
e
)
{
if
(
logger
.
isLoggable
(
BasicLevel
.
WARN
))
logger
.
log
(
BasicLevel
.
WARN
,
""
,
e
);
...
...
joram/joram/mom/extensions/restbridge/src/main/java/com/scalagent/joram/mom/dest/rest/RESTAcquisitionDaemon.java
View file @
db2e6b3a
...
...
@@ -44,8 +44,8 @@ import javax.ws.rs.core.UriBuilder;
import
org.glassfish.jersey.client.ClientConfig
;
import
org.objectweb.joram.mom.dest.AcquisitionDaemon
;
import
org.objectweb.joram.mom.dest.AcquisitionModule
;
import
org.objectweb.joram.mom.dest.ReliableTransmitter
;
import
org.objectweb.joram.shared.DestinationConstants
;
import
org.objectweb.joram.shared.excepts.MessageValueException
;
import
org.objectweb.joram.shared.messages.ConversionHelper
;
import
org.objectweb.joram.shared.messages.Message
;
...
...
@@ -59,7 +59,6 @@ import fr.dyade.aaa.common.Daemon;
import
fr.dyade.aaa.common.Debug
;
public
class
RESTAcquisitionDaemon
implements
AcquisitionDaemon
{
private
static
final
Logger
logger
=
Debug
.
getLogger
(
RESTAcquisitionDaemon
.
class
.
getName
());
private
static
final
String
HOST_PROP
=
"rest.hostName"
;
...
...
@@ -179,9 +178,9 @@ public class RESTAcquisitionDaemon implements AcquisitionDaemon {
mediaTypeJson
=
Boolean
.
parseBoolean
(
properties
.
getProperty
(
MEDIA_TYPE_JSON_PROP
));
}
if
(
properties
.
containsKey
(
AcquisitionModule
.
PERSISTENT
_PROPERTY
))
{
if
(
properties
.
containsKey
(
DestinationConstants
.
ACQUISITION_
PERSISTENT
))
{
try
{
persistent
=
ConversionHelper
.
toBoolean
(
properties
.
get
(
AcquisitionModule
.
PERSISTENT
_PROPERTY
));
persistent
=
ConversionHelper
.
toBoolean
(
properties
.
get
(
DestinationConstants
.
ACQUISITION_
PERSISTENT
));
}
catch
(
MessageValueException
e
)
{
if
(
logger
.
isLoggable
(
BasicLevel
.
WARN
))
logger
.
log
(
BasicLevel
.
WARN
,
""
,
e
);
...
...
joram/joram/mom/extensions/restbridge/src/main/java/com/scalagent/joram/mom/dest/rest/RESTDistribution.java
View file @
db2e6b3a
This diff is collapsed.
Click to expand it.
joram/joram/mom/extensions/restbridge/src/main/java/com/scalagent/joram/mom/dest/rest/RestAcquisitionAsync.java
0 → 100644
View file @
db2e6b3a
This diff is collapsed.
Click to expand it.
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment