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
29b90643
Commit
29b90643
authored
Jul 27, 2017
by
afreyssin
Browse files
Use DestinationConstants shared definition.
parent
9894a8d1
Changes
1
Hide whitespace changes
Inline
Side-by-side
joram/joram/mom/core/src/main/java/org/objectweb/joram/mom/dest/AcquisitionModule.java
View file @
29b90643
/*
* JORAM: Java(TM) Open Reliable Asynchronous Messaging
* Copyright (C) 2010 - 201
5
ScalAgent Distributed Technologies
* Copyright (C) 2010 - 201
7
ScalAgent Distributed Technologies
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
...
...
@@ -30,6 +30,7 @@ import java.util.TimerTask;
import
org.objectweb.joram.mom.notifications.ClientMessages
;
import
org.objectweb.joram.mom.util.DMQManager
;
import
org.objectweb.joram.shared.DestinationConstants
;
import
org.objectweb.joram.shared.MessageErrorConstants
;
import
org.objectweb.joram.shared.excepts.MessageValueException
;
import
org.objectweb.joram.shared.messages.ConversionHelper
;
...
...
@@ -46,28 +47,12 @@ import fr.dyade.aaa.common.Debug;
* and the specified {@link AcquisitionHandler}.
*/
public
class
AcquisitionModule
implements
ReliableTransmitter
{
public
static
Logger
logger
=
Debug
.
getLogger
(
AcquisitionModule
.
class
.
getName
());
/** The property name for the acquisition period. */
public
static
final
String
PERIOD
=
"acquisition.period"
;
/** The property name for the acquisition handler class name. */
public
static
final
String
CLASS_NAME
=
"acquisition.className"
;
/** Persistent property name: tells if produced messages will be persistent. */
public
static
final
String
PERSISTENT_PROPERTY
=
"persistent"
;
/** Expiration property name: tells the life expectancy of produced messages. */
public
static
final
String
EXPIRATION_PROPERTY
=
"expiration"
;
/** Priority property name: tells the JMS priority of produced messages. */
public
static
final
String
PRIORITY_PROPERTY
=
"priority"
;
/** Verify that one and only one correct interface is implemented. */
public
static
void
checkAcquisitionClass
(
String
className
)
throws
Exception
{
if
(
className
==
null
)
{
throw
new
Exception
(
"AcquisitionHandler class not defined: use "
+
CLASS_NAME
throw
new
Exception
(
"AcquisitionHandler class not defined: use "
+
DestinationConstants
.
ACQUISITION_
CLASS_NAME
+
" property to chose acquisition class."
);
}
Class
<?>
clazz
=
Class
.
forName
(
className
);
...
...
@@ -264,9 +249,9 @@ public class AcquisitionModule implements ReliableTransmitter {
logger
.
log
(
BasicLevel
.
DEBUG
,
"AcquisitionModule.setProperties = "
+
props
+
" daemon = "
+
isDaemon
);
}
if
(
props
.
containsKey
(
PERIOD
))
{
if
(
props
.
containsKey
(
DestinationConstants
.
ACQUISITION_
PERIOD
))
{
try
{
period
=
ConversionHelper
.
toLong
(
props
.
get
(
PERIOD
));
period
=
ConversionHelper
.
toLong
(
props
.
get
(
DestinationConstants
.
ACQUISITION_
PERIOD
));
}
catch
(
MessageValueException
exc
)
{
logger
.
log
(
BasicLevel
.
ERROR
,
"AcquisitionModule: can't parse defined period property."
);
}
...
...
@@ -280,20 +265,20 @@ public class AcquisitionModule implements ReliableTransmitter {
AgentServer
.
getTimer
().
schedule
(
acquisitionTask
,
period
,
period
);
}
if
(
props
.
containsKey
(
PERSISTENT
_PROPERTY
))
{
if
(
props
.
containsKey
(
DestinationConstants
.
ACQUISITION_
PERSISTENT
))
{
try
{
isPersistent
=
ConversionHelper
.
toBoolean
(
props
.
get
(
PERSISTENT
_PROPERTY
));
isPersistent
=
ConversionHelper
.
toBoolean
(
props
.
get
(
DestinationConstants
.
ACQUISITION_
PERSISTENT
));
isPersistencySet
=
true
;
}
catch
(
MessageValueException
exc
)
{
logger
.
log
(
BasicLevel
.
ERROR
,
"AcquisitionModule: can't parse defined message persistence property."
);
props
.
remove
(
PERSISTENT
_PROPERTY
);
props
.
remove
(
DestinationConstants
.
ACQUISITION_
PERSISTENT
);
}
// props.remove(PERSISTENT_PROPERTY);
}
if
(
props
.
containsKey
(
PRIORITY_PROPER
TY
))
{
if
(
props
.
containsKey
(
DestinationConstants
.
ACQUISITION_PRIORI
TY
))
{
try
{
priority
=
ConversionHelper
.
toInt
(
props
.
get
(
PRIORITY_PROPER
TY
));
priority
=
ConversionHelper
.
toInt
(
props
.
get
(
DestinationConstants
.
ACQUISITION_PRIORI
TY
));
isPrioritySet
=
true
;
}
catch
(
MessageValueException
exc
)
{
logger
.
log
(
BasicLevel
.
ERROR
,
"AcquisitionModule: can't parse defined message priority property."
);
...
...
@@ -301,9 +286,9 @@ public class AcquisitionModule implements ReliableTransmitter {
// props.remove(PRIORITY_PROPERTY);
}
if
(
props
.
containsKey
(
EXPIRATION
_PROPERTY
))
{
if
(
props
.
containsKey
(
DestinationConstants
.
ACQUISITION_
EXPIRATION
))
{
try
{
expiration
=
ConversionHelper
.
toLong
(
props
.
get
(
EXPIRATION
_PROPERTY
));
expiration
=
ConversionHelper
.
toLong
(
props
.
get
(
DestinationConstants
.
ACQUISITION_
EXPIRATION
));
isExpirationSet
=
true
;
}
catch
(
MessageValueException
exc
)
{
logger
.
log
(
BasicLevel
.
ERROR
,
"AcquisitionModule: can't parse defined message expiration property."
);
...
...
@@ -311,11 +296,11 @@ public class AcquisitionModule implements ReliableTransmitter {
// props.remove(EXPIRATION_PROPERTY);
}
if
(
props
.
containsKey
(
CLASS_NAME
)
&&
!
props
.
get
(
CLASS_NAME
).
equals
(
acquisitionHandler
.
getClass
().
getName
()))
{
if
(
props
.
containsKey
(
DestinationConstants
.
ACQUISITION_
CLASS_NAME
)
&&
!
props
.
get
(
DestinationConstants
.
ACQUISITION_
CLASS_NAME
).
equals
(
acquisitionHandler
.
getClass
().
getName
()))
{
logger
.
log
(
BasicLevel
.
ERROR
,
"AcquisitionModule: Changing dynamically the acquisition class is not allowed."
);
props
.
remove
(
CLASS_NAME
);
props
.
remove
(
DestinationConstants
.
ACQUISITION_
CLASS_NAME
);
}
if
(
isDaemon
)
{
...
...
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