Author: kstam
Date: Mon Mar 4 21:34:16 2013
New Revision: 1452536
URL: http://svn.apache.org/r1452536
Log:
JUDDI-540 working on adding the examples to the bundle
Added:
juddi/trunk/juddi-examples/hello-world/
juddi/trunk/juddi-examples/hello-world/README
juddi/trunk/juddi-examples/hello-world/pom.xml
juddi/trunk/juddi-examples/hello-world/src/
juddi/trunk/juddi-examples/hello-world/src/main/
juddi/trunk/juddi-examples/hello-world/src/main/java/
juddi/trunk/juddi-examples/hello-world/src/main/java/org/
juddi/trunk/juddi-examples/hello-world/src/main/java/org/apache/
juddi/trunk/juddi-examples/hello-world/src/main/java/org/apache/juddi/
juddi/trunk/juddi-examples/hello-world/src/main/java/org/apache/juddi/example/
juddi/trunk/juddi-examples/hello-world/src/main/java/org/apache/juddi/example/helloworld/
juddi/trunk/juddi-examples/hello-world/src/main/java/org/apache/juddi/example/helloworld/HelloWorld.java
juddi/trunk/juddi-examples/hello-world/src/main/resources/
juddi/trunk/juddi-examples/hello-world/src/main/resources/META-INF/
juddi/trunk/juddi-examples/hello-world/src/main/resources/META-INF/uddi.xml
juddi/trunk/juddi-examples/simple-publish/
juddi/trunk/juddi-examples/simple-publish/README.txt
juddi/trunk/juddi-examples/simple-publish/pom.xml
juddi/trunk/juddi-examples/simple-publish/src/
juddi/trunk/juddi-examples/simple-publish/src/main/
juddi/trunk/juddi-examples/simple-publish/src/main/java/
juddi/trunk/juddi-examples/simple-publish/src/main/java/org/
juddi/trunk/juddi-examples/simple-publish/src/main/java/org/apache/
juddi/trunk/juddi-examples/simple-publish/src/main/java/org/apache/juddi/
juddi/trunk/juddi-examples/simple-publish/src/main/java/org/apache/juddi/example/
juddi/trunk/juddi-examples/simple-publish/src/main/java/org/apache/juddi/example/publish/
juddi/trunk/juddi-examples/simple-publish/src/main/java/org/apache/juddi/example/publish/SimplePublish.java
juddi/trunk/juddi-examples/simple-publish/src/main/resources/
juddi/trunk/juddi-examples/simple-publish/src/main/resources/META-INF/
juddi/trunk/juddi-examples/simple-publish/src/main/resources/META-INF/uddi.xml
juddi/trunk/juddi-examples/simple-publish/src/test/
juddi/trunk/juddi-examples/simple-publish/src/test/java/
juddi/trunk/juddi-examples/simple-publish/src/test/resources/
Modified:
juddi/trunk/juddi-examples/pom.xml
Added: juddi/trunk/juddi-examples/hello-world/README
URL:
http://svn.apache.org/viewvc/juddi/trunk/juddi-examples/hello-world/README?rev=1452536&view=auto
==============================================================================
--- juddi/trunk/juddi-examples/hello-world/README (added)
+++ juddi/trunk/juddi-examples/hello-world/README Mon Mar 4 21:34:16 2013
@@ -0,0 +1,18 @@
+This example is a command line demonstration of how to interact with JUDDI.
+
+1. Download Apache Ivy and update the project.properties
+
+2. Check the settings of the META-INF/uddi.xml, to make sure the serverName
and serverPort are set correctly.
+
+3. ant run
+
+ run:
+ [echo] HelloWorld Grab AuthToken
+ [java] log4j:WARN No appenders could be found for logger
(org.apache.commons.configuration.ConfigurationUtils).
+ [java] log4j:WARN Please initialize the log4j system properly.
+ [java] AUTHTOKEN = authtoken:8f18d677-b19d-454f-b1ba-61bc5947c16e
+
+
+
+For further examples, see the uddi-client module, which includes a number
+of unit tests that exercise API other than just the security API.
Added: juddi/trunk/juddi-examples/hello-world/pom.xml
URL:
http://svn.apache.org/viewvc/juddi/trunk/juddi-examples/hello-world/pom.xml?rev=1452536&view=auto
==============================================================================
--- juddi/trunk/juddi-examples/hello-world/pom.xml (added)
+++ juddi/trunk/juddi-examples/hello-world/pom.xml Mon Mar 4 21:34:16 2013
@@ -0,0 +1,58 @@
+<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/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.apache.juddi</groupId>
+ <artifactId>juddi-examples</artifactId>
+ <version>3.1.5-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+ <artifactId>hello-world</artifactId>
+ <name>jUDDI Example Hello World</name>
+ <description>Demonstrates the steps taken to publish a service using the
jUDDI API directly</description>
+
+ <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.example.helloworld.HelloWorld</mainClass>
+ <!--
+ <arguments>
+ <argument>arg0</argument>
+ </arguments>
+ -->
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.juddi</groupId>
+ <artifactId>uddi-ws</artifactId>
+ <version>3.1.5-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.juddi</groupId>
+ <artifactId>juddi-core</artifactId>
+ <version>3.1.5-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.juddi</groupId>
+ <artifactId>juddi-client</artifactId>
+ <version>3.1.5-SNAPSHOT</version>
+ </dependency>
+ </dependencies>
+
+</project>
+
Added:
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=1452536&view=auto
==============================================================================
---
juddi/trunk/juddi-examples/hello-world/src/main/java/org/apache/juddi/example/helloworld/HelloWorld.java
(added)
+++
juddi/trunk/juddi-examples/hello-world/src/main/java/org/apache/juddi/example/helloworld/HelloWorld.java
Mon Mar 4 21:34:16 2013
@@ -0,0 +1,62 @@
+/*
+ * 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.examples.helloworld;
+
+import org.uddi.api_v3.*;
+import org.apache.juddi.v3.client.ClassUtil;
+import org.apache.juddi.v3.client.config.UDDIClerkManager;
+import org.apache.juddi.v3.client.config.UDDIClientContainer;
+import org.apache.juddi.v3.client.transport.Transport;
+import org.uddi.v3_service.UDDISecurityPortType;
+
+public class HelloWorld {
+ private Transport transport = null;
+ private static UDDISecurityPortType security = null;
+
+ public HelloWorld() {
+ try {
+ String clazz =
UDDIClientContainer.getUDDIClerkManager("example-manager").
+ getClientConfig().getUDDINode("default").getProxyTransport();
+ Class<?> transportClass = ClassUtil.forName(clazz,
Transport.class);
+ if (transportClass!=null) {
+ Transport transport = (Transport)
transportClass.
+
getConstructor(String.class).newInstance("default");
+ 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();
+ }
+}
Added:
juddi/trunk/juddi-examples/hello-world/src/main/resources/META-INF/uddi.xml
URL:
http://svn.apache.org/viewvc/juddi/trunk/juddi-examples/hello-world/src/main/resources/META-INF/uddi.xml?rev=1452536&view=auto
==============================================================================
--- juddi/trunk/juddi-examples/hello-world/src/main/resources/META-INF/uddi.xml
(added)
+++ juddi/trunk/juddi-examples/hello-world/src/main/resources/META-INF/uddi.xml
Mon Mar 4 21:34:16 2013
@@ -0,0 +1,27 @@
+<?xml version="1.0" encoding="ISO-8859-1" ?>
+
+<uddi>
+ <reloadDelay>5000</reloadDelay>
+ <manager name="example-manager">
+ <nodes>
+ <node>
+ <!-- required 'default' node -->
+ <name>default</name>
+ <properties>
+ <property name="serverName" value="localhost"/>
+ <property name="serverPort" value="8080"/>
+ </properties>
+ <description>Main jUDDI node</description>
+ <!-- JAX-WS Transport -->
+
<proxyTransport>org.apache.juddi.v3.client.transport.JAXWSTransport</proxyTransport>
+
<custodyTransferUrl>http://${serverName}:${serverPort}/juddiv3/services/custody-transfer?wsdl</custodyTransferUrl>
+
<inquiryUrl>http://${serverName}:${serverPort}/juddiv3/services/inquiry?wsdl</inquiryUrl>
+
<publishUrl>http://${serverName}:${serverPort}/juddiv3/services/publish?wsdl</publishUrl>
+
<securityUrl>http://${serverName}:${serverPort}/juddiv3/services/security?wsdl</securityUrl>
+
<subscriptionUrl>http://${serverName}:${serverPort}/juddiv3/services/subscription?wsdl</subscriptionUrl>
+
<subscriptionListenerUrl>http://${serverName}:${serverPort}/juddiv3/services/subscription-listener?wsdl</subscriptionListenerUrl>
+
<juddiApiUrl>http://${serverName}:${serverPort}/juddiv3/services/juddi-api</juddiApiUrl>
+ </node>
+ </nodes>
+ </manager>
+</uddi>
Modified: juddi/trunk/juddi-examples/pom.xml
URL:
http://svn.apache.org/viewvc/juddi/trunk/juddi-examples/pom.xml?rev=1452536&r1=1452535&r2=1452536&view=diff
==============================================================================
--- juddi/trunk/juddi-examples/pom.xml (original)
+++ juddi/trunk/juddi-examples/pom.xml Mon Mar 4 21:34:16 2013
@@ -25,7 +25,9 @@
<prerequisites>
<maven>3.0.3</maven>
</prerequisites>
- <modules>
- <module>uddi-annotations</module>
- </modules>
+ <modules>
+ <module>hello-world</module>
+ <module>simple-publish</module>
+ <module>uddi-annotations</module>
+ </modules>
</project>
\ No newline at end of file
Added: juddi/trunk/juddi-examples/simple-publish/README.txt
URL:
http://svn.apache.org/viewvc/juddi/trunk/juddi-examples/simple-publish/README.txt?rev=1452536&view=auto
==============================================================================
--- juddi/trunk/juddi-examples/simple-publish/README.txt (added)
+++ juddi/trunk/juddi-examples/simple-publish/README.txt Mon Mar 4 21:34:16
2013
@@ -0,0 +1,18 @@
+This example contains one class: the SimplePublish.java. When
+executed it will obtain an AuthToken and use it to publish
+a Publisher, a Business and a Service.
+
+The easiest way to run execute the main of this class in from
+your IDE. If your IDE has maven integration it should set up
+the project class path for you, and you can simple run it from
+there.
+
+You should see the following output being written to the console:
+
+root AUTHTOKEN = authtoken:0494e382-1ad3-4c52-8806-ae70a0ed37ad
+myPub AUTHTOKEN = authtoken:bf973e5f-7361-4c57-92f7-7b499b886b6d
+myBusiness key: uddi:juddi.apache.org:6f3e4e62-e483-48ff-a1b3-6855310505c6
+myService key: uddi:juddi.apache.org:549a9580-cd7b-4969-9b77-527ab9f8f261
+
+However since the keys are being generated in this case your keys will differ.
+
Added: juddi/trunk/juddi-examples/simple-publish/pom.xml
URL:
http://svn.apache.org/viewvc/juddi/trunk/juddi-examples/simple-publish/pom.xml?rev=1452536&view=auto
==============================================================================
--- juddi/trunk/juddi-examples/simple-publish/pom.xml (added)
+++ juddi/trunk/juddi-examples/simple-publish/pom.xml Mon Mar 4 21:34:16 2013
@@ -0,0 +1,58 @@
+<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/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.apache.juddi</groupId>
+ <artifactId>juddi-examples</artifactId>
+ <version>3.1.5-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+ <artifactId>simple-publish</artifactId>
+ <name>jUDDI Example Simple Publish</name>
+ <description>Demonstrates the steps taken to publish a service using the
jUDDI API directly</description>
+
+ <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.example.publish.SimplePublish</mainClass>
+ <!--
+ <arguments>
+ <argument>arg0</argument>
+ </arguments>
+ -->
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.juddi</groupId>
+ <artifactId>uddi-ws</artifactId>
+ <version>3.1.5-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.juddi</groupId>
+ <artifactId>juddi-core</artifactId>
+ <version>3.1.5-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.juddi</groupId>
+ <artifactId>juddi-client</artifactId>
+ <version>3.1.5-SNAPSHOT</version>
+ </dependency>
+ </dependencies>
+
+</project>
+
Added:
juddi/trunk/juddi-examples/simple-publish/src/main/java/org/apache/juddi/example/publish/SimplePublish.java
URL:
http://svn.apache.org/viewvc/juddi/trunk/juddi-examples/simple-publish/src/main/java/org/apache/juddi/example/publish/SimplePublish.java?rev=1452536&view=auto
==============================================================================
---
juddi/trunk/juddi-examples/simple-publish/src/main/java/org/apache/juddi/example/publish/SimplePublish.java
(added)
+++
juddi/trunk/juddi-examples/simple-publish/src/main/java/org/apache/juddi/example/publish/SimplePublish.java
Mon Mar 4 21:34:16 2013
@@ -0,0 +1,124 @@
+/*
+ * 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.example.publish;
+
+import org.uddi.api_v3.*;
+import org.apache.juddi.ClassUtil;
+import org.apache.juddi.api_v3.*;
+import org.apache.juddi.v3.client.config.UDDIClientContainer;
+import org.apache.juddi.v3.client.transport.Transport;
+import org.uddi.v3_service.UDDISecurityPortType;
+import org.uddi.v3_service.UDDIPublicationPortType;
+import org.apache.juddi.v3_service.JUDDIApiPortType;
+
+public class SimplePublish {
+ private static UDDISecurityPortType security = null;
+
+ private static JUDDIApiPortType juddiApi = null;
+ private static UDDIPublicationPortType publish = null;
+
+ public SimplePublish() {
+ try {
+ String clazz =
UDDIClientContainer.getUDDIClerkManager("example-manager").
+ getClientConfig().getUDDINode("default").getProxyTransport();
+ Class<?> transportClass = ClassUtil.forName(clazz,
Transport.class);
+ if (transportClass!=null) {
+ Transport transport = (Transport)
transportClass.
+
getConstructor(String.class).newInstance("default");
+
+ security = transport.getUDDISecurityService();
+ juddiApi = transport.getJUDDIApiService();
+ publish = transport.getUDDIPublishService();
+ }
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+ public void publish() {
+ 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("");
+
+ // Making API call that retrieves the authentication
token for the 'root' user.
+ AuthToken rootAuthToken =
security.getAuthToken(getAuthTokenRoot);
+ System.out.println ("root AUTHTOKEN = " +
rootAuthToken.getAuthInfo());
+
+ // Creating a new publisher that we will use to publish
our entities to.
+ Publisher p = new Publisher();
+ p.setAuthorizedName("my-publisher");
+ p.setPublisherName("My Publisher");
+
+ // Adding the publisher to the "save" structure, using
the 'root' user authentication info and saving away.
+ SavePublisher sp = new SavePublisher();
+ sp.getPublisher().add(p);
+ sp.setAuthInfo(rootAuthToken.getAuthInfo());
+ juddiApi.savePublisher(sp);
+
+ // Our publisher is now saved, so now we want to
retrieve its authentication token
+ GetAuthToken getAuthTokenMyPub = new GetAuthToken();
+ getAuthTokenMyPub.setUserID("my-publisher");
+ getAuthTokenMyPub.setCred("");
+ AuthToken myPubAuthToken =
security.getAuthToken(getAuthTokenMyPub);
+ System.out.println ("myPub AUTHTOKEN = " +
myPubAuthToken.getAuthInfo());
+
+ // Creating the parent business entity that will
contain our service.
+ BusinessEntity myBusEntity = new BusinessEntity();
+ Name myBusName = new Name();
+ myBusName.setValue("My Business");
+ myBusEntity.getName().add(myBusName);
+
+ // Adding the business entity to the "save" structure,
using our publisher's authentication info and saving away.
+ SaveBusiness sb = new SaveBusiness();
+ sb.getBusinessEntity().add(myBusEntity);
+ sb.setAuthInfo(myPubAuthToken.getAuthInfo());
+ BusinessDetail bd = publish.saveBusiness(sb);
+ String myBusKey =
bd.getBusinessEntity().get(0).getBusinessKey();
+ System.out.println("myBusiness key: " + myBusKey);
+
+ // Creating a service to save. Only adding the minimum
data: the parent business key retrieved from saving the business
+ // above and a single name.
+ BusinessService myService = new BusinessService();
+ myService.setBusinessKey(myBusKey);
+ Name myServName = new Name();
+ myServName.setValue("My Service");
+ myService.getName().add(myServName);
+ // Add binding templates, etc...
+
+ // Adding the service to the "save" structure, using
our publisher's authentication info and saving away.
+ SaveService ss = new SaveService();
+ ss.getBusinessService().add(myService);
+ ss.setAuthInfo(myPubAuthToken.getAuthInfo());
+ ServiceDetail sd = publish.saveService(ss);
+ String myServKey =
sd.getBusinessService().get(0).getServiceKey();
+ System.out.println("myService key: " + myServKey);
+
+ // Now you have a publisher saved who in turn published
a business and service via the jUDDI API!
+ }
+ catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+ public static void main (String args[]) {
+ SimplePublish sp = new SimplePublish();
+ sp.publish();
+ }
+}
Added:
juddi/trunk/juddi-examples/simple-publish/src/main/resources/META-INF/uddi.xml
URL:
http://svn.apache.org/viewvc/juddi/trunk/juddi-examples/simple-publish/src/main/resources/META-INF/uddi.xml?rev=1452536&view=auto
==============================================================================
---
juddi/trunk/juddi-examples/simple-publish/src/main/resources/META-INF/uddi.xml
(added)
+++
juddi/trunk/juddi-examples/simple-publish/src/main/resources/META-INF/uddi.xml
Mon Mar 4 21:34:16 2013
@@ -0,0 +1,27 @@
+<?xml version="1.0" encoding="ISO-8859-1" ?>
+
+<uddi>
+ <reloadDelay>5000</reloadDelay>
+ <manager name="example-manager">
+ <nodes>
+ <node>
+ <!-- required 'default' node -->
+ <name>default</name>
+ <properties>
+ <property name="serverName" value="localhost"/>
+ <property name="serverPort" value="8080"/>
+ </properties>
+ <description>Main jUDDI node</description>
+ <!-- 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>
+
<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>
+ </node>
+ </nodes>
+ </manager>
+</uddi>
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]