Author: kstam
Date: Thu Jun  9 14:21:00 2011
New Revision: 1133883

URL: http://svn.apache.org/viewvc?rev=1133883&view=rev
Log:
JUDDI-492 adding option to run registration asynchronously.

Added:
    
juddi/trunk/juddi-client/src/main/java/org/apache/juddi/v3/client/mapping/AsyncRegistration.java
    
juddi/trunk/juddi-client/src/main/java/org/apache/juddi/v3/client/mapping/RegistrationInfo.java
    
juddi/trunk/juddi-client/src/main/java/org/apache/juddi/v3/client/mapping/RegistrationType.java

Added: 
juddi/trunk/juddi-client/src/main/java/org/apache/juddi/v3/client/mapping/AsyncRegistration.java
URL: 
http://svn.apache.org/viewvc/juddi/trunk/juddi-client/src/main/java/org/apache/juddi/v3/client/mapping/AsyncRegistration.java?rev=1133883&view=auto
==============================================================================
--- 
juddi/trunk/juddi-client/src/main/java/org/apache/juddi/v3/client/mapping/AsyncRegistration.java
 (added)
+++ 
juddi/trunk/juddi-client/src/main/java/org/apache/juddi/v3/client/mapping/AsyncRegistration.java
 Thu Jun  9 14:21:00 2011
