Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Ryan Berkheimer
messageapi
Commits
27bff43f
Commit
27bff43f
authored
Sep 21, 2020
by
Ryan Berkheimer
Browse files
completed adding final keywords to all java files in core where possible
parent
8e3aa425
Changes
51
Hide whitespace changes
Inline
Side-by-side
dist/artifacts/c/messageapi_1_0_0/messageapi.tar
View file @
27bff43f
No preview for this file type
dist/artifacts/java/messageapi_1_0_0/messageapi.tar
View file @
27bff43f
No preview for this file type
dist/docs/api/messageapi_docs.tar
View file @
27bff43f
No preview for this file type
src/java/main/gov/noaa/messageapi/collections/DefaultCollection.java
View file @
27bff43f
...
...
@@ -30,12 +30,12 @@ public class DefaultCollection implements ICollection {
protected
List
<
String
>
conditionIds
=
null
;
@SuppressWarnings
(
"unchecked"
)
public
DefaultCollection
(
Map
<
String
,
Object
>
collectionMap
)
{
public
DefaultCollection
(
final
Map
<
String
,
Object
>
collectionMap
)
{
this
.
setId
((
String
)
collectionMap
.
get
(
"id"
));
if
(
collectionMap
.
containsKey
(
"classifiers"
))
{
this
.
setClassifiers
((
Map
<
String
,
Object
>)
collectionMap
.
get
(
"classifiers"
));
}
else
{
this
.
setClassifiers
(
new
HashMap
<
String
,
Object
>());
this
.
setClassifiers
(
new
HashMap
<
String
,
Object
>());
}
this
.
initializeFields
((
List
<
String
>)
collectionMap
.
get
(
"fields"
));
if
(
collectionMap
.
containsKey
(
"conditions"
))
{
...
...
@@ -45,7 +45,7 @@ public class DefaultCollection implements ICollection {
}
}
public
DefaultCollection
(
ICollection
collection
)
{
public
DefaultCollection
(
final
ICollection
collection
)
{
this
.
setId
(
collection
.
getId
());
this
.
copyClassifiers
(
collection
.
getClassifiers
());
this
.
setFields
(
collection
.
getFields
());
...
...
@@ -60,7 +60,7 @@ public class DefaultCollection implements ICollection {
return
this
.
id
;
}
public
Map
<
String
,
Object
>
getClassifiers
()
{
public
Map
<
String
,
Object
>
getClassifiers
()
{
return
this
.
classifiers
;
}
...
...
@@ -72,48 +72,47 @@ public class DefaultCollection implements ICollection {
return
this
.
conditionIds
;
}
public
Object
getClassifier
(
String
classiferKey
)
{
public
Object
getClassifier
(
final
String
classiferKey
)
{
return
this
.
classifiers
.
get
(
classiferKey
);
}
private
void
setId
(
String
id
)
{
private
void
setId
(
final
String
id
)
{
this
.
id
=
id
;
}
private
void
copyClassifiers
(
Map
<
String
,
Object
>
classifiers
)
{
private
void
copyClassifiers
(
final
Map
<
String
,
Object
>
classifiers
)
{
this
.
classifiers
=
classifiers
;
}
private
void
setClassifiers
(
Map
<
String
,
Object
>
classifiers
)
{
this
.
classifiers
=
new
HashMap
<
String
,
Object
>();
private
void
setClassifiers
(
final
Map
<
String
,
Object
>
classifiers
)
{
this
.
classifiers
=
new
HashMap
<
String
,
Object
>();
classifiers
.
entrySet
().
forEach
(
classifierEntry
->
{
if
(
classifierEntry
.
getValue
()
instanceof
List
)
{
this
.
classifiers
.
put
(
classifierEntry
.
getKey
(),
classifierEntry
.
getValue
());
}
else
{
List
<
String
>
classifierEntryValue
=
new
ArrayList
<
String
>();
classifierEntryValue
.
add
((
String
)
classifierEntry
.
getValue
().
toString
());
this
.
classifiers
.
put
(
classifierEntry
.
getKey
(),
classifierEntryValue
);
}
});
this
.
classifiers
.
put
(
classifierEntry
.
getKey
(),
classifierEntry
.
getValue
());
}
else
{
final
List
<
String
>
classifierEntryValue
=
new
ArrayList
<
String
>();
classifierEntryValue
.
add
((
String
)
classifierEntry
.
getValue
().
toString
());
this
.
classifiers
.
put
(
classifierEntry
.
getKey
(),
classifierEntryValue
);
}
});
}
private
void
initializeFields
(
List
<
String
>
fieldNames
)
{
this
.
fields
=
fieldNames
.
stream
()
.
map
(
name
->
new
DefaultField
(
name
)).
collect
(
Collectors
.
toList
());
private
void
initializeFields
(
final
List
<
String
>
fieldNames
)
{
this
.
fields
=
fieldNames
.
stream
().
map
(
name
->
new
DefaultField
(
name
)).
collect
(
Collectors
.
toList
());
}
public
void
setFields
(
List
<
IField
>
fields
)
{
public
void
setFields
(
final
List
<
IField
>
fields
)
{
this
.
fields
=
fields
.
stream
().
map
(
f
->
{
try
{
IField
newField
=
new
DefaultField
(
f
);
final
IField
newField
=
new
DefaultField
(
f
);
return
newField
;
}
catch
(
Exception
e
)
{
}
catch
(
final
Exception
e
)
{
return
null
;
}
}).
collect
(
Collectors
.
toList
());
}
private
void
setConditionIds
(
List
<
String
>
conditionIds
)
{
private
void
setConditionIds
(
final
List
<
String
>
conditionIds
)
{
this
.
conditionIds
=
conditionIds
;
}
...
...
src/java/main/gov/noaa/messageapi/conditions/BaseCondition.java
View file @
27bff43f
...
...
@@ -23,7 +23,7 @@ public class BaseCondition {
* This is generally used during session bootstrapping.
* @param conditionMap A map holding the id, type, and operator for a condition.
*/
public
BaseCondition
(
Map
<
String
,
Object
>
conditionMap
)
{
public
BaseCondition
(
final
Map
<
String
,
Object
>
conditionMap
)
{
setId
((
String
)
conditionMap
.
get
(
"id"
));
setType
((
String
)
conditionMap
.
get
(
"type"
));
setOperator
((
String
)
conditionMap
.
get
(
"operator"
));
...
...
@@ -32,9 +32,10 @@ public class BaseCondition {
/**
* Copy constructor for creating a new condition from an existing condition.
* Used in immutable processing of records.
*
* @param condition The original condition to copy.
*/
public
BaseCondition
(
ICondition
condition
)
{
public
BaseCondition
(
final
ICondition
condition
)
{
setId
(
condition
.
getId
());
setType
(
condition
.
getType
());
setOperator
(
condition
.
getOperator
());
...
...
@@ -42,6 +43,7 @@ public class BaseCondition {
/**
* Returns the condition ID
*
* @return condition ID
*/
public
String
getId
()
{
...
...
@@ -50,6 +52,7 @@ public class BaseCondition {
/**
* Returns the condition type (comparison or composite)
*
* @return condition type
*/
public
String
getType
()
{
...
...
@@ -58,21 +61,22 @@ public class BaseCondition {
/**
* Returns the condition operator
*
* @return condition operator
*/
public
String
getOperator
()
{
return
this
.
operator
;
}
private
void
setId
(
String
id
)
{
private
void
setId
(
final
String
id
)
{
this
.
id
=
id
;
}
private
void
setType
(
String
type
)
{
private
void
setType
(
final
String
type
)
{
this
.
type
=
type
;
}
private
void
setOperator
(
String
operator
)
{
private
void
setOperator
(
final
String
operator
)
{
this
.
operator
=
operator
;
}
...
...
src/java/main/gov/noaa/messageapi/conditions/ComparisonCondition.java
View file @
27bff43f
...
...
@@ -20,7 +20,7 @@ public class ComparisonCondition extends BaseCondition implements IComparisonCon
* This is usually used by the schema when bootstrapping a new session.
* @param conditionMap A map holding all required condition parameters.
*/
public
ComparisonCondition
(
Map
<
String
,
Object
>
conditionMap
)
{
public
ComparisonCondition
(
final
Map
<
String
,
Object
>
conditionMap
)
{
super
(
conditionMap
);
this
.
setField
((
String
)
conditionMap
.
get
(
"field"
));
if
(
conditionMap
.
containsKey
(
"value"
))
{
...
...
@@ -29,20 +29,22 @@ public class ComparisonCondition extends BaseCondition implements IComparisonCon
}
/**
* Copy constructor for creating a new ComparisonCondition from an existing
* one. This is generally used in immutable operations when creating new
* records during request building.
* Copy constructor for creating a new ComparisonCondition from an existing one.
* This is generally used in immutable operations when creating new records
* during request building.
*
* @param condition The original condition to copy
*/
public
ComparisonCondition
(
IComparisonCondition
condition
)
{
public
ComparisonCondition
(
final
IComparisonCondition
condition
)
{
super
(
condition
);
this
.
setField
(
condition
.
getField
());
this
.
setValue
(
condition
.
getValue
());
}
/**
* Returns the value held by the condition. Values are generalized objects.
* The value is cast during comparison operation against field values.
* Returns the value held by the condition. Values are generalized objects. The
* value is cast during comparison operation against field values.
*
* @return The value held by a condition as an object.
*/
public
Object
getValue
()
{
...
...
@@ -50,9 +52,11 @@ public class ComparisonCondition extends BaseCondition implements IComparisonCon
}
/**
* The field (as a name string) referenced by the comparison condition. All comparison
* conditions correspond to one field.
* @return The field name corresponding the the field to which the condition applies
* The field (as a name string) referenced by the comparison condition. All
* comparison conditions correspond to one field.
*
* @return The field name corresponding the the field to which the condition
* applies
*/
public
String
getField
()
{
return
this
.
field
;
...
...
@@ -60,18 +64,20 @@ public class ComparisonCondition extends BaseCondition implements IComparisonCon
/**
* Sets the condition value for the condition. Any object type is a valid value.
*
* @param value The value to associate with the condition
*/
public
void
setValue
(
Object
value
){
public
void
setValue
(
final
Object
value
)
{
this
.
value
=
value
;
}
/**
* Sets the field value for the condition. The field should be part of the
* schema topology. The field is set here as a string.
*
* @param field A field name corresponding to a schema field
*/
private
void
setField
(
String
field
)
{
private
void
setField
(
final
String
field
)
{
this
.
field
=
field
;
}
...
...
src/java/main/gov/noaa/messageapi/conditions/CompositeCondition.java
View file @
27bff43f
...
...
@@ -21,28 +21,30 @@ public class CompositeCondition extends BaseCondition implements ICompositeCondi
* This is usually used by the schema when bootstrapping a new session.
* @param conditionMap A map holding all required condition parameters.
*/
public
CompositeCondition
(
Map
<
String
,
Object
>
conditionMap
)
{
public
CompositeCondition
(
final
Map
<
String
,
Object
>
conditionMap
)
{
super
(
conditionMap
);
setValue
(
conditionMap
.
get
(
"conditions"
));
}
/**
* Copy constructor for creating a new CompositeCondition from an existing
* one. This is generally used in immutable operations when creating new
* records during request building.
* Copy constructor for creating a new CompositeCondition from an existing one.
* This is generally used in immutable operations when creating new records
* during request building.
*
* @param condition The original condition to copy
*/
public
CompositeCondition
(
ICompositeCondition
condition
)
{
public
CompositeCondition
(
final
ICompositeCondition
condition
)
{
super
(
condition
);
setValue
(
condition
.
getConditions
());
}
/**
* sets the value for a composite condition. In a composite condition,
* the value is a list of the ids of other conditions.
* sets the value for a composite condition. In a composite condition, the value
* is a list of the ids of other conditions.
*
* @param value A list of condition ids
*/
public
void
setValue
(
Object
value
){
public
void
setValue
(
final
Object
value
)
{
this
.
value
=
value
;
}
...
...
src/java/main/gov/noaa/messageapi/connections/BaseConnection.java
View file @
27bff43f
...
...
@@ -24,25 +24,28 @@ public class BaseConnection {
private
Map
<
String
,
Object
>
constructorMap
=
null
;
@SuppressWarnings
(
"unchecked"
)
public
BaseConnection
(
String
endpointClass
,
Map
<
String
,
Object
>
connectionMap
,
ContainerDefinition
containerDefinition
)
throws
Exception
{
public
BaseConnection
(
final
String
endpointClass
,
final
Map
<
String
,
Object
>
connectionMap
,
final
ContainerDefinition
containerDefinition
)
throws
Exception
{
try
{
Map
<
String
,
Object
>
constructorMap
=
(
Map
<
String
,
Object
>)
connectionMap
.
get
(
"constructor"
);
final
Map
<
String
,
Object
>
constructorMap
=
(
Map
<
String
,
Object
>)
connectionMap
.
get
(
"constructor"
);
this
.
updateConstructorMap
(
connectionMap
,
constructorMap
,
containerDefinition
);
this
.
setEndpointClass
(
endpointClass
);
this
.
setEndpointConstructor
(
constructorMap
);
this
.
setEndpoint
(
endpointClass
,
constructorMap
);
}
catch
(
Exception
e
)
{
throw
new
InstantiationException
(
String
.
format
(
"Could not initialize the base connection class from the specified class %s."
,
endpointClass
));
}
catch
(
final
Exception
e
)
{
throw
new
InstantiationException
(
String
.
format
(
"Could not initialize the base connection class from the specified class %s."
,
endpointClass
));
}
}
public
BaseConnection
(
IConnection
connection
)
throws
Exception
{
public
BaseConnection
(
final
IConnection
connection
)
throws
Exception
{
try
{
this
.
setEndpointClass
(
connection
.
getEndpointClass
());
this
.
setEndpointConstructor
(
connection
.
getEndpointConstructor
());
this
.
setEndpoint
(
this
.
getEndpointClass
(),
this
.
getEndpointConstructor
());
}
catch
(
Exception
e
)
{
throw
new
InstantiationException
(
"Could not initialize the base connection class from the passed existing connection object."
);
}
catch
(
final
Exception
e
)
{
throw
new
InstantiationException
(
"Could not initialize the base connection class from the passed existing connection object."
);
}
}
...
...
@@ -50,7 +53,7 @@ public class BaseConnection {
return
this
.
endpointClass
;
}
public
Map
<
String
,
Object
>
getEndpointConstructor
()
{
public
Map
<
String
,
Object
>
getEndpointConstructor
()
{
return
this
.
constructorMap
;
}
...
...
@@ -58,26 +61,29 @@ public class BaseConnection {
return
this
.
endpoint
;
}
private
void
updateConstructorMap
(
Map
<
String
,
Object
>
connectionMap
,
Map
<
String
,
Object
>
constructorMap
,
ContainerDefinition
containerDefinition
)
throws
Exception
{
Map
<
String
,
Object
>
parameterMap
=
new
HashMap
<
String
,
Object
>();
private
void
updateConstructorMap
(
final
Map
<
String
,
Object
>
connectionMap
,
final
Map
<
String
,
Object
>
constructorMap
,
final
ContainerDefinition
containerDefinition
)
throws
Exception
{
final
Map
<
String
,
Object
>
parameterMap
=
new
HashMap
<
String
,
Object
>();
if
(
connectionMap
.
containsKey
(
"fields"
))
{
parameterMap
.
put
(
"fields"
,
this
.
parseFields
(
connectionMap
.
get
(
"fields"
)));
}
else
{
parameterMap
.
put
(
"fields"
,
new
ArrayList
<
String
>());
}
if
(
connectionMap
.
containsKey
(
"collections"
))
{
parameterMap
.
put
(
"collections"
,
this
.
parseCollections
(
connectionMap
.
get
(
"collections"
),
containerDefinition
.
getCollections
()));
parameterMap
.
put
(
"collections"
,
this
.
parseCollections
(
connectionMap
.
get
(
"collections"
),
containerDefinition
.
getCollections
()));
}
else
{
parameterMap
.
put
(
"collections"
,
new
ArrayList
<
String
>());
}
if
(
connectionMap
.
containsKey
(
"classifiers"
))
{
parameterMap
.
put
(
"classifiers"
,
this
.
parseClassifiers
(
connectionMap
.
get
(
"classifiers"
),
containerDefinition
.
getClassifiers
()));
parameterMap
.
put
(
"classifiers"
,
this
.
parseClassifiers
(
connectionMap
.
get
(
"classifiers"
),
containerDefinition
.
getClassifiers
()));
}
else
{
parameterMap
.
put
(
"classifiers"
,
new
ArrayList
<
Map
.
Entry
<
String
,
String
>>());
parameterMap
.
put
(
"classifiers"
,
new
ArrayList
<
Map
.
Entry
<
String
,
String
>>());
}
if
(
connectionMap
.
containsKey
(
"transformations"
))
{
parameterMap
.
put
(
"transformations"
,
this
.
parseTransformations
(
connectionMap
.
get
(
"transformations"
),
containerDefinition
.
getTransformations
()));
parameterMap
.
put
(
"transformations"
,
this
.
parseTransformations
(
connectionMap
.
get
(
"transformations"
),
containerDefinition
.
getTransformations
()));
}
else
{
parameterMap
.
put
(
"transformations"
,
new
ArrayList
<
Map
<
String
,
Object
>>());
}
...
...
@@ -85,7 +91,7 @@ public class BaseConnection {
}
@SuppressWarnings
(
"unchecked"
)
private
List
<
String
>
parseFields
(
Object
fields
)
{
private
List
<
String
>
parseFields
(
final
Object
fields
)
{
if
(
fields
instanceof
List
)
{
return
(
List
<
String
>)
fields
;
}
else
{
...
...
@@ -94,13 +100,14 @@ public class BaseConnection {
}
@SuppressWarnings
(
"unchecked"
)
private
List
<
String
>
parseCollections
(
Object
rawCollections
,
List
<
String
>
allCollections
)
throws
Exception
{
private
List
<
String
>
parseCollections
(
final
Object
rawCollections
,
final
List
<
String
>
allCollections
)
throws
Exception
{
try
{
if
(
rawCollections
instanceof
String
)
{
if
(((
String
)
rawCollections
).
equals
(
"*"
))
{
return
new
ArrayList
<
String
>(
allCollections
);
}
else
{
List
<
String
>
collections
=
new
ArrayList
<
String
>();
final
List
<
String
>
collections
=
new
ArrayList
<
String
>();
if
(
allCollections
.
contains
((
String
)
rawCollections
))
{
collections
.
add
((
String
)
rawCollections
);
}
...
...
@@ -110,54 +117,64 @@ public class BaseConnection {
if
(((
List
<
String
>)
rawCollections
).
contains
(
"*"
))
{
return
new
ArrayList
<
String
>(
allCollections
);
}
else
{
return
((
List
<
String
>)
rawCollections
).
stream
().
filter
(
rC
->
allCollections
.
contains
(
rC
)).
collect
(
Collectors
.
toList
());
return
((
List
<
String
>)
rawCollections
).
stream
().
filter
(
rC
->
allCollections
.
contains
(
rC
))
.
collect
(
Collectors
.
toList
());
}
}
return
new
ArrayList
<
String
>();
}
catch
(
Exception
e
)
{
}
catch
(
final
Exception
e
)
{
throw
new
Exception
(
"Error while attempting to parse internal collections in BaseCollection."
);
}
}
@SuppressWarnings
(
"unchecked"
)
private
List
<
Map
.
Entry
<
String
,
String
>>
parseClassifiers
(
Object
rawClassifiers
,
List
<
Map
.
Entry
<
String
,
String
>>
allClassifiers
)
throws
Exception
{
private
List
<
Map
.
Entry
<
String
,
String
>>
parseClassifiers
(
final
Object
rawClassifiers
,
final
List
<
Map
.
Entry
<
String
,
String
>>
allClassifiers
)
throws
Exception
{
try
{
if
(
rawClassifiers
instanceof
String
&&
rawClassifiers
.
equals
(
"*"
))
{
return
allClassifiers
;
}
else
if
(
rawClassifiers
instanceof
Map
)
{
return
ListUtils
.
flatten
(((
Map
<
String
,
Object
>)
rawClassifiers
).
entrySet
().
stream
().
map
(
e
->
{
return
ListUtils
.
flatten
(((
Map
<
String
,
Object
>)
rawClassifiers
).
entrySet
().
stream
().
map
(
e
->
{
if
(
e
.
getValue
()
instanceof
List
)
{
if
(((
List
<
String
>)
e
.
getValue
()).
size
()
==
1
&&
((
List
<
String
>)
e
.
getValue
()).
get
(
0
).
equals
(
"*"
))
{
return
allClassifiers
.
stream
().
filter
(
c
->
c
.
getKey
().
equals
(
e
.
getKey
())).
collect
(
Collectors
.
toList
());
if
(((
List
<
String
>)
e
.
getValue
()).
size
()
==
1
&&
((
List
<
String
>)
e
.
getValue
()).
get
(
0
).
equals
(
"*"
))
{
return
allClassifiers
.
stream
().
filter
(
c
->
c
.
getKey
().
equals
(
e
.
getKey
()))
.
collect
(
Collectors
.
toList
());
}
else
{
return
ListUtils
.
flatten
(((
List
<
String
>)
e
.
getValue
()).
stream
().
map
(
c
->
{
return
allClassifiers
.
stream
().
filter
(
allc
->
(
allc
.
getKey
().
equals
(
e
.
getKey
())
&&
allc
.
getValue
().
equals
(
c
))).
collect
(
Collectors
.
toList
());
return
allClassifiers
.
stream
()
.
filter
(
allc
->
(
allc
.
getKey
().
equals
(
e
.
getKey
())
&&
allc
.
getValue
().
equals
(
c
)))
.
collect
(
Collectors
.
toList
());
}).
collect
(
Collectors
.
toList
()));
}
}
else
if
(
e
.
getValue
()
instanceof
String
)
{
if
(((
String
)
e
.
getValue
()).
equals
(
"*"
))
{
return
allClassifiers
.
stream
().
filter
(
c
->
c
.
getKey
().
equals
(
e
.
getKey
())).
collect
(
Collectors
.
toList
());
return
allClassifiers
.
stream
().
filter
(
c
->
c
.
getKey
().
equals
(
e
.
getKey
()))
.
collect
(
Collectors
.
toList
());
}
else
{
return
allClassifiers
.
stream
().
filter
(
c
->
(
c
.
getKey
().
equals
(
e
.
getKey
())
&&
c
.
getValue
().
equals
(
e
.
getValue
()))).
collect
(
Collectors
.
toList
());
return
allClassifiers
.
stream
()
.
filter
(
c
->
(
c
.
getKey
().
equals
(
e
.
getKey
())
&&
c
.
getValue
().
equals
(
e
.
getValue
())))
.
collect
(
Collectors
.
toList
());
}
}
return
null
;
}).
collect
(
Collectors
.
toList
()));
}
return
new
ArrayList
<
Map
.
Entry
<
String
,
String
>>();
}
catch
(
Exception
e
)
{
return
new
ArrayList
<
Map
.
Entry
<
String
,
String
>>();
}
catch
(
final
Exception
e
)
{
throw
new
Exception
(
"Error while attempting to parse collections in BaseCollection."
);
}
}
@SuppressWarnings
(
"unchecked"
)
private
List
<
String
>
parseTransformations
(
Object
rawTransformations
,
List
<
String
>
allTransformations
)
throws
Exception
{
private
List
<
String
>
parseTransformations
(
final
Object
rawTransformations
,
final
List
<
String
>
allTransformations
)
throws
Exception
{
try
{
if
(
rawTransformations
instanceof
String
)
{
if
(((
String
)
rawTransformations
).
equals
(
"*"
))
{
return
allTransformations
;
}
else
{
List
<
String
>
transformations
=
new
ArrayList
<
String
>();
final
List
<
String
>
transformations
=
new
ArrayList
<
String
>();
if
(
allTransformations
.
contains
((
String
)
rawTransformations
))
{
transformations
.
add
((
String
)
rawTransformations
);
}
...
...
@@ -172,32 +189,34 @@ public class BaseConnection {
}
}
return
new
ArrayList
<
String
>();
}
catch
(
Exception
e
)
{
}
catch
(
final
Exception
e
)
{
throw
new
Exception
(
"Error while attempting to parse internal collections in BaseCollection."
);
}
}
private
IEndpoint
initializeConnection
(
String
endpoint
,
Map
<
String
,
Object
>
constructor
)
throws
Exception
{
Class
<?>[]
ctrClasses
=
{
Map
.
class
};
Object
[]
args
=
{
constructor
};
private
IEndpoint
initializeConnection
(
final
String
endpoint
,
final
Map
<
String
,
Object
>
constructor
)
throws
Exception
{
final
Class
<?>[]
ctrClasses
=
{
Map
.
class
};
final
Object
[]
args
=
{
constructor
};
return
(
IEndpoint
)
instantiateEndpoint
(
Class
.
forName
(
endpoint
),
ctrClasses
,
args
);
}
private
Object
instantiateEndpoint
(
Class
<?>
pluginClass
,
Class
<?>[]
ctrClasses
,
Object
[]
args
)
throws
Exception
{
Constructor
<?>
constructor
=
pluginClass
.
getDeclaredConstructor
(
ctrClasses
);
private
Object
instantiateEndpoint
(
final
Class
<?>
pluginClass
,
final
Class
<?>[]
ctrClasses
,
final
Object
[]
args
)
throws
Exception
{
final
Constructor
<?>
constructor
=
pluginClass
.
getDeclaredConstructor
(
ctrClasses
);
return
constructor
.
newInstance
(
args
);
}
private
void
setEndpointConstructor
(
Map
<
String
,
Object
>
constructorMap
)
{
private
void
setEndpointConstructor
(
final
Map
<
String
,
Object
>
constructorMap
)
{
this
.
constructorMap
=
constructorMap
;
}
private
void
setEndpointClass
(
String
endpointClass
)
{
private
void
setEndpointClass
(
final
String
endpointClass
)
{
this
.
endpointClass
=
endpointClass
;
}
protected
void
setEndpoint
(
String
endpointClass
,
Map
<
String
,
Object
>
constructorMap
)
throws
Exception
{
protected
void
setEndpoint
(
final
String
endpointClass
,
final
Map
<
String
,
Object
>
constructorMap
)
throws
Exception
{
this
.
endpoint
=
this
.
initializeConnection
(
endpointClass
,
constructorMap
);
}
...
...
src/java/main/gov/noaa/messageapi/connections/DefaultConnection.java
View file @
27bff43f
...
...
@@ -27,8 +27,8 @@ public class DefaultConnection extends BaseConnection implements IConnection {
private
Map
<
String
,
Map
<
String
,
Object
>>
transformationMap
=
null
;
@SuppressWarnings
(
"unchecked"
)
public
DefaultConnection
(
String
endpointClass
,
Map
<
String
,
Object
>
connectionMap
,
ContainerDefinition
containerDefinition
)
throws
Exception
{
public
DefaultConnection
(
final
String
endpointClass
,
final
Map
<
String
,
Object
>
connectionMap
,
final
ContainerDefinition
containerDefinition
)
throws
Exception
{
super
(
endpointClass
,
connectionMap
,
containerDefinition
);
try
{
this
.
setId
((
String
)
connectionMap
.
get
(
"id"
));
...
...
@@ -38,29 +38,30 @@ public class DefaultConnection extends BaseConnection implements IConnection {
this
.
setCollections
(
new
ArrayList
<
String
>());
}
if
(
connectionMap
.
containsKey
(
"classifiers"
))
{
this
.
setClassifiers
((
Map
<
String
,
List
<
Object
>>)
connectionMap
.
get
(
"classifiers"
));
this
.
setClassifiers
((
Map
<
String
,
List
<
Object
>>)
connectionMap
.
get
(
"classifiers"
));
}
else
{
this
.
setClassifiers
(
new
HashMap
<
String
,
List
<
Object
>>());
this
.
setClassifiers
(
new
HashMap
<
String
,
List
<
Object
>>());
}
if
(
connectionMap
.
containsKey
(
"transformations"
))
{
this
.
integrateTransformations
((
List
<
String
>)
connectionMap
.
get
(
"transformations"
),
containerDefinition
.
getTransformationMaps
());
this
.
integrateTransformations
((
List
<
String
>)
connectionMap
.
get
(
"transformations"
),
containerDefinition
.
getTransformationMaps
());
}
else
{
this
.
setTransformationMap
(
new
HashMap
<
String
,
Map
<
String
,
Object
>>());
}
}
catch
(
Exception
e
)
{
throw
new
InstantiationException
(
String
.
format
(
"Error in instantiating connection with class %s, connectionMap %s"
,
endpointClass
,
connectionMap
));
}
catch
(
final
Exception
e
)
{
throw
new
InstantiationException
(
String
.
format
(
"Error in instantiating connection with class %s, connectionMap %s"
,
endpointClass
,
connectionMap
));
}
}
public
DefaultConnection
(
IConnection
connection
)
throws
Exception
{
public
DefaultConnection
(
final
IConnection
connection
)
throws
Exception
{
super
(
connection
);
try
{
this
.
setId
(
connection
.
getId
());
this
.
setCollections
(
connection
.
getCollections
());
this
.
setClassifiers
(
connection
.
getClassifiers
());
this
.
setTransformationMap
(
connection
.
getTransformationMap
());
}
catch
(
Exception
e
)
{
}
catch
(
final
Exception
e
)
{
throw
new
InstantiationException
(
"Error in instantiating new connection from existing connection"
);
}
}
...
...
@@ -68,12 +69,12 @@ public class DefaultConnection extends BaseConnection implements IConnection {
public
DefaultConnection
getCopy
()
{
try
{
return
new
DefaultConnection
(
this
);
}
catch
(
Exception
e
)
{
}
catch
(
final
Exception
e
)
{
return
null
;
}