summaryrefslogtreecommitdiff
path: root/java/management/client/src/example/org
diff options
context:
space:
mode:
Diffstat (limited to 'java/management/client/src/example/org')
-rw-r--r--java/management/client/src/example/org/apache/qpid/management/example/AbstractQManExample.java140
-rw-r--r--java/management/client/src/example/org/apache/qpid/management/example/ConnectWithBrokerExample.java240
-rw-r--r--java/management/client/src/example/org/apache/qpid/management/example/ConsumerAndProducerExample.java293
-rw-r--r--java/management/client/src/example/org/apache/qpid/management/example/GetMultipleResourcePropertiesExample.java179
-rw-r--r--java/management/client/src/example/org/apache/qpid/management/example/GetQManResourceMembersExample.java93
-rw-r--r--java/management/client/src/example/org/apache/qpid/management/example/GetResourceMetadataDescriptorExample.java156
-rw-r--r--java/management/client/src/example/org/apache/qpid/management/example/GetResourcePropertyDocumentExample.java111
-rw-r--r--java/management/client/src/example/org/apache/qpid/management/example/GetResourcePropertyExample.java172
-rw-r--r--java/management/client/src/example/org/apache/qpid/management/example/GetWSDLMetadataExample.java156
-rw-r--r--java/management/client/src/example/org/apache/qpid/management/example/PausableSubscriptionExample.java88
-rw-r--r--java/management/client/src/example/org/apache/qpid/management/example/SetResourcePropertyExample.java306
11 files changed, 0 insertions, 1934 deletions
diff --git a/java/management/client/src/example/org/apache/qpid/management/example/AbstractQManExample.java b/java/management/client/src/example/org/apache/qpid/management/example/AbstractQManExample.java
deleted file mode 100644
index ffa96635a8..0000000000
--- a/java/management/client/src/example/org/apache/qpid/management/example/AbstractQManExample.java
+++ /dev/null
@@ -1,140 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you 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.qpid.management.example;
-
-import java.io.IOException;
-import java.net.URI;
-
-import org.apache.muse.ws.addressing.EndpointReference;
-
-/**
- * Common interface for all QMan related examples.
- *
- * @author Andrea Gazzarini
- */
-public abstract class AbstractQManExample
-{
- final static String LINE_SEPARATOR = System.getProperty("line.separator","\n");
- protected final static String PREFIX = "qman";
-
- /**
- * Prints out the expected command line of this sample and after that exits.
- */
- static void printUsageAndExit(String reason)
- {
- StringBuilder builder = new StringBuilder();
- builder.append("WARNING! Unable to run this sample : ")
- .append(reason)
- .append(LINE_SEPARATOR)
- .append("-------------------------------------------------------------")
- .append(LINE_SEPARATOR)
- .append("Expected command line args for this sample are :")
- .append(LINE_SEPARATOR)
- .append(LINE_SEPARATOR)
- .append("1) host : ip or host name where QMan is running.")
- .append(LINE_SEPARATOR)
- .append("2) port : port number where QMan is running.")
- .append(LINE_SEPARATOR)
- .append("------------------------------------------------------------");
- System.out.println(builder);
- System.exit(1);
- }
-
- /**
- * Prints out a description of this example.
- */
- abstract void printOutExampleDescription();
-
- /**
- * Executes this example.
- * Note that this is just a template method used to avoid code duplication
- * (printOutExampleDescription() line) so in order to see how the example
- * works you should have a look at the concrete implementation of
- * executeExample(String host, int port).
- *
- * @param host the host where QMan is running.
- * @param port the port where QMan is running.
- */
- void execute(String [] arguments)
- {
- if (arguments.length != 2){
- printUsageAndExit("invalid command line was given.");
- }
-
- try
- {
- // 1) Parses command line arguments...
- String host = arguments[0];
- int port = Integer.parseInt(arguments[1]);
-
- printOutExampleDescription();
-
- waitForUserInput("Type enter to proceed...");
-
- executeExample(host, port);
-
- } catch(NumberFormatException exception)
- {
- printUsageAndExit("port number must be a number.");
- } catch(Exception exception)
- {
- System.out.println("-----------------------EXAMPLE FAILURE-----------");
- System.out.println("Not well-defined exception was detected while");
- System.out.println("running the example.");
- exception.printStackTrace(System.out);
- System.out.println("--------------------------------------------------------");
- }
- }
-
- protected void waitForUserInput(String message) throws IOException {
- System.out.println(message);
- System.in.read();
- }
-
- /**
- * Each concrete implementor must define here how the example works.
- * So, on top of that, user who wants to see how to use a specific feature
- * should have a look at the concrete implementation of this method..
- *
- * @param host the host where QMan is running.
- * @param port the port where QMan is running.
- * @throws Exception when the example fails (not at application level).
- */
- void executeExample(String host, int port) throws Exception{};
-
- /**
- * Returns the endpoint reference of the adapter service.
- *
- * @param host ip or host name where the service is running.
- * @param port the port number of the server where the service is running.
- * @return the endpoint reference of the adapter service.
- */
- EndpointReference getAdapterEndpointReference(String host, int port)
- {
- URI address = URI.create(
- "http://"+
- host+
- ":"+
- port+
- "/qman/services/adapter");
- return new EndpointReference(address);
- }
-} \ No newline at end of file
diff --git a/java/management/client/src/example/org/apache/qpid/management/example/ConnectWithBrokerExample.java b/java/management/client/src/example/org/apache/qpid/management/example/ConnectWithBrokerExample.java
deleted file mode 100644
index 153f0f66d5..0000000000
--- a/java/management/client/src/example/org/apache/qpid/management/example/ConnectWithBrokerExample.java
+++ /dev/null
@@ -1,240 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you 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.qpid.management.example;
-
-import javax.xml.namespace.QName;
-
-import org.apache.muse.core.proxy.ProxyHandler;
-import org.apache.muse.core.proxy.ReflectionProxyHandler;
-import org.apache.muse.ws.addressing.EndpointReference;
-import org.apache.muse.ws.resource.remote.WsResourceClient;
-
-/**
- * This example shows how to connect QMan with a broker using the adapter interface.
- * As you can see the interface is very simple and requests you the following parameters :
- *
- * <ul>
- * <li>hostname : the host (hostname or ip) where the broker is running;</li>
- * <li>port : the port number of the running broker;</li>
- * <li>virtual host : the name of the virtual host;</li>
- * <li>username : the username that will be used for estabilshing connection.</li>
- * <li>password : the password that will be used for estabilshing connection.</li>
- * <li>initial pool capacity : the initial size of broker connection pool. </li>
- * <li>maximum pool capacity : the max allowed size of broker connection pool.</li>
- * <li>maximum wait timeout : the max wait timeout for retrieving connections.</li>
- * </ul>
- *
- * @author Andrea Gazzarini
- */
-public class ConnectWithBrokerExample extends AbstractQManExample
-{
-
- /**
- * Executes the connect example.
- * Although not specified explicitly, the input array MUST contains in the following order :
- *
- * <ul>
- * <li>host : the hostname where QMan is running;</li>
- * <li>port : the port number where QMan is running;</li>
- * <li>qpid host : the host name where QPid is running;</li>
- * <li>qpid port : the port number where Qpid is running;</li>
- * <li>virtual host : the virtual host name;</li>
- * <li>username : the username that will be used for estabilshing connection.</li>
- * <li>password : the password that will be used for estabilshing connection.</li>
- * <li>initial pool capacity : the initial size of broker connection pool. </li>
- * <li>maximum pool capacity : the max allowed size of broker connection pool.</li>
- * <li>maximum wait timeout : the max wait timeout for retrieving connections.</li>
- * </ul>
- *
- * Note that this example differs from the others (and therefore is overriding the execute() method) because
- * in this case we are not using the "standard" WSRF interface but instead an additional custom
- * "operation" on a WS-Resource.
- *
- * @param arguments the commadn line arguments.
- */
- void execute(String [] arguments)
- {
- if (arguments.length != 10){
- printUsageAndExit("invalid command line was given.");
- }
-
- try
- {
- // 1) Parses command line arguments...
- String host = arguments[0];
- int port = Integer.parseInt(arguments[1]);
- String qpidHost = arguments[2];
- int qpidPort = Integer.parseInt(arguments[3]);
- String virtualHost = arguments[4];
- String username = arguments[5];
- String password = arguments[6];
- int initPoolCapacity = Integer.parseInt(arguments[7]);
- int maxPoolCapacity = Integer.parseInt(arguments[8]);
- long maxWaitTimeout = Long.parseLong(arguments[9]);
-
- printOutExampleDescription();
-
- waitForUserInput("Type enter to proceed...");
-
- executeExample(
- host,
- port,
- qpidHost,
- qpidPort,
- virtualHost,
- username,
- password,
- initPoolCapacity,
- maxPoolCapacity,
- maxWaitTimeout);
-
- } catch(NumberFormatException exception)
- {
- printUsageAndExit("Unable to run the example. Please ensure that all numeric values are correctly supplied.");
- } catch(Exception exception)
- {
- System.out.println("-----------------------EXAMPLE FAILURE-----------");
- System.out.println("Not well-defined exception was detected while");
- System.out.println("running the example.");
- exception.printStackTrace(System.out);
- System.out.println("--------------------------------------------------------");
- }
- }
-
- /**
- * Connects QMan with a broker.
- *
- *@param host the hostname where QMan is running;
- *@param port the port number where QMan is running;
- *@param qpidHost the host name where QPid is running;
- *@param qpidPort the port number where Qpid is running;
- *@param virtualHost the virtual host name;
- *@param username the username that will be used for estabilshing connection.
- *@param password the password that will be used for estabilshing connection.
- *@param initPoolCapacity the initial size of broker connection pool.
- *@param maxPoolCapacity the max allowed size of broker connection pool.
- *@param maxWaitTimeout the max wait timeout for retrieving connections.
- *
- * @throws Exception when the example fails (not at application level).
- */
- void executeExample(String host, int port, String qpidHost, int qpidPort, String virtualHost, String username, String password, int initPoolCapacity, int maxPoolCapacity, long maxWaitTimeout) throws Exception
- {
- // 1) Creates an endpoint reference of the adapter service...
- EndpointReference adapterEndpointReference = getAdapterEndpointReference(host, port);
- WsResourceClient adapterClient = new WsResourceClient(adapterEndpointReference);
- adapterClient.setTrace(true);
-
- // 2) Creates the Adapter service client...
- adapterClient.invoke(
- getProxyHandler(),
- new Object[]{
- qpidHost,
- qpidPort,
- username,
- password,
- virtualHost,
- initPoolCapacity,
- maxPoolCapacity,
- maxWaitTimeout});
- }
-
- /**
- * Prints out a description of this example.
- */
- void printOutExampleDescription()
- {
- System.out.println(" "+getClass().getSimpleName()+" ");
- System.out.println("-------------------------------------------------------------------");
- System.out.println();
- System.out.println("This example shows how to connect QMan with a broker using");
- System.out.println("the adapter interface.");
- System.out.println();
- }
-
- /**
- * A proxy handler is a module needed in order to make a capability
- * service invocation.
- * It contains logic to serialize and deserialize request, response, input and
- * output parameters during a web service invocation.
- *
- * @return a proxy handler.
- */
- private ProxyHandler getProxyHandler()
- {
- ProxyHandler handler = new ReflectionProxyHandler();
- handler.setAction("http://amqp.apache.org/qpid/management/qman/Connect");
- handler.setRequestName(new QName("http://amqp.apache.org/qpid/management/qman", "Connect", PREFIX));
- handler.setRequestParameterNames(new QName[]{
- new QName("http://amqp.apache.org/qpid/management/qman", "host", PREFIX),
- new QName("http://amqp.apache.org/qpid/management/qman", "port", PREFIX),
- new QName("http://amqp.apache.org/qpid/management/qman", "username", PREFIX),
- new QName("http://amqp.apache.org/qpid/management/qman", "password", PREFIX),
- new QName("http://amqp.apache.org/qpid/management/qman", "virtualHost", PREFIX),
- new QName("http://amqp.apache.org/qpid/management/qman", "initialPoolCapacity", PREFIX),
- new QName("http://amqp.apache.org/qpid/management/qman", "maxPoolCapacity", PREFIX),
- new QName("http://amqp.apache.org/qpid/management/qman", "maxWaitTimeout", PREFIX)});
- handler.setResponseName(new QName("http://amqp.apache.org/qpid/management/qman", "ConnectResponse", PREFIX));
- handler.setReturnType(null);
- return handler;
- }
-
- public static void main(String[] arguments)
- {
- new ConnectWithBrokerExample().execute(arguments);
- }
-
- static void printUsageAndExit(String reason)
- {
- StringBuilder builder = new StringBuilder();
- builder.append("WARNING! Unable to run this sample : ")
- .append(reason)
- .append(LINE_SEPARATOR)
- .append("-------------------------------------------------------------")
- .append(LINE_SEPARATOR)
- .append("Expected command line args for this sample are :")
- .append(LINE_SEPARATOR)
- .append(LINE_SEPARATOR)
- .append("1) host : ip or host name where QMan is running.")
- .append(LINE_SEPARATOR)
- .append("2) port : port number where QMan is running.")
- .append(LINE_SEPARATOR)
- .append("3) qpid host : port number where Qpid is running.")
- .append(LINE_SEPARATOR)
- .append("4) qpid port : port number where Qpid is running.")
- .append(LINE_SEPARATOR)
- .append("5) virtual host : virtual host name.")
- .append(LINE_SEPARATOR)
- .append("6) username : port number where QMan is running.")
- .append(LINE_SEPARATOR)
- .append("7) password : port number where QMan is running.")
- .append(LINE_SEPARATOR)
- .append("8) initial pool capacity : port number where QMan is running.")
- .append(LINE_SEPARATOR)
- .append("9) max pool capacity : port number where QMan is running.")
- .append(LINE_SEPARATOR)
- .append("10) max wait timeout : port number where QMan is running.")
- .append(LINE_SEPARATOR)
-
- .append("------------------------------------------------------------");
- System.out.println(builder);
- System.exit(1);
- }
-} \ No newline at end of file
diff --git a/java/management/client/src/example/org/apache/qpid/management/example/ConsumerAndProducerExample.java b/java/management/client/src/example/org/apache/qpid/management/example/ConsumerAndProducerExample.java
deleted file mode 100644
index 42587d78ff..0000000000
--- a/java/management/client/src/example/org/apache/qpid/management/example/ConsumerAndProducerExample.java
+++ /dev/null
@@ -1,293 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you 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.qpid.management.example;
-
-import java.net.URI;
-import java.util.Date;
-
-import org.apache.muse.util.xml.XPathUtils;
-import org.apache.muse.ws.addressing.EndpointReference;
-import org.apache.muse.ws.addressing.soap.SoapFault;
-import org.apache.muse.ws.notification.impl.FilterCollection;
-import org.apache.muse.ws.notification.impl.MessagePatternFilter;
-import org.apache.muse.ws.notification.impl.ProducerPropertiesFilter;
-import org.apache.muse.ws.notification.impl.TopicFilter;
-import org.apache.muse.ws.notification.remote.NotificationProducerClient;
-import org.apache.qpid.management.Names;
-
-/**
- * This example is demonstrating a WS-Notification scenario
- * when (for simplicity) QMan is at the same time consumer
- * and producer.
- *
- * Basically we have (on producer side) two topics : one for
- * lifecycle events of object instance (objects created & removed)
- * and another one for lifecycle of event (events created).
- *
- * On consumer side there are many options that you can use in
- * order to made a sunscription :
- *
- * <ul>
- * <li>you could be an observer of all messages (all topics);</li>
- * <li>you could be an observer of one specific topic;</li>
- * <li>
- * you could be an observer of all messages that match
- * a condition expressed in XPath;
- * </li>
- * </ul>
- *
- * All those options are provided with or withour a termination time.
- * A subscription with a termination time will have a predefined expiry
- * date while if there's no termination the subscription will never expire.
- *
- * @author Andrea Gazzarini
- *
- */
-public class ConsumerAndProducerExample extends AbstractQManExample
-{
- @Override
- void executeExample(String host, int port) throws Exception
- {
- // This is QMan...
- URI producerURI = URI.create("http://"+host+":"+port+"/qman/services/adapter");
-
- // ...and this is QMan too! Note that it has an hidden consumer capability that is used in
- // order to run successfully this example...
- URI consumerURI = URI.create("http://"+host+":"+port+"/qman/services/consumer");
-
- EndpointReference producerEPR = new EndpointReference(producerURI);
- EndpointReference consumerEPR = new EndpointReference(consumerURI);
-
- // Example 1 : all messages on all topics without termination time.
- subscribeAllMessagesWithoutTerminationTime(producerEPR,consumerEPR);
-
- // Example 2 : all messages on all topics with termination time.
- subscribeAllMessagesWithTerminationTime(producerEPR,consumerEPR);
-
- // Example 3: Topic filter without termination time.
- topicSubscriptionWithoutTerminationTime(producerEPR,consumerEPR);
-
- // Example 4: Topic filter with termination time.
- topicSubscriptionWithTerminationTime(producerEPR,consumerEPR);
-
- // Example 5: a MessageFilter is installed in order to listen only for connection events
- // (connections created or removed). The subscription never expire.
- allMessagesWithMessageFilterWithoutTerminationTime(producerEPR,consumerEPR);
-
- // Example 6: a MessageFilter is installed in order to listen only for connection events
- // (connections created or removed). The subscription will expire in 10 seconds.
- allMessagesWithMessageFilterAndTerminationTime(producerEPR,consumerEPR);
-
- // Example 7 : a subscription with more than one filter.
- complexSubscription(producerEPR, consumerEPR);
- }
-
- /**
- * Makes a subscription on all topics / all messages without an expiry date.
- *
- * @param producer the producer endpoint reference.
- * @param consumer the consumer endpoint reference .
- * @throws SoapFault when the subscription cannot be made.
- */
- private void subscribeAllMessagesWithoutTerminationTime(EndpointReference producer, EndpointReference consumer) throws SoapFault
- {
- NotificationProducerClient producerClient = new NotificationProducerClient(producer);
- producerClient.setTrace(true);
-
- producerClient.subscribe(
- consumer, // Consumer Endpoint reference
- null, // Filter, if null that means "all messages"
- null); // Termination Time : if null the subscription will never expire.
- }
-
- /**
- * Makes a subscription on all topics / all messages with 10 seconds as termination time.
- * The subscription will expire after 10 seconds.
- *
- * @param producer the producer endpoint reference.
- * @param consumer the consumer endpoint reference .
- * @throws SoapFault when the subscription cannot be made.
- */
- private void subscribeAllMessagesWithTerminationTime(EndpointReference producer, EndpointReference consumer) throws SoapFault
- {
- NotificationProducerClient producerClient = new NotificationProducerClient(producer);
- producerClient.setTrace(true);
-
- producerClient.subscribe(
- consumer, // Consumer Endpoint reference
- null, // Filter, if null that means "all messages"
- new Date(System.currentTimeMillis() + 10000)); // Termination Time
- }
-
- /**
- * Makes a subscription on a specifc topic without an expiry date.
- * Only messages published on the given topic will be delivered to the given consumer.
- *
- * @param producer the producer endpoint reference.
- * @param consumer the consumer endpoint reference .
- * @throws SoapFault when the subscription cannot be made.
- */
- private void topicSubscriptionWithoutTerminationTime(EndpointReference producer, EndpointReference consumer) throws SoapFault
- {
- NotificationProducerClient producerClient = new NotificationProducerClient(producer);
- producerClient.setTrace(true);
-
- TopicFilter filter = new TopicFilter(Names.EVENTS_LIFECYLE_TOPIC_NAME);
-
- producerClient.subscribe(
- consumer, // Consumer Endpoint reference
- filter, // Topic Filter
- null); // Termination Time : if null the subscription will never expire.
- }
-
- /**
- * Makes a subscription on a specifc topic with an expiry date.
- * Only messages published on the given topic will be delivered to the given consumer.
- * The subscription will end after 10 seconds
- *
- * @param producer the producer endpoint reference.
- * @param consumer the consumer endpoint reference .
- * @throws SoapFault when the subscription cannot be made.
- */
- private void topicSubscriptionWithTerminationTime(EndpointReference producer, EndpointReference consumer) throws SoapFault
- {
- NotificationProducerClient producerClient = new NotificationProducerClient(producer);
- producerClient.setTrace(true);
-
- TopicFilter filter = new TopicFilter(Names.EVENTS_LIFECYLE_TOPIC_NAME);
-
- producerClient.subscribe(
- consumer, // Consumer Endpoint reference
- filter, // Topic Filter
- new Date(System.currentTimeMillis() + 10000)); // Termination Time
- }
-
- /**
- * Makes a subscription on all topics with a message filter without an expiry date.
- *
- * @param producer the producer endpoint reference.
- * @param consumer the consumer endpoint reference .
- * @throws SoapFault when the subscription cannot be made.
- */
- private void allMessagesWithMessageFilterWithoutTerminationTime(EndpointReference producer, EndpointReference consumer) throws SoapFault
- {
- NotificationProducerClient producerClient = new NotificationProducerClient(producer);
- producerClient.setTrace(true);
-
- // Applying this filter will result in a subscription that wll be notified only when a "connection"
- // object is created or removed
- MessagePatternFilter filter= new MessagePatternFilter(
- "/wsnt:NotificationMessage/wsnt:Message/qman:LifeCycleEvent/qman:Resource/qman:Name/text()='connection'", // expression (XPath)
- XPathUtils.NAMESPACE_URI); // Dialect : the only supported dialect is XPath 1.0
-
- producerClient.subscribe(
- consumer, // Consumer Endpoint reference
- filter, // Message Filter
- null); // Termination Time : if null the subscription will never expire.
- }
-
- /**
- * Makes a subscription on all topics with a message filter and an expiry date.
- *
- * @param producer the producer endpoint reference.
- * @param consumer the consumer endpoint reference .
- * @throws SoapFault when the subscription cannot be made.
- */
- private void allMessagesWithMessageFilterAndTerminationTime(EndpointReference producer, EndpointReference consumer) throws SoapFault
- {
- NotificationProducerClient producerClient = new NotificationProducerClient(producer);
- producerClient.setTrace(true);
-
- // Applying this filter will result in a subscription that wll be notified only when a "connection"
- // object is created or removed
- MessagePatternFilter filter= new MessagePatternFilter(
- "/wsnt:NotificationMessage/wsnt:Message/qman:LifeCycleEvent/qman:Resource/qman:Name/text()='connection'", // expression (XPath)
- XPathUtils.NAMESPACE_URI); // Dialect : the only supported dialect is XPath 1.0
-
- producerClient.subscribe(
- consumer, // Consumer Endpoint reference
- filter, // Message Filter
- new Date(System.currentTimeMillis() + 10000)); // Termination Time
- }
-
- /**
- * Makes a subscription on a specifc topic with an expiry date.
- * Only messages published on the given topic will be delivered to the given consumer.
- * The subscription will end after 10 seconds
- *
- * @param producer the producer endpoint reference.
- * @param consumer the consumer endpoint reference .
- * @throws SoapFault when the subscription cannot be made.
- */
- private void complexSubscription(EndpointReference producer, EndpointReference consumer) throws SoapFault
- {
- NotificationProducerClient producerClient = new NotificationProducerClient(producer);
- producerClient.setTrace(true);
-
- FilterCollection filter = new FilterCollection();
-
- TopicFilter topicFilter = new TopicFilter(Names.EVENTS_LIFECYLE_TOPIC_NAME);
- MessagePatternFilter messageFilter= new MessagePatternFilter(
- "/wsnt:NotificationMessage/wsnt:Message/qman:LifeCycleEvent/qman:Resource/qman:Name/text()='connection'", // expression (XPath)
- XPathUtils.NAMESPACE_URI); // Dialect : the only supported dialect is XPath 1.0
-
- ProducerPropertiesFilter producerFilter = new ProducerPropertiesFilter(
- "boolean(/*/MgtPubInterval > 100 and /*/MsgTotalEnqueues > 56272)",
- XPathUtils.NAMESPACE_URI);
-
- filter.addFilter(topicFilter);
- filter.addFilter(messageFilter);
- filter.addFilter(producerFilter);
-
- producerClient.subscribe(
- consumer, // Consumer Endpoint reference
- filter, // Topic Filter
- new Date(System.currentTimeMillis() + 10000)); // Termination Time
- }
-
- @Override
- void printOutExampleDescription()
- {
- System.out.println("This example is demonstrating a WS-Notification scenario ");
- System.out.println("when (for simplicity) QMan is at the same time consumer ");
- System.out.println("and producer.");
- System.out.println();
- System.out.println("Basically we have (on producer side) two topics : one for");
- System.out.println("lifecycle events of object instance (objects created & removed) ");
- System.out.println("and another one for lifecycle of event (events created).");
- System.out.println();
- System.out.println("On consumer side there are many options that you can use in");
- System.out.println("order to made a sunscription :");
- System.out.println();
- System.out.println("- you could be an observer of all messages (all topics);");
- System.out.println("- you could be an observer of one specific topic;");
- System.out.println("- you could be an observer of all messages that match a condition expressed in XPath;");
- System.out.println();
- System.out.println("All those options are provided with or withour a termination time.");
- System.out.println("A subscription with a termination time will have a predefined expiry");
- System.out.println("date while if there's no termination the subscription will never expire.");
- }
-
- public static void main(String[] args)
- {
- new ConsumerAndProducerExample().execute(new String[]{"localhost","8080"});
- }
-}
diff --git a/java/management/client/src/example/org/apache/qpid/management/example/GetMultipleResourcePropertiesExample.java b/java/management/client/src/example/org/apache/qpid/management/example/GetMultipleResourcePropertiesExample.java
deleted file mode 100644
index 413222a79d..0000000000
--- a/java/management/client/src/example/org/apache/qpid/management/example/GetMultipleResourcePropertiesExample.java
+++ /dev/null
@@ -1,179 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you 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.qpid.management.example;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import javax.xml.namespace.QName;
-
-import org.apache.muse.core.proxy.ProxyHandler;
-import org.apache.muse.core.proxy.ReflectionProxyHandler;
-import org.apache.muse.util.xml.XmlUtils;
-import org.apache.muse.ws.addressing.EndpointReference;
-import org.apache.muse.ws.resource.remote.WsResourceClient;
-import org.apache.muse.ws.resource.sg.remote.ServiceGroupClient;
-import org.w3c.dom.Element;
-
-/**
- * This example shows how to get properties from a WS-Resource using one request.
- * First of all a request is send to WS-DM in order to get all registered WS-Resources.
- * If the returned list is not empty then a GetMetadataRequest is sent to the
- * first child.
- * The result metadata descriptor contains all properties names of the target WS-Resource.
- * Those names are then used for retrieving the corresponding values.
- *
- * @author Andrea Gazzarini
- */
-public class GetMultipleResourcePropertiesExample extends AbstractQManExample
-{
-
- /**
- * First of all a request is send to WS-DM in order to get all registered WS-Resources.
- * If the returned list is not empty then a GetMetadataRequest is sent to the
- * first child.
- * The result metadata descriptor contains all properties names of the target WS-Resource.
- * Those names are then used for retrieving the corresponding values.
- *
- * @param host the host where QMan is running.
- * @param port the port where QMan is running.
- * @throws Exception when the example fails (not at application level).
- */
- void executeExample(String host, int port) throws Exception
- {
-
- // 1) Creates an endpoint reference of the adapter service...
- EndpointReference adapterEndpointReference = getAdapterEndpointReference(host, port);
-
- // 2) Creates the Adapter service client...
- ServiceGroupClient adapterClient = new ServiceGroupClient(adapterEndpointReference);
- adapterClient.setTrace(true);
-
- // 3) Retrieves the all registered members (QMan WS-Resources)
- WsResourceClient [] resources = adapterClient.getMembers();
-
- // Sanity check : we cannot proceed if there are no WS-Resources.
- if (resources.length == 0)
- {
- System.out.println("----------------------------WARNING---------------------------");
- System.out.println("Cannot proceed with the example... it seems");
- System.out.println("that there are no managed WS-Resources on QMan.");
- System.out.println("Please check QMan in order to see that it is really");
- System.out.println("connected with a broker.");
- System.out.println("-------------------------------------------------------------------");
- System.exit(0);
- }
-
- // 4) Creates a proxy handler for service invocation.
- ProxyHandler metadataProxyHandler = createProxyHandler();
-
- // 5) ..and invokes the GetMetadata on the first member.
- WsResourceClient wsResourceClient = resources[0];
- wsResourceClient.setTrace(true);
-
- // Dialect is RDM for this example
- String dialect = "http://docs.oasis-open.org/wsrf/rmd-1";
- Object [] inputParameters = {dialect};
-
- // RDM is the first element of the returned array.
- // The first element is a wsx:Metadata containing all resource properties.
- Element [] metadata = (Element[]) wsResourceClient.invoke(metadataProxyHandler, inputParameters);
- Element resourceMetadataDescriptor = metadata[0];
-
- // 6) using XPath navigates xml in order to get the list of all properties.
- Element [] properties = XmlUtils.findInSubTree(
- resourceMetadataDescriptor,
- new QName("http://docs.oasis-open.org/wsrf/rmd-1","Property","wsrmd"));
- List<QName> names = new ArrayList<QName>();
-
- for (Element property : properties)
- {
-
- String attributeName = property.getAttribute("name"); // = qman:<Attribute Name>
-
- // For this example we are only interested on qman namespace related properties...
- if (attributeName.startsWith("qman"))
- {
- String attributeNameWithoutPrefix = attributeName.replaceFirst("qman:", ""); // = <Attribute Name>
-
- names.add(new QName(
- "http://amqp.apache.org/qpid/management/qman",
- attributeNameWithoutPrefix,
- "qman"));
- }
- }
-
- QName [] qnames = names.toArray(new QName[names.size()]);
-
- // 7) Send a GetMultipleResourcePropertiesRequest.
- // We do nothing with the returned value(s) because it / they
- // has / have already printed out (wsResourceClient.setTrace(true))
- @SuppressWarnings("unused")
- Element [] values = wsResourceClient.getMultipleResourceProperties(qnames);
- }
-
- /**
- * Prints out a description of this example.
- */
- void printOutExampleDescription()
- {
- System.out.println(" "+getClass().getSimpleName()+" ");
- System.out.println("-------------------------------------------------------------------");
- System.out.println();
- System.out.println("This example shows how to get properties from a");
- System.out.println("WS-Resource using one request. ");
- System.out.println("First of all a request is send to WS-DM in order to get");
- System.out.println("all registered WS-Resources.");
- System.out.println("If the returned list is not empty then a GetMetadataRequest");
- System.out.println("to the first child.");
- System.out.println("The result metadata descriptor contains all property names of");
- System.out.println("the target WS-Resource.");
- System.out.println("Those names are then used for retrieving the corresponding values");
- System.out.println("using the GetMultipleResourceProperties request.");
- System.out.println();
- System.out.println("-------------------------------------------------------------------");
- System.out.println();
- }
-
- /**
- * A proxy handler is a module needed in order to make a capability
- * service invocation.
- * It contains logic to serialize and deserialize request, response, input and
- * output parameters during a web service invocation.
- *
- * @return a proxy handler.
- */
- private ProxyHandler createProxyHandler()
- {
- ProxyHandler handler = new ReflectionProxyHandler();
- handler.setAction("http://schemas.xmlsoap.org/ws/2004/09/mex/GetMetadata");
- handler.setRequestName(new QName("http://schemas.xmlsoap.org/ws/2004/09/mex", "GetMetadata", PREFIX));
- handler.setRequestParameterNames(new QName[]{new QName("http://schemas.xmlsoap.org/ws/2004/09/mex", "Dialect", PREFIX)});
- handler.setResponseName(new QName("http://schemas.xmlsoap.org/ws/2004/09/mex", "Metadata", PREFIX));
- handler.setReturnType(Element[].class);
- return handler;
- }
-
- public static void main(String[] arguments)
- {
- new GetMultipleResourcePropertiesExample().execute(arguments);
- }
-} \ No newline at end of file
diff --git a/java/management/client/src/example/org/apache/qpid/management/example/GetQManResourceMembersExample.java b/java/management/client/src/example/org/apache/qpid/management/example/GetQManResourceMembersExample.java
deleted file mode 100644
index f74a44ab57..0000000000
--- a/java/management/client/src/example/org/apache/qpid/management/example/GetQManResourceMembersExample.java
+++ /dev/null
@@ -1,93 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you 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.qpid.management.example;
-
-import org.apache.muse.ws.addressing.EndpointReference;
-import org.apache.muse.ws.resource.remote.WsResourceClient;
-import org.apache.muse.ws.resource.sg.remote.ServiceGroupClient;
-
-/**
- * An example demonstrating the usage of GetResourcePropertyRequest/Response on
- * the WS-DM Adapter.
- *
- * @author Andrea Gazzarini
- */
-public class GetQManResourceMembersExample extends AbstractQManExample
-{
- /**
- * Looks for memebers of QMan group requesting ws-rp:Entry property to
- * WS-DM Adapter resource service.
- *
- * @param host the host where QMan is running.
- * @param port the port where QMan is running.
- * @throws Exception when the example fails (not at application level).
- */
- void executeExample(String host, int port) throws Exception
- {
- // 1) Creates an endpoint reference of the adapter service...
- EndpointReference serviceEndpointReference = getAdapterEndpointReference(host, port);
-
- // 2) Creates the Service client...
- ServiceGroupClient adapterClient = new ServiceGroupClient(serviceEndpointReference);
- adapterClient.setTrace(true);
-
- // 3) Invokes the service.
- WsResourceClient [] resources = adapterClient.getMembers();
-
- String result = (resources.length != 0)
- ? ("QMan has at the moment "+resources.length+" registered resources.")
- : "It seems that there are no managed resource on QMan side...";
-
- System.out.println("--------------------------------------------------------------------------");
- System.out.println(result);
- System.out.println("--------------------------------------------------------------------------");
- }
-
- /**
- * Prints out a description of this example.
- */
- void printOutExampleDescription()
- {
- System.out.println(" "+getClass().getSimpleName()+" ");
- System.out.println("-------------------------------------------------------------------");
- System.out.println();
- System.out.println("This example shows the usage of WS-DM ");
- System.out.println("GetResourcePropertyRequest / Response on a ");
- System.out.println("Group service.");
- System.out.println("The target resource is the WS-DM Adapter itself ");
- System.out.println("and the requested property is \"wsrf-sg:Entry\".");
- System.out.println("WS-DM Adapter is a special WS-Resource (is a Group)");
- System.out.println("that acts as the main entry point for retrieving");
- System.out.println("all other managed resources.");
- System.out.println("So clients that want to deal with QMan WS-Resources");
- System.out.println("must first get resource identifiers sending");
- System.out.println("a GetResourcePropertyRequest to WS-DM Adapter ");
- System.out.println("with \"wsrf-sg:Entry\" as target target property.");
- System.out.println();
- System.out.println("-------------------------------------------------------------------");
- System.out.println();
- }
-
- public static void main(String[] arguments)
- {
- new GetQManResourceMembersExample().execute(arguments);
- }
-} \ No newline at end of file
diff --git a/java/management/client/src/example/org/apache/qpid/management/example/GetResourceMetadataDescriptorExample.java b/java/management/client/src/example/org/apache/qpid/management/example/GetResourceMetadataDescriptorExample.java
deleted file mode 100644
index 84befc01e4..0000000000
--- a/java/management/client/src/example/org/apache/qpid/management/example/GetResourceMetadataDescriptorExample.java
+++ /dev/null
@@ -1,156 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you 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.qpid.management.example;
-
-import javax.xml.namespace.QName;
-
-import org.apache.muse.core.proxy.ProxyHandler;
-import org.apache.muse.core.proxy.ReflectionProxyHandler;
-import org.apache.muse.ws.addressing.EndpointReference;
-import org.apache.muse.ws.resource.remote.WsResourceClient;
-import org.apache.muse.ws.resource.sg.remote.ServiceGroupClient;
-import org.w3c.dom.Element;
-
-/**
- * This example shows how to get metadata from a WS-Resource.
- * The service supports different kinds of metadata.
- * User who wants to receive metadata of a WS-Resource must
- * send a GetMetadataRequesta specifying the requested dialect.
- *
- * Supported metadata that could be requested are
- *
- * <ul>
- * <li>
- * WSDL : requested using "http://schemas.xmlsoap.org/wsdl/" as dialect..
- * <li>
- * <li>
- * RDM (Resource Metadata Descriptor) : requested using "http://docs.oasis-open.org/wsrf/rmd-1 "as dialect.
- * </li>
- * </ul>
- *
- * Note that this example focuses on RDM Metadata only; another example is dedicated to WSDL.
- *
- * @author Andrea Gazzarini
- */
-public class GetResourceMetadataDescriptorExample extends AbstractQManExample
-{
-
- /**
- * First, sends a request to WS-DM Adapter in order to get the list of managed resources.
- * If the list is not empty, then takes the first member and sends it a GetMetadataRequest
- * in order to get its RDM.
- *
- * @param host the host where QMan is running.
- * @param port the port where QMan is running.
- * @throws Exception when the example fails (not at application level).
- */
- void executeExample(String host, int port) throws Exception
- {
-
- // 1) Creates an endpoint reference of the adapter service...
- EndpointReference adapterEndpointReference = getAdapterEndpointReference(host, port);
-
- // 2) Creates the Adapter service client...
- ServiceGroupClient adapterClient = new ServiceGroupClient(adapterEndpointReference);
- adapterClient.setTrace(true);
-
- // 3) Retrieves the all registered members (QMan WS-Resources)
- WsResourceClient [] resources = adapterClient.getMembers();
-
- // Sanity check : we cannot proceed if there are no WS-Resources.
- if (resources.length == 0)
- {
- System.out.println("----------------------------WARNING---------------------------");
- System.out.println("Cannot proceed with the example... it seems");
- System.out.println("that there are no managed WS-Resources on QMan.");
- System.out.println("Please check QMan in order to see that it is really");
- System.out.println("connected with a broker.");
- System.out.println("-------------------------------------------------------------------");
- System.exit(0);
- }
-
- // 4) Creates a proxy handler for service invocation.
- ProxyHandler metadataProxyHandler = createProxyHandler();
-
- // 5) ..and invokes the GetMetadata on the first member.
- WsResourceClient firstMember = resources[0];
- firstMember.setTrace(true);
-
- // Dialect is RDM for this example
- String dialect = "http://docs.oasis-open.org/wsrf/rmd-1";
- Object [] inputParameters = {dialect};
-
- // WSDL is the first element of the returned array. We don't need to print out it here
- // because at this point it should have been already printed out (line 96 : firstMember.setTrace(true))
- @SuppressWarnings("unused")
- Element [] metadata = (Element[]) firstMember.invoke(metadataProxyHandler, inputParameters);
- }
-
- /**
- * Prints out a description of this example.
- */
- void printOutExampleDescription()
- {
- System.out.println(" "+getClass().getSimpleName()+" ");
- System.out.println("-------------------------------------------------------------------");
- System.out.println();
- System.out.println("The example shows how to get metadata from a");
- System.out.println("WS-Resource.");
- System.out.println("A QMan WS-Resource has different kinds of metadata.");
- System.out.println("(see below)");
- System.out.println("User who wants to receive metadata of a WS-Resource");
- System.out.println("must send a GetMetadataRequesta specifying the");
- System.out.println("associated dialect.");
- System.out.println("Supported metadata that could be requested are : ");
- System.out.println();
- System.out.println("- WSDL : in this case dialect is \"http://schemas.xmlsoap.org/wsdl/\";");
- System.out.println("- RDM (Resource Metadata Descriptor) : in this case dialect is \"http://docs.oasis-open.org/wsrf/rmd-1 \".");
- System.out.println();
- System.out.println("Note that this examples focuses on RDM Metadata only;");
- System.out.println("another one is dedicated to WSDL.");
- System.out.println("-------------------------------------------------------------------");
- System.out.println();
- }
-
- /**
- * A proxy handler is a module needed in order to make a capability
- * service invocation.
- * It contains logic to serialize and deserialize request, response, input and
- * output parameters during a web service invocation.
- *
- * @return a proxy handler.
- */
- private ProxyHandler createProxyHandler()
- {
- ProxyHandler handler = new ReflectionProxyHandler();
- handler.setAction("http://schemas.xmlsoap.org/ws/2004/09/mex/GetMetadata");
- handler.setRequestName(new QName("http://schemas.xmlsoap.org/ws/2004/09/mex", "GetMetadata", PREFIX));
- handler.setRequestParameterNames(new QName[]{new QName("http://schemas.xmlsoap.org/ws/2004/09/mex", "Dialect", PREFIX)});
- handler.setResponseName(new QName("http://schemas.xmlsoap.org/ws/2004/09/mex", "Metadata", PREFIX));
- handler.setReturnType(Element[].class);
- return handler;
- }
-
- public static void main(String[] arguments)
- {
- new GetResourceMetadataDescriptorExample().execute(arguments);
- }
-} \ No newline at end of file
diff --git a/java/management/client/src/example/org/apache/qpid/management/example/GetResourcePropertyDocumentExample.java b/java/management/client/src/example/org/apache/qpid/management/example/GetResourcePropertyDocumentExample.java
deleted file mode 100644
index 56ce81358d..0000000000
--- a/java/management/client/src/example/org/apache/qpid/management/example/GetResourcePropertyDocumentExample.java
+++ /dev/null
@@ -1,111 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you 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.qpid.management.example;
-
-import org.apache.muse.ws.addressing.EndpointReference;
-import org.apache.muse.ws.resource.remote.WsResourceClient;
-import org.apache.muse.ws.resource.sg.remote.ServiceGroupClient;
-import org.w3c.dom.Element;
-
-/**
- * This example shows how to get the whole property document from a WS-Resource.
- * Resource property document represents a particular composed structural view of
- * the resource properties of the WS-Resource.
- * Let's say that It is a way to get all-in-once the state of the WS-Resource.
- *
- * First of all a request is send to WS-DM in order to get all registered WS-Resources.
- * If the returned list is not empty then a GetResourcePropertyDocumentRequest is
- * sent to the first child.
- *
- * @author Andrea Gazzarini
- */
-public class GetResourcePropertyDocumentExample extends AbstractQManExample
-{
-
- /**
- * First of all a request is send to WS-DM in order to get all registered WS-Resources.
- * If the returned list is not empty then a GetResourcePropertyDocumentRequest is
- * sent to the first child.
- *
- * @param host the host where QMan is running.
- * @param port the port where QMan is running.
- * @throws Exception when the example fails (not at application level).
- */
- void executeExample(String host, int port) throws Exception
- {
-
- // 1) Creates an endpoint reference of the adapter service...
- EndpointReference adapterEndpointReference = getAdapterEndpointReference(host, port);
-
- // 2) Creates the Adapter service client...
- ServiceGroupClient adapterClient = new ServiceGroupClient(adapterEndpointReference);
- adapterClient.setTrace(true);
-
- // 3) Retrieves the all registered members (QMan WS-Resources)
- WsResourceClient [] resources = adapterClient.getMembers();
-
- // Sanity check : we cannot proceed if there are no WS-Resources.
- if (resources.length == 0)
- {
- System.out.println("----------------------------WARNING---------------------------");
- System.out.println("Cannot proceed with the example... it seems");
- System.out.println("that there are no managed WS-Resources on QMan.");
- System.out.println("Please check QMan in order to see that it is really");
- System.out.println("connected with a broker.");
- System.out.println("-------------------------------------------------------------------");
- System.exit(0);
- }
-
- // 4) ..and invokes the GetMetadata on the first member.
- WsResourceClient wsResourceClient = resources[0];
- wsResourceClient.setTrace(true);
-
- @SuppressWarnings("unused")
- Element resourcePropertyDocument = wsResourceClient.getResourcePropertyDocument();
- }
- /**
- * Prints out a description of this example.
- */
- void printOutExampleDescription()
- {
- System.out.println(" "+getClass().getSimpleName()+" ");
- System.out.println("-------------------------------------------------------------------");
- System.out.println();
- System.out.println("This example shows how to get the whole property");
- System.out.println("document from a WS-Resource.");
- System.out.println("Resource property document represents a particular ");
- System.out.println("composed structural view of the resource properties");
- System.out.println("of the WS-Resource.");
- System.out.println("First of all a request is send to WS-DM in order to get");
- System.out.println("all registered WS-Resources.");
- System.out.println("the target WS-Resource.");
- System.out.println("If the returned list is not empty then a");
- System.out.println("GetResourcePropertyDocumentRequest is sent to the first child.");
- System.out.println();
- System.out.println("-------------------------------------------------------------------");
- System.out.println();
- }
-
- public static void main(String[] arguments)
- {
- new GetResourcePropertyDocumentExample().execute(arguments);
- }
-} \ No newline at end of file
diff --git a/java/management/client/src/example/org/apache/qpid/management/example/GetResourcePropertyExample.java b/java/management/client/src/example/org/apache/qpid/management/example/GetResourcePropertyExample.java
deleted file mode 100644
index 28ed1c7925..0000000000
--- a/java/management/client/src/example/org/apache/qpid/management/example/GetResourcePropertyExample.java
+++ /dev/null
@@ -1,172 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you 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.qpid.management.example;
-
-import javax.xml.namespace.QName;
-
-import org.apache.muse.core.proxy.ProxyHandler;
-import org.apache.muse.core.proxy.ReflectionProxyHandler;
-import org.apache.muse.util.xml.XmlUtils;
-import org.apache.muse.ws.addressing.EndpointReference;
-import org.apache.muse.ws.resource.remote.WsResourceClient;
-import org.apache.muse.ws.resource.sg.remote.ServiceGroupClient;
-import org.w3c.dom.Element;
-
-/**
- * This example shows how to get the property value from a WS-Resource.
- * First of all a request is send to WS-DM in order to get all registered WS-Resources.
- * If the returned list is not empty then a GetMetadataRequest is sent to the
- * first child.
- * The result metadata descriptor contains all properties of the target WS-Resource.
- * For each of them a GetResourcePropertyRequest is sent in order to get its value.
- *
- * @author Andrea Gazzarini
- */
-public class GetResourcePropertyExample extends AbstractQManExample
-{
-
- /**
- * First, sends a request to WS-DM Adapter in order to get the list of managed resources.
- * If the list is not empty, then takes the first member and sends it a GetMetadataRequest
- * in order to get its WSDL.
- * After that, for each property contained in ResourceMetadataDescriptorm (RDM) a
- * GetResourcePropertyRequest is sent in order to get its value.
- *
- * @param host the host where QMan is running.
- * @param port the port where QMan is running.
- * @throws Exception when the example fails (not at application level).
- */
- void executeExample(String host, int port) throws Exception
- {
-
- // 1) Creates an endpoint reference of the adapter service...
- EndpointReference adapterEndpointReference = getAdapterEndpointReference(host, port);
-
- // 2) Creates the Adapter service client...
- ServiceGroupClient adapterClient = new ServiceGroupClient(adapterEndpointReference);
- adapterClient.setTrace(true);
-
- // 3) Retrieves the all registered members (QMan WS-Resources)
- WsResourceClient [] resources = adapterClient.getMembers();
-
- // Sanity check : we cannot proceed if there are no WS-Resources.
- if (resources.length == 0)
- {
- System.out.println("----------------------------WARNING---------------------------");
- System.out.println("Cannot proceed with the example... it seems");
- System.out.println("that there are no managed WS-Resources on QMan.");
- System.out.println("Please check QMan in order to see that it is really");
- System.out.println("connected with a broker.");
- System.out.println("-------------------------------------------------------------------");
- System.exit(0);
- }
-
- // 4) Creates a proxy handler for service invocation.
- ProxyHandler metadataProxyHandler = createProxyHandler();
-
- // 5) ..and invokes the GetMetadata on the first member.
- WsResourceClient wsResourceClient = resources[0];
- wsResourceClient.setTrace(true);
-
- // Dialect is RDM for this example
- String dialect = "http://docs.oasis-open.org/wsrf/rmd-1";
- Object [] inputParameters = {dialect};
-
- // RDM is the first element of the returned array.
- // The first element is a wsx:Metadata containing all resource properties.
- Element [] metadata = (Element[]) wsResourceClient.invoke(metadataProxyHandler, inputParameters);
- Element resourceMetadataDescriptor = metadata[0];
-
- // 6) using XPath navigates xml in order to get the list of all properties.
- Element [] properties = XmlUtils.findInSubTree(
- resourceMetadataDescriptor,
- new QName("http://docs.oasis-open.org/wsrf/rmd-1","Property","wsrmd"));
-
- for (Element property : properties)
- {
-
- String attributeName = property.getAttribute("name"); // = qman:<Attribute Name>
-
- // For this example we are only interested on qman namespace related properties...
- if (attributeName.startsWith("qman"))
- {
- String attributeNameWithoutPrefix = attributeName.replaceFirst("qman:", ""); // = <Attribute Name>
-
- // 7) Send a GetResourcePropertyRequest for the given attribute.
- // We do nothing with the returned value(s) because it / they
- // has / have already printed out (wsResourceClient.setTrace(true))
- @SuppressWarnings("unused")
- Element [] values = wsResourceClient.getResourceProperty(
- new QName(
- "http://amqp.apache.org/qpid/management/qman",
- attributeNameWithoutPrefix,
- "qman"));
- }
- }
- }
-
- /**
- * Prints out a description of this example.
- */
- void printOutExampleDescription()
- {
- System.out.println(" "+getClass().getSimpleName()+" ");
- System.out.println("-------------------------------------------------------------------");
- System.out.println();
- System.out.println("This example shows how to get the property value");
- System.out.println("from a WS-Resource.");
- System.out.println("First of all a request is send to WS-DM in order to get");
- System.out.println("all registered WS-Resources.");
- System.out.println("If the returned list is not empty then a GetMetadataRequest");
- System.out.println("to the first child.");
- System.out.println("The result metadata descriptor contains all properties of");
- System.out.println("the target WS-Resource.");
- System.out.println("For each of them a GetResourcePropertyRequest is sent");
- System.out.println(" in order to get its value.");
- System.out.println();
- System.out.println("-------------------------------------------------------------------");
- System.out.println();
- }
-
- /**
- * A proxy handler is a module needed in order to make a capability
- * service invocation.
- * It contains logic to serialize and deserialize request, response, input and
- * output parameters during a web service invocation.
- *
- * @return a proxy handler.
- */
- private ProxyHandler createProxyHandler()
- {
- ProxyHandler handler = new ReflectionProxyHandler();
- handler.setAction("http://schemas.xmlsoap.org/ws/2004/09/mex/GetMetadata");
- handler.setRequestName(new QName("http://schemas.xmlsoap.org/ws/2004/09/mex", "GetMetadata", PREFIX));
- handler.setRequestParameterNames(new QName[]{new QName("http://schemas.xmlsoap.org/ws/2004/09/mex", "Dialect", PREFIX)});
- handler.setResponseName(new QName("http://schemas.xmlsoap.org/ws/2004/09/mex", "Metadata", PREFIX));
- handler.setReturnType(Element[].class);
- return handler;
- }
-
- public static void main(String[] arguments)
- {
- new GetResourcePropertyExample().execute(arguments);
- }
-} \ No newline at end of file
diff --git a/java/management/client/src/example/org/apache/qpid/management/example/GetWSDLMetadataExample.java b/java/management/client/src/example/org/apache/qpid/management/example/GetWSDLMetadataExample.java
deleted file mode 100644
index ecda6e8fb1..0000000000
--- a/java/management/client/src/example/org/apache/qpid/management/example/GetWSDLMetadataExample.java
+++ /dev/null
@@ -1,156 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you 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.qpid.management.example;
-
-import javax.xml.namespace.QName;
-
-import org.apache.muse.core.proxy.ProxyHandler;
-import org.apache.muse.core.proxy.ReflectionProxyHandler;
-import org.apache.muse.ws.addressing.EndpointReference;
-import org.apache.muse.ws.resource.remote.WsResourceClient;
-import org.apache.muse.ws.resource.sg.remote.ServiceGroupClient;
-import org.w3c.dom.Element;
-
-/**
- * This example shows how to get metadata from a WS-Resource.
- * The service supports different kinds of metadata.
- * User who wants to receive metadata of a WS-Resource must
- * send a GetMetadataRequesta specifying the requested dialect.
- *
- * Supported metadata that could be requested are
- *
- * <ul>
- * <li>
- * WSDL : requested using "http://schemas.xmlsoap.org/wsdl/" as dialect..
- * <li>
- * <li>
- * RDM (Resource Metadata Descriptor) : requested using "http://docs.oasis-open.org/wsrf/rmd-1 "as dialect.
- * </li>
- * </ul>
- *
- * Note that this example focuses on WSDL Metadata only; another example is dedicated to RDM.
- *
- * @author Andrea Gazzarini
- */
-public class GetWSDLMetadataExample extends AbstractQManExample
-{
-
- /**
- * First, sends a request to WS-DM Adapter in order to get the list of managed resources.
- * If the list is not empty, then takes the first member and sends it a GetMetadataRequest
- * in order to get its WSDL.
- *
- * @param host the host where QMan is running.
- * @param port the port where QMan is running.
- * @throws Exception when the example fails (not at application level).
- */
- void executeExample(String host, int port) throws Exception
- {
-
- // 1) Creates an endpoint reference of the adapter service...
- EndpointReference adapterEndpointReference = getAdapterEndpointReference(host, port);
-
- // 2) Creates the Adapter service client...
- ServiceGroupClient adapterClient = new ServiceGroupClient(adapterEndpointReference);
- adapterClient.setTrace(true);
-
- // 3) Retrieves the all registered members (QMan WS-Resources)
- WsResourceClient [] resources = adapterClient.getMembers();
-
- // Sanity check : we cannot proceed if there are no WS-Resources.
- if (resources.length == 0)
- {
- System.out.println("----------------------------WARNING---------------------------");
- System.out.println("Cannot proceed with the example... it seems");
- System.out.println("that there are no managed WS-Resources on QMan.");
- System.out.println("Please check QMan in order to see that it is really");
- System.out.println("connected with a broker.");
- System.out.println("-------------------------------------------------------------------");
- System.exit(0);
- }
-
- // 4) Creates a proxy handler for service invocation.
- ProxyHandler metadataProxyHandler = createProxyHandler();
-
- // 5) ..and invokes the GetMetadata on the first member.
- WsResourceClient firstMember = resources[0];
- firstMember.setTrace(true);
-
- // Dialect is WSDL for this example
- String dialect = "http://schemas.xmlsoap.org/wsdl/";
- Object [] inputParameters = {dialect};
-
- // WSDL is the first element of the returned array. We don't need to print out it here
- // because at this point it should have been already printed out (line 96 : firstMember.setTrace(true))
- @SuppressWarnings("unused")
- Element [] metadata = (Element[]) firstMember.invoke(metadataProxyHandler, inputParameters);
- }
-
- /**
- * Prints out a description of this example.
- */
- void printOutExampleDescription()
- {
- System.out.println(" "+getClass().getSimpleName()+" ");
- System.out.println("-------------------------------------------------------------------");
- System.out.println();
- System.out.println("The example shows how to get metadata from a");
- System.out.println("WS-Resource.");
- System.out.println("A QMan WS-Resource has different kinds of metadata.");
- System.out.println("(see below)");
- System.out.println("User who wants to receive metadata of a WS-Resource");
- System.out.println("must send a GetMetadataRequesta specifying the");
- System.out.println("associated dialect.");
- System.out.println("Supported metadata that could be requested are : ");
- System.out.println();
- System.out.println("- WSDL : in this case dialect is \"http://schemas.xmlsoap.org/wsdl/\";");
- System.out.println("- RDM (Resource Metadata Descriptor) : in this case dialect is \"http://docs.oasis-open.org/wsrf/rmd-1 \".");
- System.out.println();
- System.out.println("Note that this examples focuses on WSDL Metadata only;");
- System.out.println("another one is dedicated to RDM.");
- System.out.println("-------------------------------------------------------------------");
- System.out.println();
- }
-
- /**
- * A proxy handler is a module needed in order to make a capability
- * service invocation.
- * It contains logic to serialize and deserialize request, response, input and
- * output parameters during a web service invocation.
- *
- * @return a proxy handler.
- */
- private ProxyHandler createProxyHandler()
- {
- ProxyHandler handler = new ReflectionProxyHandler();
- handler.setAction("http://schemas.xmlsoap.org/ws/2004/09/mex/GetMetadata");
- handler.setRequestName(new QName("http://schemas.xmlsoap.org/ws/2004/09/mex", "GetMetadata", PREFIX));
- handler.setRequestParameterNames(new QName[]{new QName("http://schemas.xmlsoap.org/ws/2004/09/mex", "Dialect", PREFIX)});
- handler.setResponseName(new QName("http://schemas.xmlsoap.org/ws/2004/09/mex", "Metadata", PREFIX));
- handler.setReturnType(Element[].class);
- return handler;
- }
-
- public static void main(String[] arguments)
- {
- new GetWSDLMetadataExample().execute(arguments);
- }
-} \ No newline at end of file
diff --git a/java/management/client/src/example/org/apache/qpid/management/example/PausableSubscriptionExample.java b/java/management/client/src/example/org/apache/qpid/management/example/PausableSubscriptionExample.java
deleted file mode 100644
index 01a27a16f9..0000000000
--- a/java/management/client/src/example/org/apache/qpid/management/example/PausableSubscriptionExample.java
+++ /dev/null
@@ -1,88 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you 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.qpid.management.example;
-
-import java.net.URI;
-
-import org.apache.muse.ws.addressing.EndpointReference;
-import org.apache.muse.ws.notification.remote.NotificationProducerClient;
-import org.apache.muse.ws.notification.remote.SubscriptionClient;
-
-/**
- * This example is demonstrating a WS-Notification scenario
- * when (for simplicity) QMan is at the same time consumer
- * and producer.
- *
- * Specifically the example shows how a requestor can create, pause and resume
- * a subscription.
- *
- * @author Andrea Gazzarini
- *
- */
-public class PausableSubscriptionExample extends AbstractQManExample
-{
- @Override
- void executeExample(String host, int port) throws Exception
- {
- // This is QMan...
- URI producerURI = URI.create("http://"+host+":"+port+"/qman/services/adapter");
-
- // ...and this is QMan too! Note that it has an hidden consumer capability that is used in
- // order to run successfully this example...
- URI consumerURI = URI.create("http://"+host+":"+port+"/qman/services/consumer");
-
- EndpointReference producerEPR = new EndpointReference(producerURI);
- EndpointReference consumerEPR = new EndpointReference(consumerURI);
-
- NotificationProducerClient producerClient = new NotificationProducerClient(producerEPR);
- producerClient.setTrace(true);
-
- // 1) Creates a subscription and gets the corresponding reference.
- SubscriptionClient subscriptionClient = producerClient.subscribe(
- consumerEPR, // Consumer Endpoint reference
- null, // Filter, if null that means "all messages"
- null); // Termination Time : if null the subscription will never expire.
- subscriptionClient.setTrace(true);
-
-
- // 2) Pauses the subscription.
- subscriptionClient.pauseSubscription();
-
- // 3) Resumes the subscription.
- subscriptionClient.resumeSubscription();
- }
-
- @Override
- void printOutExampleDescription()
- {
- System.out.println("This example is demonstrating a WS-Notification scenario ");
- System.out.println("when (for simplicity) QMan is at the same time consumer ");
- System.out.println("and producer.");
- System.out.println();
- System.out.println("Specifically the example shows how a requestor can create,");
- System.out.println("pause and resume a subscription.");
- }
-
- public static void main(String[] args)
- {
- new PausableSubscriptionExample().execute(new String[]{"romagazzarini","8080"});
- }
-}
diff --git a/java/management/client/src/example/org/apache/qpid/management/example/SetResourcePropertyExample.java b/java/management/client/src/example/org/apache/qpid/management/example/SetResourcePropertyExample.java
deleted file mode 100644
index 8aed3101ff..0000000000
--- a/java/management/client/src/example/org/apache/qpid/management/example/SetResourcePropertyExample.java
+++ /dev/null
@@ -1,306 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you 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.qpid.management.example;
-
-import java.lang.reflect.Array;
-import java.util.HashMap;
-import java.util.Map;
-
-import javax.xml.namespace.QName;
-
-import org.apache.muse.core.proxy.ProxyHandler;
-import org.apache.muse.core.proxy.ReflectionProxyHandler;
-import org.apache.muse.util.xml.XmlUtils;
-import org.apache.muse.ws.addressing.EndpointReference;
-import org.apache.muse.ws.resource.remote.WsResourceClient;
-import org.apache.muse.ws.resource.sg.remote.ServiceGroupClient;
-import org.w3c.dom.Element;
-
-/**
- * This example shows how to change the state of a WS-Resource. That means
- * a SetResourcePropertyRequest is sent to that WS-Resource.
- * First of all a request is send to WS-DM in order to get all registered WS-Resources.
- * If the returned list is not empty then two GetMetadataRequests are sent to the
- * first child (one for WSDL and one for RDM).
- * The result metadata descriptors are the used to determine :
- *
- * <br> What are names of WS-Resouce properties
- * <br> Their modifiability (read-only or read-write)
- * <br> Their type
- *
- * So a SetResourcePropertyRequest can be sent in order to change the WS-Resource state.
- * The example is looking for a property that has one of the following datatype :
- *
- * <ul>
- * <li>String</li>
- * <li>Long</li>
- * <li>Integer</li>
- * <li>Short</li>
- * <li>Double</li>
- * <li>Float</li>
- * </ul>
- *
- * After the update / insert request has been sent, a GetResourcePropertiesRequest is made
- * again in order to see if the state has changed correctly.
- *
- * @author Andrea Gazzarini
- */
-public class SetResourcePropertyExample extends AbstractQManExample
-{
- /**
- * First of all a request is send to WS-DM in order to get all registered WS-Resources.
- * If the returned list is not empty then two GetMetadataRequests are sent to the
- * first child (one for WSDL and one for RDM).
- * The result metadata descriptors are the used to determine :
- *
- * <br> What are names of WS-Resouce properties
- * <br> Their modifiability (read-only or read-write)
- * <br> Their type
- *
- * So a SetResourcePropertyRequest can be sent in order to change the WS-Resource state.
- * The example is looking for a property that has one of the following datatype :
- *
- * <ul>
- * <li>String</li>
- * <li>Long</li>
- * <li>Integer</li>
- * <li>Short</li>
- * <li>Double</li>
- * <li>Float</li>
- * </ul>
- *
- * After the update / insert request has been sent, a GetResourcePropertiesRequest is made
- * again in order to see if the state has changed correctly.
- *
- * @param host the host where QMan is running.
- * @param port the port where QMan is running.
- * @throws Exception when the example fails (not at application level).
- */
- void executeExample(String host, int port) throws Exception
- {
- // 1) Creates an endpoint reference of the adapter service...
- EndpointReference adapterEndpointReference = getAdapterEndpointReference(host, port);
-
- // 2) Creates the Adapter service client...
- ServiceGroupClient adapterClient = new ServiceGroupClient(adapterEndpointReference);
- adapterClient.setTrace(false);
-
- // 3) Retrieves the all registered members (QMan WS-Resources)
- WsResourceClient [] resources = adapterClient.getMembers();
-
- // Sanity check : we cannot proceed if there are no WS-Resources.
- if (resources.length == 0)
- {
- System.out.println("----------------------------WARNING---------------------------");
- System.out.println("Cannot proceed with the example... it seems");
- System.out.println("that there are no managed WS-Resources on QMan.");
- System.out.println("Please check QMan in order to see that it is really");
- System.out.println("connected with a broker.");
- System.out.println("-------------------------------------------------------------------");
- System.exit(0);
- }
-
- // 4) Creates a proxy handler for service invocation.
- ProxyHandler metadataProxyHandler = createProxyHandler();
-
- // 5) ..and invokes the GetMetadata on the first member.
- WsResourceClient wsResourceClient = resources[0];
- wsResourceClient.setTrace(true);
-
- // Resource Metadata Descriptor
- String dialect = "http://docs.oasis-open.org/wsrf/rmd-1";
- Object [] inputParameters = {dialect};
-
- // RDM is the first element of the returned array.
- // The first element is a wsx:Metadata containing all resource properties.
- Element [] metadata = (Element[]) wsResourceClient.invoke(metadataProxyHandler, inputParameters);
- Element resourceMetadataDescriptor = metadata[0];
-
- // 6) Now we need WSDL in order to catch datatypes
- dialect = "http://schemas.xmlsoap.org/wsdl/";
- inputParameters = new Object[]{dialect};
- metadata = (Element[]) wsResourceClient.invoke(metadataProxyHandler, inputParameters);
- Element wsdl = metadata[0];
-
- //7) Defines sample values used for update property.
- Map<String, Object> sampleValues = new HashMap<String, Object>();
- sampleValues.put("xsd:string","This is a string.");
- sampleValues.put("xsd:integer",new Integer(12345));
- sampleValues.put("xsd:int",new Integer(54321));
- sampleValues.put("xsd:long",new Integer(12345));
- sampleValues.put("xsd:double",new Double(12345.6d));
- sampleValues.put("xsd:float",new Float(123.4f));
- sampleValues.put("xsd:short",new Short((short)12));
-
- // 8) using XPath navigates xml in order to get the list of all properties.
- Element [] properties = XmlUtils.findInSubTree(
- resourceMetadataDescriptor,
- new QName("http://docs.oasis-open.org/wsrf/rmd-1","Property","wsrmd"));
-
- Element [] wsdlElements = XmlUtils.findInSubTree(
- wsdl,
- new QName("http://www.w3.org/2001/XMLSchema","element","xsd"));
-
- // Did we find at least one writable property?
- boolean atLeastOnePropertyHasBeenFound = false;
-
- for (Element property : properties)
- {
- // Sanity check : if the property is read-only then proceed with next
- // property.
- if (!"read-write".equals(property.getAttribute("modifiability")))
- {
- continue;
- }
-
- String attributeName = property.getAttribute("name"); // = qman:<Attribute Name>
-
- // For this example we are only interested on qman namespace related properties...
- if (attributeName.startsWith("qman"))
- {
- String attributeNameWithoutPrefix = attributeName.replaceFirst("qman:", ""); // = <Attribute Name>
-
- for (Element wsdlElement : wsdlElements)
- {
- String name = wsdlElement.getAttribute("name");
- String type = wsdlElement.getAttribute("type");
- if ((name != null) && (attributeNameWithoutPrefix.equals(name)) && (type != null))
- {
- Object newValue = sampleValues.get(type);
- if (newValue != null)
- {
- atLeastOnePropertyHasBeenFound = true;
-
- inputParameters = new Object[] {newValue};
-
- // 9) Makes a GetResourcePropertiesRequest in order to get the current value.
- QName propertyQName = new QName(
- "http://amqp.apache.org/qpid/management/qman",
- name,
- "qman");
-
- // The returned value is really an array because property shoudl be a multi-value property.
- // So in order to get its value we need to extract the first value.
- Object currentValue = wsResourceClient.getPropertyAsObject(propertyQName,newValue.getClass());
-
- // 10a) If the property is not set (value is null) then an "Insert" request must be sent.
- if (currentValue == null || Array.getLength(currentValue) == 0)
- {
- wsResourceClient.insertResourceProperty(propertyQName,inputParameters);
- }
- // 10b) If the property is not null then an "Update" request must be sent.
- else
- {
- wsResourceClient.updateResourceProperty(propertyQName,inputParameters);
- }
-
- // 11) Let's query again the resource using GetResourceProperties in order to ensure the
- // previous property has been properly updated.
- currentValue = wsResourceClient.getPropertyAsObject(propertyQName,newValue.getClass());
-
- String resultMessage = (newValue.equals(Array.get(currentValue, 0)))
- ? "Resource has been correctly updated."
- : "Something was wrong : resource seems not to be properly updated.";
-
- System.out.println("----------------------------------------------------------------------------------");
- System.out.println(resultMessage);
- System.out.println("----------------------------------------------------------------------------------");
-
- // Let's stop...one property is enough for this example :)
- break;
- }
- }
- }
- if (!atLeastOnePropertyHasBeenFound)
- {
- System.out.println("----------------------------------------------------------------------------------");
- System.out.println("WARNING : This example wasn't able to run because no writable ");
- System.out.println("property has been found on the target WS-Resource.");
- System.out.println("----------------------------------------------------------------------------------");
- }
- }
- }
- }
-
- /**
- * Prints out a description of this example.
- */
- void printOutExampleDescription()
- {
- System.out.println(" "+getClass().getSimpleName()+" ");
- System.out.println("-------------------------------------------------------------------");
- System.out.println();
- System.out.println("This example shows how to change the state of a WS-Resource.");
- System.out.println("That means a SetResourcePropertyRequest is sent to that");
- System.out.println("WS-Resource.");
- System.out.println("First of all a request is send to WS-DM in order to get all");
- System.out.println("registered WS-Resources.");
- System.out.println("If the returned list is not empty then two GetMetadataRequests");
- System.out.println("(one for WSDL and one for RDM) are sent to the first child.");
- System.out.println("The result metadata descriptors are used for determine :");
- System.out.println();
- System.out.println("1) WS-Resource property names;");
- System.out.println("2) Modifiability (read-only, read-write");
- System.out.println("3) Datatype;");
- System.out.println("-------------------------------------------------------------------");
- System.out.println();
- System.out.println("So a SetResourcePropertyRequest can be sent in order");
- System.out.println("to change the WS-Resource state.");
- System.out.println("The example is looking for a property that has one of the");
- System.out.println("following datatype :");
- System.out.println();
- System.out.println("1) String (xsd:string)");
- System.out.println("2) Long (xsd:long)");
- System.out.println("3) Integer (xsd:integer or xsd:int)");
- System.out.println("4) Double (xsd:double)");
- System.out.println("5) Float (xsd:float)");
- System.out.println("6) Short (xsd:short)");
- System.out.println();
- System.out.println("After the update / insert request has been sent, a ");
- System.out.println("GetResourcePropertiesRequest is made again");
- System.out.println("in order to see if the state has changed correctly.");
- System.out.println();
- }
-
- /**
- * A proxy handler is a module needed in order to make a capability
- * service invocation.
- * It contains logic to serialize and deserialize request, response, input and
- * output parameters during a web service invocation.
- *
- * @return a proxy handler.
- */
- private ProxyHandler createProxyHandler()
- {
- ProxyHandler handler = new ReflectionProxyHandler();
- handler.setAction("http://schemas.xmlsoap.org/ws/2004/09/mex/GetMetadata");
- handler.setRequestName(new QName("http://schemas.xmlsoap.org/ws/2004/09/mex", "GetMetadata", PREFIX));
- handler.setRequestParameterNames(new QName[]{new QName("http://schemas.xmlsoap.org/ws/2004/09/mex", "Dialect", PREFIX)});
- handler.setResponseName(new QName("http://schemas.xmlsoap.org/ws/2004/09/mex", "Metadata", PREFIX));
- handler.setReturnType(Element[].class);
- return handler;
- }
-
- public static void main(String[] arguments)
- {
- new SetResourcePropertyExample().execute(arguments);
- }
-} \ No newline at end of file