Skip to content
Permalink
Browse files
JUDDI-931 CLI client
  • Loading branch information
spyhunter99 committed Mar 27, 2015
1 parent bcd3c07 commit 9dafe4e83e9068c2ce8afc8869ed433be885dde7
Showing 41 changed files with 6,941 additions and 31 deletions.
@@ -0,0 +1,6 @@
target
**/target/*
**/derby.log
**/.project
**/.classpath
**/.settings/*
@@ -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/Jenkins

3. mvn clean install -Pinteractive

Follow the onscreen prompts
Binary file not shown.
@@ -0,0 +1,139 @@
<?xml version="1.0"?>
<!--
* 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.
*
*/ -->
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.apache.juddi</groupId>
<artifactId>juddi-parent</artifactId>
<version>3.3.0-SNAPSHOT</version>
</parent>
<groupId>org.apache.juddi</groupId>
<artifactId>juddi-client-cli</artifactId>
<version>3.3.0-SNAPSHOT</version>
<packaging>bundle</packaging>

<name>jUDDI CLI Client</name>
<url>http://maven.apache.org</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.11</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>juddi-client</artifactId>
<version>${project.parent.version}</version>
</dependency>
<!-- a lorem ipsum generator MIT license-->
<dependency>
<groupId>de.sven-jacobs</groupId>
<artifactId>loremipsum</artifactId>
<version>1.0</version>
</dependency>
<dependency>
<groupId>commons-cli</groupId>
<artifactId>commons-cli</artifactId>
<version>1.2</version>
</dependency>


</dependencies>
<build>
<plugins>
<!-- examples are not very useful from a maven repo, so don't put it there -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-deploy-plugin</artifactId>
<configuration>
<skip>true</skip>
</configuration>
</plugin>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<configuration>
<archive>
<manifest>
<mainClass>org.apache.juddi.samples.EntryPoint</mainClass>
</manifest>
</archive>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
</configuration>
<executions>
<execution>
<id>make-assembly</id> <!-- this is used for inheritance merges -->
<phase>package</phase> <!-- bind to the packaging phase -->
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
<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>
@@ -0,0 +1,125 @@
/*
* Copyright 2013 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.cli;

import org.apache.juddi.api_v3.AccessPointType;
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.uddi.api_v3.AccessPoint;
import org.uddi.api_v3.BindingTemplate;
import org.uddi.api_v3.BindingTemplates;
import org.uddi.api_v3.BusinessEntity;
import org.uddi.api_v3.BusinessService;
import org.uddi.api_v3.BusinessServices;
import org.uddi.api_v3.Contact;
import org.uddi.api_v3.Contacts;
import org.uddi.api_v3.Description;
import org.uddi.api_v3.DiscoveryURL;
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.TModelInstanceDetails;
import org.uddi.api_v3.TModelInstanceInfo;

/**
* doesn't make changes to a remote server, just creates a few businesses and compares the two by qos parameters
* @author Alex O'Ree
*/
public class CompareByTModelInstanceInfoQOS {


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(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).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).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).getBindingTemplates().getBindingTemplate().get(0).getAccessPoint().getValue() +
" is equal to " + mary.getBusinessServices().getBusinessService().get(0).getBindingTemplates().getBindingTemplate().get(1).getAccessPoint().getValue());

}



/**
* creates a business, service, bt with tmodel instance details with qos
* parameters
*
* @param rootAuthToken
* @throws Exception
*/
private static BusinessEntity CreateMary() 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/endpoint1BAD", 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);

bt = new BindingTemplate();
bt.setAccessPoint(new AccessPoint("http://localhost/endpoint2BETTER", AccessPointType.WSDL_DEPLOYMENT.toString()));
bt.setTModelInstanceDetails(new TModelInstanceDetails());
tii = new TModelInstanceInfo();
tii.setTModelKey(WSDMQosConstants.METRIC_FAULT_COUNT_KEY);

tii.setInstanceDetails(new InstanceDetails());
tii.getInstanceDetails().setInstanceParms("4");
bt = UDDIClient.addSOAPtModels(bt);
bt.getTModelInstanceDetails().getTModelInstanceInfo().add(tii);
bs.getBindingTemplates().getBindingTemplate().add(bt);


be.getBusinessServices().getBusinessService().add(bs);

return be;
}
}

0 comments on commit 9dafe4e

Please sign in to comment.