[prev in list] [next in list] [prev in thread] [next in thread]
List: scout-dev
Subject: [jira] [Comment Edited] (JUDDI-941) Dynamic discovery of web service endpoint
From: "Matthieu Ghilain (JIRA)" <juddi-dev () ws ! apache ! org>
Date: 2015-11-17 8:35:11
Message-ID: JIRA.12913069.1447501616000.90764.1447749311228 () Atlassian ! JIRA
[Download RAW message or body]
[ https://issues.apache.org/jira/browse/JUDDI-941?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15008242#comment-15008242 \
]
Matthieu Ghilain edited comment on JUDDI-941 at 11/17/15 8:34 AM:
------------------------------------------------------------------
I did it this way:
{code}
import org.apache.commons.configuration.ConfigurationException;
import org.apache.juddi.v3.client.config.UDDIClerk;
import org.apache.juddi.v3.client.config.UDDIClerkServlet;
import org.apache.juddi.v3.client.config.UDDIClient;
import org.apache.juddi.v3.client.config.WebHelper;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import javax.servlet.ServletContext;
import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;
import javax.servlet.ServletRegistration;
import javax.servlet.annotation.WebListener;
@WebListener
public class JUDDIServletContextListener implements ServletContextListener {
private static final Logger logger = \
LoggerFactory.getLogger(JUDDIServletContextListener.class); private static final \
String JUDDI_SERVLET_NAME = "juddi-servlet";
@Override
public void contextInitialized(ServletContextEvent servletContextEvent) {
logger.info("Registering JUDDI servlet '"+JUDDI_SERVLET_NAME+"' to \
automatically register service");
ServletContext servletContext = servletContextEvent.getServletContext();
configureUddiClient(servletContext);
ServletRegistration.Dynamic dynamic = \
servletContext.addServlet(JUDDI_SERVLET_NAME, UDDIClerkServlet.class); \
dynamic.setLoadOnStartup(1); }
private void configureUddiClient(ServletContext servletContext) {
try {
UDDIClient uddiClient = WebHelper.getUDDIClient(servletContext);
//Do not work despite it should be according to me see Jira \
ticket:JUDDI-941
//uddiClient.getClientConfig().getConfiguration().addProperty("tomee-port", \
"8585");
for (UDDIClerk uddiClerk : \
uddiClient.getClientConfig().getUDDIClerks().values()) {
uddiClerk.getUDDINode().getProperties().setProperty("tomee-port","8585");
}
servletContext.setAttribute("juddi.client.name", "test-client");
} catch (ConfigurationException e) {
throw new RuntimeException(e);
}
}
@Override
public void contextDestroyed(ServletContextEvent servletContextEvent) {
}
}
{code}
However it would be nice to be able to inject properties dynamically in the UDDI \
client config without initiating the ServletContextListener (which will be automatic \
see ticket JUDDI-942).
It could be nice if we could provide implementation of some interface (like \
PropertySource) in the uddi.xml so that we can provide our own properties loaded from \
our environment because command line is not always convenient.
Something like:
{code}
<node isHomeJUDDI="true">
<propertySources>
<propertySource>com.test.myPropertySource</propertySource>
</propertySources>
...
</node>
{code}
was (Author: ghilainm@gmail.com):
I did it this way:
{code}
import org.apache.commons.configuration.ConfigurationException;
import org.apache.juddi.v3.client.config.UDDIClerk;
import org.apache.juddi.v3.client.config.UDDIClerkServlet;
import org.apache.juddi.v3.client.config.UDDIClient;
import org.apache.juddi.v3.client.config.WebHelper;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import javax.servlet.ServletContext;
import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;
import javax.servlet.ServletRegistration;
import javax.servlet.annotation.WebListener;
@WebListener
public class JUDDIServletContextListener implements ServletContextListener {
private static final Logger logger = \
LoggerFactory.getLogger(JUDDIServletContextListener.class); private static final \
String JUDDI_SERVLET_NAME = "juddi-servlet";
@Override
public void contextInitialized(ServletContextEvent servletContextEvent) {
logger.info("Registering JUDDI servlet '"+JUDDI_SERVLET_NAME+"' to \
automatically register service");
ServletContext servletContext = servletContextEvent.getServletContext();
configureUddiClient(servletContext);
ServletRegistration.Dynamic dynamic = \
servletContext.addServlet(JUDDI_SERVLET_NAME, UDDIClerkServlet.class); \
dynamic.setLoadOnStartup(1); }
private void configureUddiClient(ServletContext servletContext) {
try {
UDDIClient uddiClient = WebHelper.getUDDIClient(servletContext);
//Do not work despite it should be according to me see Jira \
ticket:JUDDI-941
//uddiClient.getClientConfig().getConfiguration().addProperty("tomee-port", \
"8585");
for (UDDIClerk uddiClerk : \
uddiClient.getClientConfig().getUDDIClerks().values()) {
uddiClerk.getUDDINode().getProperties().setProperty("tomee-port","8585");
}
servletContext.setAttribute("juddi.client.name", "test-client");
} catch (ConfigurationException e) {
throw new RuntimeException(e);
}
}
@Override
public void contextDestroyed(ServletContextEvent servletContextEvent) {
}
}
{code}
However it would be nice to be able to inject properties dynamically in the UDDI \
client config without initiating the ServletContextListener (which will be automatic \
see ticket JUDDI-942).
It could be nice if we could provide implementation of some interface (like \
PropertySource) in the uddi.xml so that we can provide our own properties loaded from \
our environment because command line is not always convenient.
> Dynamic discovery of web service endpoint
> -----------------------------------------
>
> Key: JUDDI-941
> URL: https://issues.apache.org/jira/browse/JUDDI-941
> Project: jUDDI
> Issue Type: Improvement
> Components: juddi-client
> Affects Versions: 3.3.1
> Reporter: Matthieu Ghilain
> Labels: SOAP, discovery, dynamic, endpoint, juddi
> Original Estimate: 72h
> Remaining Estimate: 72h
>
> Here is the example from the JUDDI documentation:
> {code:title=HelloWorldImpl .java|borderStyle=solid}
> @UDDIService(
> businessKey="uddi:myBusinessKey",
> serviceKey="uddi:myServiceKey",
> description = "Hello World test service")
> @UDDIServiceBinding(
> bindingKey="uddi:myServiceBindingKey",
> description="WSDL endpoint for the helloWorld Service. This service is used for "
> + "testing the jUDDI annotation functionality",
> accessPointType="wsdlDeployment",
> accessPoint="http://localhost:8080/juddiv3-samples/services/helloworld?wsdl")
> @WebService(
> endpointInterface = "org.apache.juddi.samples.HelloWorld",
> serviceName = "HelloWorld")
> public class HelloWorldImpl implements HelloWorld {
> public String sayHi(String text) {
> System.out.println("sayHi called");
> return "Hello " + text;
> }
> }
> {code}
> The problem with this kind of registration is that it is still static. The \
> accessPoint should be resolved dynamically at runtime. Otherwise it is not possible \
> to spawn new service instances dynamically and to scale. This in my opinion should \
> be part of the JUDDI features. What do you think?
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic