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 2014/01/09 00:34:33 UTC
svn commit: r1556671 [1/4] - in /juddi/trunk:
juddi-client.net/juddi-client.net/org.apache.juddi.v3.client.config/
juddi-client/src/main/java/org/apache/juddi/v3/client/config/
juddi-client/src/main/java/org/apache/juddi/v3/client/ext/wsdm/
juddi-clien...
Author: alexoree
Date: Wed Jan 8 23:34:32 2014
New Revision: 1556671
URL: http://svn.apache.org/r1556671
Log:
JUDDI-774 added a few new methods, more javadoc
JUDDI-717 made some serious headway
Added:
juddi/trunk/juddi-examples/more-uddi-samples/README.txt
juddi/trunk/juddi-examples/service-version/README.txt
Modified:
juddi/trunk/juddi-client.net/juddi-client.net/org.apache.juddi.v3.client.config/UDDIClerk.cs
juddi/trunk/juddi-client/src/main/java/org/apache/juddi/v3/client/config/UDDIClerk.java
juddi/trunk/juddi-client/src/main/java/org/apache/juddi/v3/client/ext/wsdm/WSDMQosConstants.java
juddi/trunk/juddi-client/src/main/java/org/apache/juddi/v3/client/mapping/wsdl/ReadWSDL.java
juddi/trunk/juddi-examples/create-partition/src/main/java/org/apache/juddi/example/partition/SimpleCreateTmodelPartition.java
juddi/trunk/juddi-examples/hello-world-embedded/src/main/java/org/apache/juddi/example/helloworld/HelloWorld.java
juddi/trunk/juddi-examples/hello-world/src/main/java/org/apache/juddi/example/helloworld/HelloWorld.java
juddi/trunk/juddi-examples/more-uddi-samples/pom.xml
juddi/trunk/juddi-examples/more-uddi-samples/src/main/java/org/apache/juddi/samples/BusinessServiceKeymismatch.java
juddi/trunk/juddi-examples/more-uddi-samples/src/main/java/org/apache/juddi/samples/CompareByTModelInstanceInfoQOS.java
juddi/trunk/juddi-examples/more-uddi-samples/src/main/java/org/apache/juddi/samples/JuddiAdminService.java
juddi/trunk/juddi-examples/more-uddi-samples/src/main/java/org/apache/juddi/samples/SearchByQos.java
juddi/trunk/juddi-examples/more-uddi-samples/src/main/java/org/apache/juddi/samples/SubscriptionCallbackExample.java
juddi/trunk/juddi-examples/more-uddi-samples/src/main/java/org/apache/juddi/samples/UddiCreatebulk.java
juddi/trunk/juddi-examples/more-uddi-samples/src/main/java/org/apache/juddi/samples/UddiCustodyTransfer.java
juddi/trunk/juddi-examples/more-uddi-samples/src/main/java/org/apache/juddi/samples/UddiDigitalSignatureBusiness.java
juddi/trunk/juddi-examples/more-uddi-samples/src/main/java/org/apache/juddi/samples/UddiDigitalSignatureSearch.java
juddi/trunk/juddi-examples/more-uddi-samples/src/main/java/org/apache/juddi/samples/UddiDigitalSignatureService.java
juddi/trunk/juddi-examples/more-uddi-samples/src/main/java/org/apache/juddi/samples/UddiDigitalSignatureTmodel.java
juddi/trunk/juddi-examples/more-uddi-samples/src/main/java/org/apache/juddi/samples/UddiFindBinding.java
juddi/trunk/juddi-examples/more-uddi-samples/src/main/java/org/apache/juddi/samples/UddiFindEndpoints.java
juddi/trunk/juddi-examples/more-uddi-samples/src/main/java/org/apache/juddi/samples/UddiGetServiceDetails.java
juddi/trunk/juddi-examples/more-uddi-samples/src/main/java/org/apache/juddi/samples/UddiKeyGenerator.java
juddi/trunk/juddi-examples/more-uddi-samples/src/main/java/org/apache/juddi/samples/UddiRelatedBusinesses.java
juddi/trunk/juddi-examples/more-uddi-samples/src/main/java/org/apache/juddi/samples/WadlImport.java
juddi/trunk/juddi-examples/more-uddi-samples/src/main/java/org/apache/juddi/samples/WsdlImport.java
juddi/trunk/juddi-examples/more-uddi-samples/src/main/resources/META-INF/simple-publish-uddi.xml
juddi/trunk/juddi-examples/service-version/pom.xml
juddi/trunk/juddi-examples/service-version/src/main/java/org/apache/juddi/examples/service/version/ServiceVersioningExample.java
juddi/trunk/juddi-examples/simple-browse/src/main/java/org/apache/juddi/example/browse/SimpleBrowse.java
juddi/trunk/juddi-examples/simple-publish/src/main/java/org/apache/juddi/example/publish/SimplePublish.java
juddi/trunk/juddi-examples/uddi-annotations/src/main/java/org/apache/juddi/example/HelloWorldImpl.java
juddi/trunk/juddi-examples/uddi-annotations/src/main/resources/META-INF/uddi-annotations.xml
juddi/trunk/juddi-examples/wsdl2uddi/src/main/java/org/apache/juddi/example/wsdl2uddi/Publish.java
juddi/trunk/uddi-ws/src/main/java/org/uddi/api_v3/DiscardAuthToken.java
Modified: juddi/trunk/juddi-client.net/juddi-client.net/org.apache.juddi.v3.client.config/UDDIClerk.cs
URL: http://svn.apache.org/viewvc/juddi/trunk/juddi-client.net/juddi-client.net/org.apache.juddi.v3.client.config/UDDIClerk.cs?rev=1556671&r1=1556670&r2=1556671&view=diff
==============================================================================
--- juddi/trunk/juddi-client.net/juddi-client.net/org.apache.juddi.v3.client.config/UDDIClerk.cs (original)
+++ juddi/trunk/juddi-client.net/juddi-client.net/org.apache.juddi.v3.client.config/UDDIClerk.cs Wed Jan 8 23:34:32 2014
@@ -1088,6 +1088,37 @@ namespace org.apache.juddi.v3.client.con
+ /**
+ * kills the current auth token, aka Logout
+ */
+ public void discardAuthToken()
+ {
+ discardAuthToken(authToken);
+ }
+ /**
+ * kills the provided auth token, aka Logout
+ */
+ public void discardAuthToken(String token)
+ {
+ if (token != null)
+ {
+ try
+ {
+ discard_authToken discardAuthToken = new discard_authToken();
+ discardAuthToken.authInfo=(token);
+ getUDDINode().getTransport().getUDDISecurityService().discard_authToken(discardAuthToken);
+ token = null;
+ }
+ catch (Exception ex)
+ {
+ log.warn("Error discarding auth token: " + ex.Message);
+ log.debug("Error discarding auth token: " + ex.Message, ex);
+ }
+ }
+ }
+
+
+
/// <summary>
/// This calls a jUDDI implementation specific API call and is used to help
/// configure internode communication between jUDDI servers. This is NOT
Modified: juddi/trunk/juddi-client/src/main/java/org/apache/juddi/v3/client/config/UDDIClerk.java
URL: http://svn.apache.org/viewvc/juddi/trunk/juddi-client/src/main/java/org/apache/juddi/v3/client/config/UDDIClerk.java?rev=1556671&r1=1556670&r2=1556671&view=diff
==============================================================================
--- juddi/trunk/juddi-client/src/main/java/org/apache/juddi/v3/client/config/UDDIClerk.java (original)
+++ juddi/trunk/juddi-client/src/main/java/org/apache/juddi/v3/client/config/UDDIClerk.java Wed Jan 8 23:34:32 2014
@@ -414,9 +414,10 @@ public class UDDIClerk implements Serial
/**
* Register a tModel. Note, if registration fails, no exception is
* thrown
+ *
* @param tModel
* @param node
- * @return
+ * @return
*/
public TModelDetail register(TModel tModel, Node node) {
TModelDetail tModelDetail = null;
@@ -442,8 +443,9 @@ public class UDDIClerk implements Serial
/**
* Register a BindingTemplate, using the node of current clerk ('this').
* Note, if registration fails, no exception is thrown
+ *
* @param binding
- * @return
+ * @return
*/
public BindingTemplate register(BindingTemplate binding) {
return register(binding, this.getUDDINode().getApiNode());
@@ -452,9 +454,10 @@ public class UDDIClerk implements Serial
/**
* Register a BindingTemplate. Note, if registration fails, no exception
* is thrown
+ *
* @param binding
* @param node
- * @return
+ * @return
*/
public BindingTemplate register(BindingTemplate binding, Node node) {
@@ -495,7 +498,8 @@ public class UDDIClerk implements Serial
*
* Note, if registration fails, no exception is thrown
*
- * @param service the element returned by the server, it may be modified from the original
+ * @param service the element returned by the server, it may be modified
+ * from the original
* @param node
* @return the potentially modified service by the UDDI server
*/
@@ -1038,6 +1042,21 @@ public class UDDIClerk implements Serial
* not found.
*
* @param businessKey - the key we are looking for
+ * @return BusinessEntity is found, or null if not found.
+ * @throws RemoteException
+ * @throws TransportException
+ * @throws ConfigurationException
+ */
+ public BusinessEntity getBusinessDetail(String businessKey) throws RemoteException,
+ TransportException, ConfigurationException {
+ return getBusinessDetail(businessKey, this.getUDDINode().getApiNode());
+ }
+
+ /**
+ * Looks up the BusinessEntiry in the registry, will return null if is
+ * not found.
+ *
+ * @param businessKey - the key we are looking for
* @param node - the node which is going to be queried
* @return BusinessEntity is found, or null if not found.
* @throws RemoteException
@@ -1116,6 +1135,52 @@ public class UDDIClerk implements Serial
}
/**
+ * kills the current auth token, aka Logout current Node
+ */
+ public void discardAuthToken() {
+ discardAuthToken(authToken);
+ }
+
+ /**
+ * kills the provided auth token, aka Logout
+ *
+ * @param token
+ */
+ public void discardAuthToken(String token) {
+ if (token != null) {
+ try {
+ DiscardAuthToken discardAuthToken = new DiscardAuthToken();
+ discardAuthToken.setAuthInfo(token);
+ getUDDINode().getTransport().getUDDISecurityService(getUDDINode().getSecurityUrl()).discardAuthToken(discardAuthToken);
+ token = null;
+ } catch (Exception ex) {
+ log.warn("Error discarding auth token: " + ex.getMessage());
+ log.debug("Error discarding auth token: " + ex.getMessage(), ex);
+ }
+ }
+ }
+
+ /**
+ * kills the provided auth token, aka Logout
+ *
+ * @param token
+ * @param endpoint
+ */
+ public void discardAuthToken(String token, String endpoint) {
+ if (token != null) {
+ try {
+ DiscardAuthToken discardAuthToken = new DiscardAuthToken();
+ discardAuthToken.setAuthInfo(token);
+ getUDDINode().getTransport().getUDDISecurityService(endpoint).discardAuthToken(discardAuthToken);
+ token = null;
+ } catch (Exception ex) {
+ log.warn("Error discarding auth token: " + ex.getMessage());
+ log.debug("Error discarding auth token: " + ex.getMessage(), ex);
+ }
+ }
+ }
+
+ /**
* Gets an auth token from the uddi server using the uddi auth token
* <br>
* Notice: never log auth tokens! Treat it like a password
@@ -1138,6 +1203,10 @@ public class UDDIClerk implements Serial
authToken = null;
}
if (authToken == null || "".equals(authToken)) {
+ if (getPublisher()==null || getPassword()==null){
+ log.warn("No credentials provided for login!");
+ return null;
+ }
tokenBirthDate = new Date();
GetAuthToken getAuthToken = new GetAuthToken();
getAuthToken.setUserID(getPublisher());
@@ -1319,7 +1388,7 @@ public class UDDIClerk implements Serial
* Used for the automated registration of services via WSDL2UDDI<br>
* config file: client.clerks.clerk(" + i + ").wsdl
*
- * @return
+ * @return
* @see WSDL2UDDI
*/
public WSDL[] getWsdls() {
@@ -1371,6 +1440,7 @@ public class UDDIClerk implements Serial
*/
public boolean setIsPasswordEncrypted() {
return this.isencrypted;
+
}
public class WSDL {
Modified: juddi/trunk/juddi-client/src/main/java/org/apache/juddi/v3/client/ext/wsdm/WSDMQosConstants.java
URL: http://svn.apache.org/viewvc/juddi/trunk/juddi-client/src/main/java/org/apache/juddi/v3/client/ext/wsdm/WSDMQosConstants.java?rev=1556671&r1=1556670&r2=1556671&view=diff
==============================================================================
--- juddi/trunk/juddi-client/src/main/java/org/apache/juddi/v3/client/ext/wsdm/WSDMQosConstants.java (original)
+++ juddi/trunk/juddi-client/src/main/java/org/apache/juddi/v3/client/ext/wsdm/WSDMQosConstants.java Wed Jan 8 23:34:32 2014
@@ -15,6 +15,9 @@
*/
package org.apache.juddi.v3.client.ext.wsdm;
+import java.util.ArrayList;
+import java.util.List;
+
/**
* Defines constants for OASIS's WSDM specification. Specifically tModels for
* use in UDDI
@@ -24,77 +27,95 @@ package org.apache.juddi.v3.client.ext.w
*/
public abstract class WSDMQosConstants {
- /**
- * This is the 'for more information' url for WSDM + UDDI
- */
- public static final String moreInfoUrl = "https://www.oasis-open.org/committees/download.php/6227/uddi-spec-tc-tn-QoS-metrics-20040224.doc";
- public static final String WSDM_KEYGEN = "urn:wsdm.org:keygenerator";
- public static final String WSDM_METRIC_KEYGEN = "urn:wsdm.org:metric:keygenerator";
- public static final String WSDM_IDENTITY_KEYGEN = "urn:wsdm.org:identity:keygenerator";
- public static final String WSDM_QOS_KEYGEN = "urn:wsdm.org:qos:keygenerator";
- /**
- * The number of requests to a given service. (number of requests)
- */
- public static final String METRIC_REQUEST_COUNT_KEY = "urn:wsdm.org:metric:requestcount";
- public static final String METRIC_RequestCount = "RequestCount";
- /**
- * The number of replies from a given service. (number of replies)
- */
- public static final String METRIC_REPLY_COUNT_KEY = "urn:wsdm.org:metric:replycount";
- public static final String METRIC_ReplyCount = "ReplyCount";
- /**
- * The number of faults from a given service. (number of faults)
- */
- public static final String METRIC_FAULT_COUNT_KEY = "urn:wsdm.org:metric:faultcount";
- public static final String METRIC_FaultCount = "FaultCount";
- /**
- * This is the unique identity by which the resource (service) is known to
- * the management system. It is useful for further queries. (resource
- * identification in URI format)
- */
- public static final String IDENTITY_RESOURCE_ID_KEY = "urn:wsdm.org:identity:resourceId";
- public static final String IDENTITY_ResourceId = "ResourceId";
- /**
- * Represents the last time this metric was updated. (time value)
- */
- public static final String METRIC_LAST_UPDATE_TIME_KEY = "urn:wsdm.org:metric:lastupdatetime";
- public static final String METRIC_LastUpdateTime = "LastUpdateTime";
- /**
- * Average response time of the service. (numeric value or symbolic rating)
- */
- public static final String QOS_RESPONSE_TIME_AVG_KEY = "urn:wsdm.org:qos:responsetime_average";
- public static final String QOS_ResponseTime_Average = "ResponseTime_Average";
- /**
- * Throughput count. (numeric value or symbolic rating)
- */
- public static final String QOS_THROUGHPUT_COUNT_KEY = "urn:wsdm.org:qos:throughput_count";
- public static final String QOS_Throughput_count = "Throughput_count";
- /**
- * Throughput bytes. (numeric value or symbolic rating)
- */
- public static final String QOS_THROUGHPUT_BYTES_KEY = "urn:wsdm.org:qos:throughput_bytes";
- public static final String QOS_Throughput_bytes = "Throughput_bytes";
- /**
- * Reliability or the measure of. (numeric value or symbolic rating)
- */
- public static final String QOS_RELIABILITY_KEY = "urn:wsdm.org:qos:reliability";
- public static final String QOS_Reliability = "Reliability";
- /**
- * The beginning on the reporting time period used for the information
- * above. (dateTime)
- */
- public static final String QOS_REPORTING_PERIOD_START_KEY = "urn:wsdm.org:qos:reportingperiodstart";
- public static final String QOS_ReportingPeriodStart = "ReportingPeriodStart";
- /**
- * The end of the reporting time period used for the information above.
- * (dateTime)
- */
- public static final String QOS_REPORTING_PERIOD_END_KEY = "urn:wsdm.org:qos:reportingperiodend";
- public static final String QOS_ReportingPeriodEnd = "ReportingPeriodEnd";
- /**
- * How often is this information updated in UDDI (it is not assumed to be
- * realtime). (duration)
- */
- public static final String QOS_UPDATE_INTERVAL_KEY = "urn:wsdm.org:qos:updateinterval";
- public static final String QOS_UpdateInterval = "UpdateInterval";
+ /**
+ * This is the 'for more information' url for WSDM + UDDI
+ */
+ public static final String moreInfoUrl = "https://www.oasis-open.org/committees/download.php/6227/uddi-spec-tc-tn-QoS-metrics-20040224.doc";
+ public static final String WSDM_KEYGEN = "urn:wsdm.org:keygenerator";
+ public static final String WSDM_METRIC_KEYGEN = "urn:wsdm.org:metric:keygenerator";
+ public static final String WSDM_IDENTITY_KEYGEN = "urn:wsdm.org:identity:keygenerator";
+ public static final String WSDM_QOS_KEYGEN = "urn:wsdm.org:qos:keygenerator";
+ /**
+ * The number of requests to a given service. (number of requests)
+ */
+ public static final String METRIC_REQUEST_COUNT_KEY = "urn:wsdm.org:metric:requestcount";
+ public static final String METRIC_RequestCount = "RequestCount";
+ /**
+ * The number of replies from a given service. (number of replies)
+ */
+ public static final String METRIC_REPLY_COUNT_KEY = "urn:wsdm.org:metric:replycount";
+ public static final String METRIC_ReplyCount = "ReplyCount";
+ /**
+ * The number of faults from a given service. (number of faults)
+ */
+ public static final String METRIC_FAULT_COUNT_KEY = "urn:wsdm.org:metric:faultcount";
+ public static final String METRIC_FaultCount = "FaultCount";
+ /**
+ * This is the unique identity by which the resource (service) is known
+ * to the management system. It is useful for further queries. (resource
+ * identification in URI format)
+ */
+ public static final String IDENTITY_RESOURCE_ID_KEY = "urn:wsdm.org:identity:resourceId";
+ public static final String IDENTITY_ResourceId = "ResourceId";
+ /**
+ * Represents the last time this metric was updated. (time value)
+ */
+ public static final String METRIC_LAST_UPDATE_TIME_KEY = "urn:wsdm.org:metric:lastupdatetime";
+ public static final String METRIC_LastUpdateTime = "LastUpdateTime";
+ /**
+ * Average response time of the service. (numeric value or symbolic
+ * rating)
+ */
+ public static final String QOS_RESPONSE_TIME_AVG_KEY = "urn:wsdm.org:qos:responsetime_average";
+ public static final String QOS_ResponseTime_Average = "ResponseTime_Average";
+ /**
+ * Throughput count. (numeric value or symbolic rating)
+ */
+ public static final String QOS_THROUGHPUT_COUNT_KEY = "urn:wsdm.org:qos:throughput_count";
+ public static final String QOS_Throughput_count = "Throughput_count";
+ /**
+ * Throughput bytes. (numeric value or symbolic rating)
+ */
+ public static final String QOS_THROUGHPUT_BYTES_KEY = "urn:wsdm.org:qos:throughput_bytes";
+ public static final String QOS_Throughput_bytes = "Throughput_bytes";
+ /**
+ * Reliability or the measure of. (numeric value or symbolic rating)
+ */
+ public static final String QOS_RELIABILITY_KEY = "urn:wsdm.org:qos:reliability";
+ public static final String QOS_Reliability = "Reliability";
+ /**
+ * The beginning on the reporting time period used for the information
+ * above. (dateTime)
+ */
+ public static final String QOS_REPORTING_PERIOD_START_KEY = "urn:wsdm.org:qos:reportingperiodstart";
+ public static final String QOS_ReportingPeriodStart = "ReportingPeriodStart";
+ /**
+ * The end of the reporting time period used for the information above.
+ * (dateTime)
+ */
+ public static final String QOS_REPORTING_PERIOD_END_KEY = "urn:wsdm.org:qos:reportingperiodend";
+ public static final String QOS_ReportingPeriodEnd = "ReportingPeriodEnd";
+ /**
+ * How often is this information updated in UDDI (it is not assumed to
+ * be realtime). (duration)
+ */
+ public static final String QOS_UPDATE_INTERVAL_KEY = "urn:wsdm.org:qos:updateinterval";
+ public static final String QOS_UpdateInterval = "UpdateInterval";
+
+ public static List<String> getAllQOSKeys() {
+ List<String> x = new ArrayList<String>();
+ x.add(WSDMQosConstants.METRIC_FAULT_COUNT_KEY);
+ x.add(WSDMQosConstants.METRIC_LAST_UPDATE_TIME_KEY);
+ x.add(WSDMQosConstants.METRIC_REPLY_COUNT_KEY);
+ x.add(WSDMQosConstants.METRIC_REQUEST_COUNT_KEY);
+ x.add(WSDMQosConstants.QOS_RELIABILITY_KEY);
+ x.add(WSDMQosConstants.QOS_REPORTING_PERIOD_END_KEY);
+ x.add(WSDMQosConstants.QOS_REPORTING_PERIOD_START_KEY);
+ x.add(WSDMQosConstants.QOS_RESPONSE_TIME_AVG_KEY);
+ x.add(WSDMQosConstants.QOS_THROUGHPUT_BYTES_KEY);
+ x.add(WSDMQosConstants.QOS_THROUGHPUT_COUNT_KEY);
+ x.add(WSDMQosConstants.QOS_UPDATE_INTERVAL_KEY);
+ x.add(WSDMQosConstants.IDENTITY_RESOURCE_ID_KEY);
+ return x;
+ }
}
Modified: juddi/trunk/juddi-client/src/main/java/org/apache/juddi/v3/client/mapping/wsdl/ReadWSDL.java
URL: http://svn.apache.org/viewvc/juddi/trunk/juddi-client/src/main/java/org/apache/juddi/v3/client/mapping/wsdl/ReadWSDL.java?rev=1556671&r1=1556670&r2=1556671&view=diff
==============================================================================
--- juddi/trunk/juddi-client/src/main/java/org/apache/juddi/v3/client/mapping/wsdl/ReadWSDL.java (original)
+++ juddi/trunk/juddi-client/src/main/java/org/apache/juddi/v3/client/mapping/wsdl/ReadWSDL.java Wed Jan 8 23:34:32 2014
@@ -29,6 +29,8 @@ import org.apache.commons.logging.LogFac
import org.apache.juddi.v3.client.ClassUtil;
import com.ibm.wsdl.factory.WSDLFactoryImpl;
+import java.io.File;
+import java.net.MalformedURLException;
/**
* A WSDL parser/reader
@@ -41,19 +43,29 @@ public class ReadWSDL {
private final Log log = LogFactory.getLog(this.getClass());
public Definition readWSDL(String fileName) throws WSDLException {
-
- Definition wsdlDefinition = null;
- WSDLFactory factory = WSDLFactoryImpl.newInstance();
- WSDLReader reader = factory.newWSDLReader();
- URL url = ClassUtil.getResource(fileName, this.getClass());
- try {
- URI uri = url.toURI();
- WSDLLocator locator = new WSDLLocatorImpl(uri);
- wsdlDefinition = reader.readWSDL(locator);
- } catch (URISyntaxException e) {
- log.error(e.getMessage(),e);
- }
- return wsdlDefinition;
+ Definition wsdlDefinition = null;
+ WSDLFactory factory = WSDLFactoryImpl.newInstance();
+ WSDLReader reader = factory.newWSDLReader();
+
+ try {
+ File f = new File(fileName);
+ URL url = null;
+ if (f.exists()) {
+ url = f.toURI().toURL();
+ } else {
+ url = ClassUtil.getResource(fileName, this.getClass());
+ }
+ if (url==null)
+ throw new WSDLException("null input", fileName);
+ URI uri = url.toURI();
+ WSDLLocator locator = new WSDLLocatorImpl(uri);
+ wsdlDefinition = reader.readWSDL(locator);
+ } catch (URISyntaxException e) {
+ log.error(e.getMessage(), e);
+ } catch (MalformedURLException ex) {
+ log.error(ex.getMessage(), ex);
+ }
+ return wsdlDefinition;
}
/**
Modified: juddi/trunk/juddi-examples/create-partition/src/main/java/org/apache/juddi/example/partition/SimpleCreateTmodelPartition.java
URL: http://svn.apache.org/viewvc/juddi/trunk/juddi-examples/create-partition/src/main/java/org/apache/juddi/example/partition/SimpleCreateTmodelPartition.java?rev=1556671&r1=1556670&r2=1556671&view=diff
==============================================================================
--- juddi/trunk/juddi-examples/create-partition/src/main/java/org/apache/juddi/example/partition/SimpleCreateTmodelPartition.java (original)
+++ juddi/trunk/juddi-examples/create-partition/src/main/java/org/apache/juddi/example/partition/SimpleCreateTmodelPartition.java Wed Jan 8 23:34:32 2014
@@ -89,6 +89,7 @@ public class SimpleCreateTmodelPartition
SimpleCreateTmodelPartition sp = new SimpleCreateTmodelPartition();
sp.TmodelsTheLongAndHardWay(args);
sp.TmodelsTheEasyWay(args);
+
uddiClient.stop();
}
@@ -97,7 +98,8 @@ public class SimpleCreateTmodelPartition
//This reads from the config file
UDDIClerk clerk = uddiClient.getClerk("defaultClerk");
- //Since the pass isn't set there, we have to provide it. Pist. it could be in the config file
+ //Since the password isn't set in the above config file, we have to provide it manually
+ //or thrown some fancy dialog box
clerk.setPublisher("uddi"); //username
clerk.setPassword("uddi"); //pass
@@ -124,6 +126,7 @@ public class SimpleCreateTmodelPartition
clerk.register(tm);
System.out.println("Creation of tModel Auth Mode Success!");
+ clerk.discardAuthToken();
} catch (Exception e) {
e.printStackTrace();
}
Modified: juddi/trunk/juddi-examples/hello-world-embedded/src/main/java/org/apache/juddi/example/helloworld/HelloWorld.java
URL: http://svn.apache.org/viewvc/juddi/trunk/juddi-examples/hello-world-embedded/src/main/java/org/apache/juddi/example/helloworld/HelloWorld.java?rev=1556671&r1=1556670&r2=1556671&view=diff
==============================================================================
--- juddi/trunk/juddi-examples/hello-world-embedded/src/main/java/org/apache/juddi/example/helloworld/HelloWorld.java (original)
+++ juddi/trunk/juddi-examples/hello-world-embedded/src/main/java/org/apache/juddi/example/helloworld/HelloWorld.java Wed Jan 8 23:34:32 2014
@@ -21,40 +21,55 @@ import org.apache.juddi.v3.client.config
import org.apache.juddi.v3.client.transport.Transport;
import org.uddi.v3_service.UDDISecurityPortType;
+/**
+ * This basic hello world example shows you how to sign into a UDDI server that
+ * supports the Security API to issue "auth tokens".
+ *
+ * The config loads from META-INF and uses INVM transport, meaning that you
+ * don't need a functioning UDDI server to use this. The jUDDI services in this
+ * case fire up in without any J2EE container. A database is still required,
+ * however by default it uses Derby, but any JPA database can be used
+ *
+ */
public class HelloWorld {
- private static UDDISecurityPortType security = null;
- public HelloWorld() {
- try {
- // create a client & server and read the config in the archive;
- // you can use your config file name
- UDDIClient uddiClient = new UDDIClient("META-INF/embedded-uddi.xml");
- // a UddiClient can be a client to multiple UDDI nodes, so
- // supply the nodeName (defined in your uddi.xml.
- // The transport can be WS, inVM, RMI etc which is defined in the uddi.xml
- Transport transport = uddiClient.getTransport("default");
- // Now you create a reference to the UDDI API
- security = transport.getUDDISecurityService();
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
-
- public void getAuthToken() {
- GetAuthToken getAuthToken = new GetAuthToken();
- getAuthToken.setUserID("root");
- getAuthToken.setCred("");
- try {
- AuthToken authToken = security.getAuthToken(getAuthToken);
- System.out.println ("AUTHTOKEN = "
- + authToken.getAuthInfo());
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
-
- public static void main (String args[]) {
- HelloWorld hw = new HelloWorld();
- hw.getAuthToken();
- }
+ private static UDDISecurityPortType security = null;
+
+ public HelloWorld() {
+ try {
+ // create a client & server and read the config in the archive;
+ // you can use your config file name
+ UDDIClient uddiClient = new UDDIClient("META-INF/embedded-uddi.xml");
+ // a UddiClient can be a client to multiple UDDI nodes, so
+ // supply the nodeName (defined in your uddi.xml.
+ // The transport can be WS, inVM, RMI etc which is defined in the uddi.xml
+ Transport transport = uddiClient.getTransport("default");
+ // Now you create a reference to the UDDI API
+ security = transport.getUDDISecurityService();
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+ public void getAuthToken() {
+ GetAuthToken getAuthToken = new GetAuthToken();
+ getAuthToken.setUserID("root");
+ getAuthToken.setCred("");
+ try {
+ AuthToken authToken = security.getAuthToken(getAuthToken);
+ System.out.println("Login successful!");
+ System.out.println("AUTHTOKEN = "
+ + "(don't log auth tokens!)");
+
+ security.discardAuthToken(new DiscardAuthToken(authToken.getAuthInfo()));
+ System.out.println("Logged out");
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+ public static void main(String args[]) {
+ HelloWorld hw = new HelloWorld();
+ hw.getAuthToken();
+ }
}
Modified: juddi/trunk/juddi-examples/hello-world/src/main/java/org/apache/juddi/example/helloworld/HelloWorld.java
URL: http://svn.apache.org/viewvc/juddi/trunk/juddi-examples/hello-world/src/main/java/org/apache/juddi/example/helloworld/HelloWorld.java?rev=1556671&r1=1556670&r2=1556671&view=diff
==============================================================================
--- juddi/trunk/juddi-examples/hello-world/src/main/java/org/apache/juddi/example/helloworld/HelloWorld.java (original)
+++ juddi/trunk/juddi-examples/hello-world/src/main/java/org/apache/juddi/example/helloworld/HelloWorld.java Wed Jan 8 23:34:32 2014
@@ -21,40 +21,53 @@ import org.apache.juddi.v3.client.config
import org.apache.juddi.v3.client.transport.Transport;
import org.uddi.v3_service.UDDISecurityPortType;
+/**
+ * This basic hello world example shows you how to sign into a UDDI server that
+ * supports the Security API to issue "auth tokens".
+ *
+ * The config loads from META-INF and uses JAXWS transport, meaning that you
+ * need a functioning UDDI server to use this
+ *
+ */
public class HelloWorld {
- private static UDDISecurityPortType security = null;
- public HelloWorld() {
- try {
+ private static UDDISecurityPortType security = null;
+
+ public HelloWorld() {
+ try {
// create a client and read the config in the archive;
- // you can use your config file name
- UDDIClient uddiClient = new UDDIClient("META-INF/hello-world-uddi.xml");
+ // you can use your config file name
+ UDDIClient uddiClient = new UDDIClient("META-INF/hello-world-uddi.xml");
// a UddiClient can be a client to multiple UDDI nodes, so
- // supply the nodeName (defined in your uddi.xml.
- // The transport can be WS, inVM, RMI etc which is defined in the uddi.xml
- Transport transport = uddiClient.getTransport();
- // Now you create a reference to the UDDI API
- security = transport.getUDDISecurityService();
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
+ // supply the nodeName (defined in your uddi.xml.
+ // The transport can be WS, inVM, RMI etc which is defined in the uddi.xml
+ Transport transport = uddiClient.getTransport();
+ // Now you create a reference to the UDDI API
+ security = transport.getUDDISecurityService();
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
- public void getAuthToken() {
- GetAuthToken getAuthToken = new GetAuthToken();
- getAuthToken.setUserID("root");
- getAuthToken.setCred("");
- try {
- AuthToken authToken = security.getAuthToken(getAuthToken);
- System.out.println ("AUTHTOKEN = "
- + authToken.getAuthInfo());
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
+ public void getAuthToken() {
+ GetAuthToken getAuthToken = new GetAuthToken();
+ getAuthToken.setUserID("root");
+ getAuthToken.setCred("");
+ try {
+ AuthToken authToken = security.getAuthToken(getAuthToken);
+ System.out.println("Login successful!");
+ System.out.println("AUTHTOKEN = "
+ + "(don't log auth tokens!)");
+
+ security.discardAuthToken(new DiscardAuthToken(authToken.getAuthInfo()));
+ System.out.println("Logged out");
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
- public static void main (String args[]) {
- HelloWorld hw = new HelloWorld();
- hw.getAuthToken();
- }
+ public static void main(String args[]) {
+ HelloWorld hw = new HelloWorld();
+ hw.getAuthToken();
+ }
}
Added: juddi/trunk/juddi-examples/more-uddi-samples/README.txt
URL: http://svn.apache.org/viewvc/juddi/trunk/juddi-examples/more-uddi-samples/README.txt?rev=1556671&view=auto
==============================================================================
--- juddi/trunk/juddi-examples/more-uddi-samples/README.txt (added)
+++ juddi/trunk/juddi-examples/more-uddi-samples/README.txt Wed Jan 8 23:34:32 2014
@@ -0,0 +1,12 @@
+This example is a command line demonstration of how to interact with JUDDI and how to use
+annotate items in UDDI for service or software versioning.
+
+1. Start the jUDDI-server (juddi-tomcat or juddi-bundle)
+
+2. Check the settings of the META-INF/simple-publish-uddi.xml, to make sure the serverName and serverPort are set correctly.
+
+Note: This is an interactive program. Do not run this from a headless server or from CI/Buildbot/Jenkisn
+
+3. mvn -Pinteractive
+
+Follow the onscreen prompts
\ No newline at end of file
Modified: juddi/trunk/juddi-examples/more-uddi-samples/pom.xml
URL: http://svn.apache.org/viewvc/juddi/trunk/juddi-examples/more-uddi-samples/pom.xml?rev=1556671&r1=1556670&r2=1556671&view=diff
==============================================================================
--- juddi/trunk/juddi-examples/more-uddi-samples/pom.xml (original)
+++ juddi/trunk/juddi-examples/more-uddi-samples/pom.xml Wed Jan 8 23:34:32 2014
@@ -28,4 +28,48 @@
<version>3.2.0-SNAPSHOT</version>
</dependency>
</dependencies>
+ <profiles>
+ <profile>
+ <id>default</id>
+ <activation>
+ <activeByDefault>true</activeByDefault>
+ </activation>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <configuration>
+ <skip>true</skip>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+ </profile>
+ <profile>
+ <id>interactive</id>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>exec-maven-plugin</artifactId>
+ <version>1.1.1</version>
+ <executions>
+ <execution>
+ <phase>test</phase>
+ <goals>
+ <goal>java</goal>
+ </goals>
+ <configuration>
+ <mainClass>org.apache.juddi.samples.EntryPoint</mainClass>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+ </profile>
+ </profiles>
+
+
</project>
Modified: juddi/trunk/juddi-examples/more-uddi-samples/src/main/java/org/apache/juddi/samples/BusinessServiceKeymismatch.java
URL: http://svn.apache.org/viewvc/juddi/trunk/juddi-examples/more-uddi-samples/src/main/java/org/apache/juddi/samples/BusinessServiceKeymismatch.java?rev=1556671&r1=1556670&r2=1556671&view=diff
==============================================================================
--- juddi/trunk/juddi-examples/more-uddi-samples/src/main/java/org/apache/juddi/samples/BusinessServiceKeymismatch.java (original)
+++ juddi/trunk/juddi-examples/more-uddi-samples/src/main/java/org/apache/juddi/samples/BusinessServiceKeymismatch.java Wed Jan 8 23:34:32 2014
@@ -38,7 +38,9 @@ import org.uddi.v3_service.UDDISecurityP
/**
* This class was created to demonstrate that UDDI entities's keys do not need
- * to be from the same key domain
+ * to be from the same key domain.
+ * I.e. Business key = "uddi:1234:business"
+ * which owns Service key "uddi:4567:service1"
*
* @author <a href="mailto:alexoree@apache.org">Alex O'Ree</a>
*/
Modified: juddi/trunk/juddi-examples/more-uddi-samples/src/main/java/org/apache/juddi/samples/CompareByTModelInstanceInfoQOS.java
URL: http://svn.apache.org/viewvc/juddi/trunk/juddi-examples/more-uddi-samples/src/main/java/org/apache/juddi/samples/CompareByTModelInstanceInfoQOS.java?rev=1556671&r1=1556670&r2=1556671&view=diff
==============================================================================
--- juddi/trunk/juddi-examples/more-uddi-samples/src/main/java/org/apache/juddi/samples/CompareByTModelInstanceInfoQOS.java (original)
+++ juddi/trunk/juddi-examples/more-uddi-samples/src/main/java/org/apache/juddi/samples/CompareByTModelInstanceInfoQOS.java Wed Jan 8 23:34:32 2014
@@ -15,13 +15,10 @@
*/
package org.apache.juddi.samples;
-import java.util.Properties;
import org.apache.juddi.api_v3.AccessPointType;
-import org.apache.juddi.jaxb.PrintUDDI;
import org.apache.juddi.v3.client.config.UDDIClient;
import org.apache.juddi.v3.client.ext.wsdm.WSDMQosConstants;
import org.apache.juddi.v3.client.compare.TModelInstanceDetailsComparator;
-import org.apache.juddi.v3_service.JUDDIApiPortType;
import org.uddi.api_v3.AccessPoint;
import org.uddi.api_v3.BindingTemplate;
import org.uddi.api_v3.BindingTemplates;
@@ -36,13 +33,8 @@ import org.uddi.api_v3.DiscoveryURLs;
import org.uddi.api_v3.InstanceDetails;
import org.uddi.api_v3.Name;
import org.uddi.api_v3.PersonName;
-import org.uddi.api_v3.SaveTModel;
-import org.uddi.api_v3.TModel;
import org.uddi.api_v3.TModelInstanceDetails;
import org.uddi.api_v3.TModelInstanceInfo;
-import org.uddi.v3_service.UDDIInquiryPortType;
-import org.uddi.v3_service.UDDIPublicationPortType;
-import org.uddi.v3_service.UDDISecurityPortType;
/**
*
@@ -50,32 +42,23 @@ import org.uddi.v3_service.UDDISecurityP
*/
public class CompareByTModelInstanceInfoQOS {
- static PrintUDDI<TModel> pTModel = new PrintUDDI<TModel>();
- static Properties properties = new Properties();
- static String wsdlURL = null;
- private static UDDISecurityPortType security = null;
- private static JUDDIApiPortType juddiApi = null;
- private static UDDIPublicationPortType publish = null;
- private static UDDIInquiryPortType inquiry;
-
-
public static void main(String[] args) throws Exception {
BusinessEntity mary = CreateMary();
BindingTemplate bt1 = mary.getBusinessServices().getBusinessService().get(0).getBindingTemplates().getBindingTemplate().get(0);
- BindingTemplate bt2 = mary.getBusinessServices().getBusinessService().get(1).getBindingTemplates().getBindingTemplate().get(1);
+ BindingTemplate bt2 = mary.getBusinessServices().getBusinessService().get(0).getBindingTemplates().getBindingTemplate().get(1);
TModelInstanceDetailsComparator tidc = new TModelInstanceDetailsComparator(WSDMQosConstants.METRIC_FAULT_COUNT_KEY, true, false, false);
int compare = tidc.compare(bt1.getTModelInstanceDetails(), bt2.getTModelInstanceDetails());
if (compare > 0)
- System.out.println(mary.getBusinessServices().getBusinessService().get(0).getName().get(0).getValue() +
- " is greater than " + mary.getBusinessServices().getBusinessService().get(1).getName().get(0).getValue());
+ System.out.println(mary.getBusinessServices().getBusinessService().get(0).getBindingTemplates().getBindingTemplate().get(0).getAccessPoint().getValue() +
+ " is greater than " + mary.getBusinessServices().getBusinessService().get(0).getBindingTemplates().getBindingTemplate().get(1).getAccessPoint().getValue());
if (compare < 0)
- System.out.println(mary.getBusinessServices().getBusinessService().get(0).getName().get(0).getValue() +
- " is less than " + mary.getBusinessServices().getBusinessService().get(1).getName().get(0).getValue());
+ System.out.println(mary.getBusinessServices().getBusinessService().get(0).getBindingTemplates().getBindingTemplate().get(0).getAccessPoint().getValue() +
+ " is less than " + mary.getBusinessServices().getBusinessService().get(0).getBindingTemplates().getBindingTemplate().get(1).getAccessPoint().getValue());
if (compare== 0)
- System.out.println(mary.getBusinessServices().getBusinessService().get(0).getName().get(0).getValue() +
- " is equal than " + mary.getBusinessServices().getBusinessService().get(1).getName().get(0).getValue());
+ System.out.println(mary.getBusinessServices().getBusinessService().get(0).getBindingTemplates().getBindingTemplate().get(0).getAccessPoint().getValue() +
+ " is equal to " + mary.getBusinessServices().getBusinessService().get(0).getBindingTemplates().getBindingTemplate().get(1).getAccessPoint().getValue());
}
@@ -139,11 +122,4 @@ public class CompareByTModelInstanceInfo
return be;
}
-
- private static void SaveTM(TModel createKeyGenator, String uddi) throws Exception {
- SaveTModel stm = new SaveTModel();
- stm.setAuthInfo(uddi);
- stm.getTModel().add(createKeyGenator);
- publish.saveTModel(stm);
- }
}
Modified: juddi/trunk/juddi-examples/more-uddi-samples/src/main/java/org/apache/juddi/samples/JuddiAdminService.java
URL: http://svn.apache.org/viewvc/juddi/trunk/juddi-examples/more-uddi-samples/src/main/java/org/apache/juddi/samples/JuddiAdminService.java?rev=1556671&r1=1556670&r2=1556671&view=diff
==============================================================================
--- juddi/trunk/juddi-examples/more-uddi-samples/src/main/java/org/apache/juddi/samples/JuddiAdminService.java (original)
+++ juddi/trunk/juddi-examples/more-uddi-samples/src/main/java/org/apache/juddi/samples/JuddiAdminService.java Wed Jan 8 23:34:32 2014
@@ -56,20 +56,16 @@ public class JuddiAdminService {
}
}
- public void go() {
+ public void go(String token) {
try {
// Setting up the values to get an authentication token for the 'root' user ('root' user has admin privileges
// and can save other publishers).
- GetAuthToken getAuthTokenRoot = new GetAuthToken();
- getAuthTokenRoot.setUserID("root");
- getAuthTokenRoot.setCred("root");
-
- // Making API call that retrieves the authentication token for the 'root' user.
- AuthToken rootAuthToken = security.getAuthToken(getAuthTokenRoot);
- System.out.println("root AUTHTOKEN = " + "***** don't log auth tokens");
+
+
+
SaveNode node = new SaveNode();
- node.setAuthInfo(rootAuthToken.getAuthInfo());
+ node.setAuthInfo(token);
Node n = new Node();
n.setClientName("juddicloud");
n.setName("juddicloud");
@@ -88,16 +84,12 @@ public class JuddiAdminService {
System.out.println("Before sending");
System.out.println(p.print(node));
juddi.saveNode(node);
- // clerk.saveNode(node);
+ System.out.println("Saved");
+
} catch (Exception e) {
e.printStackTrace();
}
}
-
- public static void main(String args[]) {
- JuddiAdminService sp = new JuddiAdminService();
- sp.go();
- }
}
Modified: juddi/trunk/juddi-examples/more-uddi-samples/src/main/java/org/apache/juddi/samples/SearchByQos.java
URL: http://svn.apache.org/viewvc/juddi/trunk/juddi-examples/more-uddi-samples/src/main/java/org/apache/juddi/samples/SearchByQos.java?rev=1556671&r1=1556670&r2=1556671&view=diff
==============================================================================
--- juddi/trunk/juddi-examples/more-uddi-samples/src/main/java/org/apache/juddi/samples/SearchByQos.java (original)
+++ juddi/trunk/juddi-examples/more-uddi-samples/src/main/java/org/apache/juddi/samples/SearchByQos.java Wed Jan 8 23:34:32 2014
@@ -70,261 +70,240 @@ import org.uddi.v3_service.UDDISecurityP
*/
public class SearchByQos {
- static PrintUDDI<TModel> pTModel = new PrintUDDI<TModel>();
- static Properties properties = new Properties();
- static String wsdlURL = null;
- private static UDDISecurityPortType security = null;
- private static JUDDIApiPortType juddiApi = null;
- private static UDDIPublicationPortType publish = null;
- private static UDDIInquiryPortType inquiry;
+ static PrintUDDI<TModel> pTModel = new PrintUDDI<TModel>();
+ static Properties properties = new Properties();
+ static String wsdlURL = null;
+ private static UDDISecurityPortType security = null;
+ private static JUDDIApiPortType juddiApi = null;
+ private static UDDIPublicationPortType publish = null;
+ private static UDDIInquiryPortType inquiry;
- static void doFindService() throws Exception {
+ public static void doFindService(String token) throws Exception {
// create a manager and read the config in the archive;
- // you can use your config file name
- UDDIClient clerkManager = new UDDIClient("META-INF/simple-publish-uddi.xml");
- Transport transport = clerkManager.getTransport();
- // Now you create a reference to the UDDI API
- security = transport.getUDDISecurityService();
- publish = transport.getUDDIPublishService();
- inquiry = transport.getUDDIInquiryService();
+ // you can use your config file name
+ UDDIClient clerkManager = new UDDIClient("META-INF/simple-publish-uddi.xml");
+ Transport transport = clerkManager.getTransport();
+ // Now you create a reference to the UDDI API
+ security = transport.getUDDISecurityService();
+ publish = transport.getUDDIPublishService();
+ inquiry = transport.getUDDIInquiryService();
//step one, get a token
- GetAuthToken getAuthTokenRoot = new GetAuthToken();
- getAuthTokenRoot.setUserID("uddi");
- getAuthTokenRoot.setCred("uddi");
+ //GetAuthToken getAuthTokenRoot = new GetAuthToken();
+ //getAuthTokenRoot.setUserID("uddi");
+ //getAuthTokenRoot.setCred("uddi");
// Making API call that retrieves the authentication token for the 'root' user.
- //String rootAuthToken = clerk.getAuthToken(clerk.getUDDINode().getSecurityUrl());
- String uddi = security.getAuthToken(getAuthTokenRoot).getAuthInfo();
+ //String rootAuthToken = clerk.getAuthToken(clerk.getUDDINode().getSecurityUrl());
+ String uddi = token;// security.getAuthToken(getAuthTokenRoot).getAuthInfo();
- System.out.println("killing mary's business if it exists");
- //first check is Mary's business exists and delete
- DeleteIfExists("uddi:uddi.marypublisher.com:marybusinessone", uddi);
-
- System.out.println("making mary's tmodel key gen");
- //make the key gen since our test case uses some custom keys
- TModel createKeyGenator = UDDIClerk.createKeyGenator("uddi.marypublisher.com", "mary key gen", "en");
- //clerk.register(createKeyGenator);
- System.out.println("saving...");
- SaveTM(createKeyGenator, uddi);
-
-
- System.out.println("fetching business list");
- ServiceList before = getServiceList(uddi);
- if (before.getServiceInfos()== null) {
- System.out.println("before no service returned!");
- before.setServiceInfos(new ServiceInfos());
- } else {
- System.out.println(before.getServiceInfos().getServiceInfo().size() + " service returned before");
- }
-
- System.out.println("saving mary");
- SaveMary(uddi);
+ System.out.println("killing mary's business if it exists");
+ //first check is Mary's business exists and delete
+ DeleteIfExists("uddi:uddi.marypublisher.com:marybusinessone", uddi);
+
+ System.out.println("making mary's tmodel key gen");
+ //make the key gen since our test case uses some custom keys
+ TModel createKeyGenator = UDDIClerk.createKeyGenator("uddi.marypublisher.com", "mary key gen", "en");
+ //clerk.register(createKeyGenator);
+ System.out.println("saving...");
+ SaveTM(createKeyGenator, uddi);
+
+ System.out.println("fetching business list");
+ ServiceList before = getServiceList(uddi);
+ if (before.getServiceInfos() == null) {
+ System.out.println("before no service returned!");
+ before.setServiceInfos(new ServiceInfos());
+ } else {
+ System.out.println(before.getServiceInfos().getServiceInfo().size() + " service returned before");
+ }
+
+ System.out.println("saving mary");
+ SaveMary(uddi);
+
+ ServiceList after = getServiceList(uddi);
+ if (after.getServiceInfos().getServiceInfo() == null) {
+ System.out.println("after no service returned!");
+ after.setServiceInfos(new ServiceInfos());
+ return;
+ } else {
+ System.out.println(after.getServiceInfos().getServiceInfo().size() + " service returned after");
+ }
+ PrintUDDI<ServiceList> p = new PrintUDDI<ServiceList>();
+ if (before.getServiceInfos().getServiceInfo().size()
+ < after.getServiceInfos().getServiceInfo().size()) {
+ System.out.println("hey it worked as advertised. Here's all the services with QOS parameters");
+ System.out.println(p.print(after));
+ } else {
+
+ System.out.println("something's not right, here's the before service listing");
+ System.out.println(p.print(before));
+ System.out.println(p.print(after));
+ }
- ServiceList after = getServiceList(uddi);
- if (after.getServiceInfos().getServiceInfo()== null) {
- System.out.println("after no service returned!");
- after.setServiceInfos(new ServiceInfos());
- } else {
- System.out.println(after.getServiceInfos().getServiceInfo().size() + " service returned after");
}
- PrintUDDI<ServiceList> p = new PrintUDDI<ServiceList>();
- if (before.getServiceInfos().getServiceInfo().size()
- < after.getServiceInfos().getServiceInfo().size()) {
- System.out.println("hey it worked as advertised, double checking");
- /*if (CheckFor(after, "uddi:uddi.marypublisher.com:marybusinessone")) {
- System.out.println("ok!");
- } else {
- System.out.println("no good!");
- }*/
- } else {
-
- System.out.println("something's not right, here's the before service listing");
- System.out.println(p.print(before));
- System.out.println(p.print(after));
- }
-
- }
- static void doFindBinding() throws Exception{
+ public static void doFindBinding(String token) throws Exception {
// create a manager and read the config in the archive;
- // you can use your config file name
- UDDIClient clerkManager = new UDDIClient("META-INF/simple-publish-uddi.xml");
- Transport transport = clerkManager.getTransport();
- // Now you create a reference to the UDDI API
- security = transport.getUDDISecurityService();
- publish = transport.getUDDIPublishService();
- inquiry = transport.getUDDIInquiryService();
+ // you can use your config file name
+ UDDIClient clerkManager = new UDDIClient("META-INF/simple-publish-uddi.xml");
+ Transport transport = clerkManager.getTransport();
+ // Now you create a reference to the UDDI API
+ security = transport.getUDDISecurityService();
+ publish = transport.getUDDIPublishService();
+ inquiry = transport.getUDDIInquiryService();
//step one, get a token
- GetAuthToken getAuthTokenRoot = new GetAuthToken();
- getAuthTokenRoot.setUserID("uddi");
- getAuthTokenRoot.setCred("uddi");
+ // GetAuthToken getAuthTokenRoot = new GetAuthToken();
+ //getAuthTokenRoot.setUserID("uddi");
+ //getAuthTokenRoot.setCred("uddi");
// Making API call that retrieves the authentication token for the 'root' user.
- //String rootAuthToken = clerk.getAuthToken(clerk.getUDDINode().getSecurityUrl());
- String uddi = security.getAuthToken(getAuthTokenRoot).getAuthInfo();
+ //String rootAuthToken = clerk.getAuthToken(clerk.getUDDINode().getSecurityUrl());
+ String uddi = token;//security.getAuthToken(getAuthTokenRoot).getAuthInfo();
- System.out.println("killing mary's business if it exists");
- //first check is Mary's business exists and delete
- DeleteIfExists("uddi:uddi.marypublisher.com:marybusinessone", uddi);
-
- System.out.println("making mary's tmodel key gen");
- //make the key gen since our test case uses some custom keys
- TModel createKeyGenator = UDDIClerk.createKeyGenator("uddi.marypublisher.com", "mary key gen", "en");
- //clerk.register(createKeyGenator);
- System.out.println("saving...");
- SaveTM(createKeyGenator, uddi);
-
-
- System.out.println("fetching business list");
- BindingDetail before = getBindingList(uddi);
- if (before.getBindingTemplate() == null) {
- System.out.println("before no service returned!");
- // before.setServiceInfos(new ServiceInfos());
- } else {
- System.out.println(before.getBindingTemplate().size() + " service returned before");
- }
-
- System.out.println("saving mary");
- SaveMary(uddi);
-
- BindingDetail after = getBindingList(uddi);
- if (after.getBindingTemplate() == null) {
- System.out.println("after no service returned!");
- //after.setServiceInfos(new ServiceInfos());
- } else {
- System.out.println(after.getBindingTemplate().size() + " service returned after");
- }
- PrintUDDI<BindingDetail> p = new PrintUDDI<BindingDetail>();
- if (before.getBindingTemplate().size()
- < after.getBindingTemplate().size()) {
- System.out.println("hey it worked as advertised, double checking");
- /*if (CheckFor(after, "uddi:uddi.marypublisher.com:marybusinessone")) {
- System.out.println("ok!");
- } else {
- System.out.println("no good!");
- }*/
- } else {
-
- System.out.println("something's not right, here's the before service listing");
- System.out.println(p.print(before));
- System.out.println(p.print(after));
+ System.out.println("killing mary's business if it exists");
+ //first check is Mary's business exists and delete
+ DeleteIfExists("uddi:uddi.marypublisher.com:marybusinessone", uddi);
+
+ System.out.println("making mary's tmodel key gen");
+ //make the key gen since our test case uses some custom keys
+ TModel createKeyGenator = UDDIClerk.createKeyGenator("uddi.marypublisher.com", "mary key gen", "en");
+ //clerk.register(createKeyGenator);
+ System.out.println("saving...");
+ SaveTM(createKeyGenator, uddi);
+
+ System.out.println("fetching business list");
+ BindingDetail before = getBindingList(uddi);
+ if (before.getBindingTemplate() == null) {
+ System.out.println("before no service returned!");
+ // before.setServiceInfos(new ServiceInfos());
+ } else {
+ System.out.println(before.getBindingTemplate().size() + " service returned before");
+ }
+
+ System.out.println("saving mary");
+ SaveMary(uddi);
+
+ BindingDetail after = getBindingList(uddi);
+ if (after.getBindingTemplate() == null) {
+ System.out.println("after no service returned!");
+ //after.setServiceInfos(new ServiceInfos());
+ } else {
+ System.out.println(after.getBindingTemplate().size() + " service returned after");
+ }
+ PrintUDDI<BindingDetail> p = new PrintUDDI<BindingDetail>();
+ if (before.getBindingTemplate().size()
+ < after.getBindingTemplate().size()) {
+ System.out.println("hey it worked as advertised. Here's all the bindings with QOS parameters");
+ System.out.println(p.print(after));
+
+ } else {
+
+ System.out.println("something's not right, here's the before service listing");
+ System.out.println(p.print(before));
+ System.out.println(p.print(after));
+ }
+
+ }
+
+ private static void DeleteIfExists(String key, String authInfo) {
+ GetBusinessDetail gbd = new GetBusinessDetail();
+ gbd.setAuthInfo(authInfo);
+ gbd.getBusinessKey().add(key);
+ boolean found = false;
+ try {
+ BusinessDetail businessDetail = inquiry.getBusinessDetail(gbd);
+ if (businessDetail != null
+ && !businessDetail.getBusinessEntity().isEmpty()
+ && businessDetail.getBusinessEntity().get(0).getBusinessKey().equals(key)) {
+ found = true;
+ }
+ } catch (Exception ex) {
+ }
+ if (found) {
+ DeleteBusiness db = new DeleteBusiness();
+ db.setAuthInfo(authInfo);
+ db.getBusinessKey().add(key);
+ try {
+ publish.deleteBusiness(db);
+ } catch (Exception ex) {
+ Logger.getLogger(FindBusinessBugHunt.class.getName()).log(Level.SEVERE, null, ex);
+ }
+ }
+ }
+
+ private static ServiceList getServiceList(String token) throws Exception {
+ FindService fb = new FindService();
+ fb.setAuthInfo(token);
+ org.uddi.api_v3.FindQualifiers fq = new org.uddi.api_v3.FindQualifiers();
+ fq.getFindQualifier().add(UDDIConstants.APPROXIMATE_MATCH);
+ fq.getFindQualifier().add(UDDIConstants.OR_ALL_KEYS);
+ fb.setFindQualifiers(fq);
+ fb.getName().add((new Name(UDDIConstants.WILDCARD, null)));
+
+ fb.setTModelBag(new TModelBag());
+ fb.getTModelBag().getTModelKey().addAll(WSDMQosConstants.getAllQOSKeys());
+
+ return inquiry.findService(fb);
+ }
+
+ private static BindingDetail getBindingList(String token) throws Exception {
+ FindBinding fb = new FindBinding();
+ fb.setAuthInfo(token);
+ fb.setTModelBag(new TModelBag());
+ fb.getTModelBag().getTModelKey().add(WSDMQosConstants.METRIC_FAULT_COUNT_KEY);
+ return inquiry.findBinding(fb);
+ }
+
+ /**
+ * -
+ * adds a business, service, bt with tmodel instance details with qos
+ * parameters
+ *
+ * @param rootAuthToken
+ * @throws Exception
+ */
+ private static void SaveMary(String rootAuthToken) throws Exception {
+ BusinessEntity be = new BusinessEntity();
+ be.setBusinessKey("uddi:uddi.marypublisher.com:marybusinessone");
+ be.setDiscoveryURLs(new DiscoveryURLs());
+ be.getDiscoveryURLs().getDiscoveryURL().add(new DiscoveryURL("home", "http://www.marybusinessone.com"));
+ be.getDiscoveryURLs().getDiscoveryURL().add(new DiscoveryURL("serviceList", "http://www.marybusinessone.com/services"));
+ be.getName().add(new Name("Mary Doe Enterprises", "en"));
+ be.getName().add(new Name("Maria Negocio Uno", "es"));
+ be.getDescription().add(new Description("This is the description for Mary Business One.", "en"));
+ be.setContacts(new Contacts());
+ Contact c = new Contact();
+ c.setUseType("administrator");
+ c.getPersonName().add(new PersonName("Mary Doe", "en"));
+ c.getPersonName().add(new PersonName("Juan Doe", "es"));
+ c.getDescription().add(new Description("This is the administrator of the service offerings.", "en"));
+ be.getContacts().getContact().add(c);
+ be.setBusinessServices(new BusinessServices());
+ BusinessService bs = new BusinessService();
+ bs.setBusinessKey("uddi:uddi.marypublisher.com:marybusinessone");
+ bs.setServiceKey("uddi:uddi.marypublisher.com:marybusinessoneservice");
+ bs.getName().add(new Name("name!", "en"));
+ bs.setBindingTemplates(new BindingTemplates());
+ BindingTemplate bt = new BindingTemplate();
+ bt.setAccessPoint(new AccessPoint("http://localhost", AccessPointType.WSDL_DEPLOYMENT.toString()));
+ bt.setTModelInstanceDetails(new TModelInstanceDetails());
+ TModelInstanceInfo tii = new TModelInstanceInfo();
+ tii.setTModelKey(WSDMQosConstants.METRIC_FAULT_COUNT_KEY);
+ tii.setInstanceDetails(new InstanceDetails());
+ tii.getInstanceDetails().setInstanceParms("400");
+ bt = UDDIClient.addSOAPtModels(bt);
+ bt.getTModelInstanceDetails().getTModelInstanceInfo().add(tii);
+ bs.getBindingTemplates().getBindingTemplate().add(bt);
+ be.getBusinessServices().getBusinessService().add(bs);
+ SaveBusiness sb = new SaveBusiness();
+ sb.setAuthInfo(rootAuthToken);
+ sb.getBusinessEntity().add(be);
+ publish.saveBusiness(sb);
+ }
+
+ private static void SaveTM(TModel createKeyGenator, String uddi) throws Exception {
+ SaveTModel stm = new SaveTModel();
+ stm.setAuthInfo(uddi);
+ stm.getTModel().add(createKeyGenator);
+ publish.saveTModel(stm);
}
-
- }
-
- public static void main(String[] args) throws Exception {
- doFindBinding();
-
- doFindService();
- }
-
- private static void DeleteIfExists(String key, String authInfo) {
- GetBusinessDetail gbd = new GetBusinessDetail();
- gbd.setAuthInfo(authInfo);
- gbd.getBusinessKey().add(key);
- boolean found = false;
- try {
- BusinessDetail businessDetail = inquiry.getBusinessDetail(gbd);
- if (businessDetail != null
- && !businessDetail.getBusinessEntity().isEmpty()
- && businessDetail.getBusinessEntity().get(0).getBusinessKey().equals(key)) {
- found = true;
- }
- } catch (Exception ex) {
- }
- if (found) {
- DeleteBusiness db = new DeleteBusiness();
- db.setAuthInfo(authInfo);
- db.getBusinessKey().add(key);
- try {
- publish.deleteBusiness(db);
- } catch (Exception ex) {
- Logger.getLogger(FindBusinessBugHunt.class.getName()).log(Level.SEVERE, null, ex);
- }
- }
- }
-
- private static ServiceList getServiceList(String token) throws Exception {
- FindService fb = new FindService();
- fb.setAuthInfo(token);
- org.uddi.api_v3.FindQualifiers fq = new org.uddi.api_v3.FindQualifiers();
- fq.getFindQualifier().add(UDDIConstants.APPROXIMATE_MATCH);
- fb.setFindQualifiers(fq);
- fb.getName().add((new Name(UDDIConstants.WILDCARD, null)));
-
- fb.setTModelBag(new TModelBag());
- fb.getTModelBag().getTModelKey().add(WSDMQosConstants.METRIC_FAULT_COUNT_KEY);
- return inquiry.findService(fb);
- }
-
- private static BindingDetail getBindingList(String token) throws Exception {
- FindBinding fb = new FindBinding();
- fb.setAuthInfo(token);
- fb.setTModelBag(new TModelBag());
- fb.getTModelBag().getTModelKey().add(WSDMQosConstants.METRIC_FAULT_COUNT_KEY);
- return inquiry.findBinding(fb);
- }
-
- /**
- * adds a business, service, bt with tmodel instance details with qos
- * parameters
- *
- * @param rootAuthToken
- * @throws Exception
- */
- private static void SaveMary(String rootAuthToken) throws Exception {
- BusinessEntity be = new BusinessEntity();
- be.setBusinessKey("uddi:uddi.marypublisher.com:marybusinessone");
- be.setDiscoveryURLs(new DiscoveryURLs());
- be.getDiscoveryURLs().getDiscoveryURL().add(new DiscoveryURL("home", "http://www.marybusinessone.com"));
- be.getDiscoveryURLs().getDiscoveryURL().add(new DiscoveryURL("serviceList", "http://www.marybusinessone.com/services"));
- be.getName().add(new Name("Mary Doe Enterprises", "en"));
- be.getName().add(new Name("Maria Negocio Uno", "es"));
- be.getDescription().add(new Description("This is the description for Mary Business One.", "en"));
- be.setContacts(new Contacts());
- Contact c = new Contact();
- c.setUseType("administrator");
- c.getPersonName().add(new PersonName("Mary Doe", "en"));
- c.getPersonName().add(new PersonName("Juan Doe", "es"));
- c.getDescription().add(new Description("This is the administrator of the service offerings.", "en"));
- be.getContacts().getContact().add(c);
- be.setBusinessServices(new BusinessServices());
- BusinessService bs = new BusinessService();
- bs.setBusinessKey("uddi:uddi.marypublisher.com:marybusinessone");
- bs.setServiceKey("uddi:uddi.marypublisher.com:marybusinessoneservice");
- bs.getName().add(new Name("name!", "en"));
- bs.setBindingTemplates(new BindingTemplates());
- BindingTemplate bt = new BindingTemplate();
- bt.setAccessPoint(new AccessPoint("http://localhost", AccessPointType.WSDL_DEPLOYMENT.toString()));
- bt.setTModelInstanceDetails(new TModelInstanceDetails());
- TModelInstanceInfo tii = new TModelInstanceInfo();
- tii.setTModelKey(WSDMQosConstants.METRIC_FAULT_COUNT_KEY);
-
- tii.setInstanceDetails(new InstanceDetails());
- tii.getInstanceDetails().setInstanceParms("400");
- bt = UDDIClient.addSOAPtModels(bt);
- bt.getTModelInstanceDetails().getTModelInstanceInfo().add(tii);
- bs.getBindingTemplates().getBindingTemplate().add(bt);
- be.getBusinessServices().getBusinessService().add(bs);
- SaveBusiness sb = new SaveBusiness();
- sb.setAuthInfo(rootAuthToken);
- sb.getBusinessEntity().add(be);
- publish.saveBusiness(sb);
- }
-
- private static boolean CheckFor(ServiceList list, String key) {
- for (int i = 0; i < list.getServiceInfos().getServiceInfo().size(); i++) {
- if (list.getServiceInfos().getServiceInfo().get(i).getServiceKey().equalsIgnoreCase(key)) {
- return true;
- }
- }
- return false;
- }
-
- private static void SaveTM(TModel createKeyGenator, String uddi) throws Exception {
- SaveTModel stm = new SaveTModel();
- stm.setAuthInfo(uddi);
- stm.getTModel().add(createKeyGenator);
- publish.saveTModel(stm);
- }
}
Modified: juddi/trunk/juddi-examples/more-uddi-samples/src/main/java/org/apache/juddi/samples/SubscriptionCallbackExample.java
URL: http://svn.apache.org/viewvc/juddi/trunk/juddi-examples/more-uddi-samples/src/main/java/org/apache/juddi/samples/SubscriptionCallbackExample.java?rev=1556671&r1=1556670&r2=1556671&view=diff
==============================================================================
--- juddi/trunk/juddi-examples/more-uddi-samples/src/main/java/org/apache/juddi/samples/SubscriptionCallbackExample.java (original)
+++ juddi/trunk/juddi-examples/more-uddi-samples/src/main/java/org/apache/juddi/samples/SubscriptionCallbackExample.java Wed Jan 8 23:34:32 2014
@@ -19,14 +19,13 @@ package org.apache.juddi.samples;
import java.util.ArrayList;
import java.util.List;
import javax.xml.ws.Holder;
+import org.apache.juddi.jaxb.PrintUDDI;
import org.apache.juddi.v3.client.UDDIConstants;
import org.apache.juddi.v3.client.config.UDDIClerk;
import org.apache.juddi.v3.client.config.UDDIClient;
-import org.apache.juddi.v3.client.config.UDDIClientContainer;
import org.apache.juddi.v3.client.subscription.ISubscriptionCallback;
import org.apache.juddi.v3.client.subscription.SubscriptionCallbackListener;
import org.apache.juddi.v3.client.transport.Transport;
-import org.apache.juddi.v3_service.JUDDIApiPortType;
import org.uddi.api_v3.*;
import org.uddi.sub_v3.DeleteSubscription;
import org.uddi.sub_v3.Subscription;
@@ -38,90 +37,107 @@ import org.uddi.v3_service.UDDISecurityP
import org.uddi.v3_service.UDDISubscriptionPortType;
/**
- * This class shows you how to find an endpoint by searching through all
- * services
+ * This class shows you how to use the client side Subscription callback
+ * interface which fires up an embedded jetty server hosting a callback web
+ * service. It also automates most of the subscription management work.
*
* @author <a href="mailto:alexoree@apache.org">Alex O'Ree</a>
*/
-public class SubscriptionCallbackExample implements ISubscriptionCallback {
+public class SubscriptionCallbackExample implements ISubscriptionCallback, Runnable {
- private static UDDISecurityPortType security = null;
- private static JUDDIApiPortType juddiApi = null;
- private static UDDIPublicationPortType publish = null;
- private static UDDIInquiryPortType inquiry = null;
- private static UDDIClient c = null;
- private static UDDISubscriptionPortType subscription = null;
- private static UDDIClerk clerk = null;
-
- public SubscriptionCallbackExample() {
- try {
-
- c = new UDDIClient("META-INF/simple-publish-uddi.xml");
- c.start();
- clerk = c.getClerk("default");
- TModel createKeyGenator = UDDIClerk.createKeyGenator("uddi:org.apache.juddi:test:keygenerator", "Test domain", "en");
- clerk.register(createKeyGenator);
- Transport transport = c.getTransport();
- // Now you create a reference to the UDDI API
- security = transport.getUDDISecurityService();
- juddiApi = transport.getJUDDIApiService();
- publish = transport.getUDDIPublishService();
- inquiry = transport.getUDDIInquiryService();
- subscription = transport.getUDDISubscriptionService();
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
-
- public static void main(String args[]) throws Exception {
- SubscriptionCallbackExample sp = new SubscriptionCallbackExample();
- //this will fireup a jetty server and host a UDDI Subscription callback Listener service
- //and register it per the config file
- BindingTemplate start = SubscriptionCallbackListener.start(c, "default");
-
- //register our code for the callback part
- SubscriptionCallbackListener.registerCallback(sp);
-
- //login
- String token = clerk.getAuthToken(clerk.getUDDINode().getSecurityUrl());
-
- //Set up a subscription using the 'start' BindingTemplate
- Holder<List<Subscription>> subs = new Holder<List<Subscription>>();
- subs.value = new ArrayList<Subscription>();
- Subscription s = new Subscription();
- s.setBindingKey(start.getBindingKey());
- s.setBrief(false);
- s.setSubscriptionFilter(new SubscriptionFilter());
- s.getSubscriptionFilter().setFindBusiness(new FindBusiness());
- s.getSubscriptionFilter().getFindBusiness().getName().add(new Name(UDDIConstants.WILDCARD, null));
- s.getSubscriptionFilter().getFindBusiness().setFindQualifiers(new FindQualifiers());
- s.getSubscriptionFilter().getFindBusiness().getFindQualifiers().getFindQualifier().add(UDDIConstants.APPROXIMATE_MATCH);
- subs.value.add(s);
-
- //save the subscription
- subscription.saveSubscription(token, subs);
-
- //Do some useful activities here, perhap something to trigger the callback
- Thread.sleep(1000);
-
- //stop and unregister the callback when we're done
- SubscriptionCallbackListener.stop(c, "default", start.getBindingKey());
-
- //clean up the subscription
- DeleteSubscription ds = new DeleteSubscription();
- ds.setAuthInfo(token);
- ds.getSubscriptionKey().add(subs.value.get(0).getSubscriptionKey());
- subscription.deleteSubscription(ds);
- }
-
- @Override
- public void HandleCallback(SubscriptionResultsList body) {
- System.out.println("callback received");
- }
+ private static UDDISecurityPortType security = null;
- @Override
- public void NotifyEndpointStopped() {
+ private static UDDIPublicationPortType publish = null;
+ private static UDDIInquiryPortType inquiry = null;
+ private static UDDIClient c = null;
+ private static UDDISubscriptionPortType subscription = null;
+ private static UDDIClerk clerk = null;
+
+ public SubscriptionCallbackExample() {
+ try {
+
+ c = new UDDIClient("META-INF/simple-publish-uddi.xml");
+ c.start();
+ clerk = c.getClerk("default");
+ //!IMPORTANT, this is needed so that the Subscription listener endpoint can register itself correctly
+ TModel createKeyGenator = UDDIClerk.createKeyGenator("uddi:org.apache.juddi:test:keygenerator", "Test domain", "en");
+ clerk.register(createKeyGenator);
+ Transport transport = c.getTransport();
+ // Now you create a reference to the UDDI API
+ security = transport.getUDDISecurityService();
+ publish = transport.getUDDIPublishService();
+ inquiry = transport.getUDDIInquiryService();
+ subscription = transport.getUDDISubscriptionService();
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+ public void Fire() throws Exception {
+
+ //this will fireup a jetty server and host a UDDI Subscription callback Listener service
+ //and register it per the config file
+ BindingTemplate start = SubscriptionCallbackListener.start(c, "default");
+
+ //register our code for the callback part
+ SubscriptionCallbackListener.registerCallback(this);
+
+ //login
+ //credentials come from the config file
+ String token = clerk.getAuthToken(clerk.getUDDINode().getSecurityUrl());
+
+ //Set up a subscription using the 'start' BindingTemplate
+ Holder<List<Subscription>> subs = new Holder<List<Subscription>>();
+ subs.value = new ArrayList<Subscription>();
+ Subscription s = new Subscription();
+ s.setBindingKey(start.getBindingKey());
+ s.setBrief(false);
+ s.setSubscriptionFilter(new SubscriptionFilter());
+ s.getSubscriptionFilter().setFindBusiness(new FindBusiness());
+ s.getSubscriptionFilter().getFindBusiness().getName().add(new Name(UDDIConstants.WILDCARD, null));
+ s.getSubscriptionFilter().getFindBusiness().setFindQualifiers(new FindQualifiers());
+ s.getSubscriptionFilter().getFindBusiness().getFindQualifiers().getFindQualifier().add(UDDIConstants.APPROXIMATE_MATCH);
+ subs.value.add(s);
+
+ //save the subscription
+ subscription.saveSubscription(token, subs);
+
+ Runtime.getRuntime().addShutdownHook(new Thread(this));
+ //Do some useful activities here, perhap something to trigger the callback
+ System.out.println("Running and waiting for changes, press Ctrl-C to break!");
+ while (running) {
+ Thread.sleep(1000);
+ }
+ //stop and unregister the callback when we're done
+ SubscriptionCallbackListener.stop(c, "default", start.getBindingKey());
+
+ //clean up the subscription
+ DeleteSubscription ds = new DeleteSubscription();
+ ds.setAuthInfo(token);
+ ds.getSubscriptionKey().add(subs.value.get(0).getSubscriptionKey());
+ subscription.deleteSubscription(ds);
+ }
+ boolean running = true;
+
+ public static void main(String args[]) throws Exception {
+ new SubscriptionCallbackExample().Fire();
+ }
- System.out.println("stopped");
- }
+ @Override
+ public void HandleCallback(SubscriptionResultsList body) {
+ System.out.println("callback received");
+ System.out.println(new PrintUDDI<SubscriptionResultsList>().print(body));
+ }
+
+ @Override
+ public void NotifyEndpointStopped() {
+
+ System.out.println("stopped");
+ }
+
+ @Override
+ public void run() {
+ System.out.println("Break signal caught!");
+ running = false;
+ }
}
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@juddi.apache.org
For additional commands, e-mail: commits-help@juddi.apache.org