You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@juddi.apache.org by al...@apache.org on 2015/12/05 04:56:20 UTC
juddi git commit: JUDDI-942 Automatic instantiation of
UDDIClerkServlet
Repository: juddi
Updated Branches:
refs/heads/feature/JUDDI-942 [created] a563edb1b
JUDDI-942 Automatic instantiation of UDDIClerkServlet
Project: http://git-wip-us.apache.org/repos/asf/juddi/repo
Commit: http://git-wip-us.apache.org/repos/asf/juddi/commit/a563edb1
Tree: http://git-wip-us.apache.org/repos/asf/juddi/tree/a563edb1
Diff: http://git-wip-us.apache.org/repos/asf/juddi/diff/a563edb1
Branch: refs/heads/feature/JUDDI-942
Commit: a563edb1b239bc6f37845d9b5d6f485a1fc593b5
Parents: fe5dcfa
Author: Alex <al...@apache.org>
Authored: Fri Dec 4 22:56:13 2015 -0500
Committer: Alex <al...@apache.org>
Committed: Fri Dec 4 22:56:13 2015 -0500
----------------------------------------------------------------------
juddi-client/pom.xml | 11 +--
.../config/UDDIServletContextListener.java | 91 ++++++++++++++++++++
.../config/model/JUDDI_943_testInterface.java | 24 ++++++
.../config/model/JUDDI_943_testService.java | 48 +++++++++++
.../src/test/resources/META-INF/JUDDI-943.xml | 58 +++++++++++++
5 files changed, 227 insertions(+), 5 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/juddi/blob/a563edb1/juddi-client/pom.xml
----------------------------------------------------------------------
diff --git a/juddi-client/pom.xml b/juddi-client/pom.xml
index 8c38d92..5612eba 100644
--- a/juddi-client/pom.xml
+++ b/juddi-client/pom.xml
@@ -48,11 +48,12 @@
<version>3.2</version>
</dependency>
<dependency>
- <groupId>javax.servlet</groupId>
- <artifactId>servlet-api</artifactId>
- <version>2.5</version>
- <scope>provided</scope>
- </dependency>
+ <groupId>javax.servlet</groupId>
+ <artifactId>javax.servlet-api</artifactId>
+ <version>3.1.0</version>
+ <scope>provided</scope>
+ </dependency>
+
<dependency>
<groupId>wsdl4j</groupId>
<artifactId>wsdl4j</artifactId>
http://git-wip-us.apache.org/repos/asf/juddi/blob/a563edb1/juddi-client/src/main/java/org/apache/juddi/v3/client/config/UDDIServletContextListener.java
----------------------------------------------------------------------
diff --git a/juddi-client/src/main/java/org/apache/juddi/v3/client/config/UDDIServletContextListener.java b/juddi-client/src/main/java/org/apache/juddi/v3/client/config/UDDIServletContextListener.java
new file mode 100644
index 0000000..7de07af
--- /dev/null
+++ b/juddi-client/src/main/java/org/apache/juddi/v3/client/config/UDDIServletContextListener.java
@@ -0,0 +1,91 @@
+/*
+ * Copyright 2015 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.juddi.v3.client.config;
+
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import javax.servlet.Servlet;
+import javax.servlet.ServletContext;
+import javax.servlet.ServletContextEvent;
+import javax.servlet.ServletContextListener;
+import org.apache.commons.configuration.ConfigurationException;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+/**
+ *
+ * @author alex
+ */
+public class UDDIServletContextListener implements ServletContextListener {
+
+ public static final Log logger = LogFactory.getLog(UDDIServletContextListener.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();
+ boolean success = false;
+ try {
+ configureUddiClient(servletContext);
+ Method m = ServletContext.class.getMethod("addServlet", String.class, Servlet.class);
+ if (m != null) {
+ //should have one of these
+ // ServletRegistration.Dynamic dynamic = servletContext.addServlet(JUDDI_SERVLET_NAME, UDDIClerkServlet.class);
+ Object obj = m.invoke(servletContext, JUDDI_SERVLET_NAME, UDDIClerkServlet.class);
+ Method setLoadOnStartup = obj.getClass().getMethod("setLoadOnStartup", int.class);
+ if (setLoadOnStartup != null) {
+ setLoadOnStartup.invoke(obj, 1);
+ success = true;
+ }
+ }
+ } catch (NoSuchMethodException ex) {
+ logger.debug("Probably not in a servlet container > v3.0. probably time to upgrade?", ex);
+ } catch (SecurityException ex) {
+ logger.warn("Probably not in a servlet container > v3.0. probably time to upgrade?", ex);
+ } catch (IllegalAccessException ex) {
+ logger.warn("Probably not in a servlet container > v3.0. probably time to upgrade?", ex);
+ } catch (IllegalArgumentException ex) {
+ logger.warn("Probably not in a servlet container > v3.0. probably time to upgrade?", ex);
+ } catch (InvocationTargetException ex) {
+ logger.warn("Probably not in a servlet container > v3.0. probably time to upgrade?", ex);
+ } catch (Throwable ex) {
+ logger.warn("Probably not in a servlet container > v3.0. probably time to upgrade?", ex);
+ }
+ if (success) {
+ logger.info("Successfully automatic registration of the UDDIClerkServlet using servlet spec 3.0+.");
+ } else {
+ logger.info("NOT Successful - autoregisteration the UDDIClerkServlet using servlet spec 3.0+. You'll have to set this up using web.xml if desired. See error log for additional details.");
+ }
+ //ServletRegistration.Dynamic dynamic = servletContext.addServlet(JUDDI_SERVLET_NAME, UDDIClerkServlet.class);
+ //dynamic.setLoadOnStartup(1);
+ }
+
+ /**
+ * override this function if you want to do some custom configurations
+ * before the juddi config files are loaded
+ *
+ * @param servletContext
+ */
+ public void configureUddiClient(ServletContext servletContext) {
+
+ }
+
+ @Override
+ public void contextDestroyed(ServletContextEvent servletContextEvent) {
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/juddi/blob/a563edb1/juddi-client/src/test/java/org/apache/juddi/v3/client/config/model/JUDDI_943_testInterface.java
----------------------------------------------------------------------
diff --git a/juddi-client/src/test/java/org/apache/juddi/v3/client/config/model/JUDDI_943_testInterface.java b/juddi-client/src/test/java/org/apache/juddi/v3/client/config/model/JUDDI_943_testInterface.java
new file mode 100644
index 0000000..0b9ac7e
--- /dev/null
+++ b/juddi-client/src/test/java/org/apache/juddi/v3/client/config/model/JUDDI_943_testInterface.java
@@ -0,0 +1,24 @@
+/*
+ * Copyright 2015 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.juddi.v3.client.config.model;
+
+/**
+ *
+ * @author alex
+ */
+public interface JUDDI_943_testInterface {
+ public String sayHell(String name);
+}
http://git-wip-us.apache.org/repos/asf/juddi/blob/a563edb1/juddi-client/src/test/java/org/apache/juddi/v3/client/config/model/JUDDI_943_testService.java
----------------------------------------------------------------------
diff --git a/juddi-client/src/test/java/org/apache/juddi/v3/client/config/model/JUDDI_943_testService.java b/juddi-client/src/test/java/org/apache/juddi/v3/client/config/model/JUDDI_943_testService.java
new file mode 100644
index 0000000..248d08e
--- /dev/null
+++ b/juddi-client/src/test/java/org/apache/juddi/v3/client/config/model/JUDDI_943_testService.java
@@ -0,0 +1,48 @@
+/*
+ * Copyright 2015 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.juddi.v3.client.config.model;
+
+import java.text.SimpleDateFormat;
+import javax.jws.WebService;
+import org.apache.juddi.v3.annotations.UDDIService;
+import org.apache.juddi.v3.annotations.UDDIServiceBinding;
+
+/**
+ *
+ * @author alex
+ */
+@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 JUDDI_943_testService implements JUDDI_943_testInterface{
+
+ static final SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssZ");
+ @Override
+ public String sayHell(String name) {
+ return "Hi " + name + "! It is now " ;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/juddi/blob/a563edb1/juddi-client/src/test/resources/META-INF/JUDDI-943.xml
----------------------------------------------------------------------
diff --git a/juddi-client/src/test/resources/META-INF/JUDDI-943.xml b/juddi-client/src/test/resources/META-INF/JUDDI-943.xml
new file mode 100644
index 0000000..04e131b
--- /dev/null
+++ b/juddi-client/src/test/resources/META-INF/JUDDI-943.xml
@@ -0,0 +1,58 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+Copyright 2015 The Apache Software Foundation.
+
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+-->
+
+<uddi xmlns="urn:juddi-apache-org:v3_client">
+ <reloadDelay>5000</reloadDelay>
+ <client name="test-client">
+ <nodes>
+ <node isHomeJUDDI="true">
+ <!-- required 'default' node -->
+ <name>uddiv3</name>
+ <description>Main jUDDI node</description>
+ <properties>
+ <property name="serverName" value="localhost"/>
+ <property name="serverPort" value="8080"/>
+ <!-- for UDDI nodes that use HTTP u/p, using the following
+ <property name="basicAuthUsername" value="root" />
+ <property name="basicAuthPassword" value="password" />
+ <property name="basicAuthPasswordIsEncrypted" value="false" />
+ <property name="basicAuthPasswordCryptoProvider" value="org.apache.juddi.v3.client.crypto.AES128Cryptor (an example)" />-->
+ </properties>
+ <!-- JAX-WS Transport -->
+ <proxyTransport>org.apache.juddi.v3.client.transport.JAXWSTransport</proxyTransport>
+ <custodyTransferUrl>http://${serverName}:${serverPort}/juddiv3/services/custody-transfer
+ </custodyTransferUrl>
+ <inquiryUrl>http://${serverName}:${serverPort}/juddiv3/services/inquiry</inquiryUrl>
+ <inquiryRESTUrl>http://${serverName}:${serverPort}/juddiv3/services/inquiryRest/XML/getDetail
+ </inquiryRESTUrl>
+ <publishUrl>http://${serverName}:${serverPort}/juddiv3/services/publish</publishUrl>
+ <securityUrl>http://${serverName}:${serverPort}/juddiv3/services/security</securityUrl>
+ <subscriptionUrl>http://${serverName}:${serverPort}/juddiv3/services/subscription</subscriptionUrl>
+ <subscriptionListenerUrl>http://${serverName}:${serverPort}/juddiv3/services/subscription-listener
+ </subscriptionListenerUrl>
+ <juddiApiUrl>http://${serverName}:${serverPort}/juddiv3/services/juddi-api</juddiApiUrl>
+ <replicationUrl>http://${serverName}:${serverPort}/juddiv3/services/replication</replicationUrl>
+ </node>
+ </nodes>
+ <clerks registerOnStartup="true">
+ <!-- this is used for the subscription callback tests -->
+ <clerk name="uddiv3" node="uddiv3" publisher="uddiadmin" password="password" isPasswordEncrypted="false" cryptoProvider="">
+ <class>org.apache.juddi.v3.client.config.model.JUDDI_943_testService</class>
+ </clerk>
+ </clerks>
+ </client>
+</uddi>
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@juddi.apache.org
For additional commands, e-mail: commits-help@juddi.apache.org