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
CHOReVOLUTION
choreospec
Commits
2a0df672
Commit
2a0df672
authored
Jan 10, 2017
by
Alessio Carenini
Browse files
Merge branch 'master' of
ssh://tuleap.ow2.org/chorevolution/chorspec
parents
5152c5ac
e1dc68bb
Changes
3
Expand all
Hide whitespace changes
Inline
Side-by-side
.gitignore
0 → 100644
View file @
2a0df672
target
pom.xml
View file @
2a0df672
This diff is collapsed.
Click to expand it.
src/main/java/eu/chorevolution/chors/Base.java
View file @
2a0df672
...
...
@@ -34,68 +34,81 @@ import javax.xml.ws.Service;
targetNamespace
=
"http://services.chorevolution.eu/"
)
public
class
Base
implements
BaseService
{
protected
Map
<
String
,
String
>
address_map
=
null
;
protected
String
ENDPOINTADDRESS
=
null
;
/**
* Each BasicService subclass has the following lifecycle:
* 1. start the service
* 2. send it its own enpoint address
* 3. send the service dependency data (according to Enactment Engine choreography requirements)
* */
public
Base
(){
address_map
=
new
HashMap
<
String
,
String
>();
}
protected
Map
<
String
,
String
>
address_map
=
null
;
/* (non-Javadoc)
* @see org.choreos.services.Base#setInvocationAddress(java.lang.String, java.lang.String)
*/
/* (non-Javadoc)
* @see eu.chorevolution.enactment.dependencies.ConfigurableService#setInvocationAddress(java.lang.String, java.lang.String, java.util.List)
protected
String
ENDPOINTADDRESS
=
null
;
/**
* Each BasicService subclass has the following lifecycle:
* 1. start the service
* 2. send it its own enpoint address
* 3. send the service dependency data (according to Enactment Engine choreography requirements)
* */
public
Base
()
{
address_map
=
new
HashMap
<>();
}
/* (non-Javadoc)
* @see org.choreos.services.Base#setInvocationAddress(java.lang.String, java.lang.String)
*/
/* (non-Javadoc)
* @see eu.chorevolution.enactment.dependencies.ConfigurableService#setInvocationAddress(java.lang.String,
* java.lang.String, java.util.List)
*/
@Override
@Override
@WebMethod
public
void
setInvocationAddress
(
String
role
,
String
name
,
List
<
String
>
endpoints
)
{
if
(
address_map
.
containsKey
(
name
))
{
address_map
.
remove
(
name
);
}
address_map
.
put
(
name
,
endpoints
.
get
(
0
));
}
public
void
setInvocationAddress
(
String
role
,
String
name
,
List
<
String
>
endpoints
)
{
if
(
address_map
.
containsKey
(
name
))
{
address_map
.
remove
(
name
);
}
address_map
.
put
(
name
,
endpoints
.
get
(
0
));
}
/**
* Example call: (Client1) (getPort("Client1", "http://localhost/client1?wsdl", Client1.class));
*
* @param <T> generic parameter
* @param service_name service name
* @param wsdlLocation WSDL location
* @param source_url source URL
* @param client_class client class
* @return service port
* @throws java.net.MalformedURLException if bad URL is passed
*/
public
static
<
T
>
T
getPort
(
String
service_name
,
String
wsdlLocation
,
String
source_url
,
Class
<
T
>
client_class
)
throws
MalformedURLException
,
IOException
{
/**
* Example call: (Client1) (getPort("Client1", "http://localhost/client1?wsdl", Client1.class));
* @throws MalformedURLException
* @throws InterruptedException
* */
public
static
<
T
>
T
getPort
(
String
service_name
,
String
wsdlLocation
,
String
source_url
,
Class
<
T
>
client_class
)
throws
MalformedURLException
,
IOException
,
InterruptedException
{
T
retPort
=
null
;
QName
serviceQName
=
null
;
URL
serviceUrl
=
null
;
Service
s
;
int
err_count
=
0
;
String
wsdl_content
=
null
;
serviceQName
=
new
QName
(
namespace
,
service_name
+
"Service"
);
T
retPort
=
null
;
QName
serviceQName
=
null
;
URL
serviceUrl
=
null
;
Service
s
;
int
err_count
=
0
;
String
wsdl_content
=
null
;
while
(
err_count
<
5
)
{
wsdl_content
=
new
Scanner
(
new
URL
(
wsdlLocation
).
openStream
(),
"UTF-8"
).
useDelimiter
(
"\\A"
).
next
();
if
((
wsdl_content
==
null
)||(
wsdl_content
.
contains
(
"<html>"
))||(
wsdl_content
.
contains
(
"<body>"
)))
{
serviceQName
=
new
QName
(
namespace
,
service_name
+
"Service"
);
while
(
err_count
<
5
)
{
wsdl_content
=
new
Scanner
(
new
URL
(
wsdlLocation
).
openStream
(),
"UTF-8"
).
useDelimiter
(
"\\A"
).
next
();
if
((
wsdl_content
==
null
)
||
(
wsdl_content
.
contains
(
"<html>"
))
||
(
wsdl_content
.
contains
(
"<body>"
)))
{
try
{
Thread
.
sleep
(
1000
);
}
catch
(
InterruptedException
e
)
{
// ignore
}
err_count
++;
}
else
}
else
{
break
;
}
//System.out.println("[cfg] Service name: "+service_name+" - WSDL: "+wsdlLocation+" - Source URL: "+source_url);
s
=
Service
.
create
(
serviceUrl
,
serviceQName
);
retPort
=
(
T
)
s
.
getPort
(
client_class
);
BindingProvider
bp
=
(
BindingProvider
)
retPort
;
}
}
//System.out.println("[cfg] Service name: "+service_name+" - WSDL: "+wsdlLocation+" - Source URL: "+source_url);
s
=
Service
.
create
(
serviceUrl
,
serviceQName
);
retPort
=
s
.
getPort
(
client_class
);
BindingProvider
bp
=
(
BindingProvider
)
retPort
;
bp
.
getRequestContext
().
put
(
BindingProvider
.
ENDPOINT_ADDRESS_PROPERTY
,
source_url
);
return
retPort
;
}
return
retPort
;
}
}
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