@@ -0,0 +1,92 @@
+/*
+ * Copyright 2001-2010 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.mapping;
+
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Properties;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.juddi.v3.client.config.UDDIClerk;
+import org.uddi.api_v3.BindingTemplate;
+
+public class AsyncRegistration implements Runnable {
+
+       private static Log log = LogFactory.getLog(AsyncRegistration.class);
+       private UDDIClerk clerk;
+       private URLLocalizer urlLocalizer;
+       private Properties properties;
+       private static Map<String,ServiceLocator> serviceLocators = new 
HashMap<String,ServiceLocator>();
+       private RegistrationInfo registrationInfo;
+       
+       public AsyncRegistration(UDDIClerk clerk, URLLocalizer urlLocalizer, 
+               Properties properties, RegistrationInfo registrationInfo) {
+               super();
+               this.clerk = clerk;
+               this.urlLocalizer = urlLocalizer;
+               this.properties = properties;
+               this.registrationInfo = registrationInfo;
+               
+       }
+
+       public void run() {
+               try {
+                       if 
(RegistrationType.WSDL.equals(registrationInfo.getRegistrationType())) {
+                               WSDL2UDDI wsdl2UDDI = new WSDL2UDDI(clerk, 
urlLocalizer, properties);
+                               BindingTemplate binding = 
wsdl2UDDI.register(registrationInfo.getServiceQName(), 
+                                                                  
registrationInfo.getPortName(),
+                                                                  
registrationInfo.getServiceUrl(),
+                                                                  
registrationInfo.getWsdlDefinition());
+                               ServiceLocator serviceLocator = null;
+                               if 
(!serviceLocators.containsKey(clerk.getName())) {
+                                       serviceLocator = new 
ServiceLocator(clerk, urlLocalizer, properties);
+                                       serviceLocators.put(clerk.getName(), 
serviceLocator);
+                               } else {
+                                       serviceLocator = 
serviceLocators.get(clerk.getName());
+                               }
+                               
serviceLocator.addService(binding.getServiceKey());
+                               
+                       } else if 
(RegistrationType.BPEL.equals(registrationInfo.getRegistrationType())) {
+                               BPEL2UDDI bpel2UDDI = new BPEL2UDDI(clerk, 
urlLocalizer, properties);
+                               BindingTemplate binding = 
bpel2UDDI.register(registrationInfo.getServiceQName(), 
+                                                                  
registrationInfo.getPortName(),
+                                                                  
registrationInfo.getServiceUrl(),
+                                                                  
registrationInfo.getWsdlDefinition());
+                               ServiceLocator serviceLocator = null;
+                               if 
(!serviceLocators.containsKey(clerk.getName())) {
+                                       serviceLocator = new 
ServiceLocator(clerk, urlLocalizer, properties);
+                                       serviceLocators.put(clerk.getName(), 
serviceLocator);
+                               } else {
+                                       serviceLocator = 
serviceLocators.get(clerk.getName());
+                               }
+                               
serviceLocator.addService(binding.getServiceKey());
+                       } else {
+                               log.error("Registration error, due to 
unsupported registration type of " + registrationInfo.getRegistrationType());
+                       }
+               } catch (Exception e) {
+                       log.error("Not able to register " + 
registrationInfo.getRegistrationType() 
+                                       + " endpoint " + 
registrationInfo.getServiceQName()
+                                       + " to UDDI Registry. " + 
e.getMessage(),e);
+               }
+               
+       }
+
+       public ServiceLocator getServiceLocator(String clerkName) {
+               return serviceLocators.get(clerkName);
+       }
+}

Added: 
juddi/trunk/juddi-client/src/main/java/org/apache/juddi/v3/client/mapping/RegistrationInfo.java
URL: 
http://svn.apache.org/viewvc/juddi/trunk/juddi-client/src/main/java/org/apache/juddi/v3/client/mapping/RegistrationInfo.java?rev=1133883&view=auto
==============================================================================
--- 
juddi/trunk/juddi-client/src/main/java/org/apache/juddi/v3/client/mapping/RegistrationInfo.java
 (added)
+++ 
juddi/trunk/juddi-client/src/main/java/org/apache/juddi/v3/client/mapping/RegistrationInfo.java
 Thu Jun  9 14:21:00 2011
@@ -0,0 +1,81 @@
+/*
+ * Copyright 2001-2011 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.mapping;
+
+import java.io.Serializable;
+import java.net.URL;
+
+import javax.wsdl.Definition;
+import javax.xml.namespace.QName;
+
+/**
+ * @author <a href="mailto:[email protected]";>Kurt T Stam</a>
+ */
+public class RegistrationInfo implements Serializable{
+       
+       private static final long serialVersionUID = 8589346728228576240L;
+       private QName serviceQName;
+       private String portName;
+       private URL serviceUrl;
+       private URL wsdlUrl;
+       private Definition wsdlDefinition;
+       private String version;
+       private RegistrationType registrationType;
+       
+       public QName getServiceQName() {
+               return serviceQName;
+       }
+       public void setServiceQName(QName serviceQName) {
+               this.serviceQName = serviceQName;
+       }
+       public String getPortName() {
+               return portName;
+       }
+       public void setPortName(String portName) {
+               this.portName = portName;
+       }
+       public URL getServiceUrl() {
+               return serviceUrl;
+       }
+       public void setServiceUrl(URL serviceUrl) {
+               this.serviceUrl = serviceUrl;
+       }
+       public Definition getWsdlDefinition() {
+               return wsdlDefinition;
+       }
+       public void setWsdlDefinition(Definition wsdlDefinition) {
+               this.wsdlDefinition = wsdlDefinition;
+       }
+       public RegistrationType getRegistrationType() {
+               return registrationType;
+       }
+       public void setRegistrationType(RegistrationType registrationType) {
+               this.registrationType = registrationType;
+       }
+       public String getVersion() {
+               return version;
+       }
+       public void setVersion(String version) {
+               this.version = version;
+       }
+       public URL getWsdlUrl() {
+               return wsdlUrl;
+       }
+       public void setWsdlUrl(URL wsdlUrl) {
+               this.wsdlUrl = wsdlUrl;
+       }
+       
+       
+}

Added: 
juddi/trunk/juddi-client/src/main/java/org/apache/juddi/v3/client/mapping/RegistrationType.java
URL: 
http://svn.apache.org/viewvc/juddi/trunk/juddi-client/src/main/java/org/apache/juddi/v3/client/mapping/RegistrationType.java?rev=1133883&view=auto
==============================================================================
--- 
juddi/trunk/juddi-client/src/main/java/org/apache/juddi/v3/client/mapping/RegistrationType.java
 (added)
+++ 
juddi/trunk/juddi-client/src/main/java/org/apache/juddi/v3/client/mapping/RegistrationType.java
 Thu Jun  9 14:21:00 2011
@@ -0,0 +1,34 @@
+/*
+ * Copyright 2001-2009 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.mapping;
+
+public enum RegistrationType {
+       
+       WSDL ("org.apache.juddiv3.client.mapping.WSDL2UDDI"),
+       BPEL ("org.apache.juddiv3.client.mapping.WSDL2UDDI");
+       
+       final String type;
+
+       private RegistrationType(String type) {
+               this.type = type;
+       }
+       
+       public String toString() {
+               return type;    
+       }
+       
+}



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to