From 11f9d9200cc40fc259cf46367908136faa3d34b7 Mon Sep 17 00:00:00 2001 From: Andrea Gazzarini Date: Wed, 11 Feb 2009 14:11:41 +0000 Subject: QPID-1582 : WS-Notification implementation on QMan git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@743341 13f79535-47bb-0310-9956-ffa450edef68 --- .../GetMultipleResourcePropertiesExample.java | 12 +- qpid/java/management/client/src/main/java/muse.xml | 76 ++- .../java/org/apache/qpid/management/Messages.java | 8 +- .../java/org/apache/qpid/management/Names.java | 48 +- .../java/org/apache/qpid/management/Protocol.java | 5 + .../qpid/management/domain/model/QpidClass.java | 6 +- .../qpid/management/domain/model/QpidEntity.java | 2 +- .../qpid/management/domain/model/QpidEvent.java | 4 +- .../jmx/EntityLifecycleNotification.java | 26 +- .../jmx/OperationHasBeenInvokedNotification.java | 39 +- .../management/servlet/ConnectQManToBroker.java | 18 +- .../qpid/management/servlet/WSDMAdapter.java | 4 +- .../java/org/apache/qpid/management/wsdm/QEmu.java | 14 +- .../qpid/management/wsdm/QEmuInitializer.java | 9 +- .../ArtifactsNotAvailableException.java | 5 +- .../wsdm/capabilities/ConsumerCapability.java | 66 +++ .../wsdm/capabilities/IArtifactBuilder.java | 8 +- .../wsdm/capabilities/MBeanCapability.java | 8 +- .../wsdm/capabilities/MBeanCapabilityBuilder.java | 14 +- .../wsdm/capabilities/QManAdapterCapability.java | 255 ++++++-- .../wsdm/capabilities/QManMessageHandler.java | 2 +- .../wsdm/common/QManResourceIdFactory.java | 57 ++ .../wsdm/muse/engine/WSDMAdapterEnvironment.java | 9 +- .../wsdm/muse/resources/QManWsResource.java | 1 - .../wsdm/notifications/LifeCycleEvent.java | 149 +++++ .../wsdm/notifications/LifeCycleEventType.java | 34 ++ .../consumer/resource-instance-1.xml | 2 + .../client/src/main/java/wsdl/QManAdapter.rmd | 37 +- .../client/src/main/java/wsdl/QManAdapter.wsdl | 331 ++++++++++- .../main/java/wsdl/WS-BaseNotification-1_3.wsdl | 450 ++++++++++++++ .../src/main/java/wsdl/WS-BaseNotification-1_3.xsd | 577 ++++++++++++++++++ .../client/src/main/java/wsdl/WS-Resource-1_2.wsdl | 54 ++ .../main/java/wsdl/WS-ResourceLifetime-1_2.wsdl | 83 +++ .../main/java/wsdl/WS-ResourceProperties-1_2.wsdl | 395 +++++++++++++ .../src/main/java/wsdl/WS-ServiceGroup-1_2.wsdl | 269 +++++++++ .../client/src/main/java/wsdl/WS-Topics-1_3.xsd | 185 ++++++ .../src/main/java/wsdl/WSDM-MUWS-Part1-1_1.xsd | 93 +++ .../src/main/java/wsdl/WSDM-MUWS-Part2-1_1.xsd | 656 +++++++++++++++++++++ .../org/apache/qpid/management/TestConstants.java | 3 - .../wsdm/EnhancedReflectionProxyHandler.java | 9 +- .../apache/qpid/management/wsdm/ServerThread.java | 40 +- .../wsdm/WebApplicationLifeCycleListener.java | 9 + .../qpid/management/wsdm/WsDmAdapterTest.java | 13 +- 43 files changed, 3898 insertions(+), 187 deletions(-) create mode 100644 qpid/java/management/client/src/main/java/org/apache/qpid/management/wsdm/capabilities/ConsumerCapability.java create mode 100644 qpid/java/management/client/src/main/java/org/apache/qpid/management/wsdm/common/QManResourceIdFactory.java create mode 100644 qpid/java/management/client/src/main/java/org/apache/qpid/management/wsdm/notifications/LifeCycleEvent.java create mode 100644 qpid/java/management/client/src/main/java/org/apache/qpid/management/wsdm/notifications/LifeCycleEventType.java create mode 100644 qpid/java/management/client/src/main/java/router-entries/consumer/resource-instance-1.xml create mode 100644 qpid/java/management/client/src/main/java/wsdl/WS-BaseNotification-1_3.wsdl create mode 100644 qpid/java/management/client/src/main/java/wsdl/WS-BaseNotification-1_3.xsd create mode 100644 qpid/java/management/client/src/main/java/wsdl/WS-Resource-1_2.wsdl create mode 100644 qpid/java/management/client/src/main/java/wsdl/WS-ResourceLifetime-1_2.wsdl create mode 100644 qpid/java/management/client/src/main/java/wsdl/WS-ResourceProperties-1_2.wsdl create mode 100644 qpid/java/management/client/src/main/java/wsdl/WS-ServiceGroup-1_2.wsdl create mode 100644 qpid/java/management/client/src/main/java/wsdl/WS-Topics-1_3.xsd create mode 100644 qpid/java/management/client/src/main/java/wsdl/WSDM-MUWS-Part1-1_1.xsd create mode 100644 qpid/java/management/client/src/main/java/wsdl/WSDM-MUWS-Part2-1_1.xsd diff --git a/qpid/java/management/client/src/example/org/apache/qpid/management/example/GetMultipleResourcePropertiesExample.java b/qpid/java/management/client/src/example/org/apache/qpid/management/example/GetMultipleResourcePropertiesExample.java index 607ae32cab..413222a79d 100644 --- a/qpid/java/management/client/src/example/org/apache/qpid/management/example/GetMultipleResourcePropertiesExample.java +++ b/qpid/java/management/client/src/example/org/apache/qpid/management/example/GetMultipleResourcePropertiesExample.java @@ -134,17 +134,7 @@ public class GetMultipleResourcePropertiesExample extends AbstractQManExample * Prints out a description of this example. */ void printOutExampleDescription() - { - /* - * * 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. - * - */ - + { System.out.println(" "+getClass().getSimpleName()+" "); System.out.println("-------------------------------------------------------------------"); System.out.println(); diff --git a/qpid/java/management/client/src/main/java/muse.xml b/qpid/java/management/client/src/main/java/muse.xml index cf4ec4000a..2b047d01f7 100644 --- a/qpid/java/management/client/src/main/java/muse.xml +++ b/qpid/java/management/client/src/main/java/muse.xml @@ -40,13 +40,66 @@ - + consumer + + wsdl/WS-BaseNotification-1_3.wsdl + wsntw:NotificationConsumer + + org.apache.qpid.management.wsdm.common.QManResourceIdFactory + org.apache.muse.core.SimpleResource + + http://docs.oasis-open.org/wsn/bw-2/NotificationConsumer + org.apache.muse.ws.notification.impl.SimpleNotificationConsumer + + + http://amqp.apache.org/qpid/management/qman/consumer + org.apache.qpid.management.wsdm.capabilities.ConsumerCapability + + + + SubscriptionManager + + wsdl/WS-BaseNotification-1_3.wsdl + wsntw:SubscriptionManager + + org.apache.qpid.management.wsdm.common.QManResourceIdFactory + org.apache.muse.ws.resource.impl.SimpleWsResource + + http://schemas.xmlsoap.org/ws/2004/09/mex/GetMetadata + org.apache.muse.ws.metadata.impl.SimpleMetadataExchange + + + http://docs.oasis-open.org/wsrf/rpw-2/Get + org.apache.muse.ws.resource.properties.get.impl.SimpleGetCapability + + + http://docs.oasis-open.org/wsn/bw-2/SubscriptionManager + org.apache.muse.ws.notification.impl.SimpleSubscriptionManager + + trace-notifications + true + + + + http://docs.oasis-open.org/wsrf/rlw-2/ImmediateResourceTermination + org.apache.muse.ws.resource.lifetime.impl.SimpleImmediateTermination + + + http://docs.oasis-open.org/wsrf/rlw-2/ScheduledResourceTermination + org.apache.muse.ws.resource.lifetime.impl.SimpleScheduledTermination + + + validate-wsrp-schema + false + + + adapter wsdl/QManAdapter.wsdl qman:QManAdapterPortType - org.apache.muse.core.routing.RandomResourceIdFactory + org.apache.qpid.management.wsdm.common.QManResourceIdFactory org.apache.muse.ws.resource.impl.SimpleWsResource http://amqp.apache.org/qpid/management/qman @@ -67,14 +120,15 @@ http://docs.oasis-open.org/wsrf/sgw-2/ServiceGroup org.apache.muse.ws.resource.sg.impl.SimpleServiceGroup - - - + + + http://docs.oasis-open.org/wsn/bw-2/NotificationProducer + org.apache.muse.ws.notification.impl.SimpleNotificationProducer + + + validate-wsrp-schema + false + QManWsResource @@ -116,7 +170,7 @@ /wsdl/WS-ServiceGroupEntry-1_2.wsdl wsrf-sgw:ServiceGroupEntryPortType - org.apache.muse.core.routing.RandomResourceIdFactory + org.apache.qpid.management.wsdm.common.QManResourceIdFactory org.apache.muse.ws.resource.impl.SimpleWsResource http://schemas.xmlsoap.org/ws/2004/09/mex/GetMetadata diff --git a/qpid/java/management/client/src/main/java/org/apache/qpid/management/Messages.java b/qpid/java/management/client/src/main/java/org/apache/qpid/management/Messages.java index dbe6d8c64f..e88434f4d9 100644 --- a/qpid/java/management/client/src/main/java/org/apache/qpid/management/Messages.java +++ b/qpid/java/management/client/src/main/java/org/apache/qpid/management/Messages.java @@ -31,7 +31,7 @@ public interface Messages // MESSAGES String EVENT_SEVERITY_ATTRIBUTE_DESCRIPTION = "Severity level for this event."; String EVENT_TIMESTAMP_ATTRIBUTE_DESCRIPTION = "Current timestamp of this event."; - String ACTION_NOT_SUPPORTED="Action %S not supported by resource %s."; + String ACTION_NOT_SUPPORTED="Action %s not supported by resource %s."; // INFO String QMAN_000001_STARTING_QMAN = " : Starting Q-Man..."; @@ -63,7 +63,10 @@ public interface Messages String QMAN_000028_TEST_MODULE_NOT_FOUND = " : Qpid emulator not found. Test notifications are disabled."; String QMAN_000029_DEFAULT_URI = " : Default URI will be set to %s"; String QMAN_000030_RESOURCE_HAS_BEEN_CREATED = " : New resource instance has been created and registered. Resource id is %s"; - String QMAN_000031_RESOURCE_HAS_BEEN_REMOVED = " : WS-Resource %s has been removed"; + String QMAN_000031_RESOURCE_HAS_BEEN_REMOVED = " : WS-Resource %s has been removed"; + String QMAN_000032_EVENTS_LIFECYCLE_TOPIC_HAS_BEEN_CREATED = " : Events lifecycle topic has been created. Its name is %s"; + String QMAN_000033_OBJECTS_LIFECYCLE_TOPIC_HAS_BEEN_CREATED = " : Objects lifecycle topic has been created. Its name is %s"; + // DEBUG String QMAN_200001_INCOMING_MESSAGE_HAS_BEEN_RECEIVED = " : New incoming message has been received. Message content is %s"; @@ -156,6 +159,7 @@ public interface Messages String QMAN_100033_WS_RESOURCE_ALREADY_SHUTDOWN = " : Bad request has been received on this WS-Resource : Shutdown is not possible because the resource has already been shutdown."; String QMAN_100034_WSDL_SCHEMA_SECTION_NOT_FOUND = " : Unable to get via XPath the schema section in WSDL."; String QMAN_100035_RESOURCE_CAPABILITY_INVOCATION_FAILURE = " : Resource thrown a failure while invoking a capability operation."; + String QMAN_100036_TOPIC_DECLARATION_FAILURE = " : WS-DM Adapter was unable to declare events and / or objects lifecycle topic(s). As conseguence of that, QMan won't be able to correctly emit lifecycle notifications."; // NEW String QMAN_100035_GET_ATTRIBUTE_FAILURE = " : Get Attribute invocation failure for attribute %s, resource %s."; diff --git a/qpid/java/management/client/src/main/java/org/apache/qpid/management/Names.java b/qpid/java/management/client/src/main/java/org/apache/qpid/management/Names.java index 4b723ee5fe..8bff553579 100644 --- a/qpid/java/management/client/src/main/java/org/apache/qpid/management/Names.java +++ b/qpid/java/management/client/src/main/java/org/apache/qpid/management/Names.java @@ -96,17 +96,49 @@ public abstract class Names // WSDM Stuff public static String NAMESPACE_URI = "http://amqp.apache.org/qpid/management/qman"; + public final static String PREFIX = "qman"; + public static String ADDRESSING_URI = "http://amqp.apache.org/qpid/management/qman/addressing"; public static String ADDRESSING_PREFIX = "qman-wsa"; - public static final QName RESOURCE_ID_QNAME = new QName(ADDRESSING_URI, "ResourceId", ADDRESSING_PREFIX); - public final static String PREFIX = "qman"; + public static final QName RESOURCE_ID_QNAME = new QName( + ADDRESSING_URI, + "ResourceId", + ADDRESSING_PREFIX); + + public static final QName RES_ID_QNAME = new QName( + NAMESPACE_URI, + "ResourceId", + PREFIX); + + public static final QName RESOURCE_QNAME = new QName( + NAMESPACE_URI, + "Resource", + PREFIX); + + public static final QName LIFECYCLE_EVENT_QNAME = new QName( + NAMESPACE_URI, + "LifeCycleEvent", + PREFIX); + + public static final QName PACKAGE_NAME_QNAME = new QName( + NAMESPACE_URI, + "PackageName", + PREFIX); + + public static final QName ENTITY_NAME_QNAME = new QName( + NAMESPACE_URI, + "Name", + PREFIX); + + public static final String TIMEMILLIS_ATTRIBUTE_NAME="TimeMillis"; + public final static String QMAN_RESOURCE_NAME = "QManWsResource"; public final static String VALIDATE_WSRP_PARAM = "validate-wsrp-schema"; public static final String WEB_APP_CLASSES_FOLDER = "/WEB-INF/classes"; - public static final String DEFAULT_ENDPOINT_URI = "http://localhost:8080/qman/adapter"; + public final static QName QMAN_RESOURCE_PORT_TYPE_NAME = new QName( Names.NAMESPACE_URI, @@ -127,6 +159,16 @@ public abstract class Names Names.NAMESPACE_URI, "AttributeName", Names.PREFIX); + + public final static QName OBJECTS_LIFECYLE_TOPIC_NAME= new QName( + Names.NAMESPACE_URI, + "ObjectsLifeCycleTopic", + Names.PREFIX); + + public final static QName EVENTS_LIFECYLE_TOPIC_NAME= new QName( + Names.NAMESPACE_URI, + "EventsLifeCycleTopic", + Names.PREFIX); public final static String NAME_ATTRIBUTE = "name"; public final static String MODIFIABILITY = "modifiability"; diff --git a/qpid/java/management/client/src/main/java/org/apache/qpid/management/Protocol.java b/qpid/java/management/client/src/main/java/org/apache/qpid/management/Protocol.java index 5b41785b11..bc3f782935 100644 --- a/qpid/java/management/client/src/main/java/org/apache/qpid/management/Protocol.java +++ b/qpid/java/management/client/src/main/java/org/apache/qpid/management/Protocol.java @@ -44,4 +44,9 @@ public interface Protocol int CLASS = 1; int EVENT = 2; + + String DEFAULT_QMAN_HOSTNAME = "localhost"; + int DEFAULT_QMAN_PORT_NUMBER = 8080; + + String DEFAULT_ENDPOINT_URI = "http://localhost:8080/qman/adapter"; } diff --git a/qpid/java/management/client/src/main/java/org/apache/qpid/management/domain/model/QpidClass.java b/qpid/java/management/client/src/main/java/org/apache/qpid/management/domain/model/QpidClass.java index 40868752fe..667e600668 100644 --- a/qpid/java/management/client/src/main/java/org/apache/qpid/management/domain/model/QpidClass.java +++ b/qpid/java/management/client/src/main/java/org/apache/qpid/management/domain/model/QpidClass.java @@ -239,7 +239,7 @@ class QpidClass extends QpidEntity implements QpidClassMBean _metadata = new MBeanInfo(_name,_name,attributesMetadata,null,operationsMetadata,null); EntityLifecycleNotification notification = new EntityLifecycleNotification( - EntityLifecycleNotification.SCHEMA_INJECTED, + EntityLifecycleNotification.SCHEMA_INJECTED_NOTIFICATION_TYPE, _parent.getName(), _name, Names.CLASS, @@ -782,7 +782,7 @@ class QpidClass extends QpidEntity implements QpidClassMBean ObjectName objectName = JMX_SERVICE.unregisterObjectInstance(_parent.getOwnerId(),_parent.getName(),_name,toBeRemoved._objectId); EntityLifecycleNotification notification = new EntityLifecycleNotification( - EntityLifecycleNotification.INSTANCE_REMOVED, + EntityLifecycleNotification.INSTANCE_REMOVED_NOTIFICATION_TYPE, _parent.getName(), _name, Names.CLASS, @@ -822,7 +822,7 @@ class QpidClass extends QpidEntity implements QpidClassMBean ObjectName objectName = JMX_SERVICE.registerObjectInstance(instance,_parent.getOwnerId(),_parent.getName(),_name,objectId); EntityLifecycleNotification notification = new EntityLifecycleNotification( - EntityLifecycleNotification.INSTANCE_ADDED, + EntityLifecycleNotification.INSTANCE_ADDED_NOTIFICATION_TYPE, packageName, className, Names.CLASS, diff --git a/qpid/java/management/client/src/main/java/org/apache/qpid/management/domain/model/QpidEntity.java b/qpid/java/management/client/src/main/java/org/apache/qpid/management/domain/model/QpidEntity.java index 5f1a786eb9..a13da559fc 100644 --- a/qpid/java/management/client/src/main/java/org/apache/qpid/management/domain/model/QpidEntity.java +++ b/qpid/java/management/client/src/main/java/org/apache/qpid/management/domain/model/QpidEntity.java @@ -153,7 +153,7 @@ public abstract class QpidEntity extends NotificationBroadcasterSupport } EntityLifecycleNotification notification = new EntityLifecycleNotification( - EntityLifecycleNotification.SCHEMA_REQUESTED, + EntityLifecycleNotification.SCHEMA_REQUESTED_NOTIFICATION_TYPE, _parent.getName(), _name, Names.CLASS, diff --git a/qpid/java/management/client/src/main/java/org/apache/qpid/management/domain/model/QpidEvent.java b/qpid/java/management/client/src/main/java/org/apache/qpid/management/domain/model/QpidEvent.java index 30288bc00e..31d8d01fc9 100644 --- a/qpid/java/management/client/src/main/java/org/apache/qpid/management/domain/model/QpidEvent.java +++ b/qpid/java/management/client/src/main/java/org/apache/qpid/management/domain/model/QpidEvent.java @@ -164,7 +164,7 @@ class QpidEvent extends QpidEntity implements QpidEventMBean _state = _schemaInjected; EntityLifecycleNotification notification = new EntityLifecycleNotification( - EntityLifecycleNotification.SCHEMA_INJECTED, + EntityLifecycleNotification.SCHEMA_INJECTED_NOTIFICATION_TYPE, _parent.getName(), _name, Names.EVENT, @@ -482,7 +482,7 @@ class QpidEvent extends QpidEntity implements QpidEventMBean ObjectName objectName = JMX_SERVICE.registerEventInstance(instance,brokerId,packageName,eventClassName); EntityLifecycleNotification notification = new EntityLifecycleNotification( - EntityLifecycleNotification.INSTANCE_ADDED, + EntityLifecycleNotification.INSTANCE_ADDED_NOTIFICATION_TYPE, packageName, eventClassName, Names.EVENT, diff --git a/qpid/java/management/client/src/main/java/org/apache/qpid/management/jmx/EntityLifecycleNotification.java b/qpid/java/management/client/src/main/java/org/apache/qpid/management/jmx/EntityLifecycleNotification.java index 5a99690756..d7f9d8d6f0 100644 --- a/qpid/java/management/client/src/main/java/org/apache/qpid/management/jmx/EntityLifecycleNotification.java +++ b/qpid/java/management/client/src/main/java/org/apache/qpid/management/jmx/EntityLifecycleNotification.java @@ -36,18 +36,19 @@ import org.apache.qpid.management.domain.services.SequenceNumberGenerator; *
- An object instance has been created (Instrumentation / Configuration response); *
- An event instance has been created (Instrumentation / Configuration response); *
- An object instance has been removed (Instrumentation / Configuration response); - *
- An event instance has been removed (Instrumentation / Configuration response); + * + * @author Andrea Gazzarini */ public class EntityLifecycleNotification extends Notification { private static final long serialVersionUID = -7755773156742412161L; - public static final String SCHEMA_INJECTED = "org.apache.qpid.management.lifecycle.entity.schema.injected"; - public static final String SCHEMA_REQUESTED = "org.apache.qpid.management.lifecycle.entity.schema.requested"; - public static final String MALFORMED_SCHEMA = "org.apache.qpid.management.lifecycle.error.schema"; + public static final String SCHEMA_INJECTED_NOTIFICATION_TYPE = "org.apache.qpid.management.lifecycle.entity.schema.injected"; + public static final String SCHEMA_REQUESTED_NOTIFICATION_TYPE = "org.apache.qpid.management.lifecycle.entity.schema.requested"; + public static final String MALFORMED_SCHEMA_NOTIFICATION_TYPE = "org.apache.qpid.management.lifecycle.error.schema"; - public static final String INSTANCE_ADDED = "qman.lifecycle.entity.instance.created"; - public static final String INSTANCE_REMOVED = "qman.lifecycle.entity.instance.removed"; + public static final String INSTANCE_ADDED_NOTIFICATION_TYPE = "qman.lifecycle.entity.instance.created"; + public static final String INSTANCE_REMOVED_NOTIFICATION_TYPE = "qman.lifecycle.entity.instance.removed"; private String _packageName = Names.NOT_AVAILABLE; private String _className = Names.NOT_AVAILABLE; @@ -65,9 +66,18 @@ public class EntityLifecycleNotification extends Notification * @param classKind the class kind (i.e. class or event) * @param objectName the object name of the affected mbean. */ - public EntityLifecycleNotification(String type,String packageName, String className, String classKind, ObjectName objectName) + public EntityLifecycleNotification( + String type, + String packageName, + String className, + String classKind, + ObjectName objectName) { - super(type,Names.APPLICATION_NAME,SequenceNumberGenerator.getNextSequenceNumber()); + super( + type, + Names.APPLICATION_NAME, + SequenceNumberGenerator.getNextSequenceNumber()); + this._className = className; this._packageName = packageName; this._classKind = classKind; diff --git a/qpid/java/management/client/src/main/java/org/apache/qpid/management/jmx/OperationHasBeenInvokedNotification.java b/qpid/java/management/client/src/main/java/org/apache/qpid/management/jmx/OperationHasBeenInvokedNotification.java index 1812b803d1..dec29c1b93 100644 --- a/qpid/java/management/client/src/main/java/org/apache/qpid/management/jmx/OperationHasBeenInvokedNotification.java +++ b/qpid/java/management/client/src/main/java/org/apache/qpid/management/jmx/OperationHasBeenInvokedNotification.java @@ -28,13 +28,15 @@ import org.apache.qpid.management.domain.services.SequenceNumberGenerator; /** * Q-Man JMX method invocation notification. - * This kind of notification is sent to interested listener by Q-Man when a method has been invoked (Method invocation request) + * This kind of notification is sent to interested listener by Q-Man when + * a method has been invoked (Method invocation request) + * + * @author Andrea Gazzarini */ public class OperationHasBeenInvokedNotification extends Notification { private static final long serialVersionUID = -7755773156742412161L; - - public static final String OPERATION_INVOKED = "org.apache.qpid.management.operation.invoked"; + public static final String NOTIFICATION_TYPE = "org.apache.qpid.management.operation.invoked"; private final String _operationName; private final Object [] _parameters; @@ -51,15 +53,22 @@ public class OperationHasBeenInvokedNotification extends Notification * @param signature the operation signature. * @param exception the exception raised by the invocation. */ - public OperationHasBeenInvokedNotification(String operationName, Object[] parameters, String [] signature, Exception exception) + public OperationHasBeenInvokedNotification( + String operationName, + Object[] parameters, + String [] signature, + Exception exception) { - super(OPERATION_INVOKED,Names.APPLICATION_NAME,SequenceNumberGenerator.getNextSequenceNumber()); + super( + NOTIFICATION_TYPE, + Names.APPLICATION_NAME, + SequenceNumberGenerator.getNextSequenceNumber()); + this._operationName= operationName; this._parameters = parameters; this._signature = signature; this._result = null; this._exception = exception; - } /** @@ -72,9 +81,17 @@ public class OperationHasBeenInvokedNotification extends Notification * @param objectName the target mbean object name. * @param result the invocation result. */ - public OperationHasBeenInvokedNotification(String operationName, Object[] parameters, String [] signature,InvocationResult result) + public OperationHasBeenInvokedNotification( + String operationName, + Object[] parameters, + String [] signature, + InvocationResult result) { - super(OPERATION_INVOKED,Names.APPLICATION_NAME,SequenceNumberGenerator.getNextSequenceNumber()); + super( + NOTIFICATION_TYPE, + Names.APPLICATION_NAME, + SequenceNumberGenerator.getNextSequenceNumber()); + this._operationName= operationName; this._parameters = parameters; this._signature = signature; @@ -83,7 +100,8 @@ public class OperationHasBeenInvokedNotification extends Notification } /** - * Returns the exception raised by this notification referred operation. + * Returns the exception raised by this notification + * referred operation. * * @return the exception raised by this notification referred operation. */ @@ -93,7 +111,8 @@ public class OperationHasBeenInvokedNotification extends Notification } /** - * Returns the exception raised by this notification referred operation. + * Returns the exception raised by this notification + * referred operation. * * @return the exception raised by this notification referred operation. */ diff --git a/qpid/java/management/client/src/main/java/org/apache/qpid/management/servlet/ConnectQManToBroker.java b/qpid/java/management/client/src/main/java/org/apache/qpid/management/servlet/ConnectQManToBroker.java index af037861ba..8f73098e20 100644 --- a/qpid/java/management/client/src/main/java/org/apache/qpid/management/servlet/ConnectQManToBroker.java +++ b/qpid/java/management/client/src/main/java/org/apache/qpid/management/servlet/ConnectQManToBroker.java @@ -36,8 +36,9 @@ import org.apache.qpid.management.domain.services.QMan; import org.apache.qpid.transport.util.Logger; /** - * When QMan is started and a configuration file is given (via system property) with - * initial broker connection data(s), this servlet simply sends connect command(s) to QMan in order + * When QMan is started and a configuration file is given + * (via system property) with initial broker connection data(s), + * this servlet simply sends connect command(s) to QMan in order * to estabilish the connection(s) to the requested broker(s). * * @author Andrea Gazzarini @@ -48,9 +49,10 @@ public class ConnectQManToBroker extends MiniServlet private final static Logger LOGGER = Logger.get(ConnectQManToBroker.class); /** - * Send one or more initial "connect" command(s) to QMan in order to estabilish a connection with broker found on the - * configuration file.. - * Note that this is done only if that configuration file is given (via system property) and It is valid. + * Send one or more initial "connect" command(s) to QMan in order + * to estabilish a connection with broker found on the configuration file.. + * Note that this is done only if that configuration file is given (via system + * property) and it is valid. */ public void init() { @@ -64,14 +66,16 @@ public class ConnectQManToBroker extends MiniServlet { qman.createManagementClient(entry.getKey(), entry.getValue()); } - } else { + } else + { LOGGER.info(Messages.QMAN_000022_NO_BROKER_CONFIGURED); } } /** * This is a startup module only so an override of the default servlet - * behaviour must be done in order to prevent incoming http requests processing. + * behaviour must be done in order to prevent incoming http + * requests processing. * * @param request the http request. * @param response the http response. diff --git a/qpid/java/management/client/src/main/java/org/apache/qpid/management/servlet/WSDMAdapter.java b/qpid/java/management/client/src/main/java/org/apache/qpid/management/servlet/WSDMAdapter.java index 10fcaeec0f..c6fcde08c4 100644 --- a/qpid/java/management/client/src/main/java/org/apache/qpid/management/servlet/WSDMAdapter.java +++ b/qpid/java/management/client/src/main/java/org/apache/qpid/management/servlet/WSDMAdapter.java @@ -100,7 +100,9 @@ public class WSDMAdapter extends HttpServlet try { XmlDebugger.debug(soapEnvelopeResposeAsString); } catch(Exception exception) { - System.out.println("Unable to parse response."); + LOGGER.error( + exception, + Messages.QMAN_100019_REQ_OR_RES_MALFORMED); } } } diff --git a/qpid/java/management/client/src/main/java/org/apache/qpid/management/wsdm/QEmu.java b/qpid/java/management/client/src/main/java/org/apache/qpid/management/wsdm/QEmu.java index 2067bc9164..79a387e80c 100644 --- a/qpid/java/management/client/src/main/java/org/apache/qpid/management/wsdm/QEmu.java +++ b/qpid/java/management/client/src/main/java/org/apache/qpid/management/wsdm/QEmu.java @@ -33,8 +33,9 @@ import org.apache.qpid.management.jmx.EntityLifecycleNotification; /** * QEmu is basically an instance creator that is installed separately * as part of QMan test cases & examples. - * Reason for that is to emulate object creation (queues, exchanges, etc...) without having Qpid broker - * connected and therefore controlling the total number of the instances that are created. + * Reason for that is to emulate object creation (queues, exchanges, etc...) + * without having Qpid broker connected and therefore controlling the + * total number of the instances that are created. * * @author Andrea Gazzarini */ @@ -53,7 +54,10 @@ public class QEmu extends NotificationBroadcasterSupport implements QEmuMBean, M public void unregister(ObjectName objectName) throws Exception { _mxServer.unregisterMBean(objectName); - sendNotification(EntityLifecycleNotification.INSTANCE_REMOVED,objectName); + + sendNotification( + EntityLifecycleNotification.INSTANCE_REMOVED_NOTIFICATION_TYPE, + objectName); } /** @@ -67,7 +71,9 @@ public class QEmu extends NotificationBroadcasterSupport implements QEmuMBean, M QpidDomainObjectMBean queue = new QpidDomainObject(); _mxServer.registerMBean(queue, objectName); - sendNotification(EntityLifecycleNotification.INSTANCE_ADDED,objectName); + sendNotification( + EntityLifecycleNotification.INSTANCE_ADDED_NOTIFICATION_TYPE, + objectName); } /** diff --git a/qpid/java/management/client/src/main/java/org/apache/qpid/management/wsdm/QEmuInitializer.java b/qpid/java/management/client/src/main/java/org/apache/qpid/management/wsdm/QEmuInitializer.java index 9a0e2c3955..545e587f79 100644 --- a/qpid/java/management/client/src/main/java/org/apache/qpid/management/wsdm/QEmuInitializer.java +++ b/qpid/java/management/client/src/main/java/org/apache/qpid/management/wsdm/QEmuInitializer.java @@ -33,8 +33,8 @@ import org.apache.qpid.transport.util.Logger; /** * QPid Emulator Initializer. - * This component is basically responsible to create and initialize an emulator module used - * for simulate object instances creation. + * This component is basically responsible to create and initialize + * an emulator module used for simulate object instances creation. * * @author Andrea Gazzarini */ @@ -63,8 +63,9 @@ public class QEmuInitializer extends HttpServlet } /** - * This is a startup module only so an override of the default servlet - * behaviour must be done in order to prevent incoming http requests processing. + * This is a startup module only so an override of the + * default servlet behaviour must be done in order to + * prevent incoming http requests processing. * * @param request the http request. * @param response the http response. diff --git a/qpid/java/management/client/src/main/java/org/apache/qpid/management/wsdm/capabilities/ArtifactsNotAvailableException.java b/qpid/java/management/client/src/main/java/org/apache/qpid/management/wsdm/capabilities/ArtifactsNotAvailableException.java index 3f1188e5af..eef70b5544 100644 --- a/qpid/java/management/client/src/main/java/org/apache/qpid/management/wsdm/capabilities/ArtifactsNotAvailableException.java +++ b/qpid/java/management/client/src/main/java/org/apache/qpid/management/wsdm/capabilities/ArtifactsNotAvailableException.java @@ -41,7 +41,10 @@ public class ArtifactsNotAvailableException extends Exception * @param cause the exception cause. * @param objectName the object name of the corresponding JMX entity. */ - public ArtifactsNotAvailableException(WsArtifacts artifacts,Throwable cause, ObjectName objectName) + public ArtifactsNotAvailableException( + WsArtifacts artifacts, + Throwable cause, + ObjectName objectName) { super(cause); this._artifacts = artifacts; diff --git a/qpid/java/management/client/src/main/java/org/apache/qpid/management/wsdm/capabilities/ConsumerCapability.java b/qpid/java/management/client/src/main/java/org/apache/qpid/management/wsdm/capabilities/ConsumerCapability.java new file mode 100644 index 0000000000..dd5eb523c1 --- /dev/null +++ b/qpid/java/management/client/src/main/java/org/apache/qpid/management/wsdm/capabilities/ConsumerCapability.java @@ -0,0 +1,66 @@ +/* + * + * 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.wsdm.capabilities; + +import org.apache.muse.core.AbstractCapability; +import org.apache.muse.ws.addressing.soap.SoapFault; +import org.apache.muse.ws.notification.NotificationConsumer; +import org.apache.muse.ws.notification.NotificationMessage; +import org.apache.muse.ws.notification.NotificationMessageListener; +import org.apache.muse.ws.notification.WsnConstants; + +/** + * WS-Notifications consumer capability. + * + * @author Andrea Gazzarini + */ +public class ConsumerCapability extends AbstractCapability implements NotificationMessageListener +{ + /** + * Initializes this capability and register itself as message listener. + * + * @throws SoapFault when the initialization fails. + */ + public void initializeCompleted() throws SoapFault + { + super.initializeCompleted(); + + NotificationConsumer wsn = (NotificationConsumer)getResource().getCapability(WsnConstants.CONSUMER_URI); + wsn.addMessageListener(this); + } + + /** + * Returns true if this consumer can accepts the message. + * + * @return true; + */ + public boolean accepts(NotificationMessage message) + { + return true; + } + + /** + * On Message callback. + */ + public void process(NotificationMessage message) + { + } +} \ No newline at end of file diff --git a/qpid/java/management/client/src/main/java/org/apache/qpid/management/wsdm/capabilities/IArtifactBuilder.java b/qpid/java/management/client/src/main/java/org/apache/qpid/management/wsdm/capabilities/IArtifactBuilder.java index 3e91e2f696..70b9b0e009 100644 --- a/qpid/java/management/client/src/main/java/org/apache/qpid/management/wsdm/capabilities/IArtifactBuilder.java +++ b/qpid/java/management/client/src/main/java/org/apache/qpid/management/wsdm/capabilities/IArtifactBuilder.java @@ -28,16 +28,16 @@ import org.apache.muse.core.Environment; /** * Defines behaviour needed by WS-DM artifact builders. - * Each concrete implementor must provide its own parser implementation of the given - * JMX data. + * Each concrete implementor must provide its own parser + * implementation of the given JMX data. * * @author Andrea Gazzarini */ public interface IArtifactBuilder { /** - * The build process begin and the given parameter is the object name of the - * corresponding JMX entity. + * The build process begin and the given parameter is the + * object name of the corresponding JMX entity. * * @throws BuilderException when the initialization fails. */ diff --git a/qpid/java/management/client/src/main/java/org/apache/qpid/management/wsdm/capabilities/MBeanCapability.java b/qpid/java/management/client/src/main/java/org/apache/qpid/management/wsdm/capabilities/MBeanCapability.java index 312315cdf1..82d8e97d37 100644 --- a/qpid/java/management/client/src/main/java/org/apache/qpid/management/wsdm/capabilities/MBeanCapability.java +++ b/qpid/java/management/client/src/main/java/org/apache/qpid/management/wsdm/capabilities/MBeanCapability.java @@ -40,8 +40,8 @@ import org.apache.qpid.management.wsdm.common.QManFault; import org.apache.qpid.transport.util.Logger; /** - * Abstract capability used for centralize common behaviour of the QMan - * resource(s) related capabilities. + * Abstract capability used for centralize common + * behaviour of the QMan resource(s) related capabilities. * * @author Andrea Gazzarini */ @@ -83,7 +83,7 @@ public abstract class MBeanCapability extends AbstractWsResourceCapability * be found. * @throws QManFault in case of internal system failure. */ - Object getAttribute(String attributeName) throws NoSuchAttributeFault,EntityInstanceNotFoundFault,QManFault + Object getAttribute(String attributeName) throws NoSuchAttributeFault, EntityInstanceNotFoundFault, QManFault { try { @@ -128,7 +128,7 @@ public abstract class MBeanCapability extends AbstractWsResourceCapability * @throws QManFault * in case of internal system failure. */ - void setAttribute(String attributeName, Object value) throws NoSuchAttributeFault,EntityInstanceNotFoundFault,QManFault + void setAttribute(String attributeName, Object value) throws NoSuchAttributeFault, EntityInstanceNotFoundFault, QManFault { try { diff --git a/qpid/java/management/client/src/main/java/org/apache/qpid/management/wsdm/capabilities/MBeanCapabilityBuilder.java b/qpid/java/management/client/src/main/java/org/apache/qpid/management/wsdm/capabilities/MBeanCapabilityBuilder.java index aa6ec5aee4..ea623138a4 100644 --- a/qpid/java/management/client/src/main/java/org/apache/qpid/management/wsdm/capabilities/MBeanCapabilityBuilder.java +++ b/qpid/java/management/client/src/main/java/org/apache/qpid/management/wsdm/capabilities/MBeanCapabilityBuilder.java @@ -43,6 +43,15 @@ import org.apache.qpid.management.wsdm.common.NoSuchAttributeFault; import org.apache.qpid.management.wsdm.common.QManFault; import org.apache.qpid.transport.util.Logger; +/** + * Builder for capability class that will implements the interface + * and the behaviour of the underlying JMX Entity. + * The product of this builder (capability class) will be used for create a new instance + * of the corresponding capability. It will be the "adapter" between WS-Resource and + * JMX MBean. + * + * @author Andrea Gazzarini + */ public class MBeanCapabilityBuilder implements IArtifactBuilder{ private final static String GET_PROPERTY_NAMES_METHOD_COMMON_PART = "public QName[] getPropertyNames() { return "; @@ -51,8 +60,9 @@ public class MBeanCapabilityBuilder implements IArtifactBuilder{ private final static Logger LOGGER = Logger.get(MBeanCapabilityBuilder.class); /** - * Handler interface definining operation needed to be peformed (by a concrete - * implementor) when the "endAttributes" director callback happens. + * Handler interface definining operation needed to be + * peformed (by a concrete implementor) when the "endAttributes" + * director callback happens. * * @author Andrea Gazzarini */ diff --git a/qpid/java/management/client/src/main/java/org/apache/qpid/management/wsdm/capabilities/QManAdapterCapability.java b/qpid/java/management/client/src/main/java/org/apache/qpid/management/wsdm/capabilities/QManAdapterCapability.java index f1e66789cf..2773d9e01a 100644 --- a/qpid/java/management/client/src/main/java/org/apache/qpid/management/wsdm/capabilities/QManAdapterCapability.java +++ b/qpid/java/management/client/src/main/java/org/apache/qpid/management/wsdm/capabilities/QManAdapterCapability.java @@ -25,6 +25,7 @@ import java.lang.reflect.Method; import java.net.URI; import java.util.ArrayList; import java.util.Collection; +import java.util.UUID; import javax.management.InstanceNotFoundException; import javax.management.MBeanServer; @@ -41,12 +42,15 @@ import org.apache.muse.core.routing.MessageHandler; import org.apache.muse.core.serializer.SerializerRegistry; import org.apache.muse.ws.addressing.EndpointReference; import org.apache.muse.ws.addressing.soap.SoapFault; +import org.apache.muse.ws.notification.NotificationProducer; +import org.apache.muse.ws.notification.WsnConstants; import org.apache.qpid.management.Messages; import org.apache.qpid.management.Names; import org.apache.qpid.management.jmx.EntityLifecycleNotification; import org.apache.qpid.management.wsdm.common.ThreadSessionManager; import org.apache.qpid.management.wsdm.muse.engine.WSDMAdapterEnvironment; import org.apache.qpid.management.wsdm.muse.serializer.ByteArraySerializer; +import org.apache.qpid.management.wsdm.notifications.LifeCycleEvent; import org.apache.qpid.transport.util.Logger; /** @@ -55,6 +59,7 @@ import org.apache.qpid.transport.util.Logger; * * @author Andrea Gazzarini */ +@SuppressWarnings("serial") public class QManAdapterCapability extends AbstractCapability { private final static Logger LOGGER = Logger.get(QManAdapterCapability.class); @@ -63,11 +68,45 @@ public class QManAdapterCapability extends AbstractCapability private WsArtifactsFactory _artifactsFactory; private URI _resourceURI; + /** + * NotificationFilter for "create" only events. + */ + private final NotificationFilter _filterForNewInstances = new NotificationFilter(){ + + /** + * Returns true when the notification is related to a creation of a new instance. + * + * @return true when the notification is related to a creation of a new instance. + */ + public boolean isNotificationEnabled(Notification notification) + { + return EntityLifecycleNotification.INSTANCE_ADDED_NOTIFICATION_TYPE.equals(notification.getType()); + } + + }; + + /** + * NotificationFilter for "remove" only events. + */ + private final NotificationFilter _filterForRemovedInstances = new NotificationFilter(){ + + /** + * Returns true when the notification is related to a deletion of an existing instance. + * + * @return true when the notification is related to a deletion of an existing instance. + */ + public boolean isNotificationEnabled(Notification notification) + { + return EntityLifecycleNotification.INSTANCE_REMOVED_NOTIFICATION_TYPE.equals(notification.getType()); + } + + }; + /** * This listener handles "create" mbean events and therefore provides procedure to create and initialize * corresponding ws resources. */ - private final NotificationListener listenerForNewInstances = new NotificationListener() + private final NotificationListener _listenerForNewInstances = new NotificationListener() { /** * Handles JMX "create" notification type. @@ -145,7 +184,7 @@ public class QManAdapterCapability extends AbstractCapability * This listener handles "remove" mbean events and therefore provides procedure to shutdown and remove * corresponding ws resources. */ - private final NotificationListener listenerForRemovedInstances = new NotificationListener() + private final NotificationListener _listenerForRemovedInstances = new NotificationListener() { /** * Handles JMX "remove" notification type. @@ -185,90 +224,107 @@ public class QManAdapterCapability extends AbstractCapability } }; + /** + * Initializes this capability. + * + * @throws SoapFault when the initialization fails.. + */ @Override public void initialize() throws SoapFault { super.initialize(); - // Workaround : it seems that is not possibile to declare a serializer for a byte array using muse descriptor... - // What is the stringified name of the class? byte[].getClass().getName() is [B but is not working (ClassNotFound). - // So, at the end, this is hard-coded here! - SerializerRegistry.getInstance().registerSerializer(byte[].class, new ByteArraySerializer()); - WSDMAdapterEnvironment environment = (WSDMAdapterEnvironment) getEnvironment(); - String resourceURI = environment.getDefaultURIPrefix()+Names.QMAN_RESOURCE_NAME; - try - { - _resourceURI = URI.create(resourceURI); - - _mxServer = ManagementFactory.getPlatformMBeanServer(); - _artifactsFactory = new WsArtifactsFactory(getEnvironment(),_mxServer); - - /** - * NotificationFilter for "create" only events. - */ - NotificationFilter filterForNewInstances = new NotificationFilter(){ - - private static final long serialVersionUID = 1733325390964454595L; + registerByteArraySerializer(); + + createLifeCycleTopics(); + + createQManResourceURI(); - public boolean isNotificationEnabled(Notification notification) + _mxServer = ManagementFactory.getPlatformMBeanServer(); + _artifactsFactory = new WsArtifactsFactory(getEnvironment(),_mxServer); + + registerQManLifecycleListeners(); + + new Thread() + { + @Override + public void run() + { + while (true) { - return EntityLifecycleNotification.INSTANCE_ADDED.equals(notification.getType()); - } - - }; - - /** - * NotificationFilter for "remove" only events. - */ - NotificationFilter filterForRemovedInstances = new NotificationFilter(){ - - private static final long serialVersionUID = 1733325390964454595L; + try + { + final NotificationProducer publisher = (NotificationProducer) getResource().getCapability(WsnConstants.PRODUCER_URI); + + publisher.publish( + Names.OBJECTS_LIFECYLE_TOPIC_NAME, + LifeCycleEvent.newCreateEvent( + UUID.randomUUID().toString(), + "org.apache.qpid.broker", + "connection")); + } catch (SoapFault e) + { + // TODO Auto-generated catch block + e.printStackTrace(); + } + try + { + Thread.sleep(10000); + } catch (InterruptedException e) + { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + } + }.start(); + } - public boolean isNotificationEnabled(Notification notification) - { - return EntityLifecycleNotification.INSTANCE_REMOVED.equals(notification.getType()); - } - - }; - + /** + * This adapter capability needs to be an event listener of QMan JMX core + * in order to detect relevant lifecycle events and therefore create WS artifacts & notification(s). + * + * @throws SoapFault when it's not possible to register event listener : is QMan running? + */ + @SuppressWarnings("serial") + private void registerQManLifecycleListeners() throws SoapFault + { + try + { _mxServer.addNotificationListener( Names.QMAN_OBJECT_NAME, - listenerForNewInstances, - filterForNewInstances, + _listenerForNewInstances, + _filterForNewInstances, null); _mxServer.addNotificationListener( Names.QMAN_OBJECT_NAME, - listenerForRemovedInstances, - filterForRemovedInstances, + _listenerForRemovedInstances, + _filterForRemovedInstances, null); - try { + try + { _mxServer.addNotificationListener( Names.QPID_EMULATOR_OBJECT_NAME, - listenerForNewInstances, - filterForNewInstances, null); + _listenerForNewInstances, + _filterForNewInstances, null); _mxServer.addNotificationListener( Names.QPID_EMULATOR_OBJECT_NAME, - listenerForRemovedInstances, - filterForRemovedInstances, null); + _listenerForRemovedInstances, + _filterForRemovedInstances, null); - } catch(IllegalArgumentException exception) + } catch (Exception exception) { - LOGGER.info(exception,Messages.QMAN_000029_DEFAULT_URI,resourceURI); - } - catch (Exception exception) { LOGGER.info(Messages.QMAN_000028_TEST_MODULE_NOT_FOUND); } - } catch(InstanceNotFoundException exception) { - // throw new QManNotRunningFault throw new SoapFault(exception); } } - + /** * Connects QMan with a broker with the given connection data. * @@ -328,14 +384,91 @@ public class QManAdapterCapability extends AbstractCapability { String name = method.getName(); - QName requestName = new QName(Names.NAMESPACE_URI,name,Names.PREFIX); - QName returnValueName = new QName(Names.NAMESPACE_URI,name+"Response",Names.PREFIX); + QName requestName = new QName( + Names.NAMESPACE_URI, + name, + Names.PREFIX); + + QName returnValueName = new QName( + Names.NAMESPACE_URI, + name+"Response", + Names.PREFIX); String actionURI = Names.NAMESPACE_URI+"/"+name; - MessageHandler handler = new QManMessageHandler(actionURI, requestName, returnValueName); - handler.setMethod(method); + + MessageHandler handler = new QManMessageHandler( + actionURI, + requestName, + returnValueName); + + handler.setMethod(method); handlers.add(handler); } return handlers; - } + } + + /** + * Creates events & objects lifecycle topic that will be used to publish lifecycle event + * messages.. + */ + private void createLifeCycleTopics() + { + try + { + final NotificationProducer publisherCapability = (NotificationProducer) getResource() + .getCapability(WsnConstants.PRODUCER_URI); + + publisherCapability.addTopic(Names.EVENTS_LIFECYLE_TOPIC_NAME); + LOGGER.info( + Messages.QMAN_000032_EVENTS_LIFECYCLE_TOPIC_HAS_BEEN_CREATED, + Names.OBJECTS_LIFECYLE_TOPIC_NAME); + + publisherCapability.addTopic(Names.OBJECTS_LIFECYLE_TOPIC_NAME); + LOGGER.info( + Messages.QMAN_000033_OBJECTS_LIFECYCLE_TOPIC_HAS_BEEN_CREATED, + Names.OBJECTS_LIFECYLE_TOPIC_NAME); + } catch(Exception exception) + { + LOGGER.error(exception, Messages.QMAN_100036_TOPIC_DECLARATION_FAILURE); + } + } + + /** + * Workaround : it seems that is not possibile to declare a serializer + * for a byte array using muse descriptor... + * What is the stringified name of the class? + * byte[].getClass().getName() is [B but is not working (ClassNotFound). + * So, at the end, this is hard-coded here! + */ + private void registerByteArraySerializer() + { + SerializerRegistry.getInstance().registerSerializer( + byte[].class, + new ByteArraySerializer()); + } + + /** + * Creates the URI that will be later used to identify a QMan WS-Resource. + * Note that the resources that will be created are identified also with their resource id. + * Briefly we could say that this is the soap:address of the WS-Resource definition. + * + * @throws SoapFault when the URI cannot be built (probably it is malformed). + */ + private void createQManResourceURI() throws SoapFault + { + WSDMAdapterEnvironment environment = (WSDMAdapterEnvironment) getEnvironment(); + String resourceURI = environment.getDefaultURIPrefix()+Names.QMAN_RESOURCE_NAME; + try + { + _resourceURI = URI.create(resourceURI); + + } catch(IllegalArgumentException exception) + { + LOGGER.info( + exception, + Messages.QMAN_100029_MALFORMED_RESOURCE_URI_FAILURE, + resourceURI); + throw new SoapFault(exception); + } + } } \ No newline at end of file diff --git a/qpid/java/management/client/src/main/java/org/apache/qpid/management/wsdm/capabilities/QManMessageHandler.java b/qpid/java/management/client/src/main/java/org/apache/qpid/management/wsdm/capabilities/QManMessageHandler.java index 9c37acbabb..95f54ef5b5 100644 --- a/qpid/java/management/client/src/main/java/org/apache/qpid/management/wsdm/capabilities/QManMessageHandler.java +++ b/qpid/java/management/client/src/main/java/org/apache/qpid/management/wsdm/capabilities/QManMessageHandler.java @@ -33,7 +33,7 @@ import org.apache.qpid.management.wsdm.muse.serializer.ByteArraySerializer; import org.w3c.dom.Element; /** - * A custom implementation of Muse message handler to properly deal with + * JMXConnectionListener_example custom implementation of Muse message handler to properly deal with * byte arrays. * * @author Andrea Gazzarini diff --git a/qpid/java/management/client/src/main/java/org/apache/qpid/management/wsdm/common/QManResourceIdFactory.java b/qpid/java/management/client/src/main/java/org/apache/qpid/management/wsdm/common/QManResourceIdFactory.java new file mode 100644 index 0000000000..1a34971c6a --- /dev/null +++ b/qpid/java/management/client/src/main/java/org/apache/qpid/management/wsdm/common/QManResourceIdFactory.java @@ -0,0 +1,57 @@ +/* + * + * 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.wsdm.common; + +import java.util.UUID; + +import javax.xml.namespace.QName; + +import org.apache.muse.core.routing.ResourceIdFactory; +import org.apache.qpid.management.Names; + +/** + * A simple implementation of resource id factory that uses a UUID as resource + * identifier. + * + * @author Andrea Gazzarini + */ +public class QManResourceIdFactory implements ResourceIdFactory +{ + /** + * Returns the identifier name for id element. + * + * @return the identifier name for id element. + */ + public QName getIdentifierName() + { + return Names.RESOURCE_ID_QNAME; + } + + /** + * Returns the next valid identifier. + * + * @return the next valid identifier. + */ + public String getNextIdentifier() + { + return UUID.randomUUID().toString(); + } +} \ No newline at end of file diff --git a/qpid/java/management/client/src/main/java/org/apache/qpid/management/wsdm/muse/engine/WSDMAdapterEnvironment.java b/qpid/java/management/client/src/main/java/org/apache/qpid/management/wsdm/muse/engine/WSDMAdapterEnvironment.java index a5d12a55f9..f47a587830 100644 --- a/qpid/java/management/client/src/main/java/org/apache/qpid/management/wsdm/muse/engine/WSDMAdapterEnvironment.java +++ b/qpid/java/management/client/src/main/java/org/apache/qpid/management/wsdm/muse/engine/WSDMAdapterEnvironment.java @@ -10,6 +10,7 @@ import org.apache.muse.util.FileUtils; import org.apache.muse.ws.addressing.EndpointReference; import org.apache.qpid.management.Messages; import org.apache.qpid.management.Names; +import org.apache.qpid.management.Protocol; import org.apache.qpid.transport.util.Logger; /** @@ -67,9 +68,13 @@ public class WSDMAdapterEnvironment extends AbstractEnvironment { return new StringBuilder() .append("http://") - .append(System.getProperty(Names.ADAPTER_HOST_PROPERTY_NAME,"localhost")) + .append(System.getProperty( + Names.ADAPTER_HOST_PROPERTY_NAME, + Protocol.DEFAULT_QMAN_HOSTNAME)) .append(":") - .append(System.getProperty(Names.ADAPTER_PORT_PROPERTY_NAME,"8080")) + .append(System.getProperty( + Names.ADAPTER_PORT_PROPERTY_NAME, + String.valueOf(Protocol.DEFAULT_QMAN_PORT_NUMBER))) .append(_servletContext.getContextPath()) .append("/services/") .toString(); diff --git a/qpid/java/management/client/src/main/java/org/apache/qpid/management/wsdm/muse/resources/QManWsResource.java b/qpid/java/management/client/src/main/java/org/apache/qpid/management/wsdm/muse/resources/QManWsResource.java index e2091a3337..c16c156b73 100644 --- a/qpid/java/management/client/src/main/java/org/apache/qpid/management/wsdm/muse/resources/QManWsResource.java +++ b/qpid/java/management/client/src/main/java/org/apache/qpid/management/wsdm/muse/resources/QManWsResource.java @@ -229,7 +229,6 @@ public class QManWsResource implements WsResource initializeCapabilities(); _properties.applyMetadata(); -// _properties.validateMetadata(); // Resource intialization completed : Let's make a state change. _currentState = _hasBeenInitialized; diff --git a/qpid/java/management/client/src/main/java/org/apache/qpid/management/wsdm/notifications/LifeCycleEvent.java b/qpid/java/management/client/src/main/java/org/apache/qpid/management/wsdm/notifications/LifeCycleEvent.java new file mode 100644 index 0000000000..9284a62461 --- /dev/null +++ b/qpid/java/management/client/src/main/java/org/apache/qpid/management/wsdm/notifications/LifeCycleEvent.java @@ -0,0 +1,149 @@ +/* + * + * 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.wsdm.notifications; + +import org.apache.muse.util.xml.XmlSerializable; +import org.apache.muse.util.xml.XmlUtils; +import org.apache.qpid.management.Names; +import org.w3c.dom.Document; +import org.w3c.dom.Element; + +/** + * Object representation of a QMan entity lifecycle event notification. + * Note that with entity we mean both object(s) and event(s). + * + * At the moment there are only two types of lifecycle events : CREATE and REMOVE. + * The first one if fired when a new instance (event or object) is created, while the second + * one is fired when an object instance (events are transient objects so they are not destroyed) + * is removed. + * + * Developer Note : The marshal & unmarshal ops could be handled using JAXB but + * we are not sure about the running environment (JAXB libs were included only + * starting from 1.6) + * + * This is the event XML representation : + * + * + + 16038bd5-b62b-4e86-9833-7560ed57b474 + org.qpid.apache.broker + session + + + + * @author Andrea Gazzarini + */ +public class LifeCycleEvent implements XmlSerializable +{ + private final String _resourceId; + private final String _packageName; + private final String _name; + + private final LifeCycleEventType _type; + + /** + * Builds a new event with the given data. + * + * @param resourceId resource identifier. + * @param packageName resource package name. + * @param name resource name. + * @param type event type. + */ + private LifeCycleEvent(String resourceId, String packageName, String name, LifeCycleEventType type) + { + this._resourceId = resourceId; + this._packageName = packageName; + this._name = name; + this._type = type; + } + + /** + * Factory method for a new "CREATE" event. + * Builds a new "CREATE" event with the given data. + * + * @param resourceId resource identifier. + * @param packageName resource package name. + * @param name resource name. + */ + public static LifeCycleEvent newCreateEvent(String resourceId, String packageName, String name) + { + return new LifeCycleEvent(resourceId, packageName, name, LifeCycleEventType.CREATED); + } + + /** + * Factory method for a new "REMOVE" event. + * Builds a new "REMOVE" event with the given data. + * + * @param resourceId resource identifier. + * @param packageName resource package name. + * @param name resource name. + */ + public static LifeCycleEvent newRemoveEvent(String resourceId, String packageName, String name) + { + return new LifeCycleEvent(resourceId, packageName, name, LifeCycleEventType.REMOVED); + } + + /** + * Returns an XML representation of this event. + * + * @return an XML representation of this event. + */ + public Element toXML() + { + return toXML(XmlUtils.EMPTY_DOC); + } + + /** + * Returns an XML representation of this event using the given + * input document as owner. + * + * @return an XML representation of this event. + */ + public Element toXML(Document factory) + { + Element lifeCycleEvent = XmlUtils.createElement(factory, Names.LIFECYCLE_EVENT_QNAME); + + lifeCycleEvent.setAttribute( + "Type", + _type.toString()); + + lifeCycleEvent.setAttribute( + Names.TIMEMILLIS_ATTRIBUTE_NAME, + String.valueOf(System.currentTimeMillis())); + + Element resource = XmlUtils.createElement(factory, Names.RESOURCE_QNAME); + lifeCycleEvent.appendChild(resource); + + Element id = XmlUtils.createElement(factory, Names.RES_ID_QNAME); + id.setTextContent(_resourceId); + resource.appendChild(id); + + Element packageName = XmlUtils.createElement(factory, Names.PACKAGE_NAME_QNAME); + packageName.setTextContent(_packageName); + resource.appendChild(packageName); + + Element name = XmlUtils.createElement(factory, Names.ENTITY_NAME_QNAME); + name.setTextContent(_name); + resource.appendChild(name); + + return lifeCycleEvent; + } +} \ No newline at end of file diff --git a/qpid/java/management/client/src/main/java/org/apache/qpid/management/wsdm/notifications/LifeCycleEventType.java b/qpid/java/management/client/src/main/java/org/apache/qpid/management/wsdm/notifications/LifeCycleEventType.java new file mode 100644 index 0000000000..9ce7bfc743 --- /dev/null +++ b/qpid/java/management/client/src/main/java/org/apache/qpid/management/wsdm/notifications/LifeCycleEventType.java @@ -0,0 +1,34 @@ +/* + * + * 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.wsdm.notifications; + +/** + * Event type enumeration. + * Event type are used as part of event WS-Notifications in order to inform + * the interested listeners about the lifecycle of a QMan managed entity (object or event instance). + * + * @author Andrea Gazzarini + */ +public enum LifeCycleEventType +{ + CREATED, + REMOVED; +} \ No newline at end of file diff --git a/qpid/java/management/client/src/main/java/router-entries/consumer/resource-instance-1.xml b/qpid/java/management/client/src/main/java/router-entries/consumer/resource-instance-1.xml new file mode 100644 index 0000000000..599ac87a57 --- /dev/null +++ b/qpid/java/management/client/src/main/java/router-entries/consumer/resource-instance-1.xml @@ -0,0 +1,2 @@ + + \ No newline at end of file diff --git a/qpid/java/management/client/src/main/java/wsdl/QManAdapter.rmd b/qpid/java/management/client/src/main/java/wsdl/QManAdapter.rmd index 865fe87592..0663acb548 100644 --- a/qpid/java/management/client/src/main/java/wsdl/QManAdapter.rmd +++ b/qpid/java/management/client/src/main/java/wsdl/QManAdapter.rmd @@ -3,8 +3,15 @@ @@ -13,5 +20,33 @@ + + + + + + + + + + diff --git a/qpid/java/management/client/src/main/java/wsdl/QManAdapter.wsdl b/qpid/java/management/client/src/main/java/wsdl/QManAdapter.wsdl index 21414c53d9..9a956c22a2 100644 --- a/qpid/java/management/client/src/main/java/wsdl/QManAdapter.wsdl +++ b/qpid/java/management/client/src/main/java/wsdl/QManAdapter.wsdl @@ -14,7 +14,12 @@ xmlns:wsrf-rp="http://docs.oasis-open.org/wsrf/rp-2" xmlns:wsrf-sg="http://docs.oasis-open.org/wsrf/sg-2" xmlns:wsrf-sgw="http://docs.oasis-open.org/wsrf/sgw-2" - xmlns:wsrmd="http://docs.oasis-open.org/wsrf/rmd-1" + xmlns:wsnt="http://docs.oasis-open.org/wsn/b-2" + xmlns:wsntw="http://docs.oasis-open.org/wsn/bw-2" + xmlns:wst="http://docs.oasis-open.org/wsn/t-1" + xmlns:wsrmd="http://docs.oasis-open.org/wsrf/rmd-1" + xmlns:muws1="http://docs.oasis-open.org/wsdm/muws1-2.xsd" + xmlns:muws2="http://docs.oasis-open.org/wsdm/muws2-2.xsd" name="QManAdapter" > @@ -35,26 +40,57 @@ + + + + + + + + + + + + - - + - - + + + + + + + ---> + @@ -100,6 +136,97 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -167,16 +294,63 @@ - - + wsrf-rp:ResourceProperties="qman:WsDmAdapterResourceProperties" + wsrmd:Descriptor="WsDmAdapterMetadata" wsrmd:DescriptorLocation="QManAdapter.rmd"> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/qpid/java/management/client/src/main/java/wsdl/WS-BaseNotification-1_3.wsdl b/qpid/java/management/client/src/main/java/wsdl/WS-BaseNotification-1_3.wsdl new file mode 100644 index 0000000000..8764c18fc9 --- /dev/null +++ b/qpid/java/management/client/src/main/java/wsdl/WS-BaseNotification-1_3.wsdl @@ -0,0 +1,450 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/qpid/java/management/client/src/main/java/wsdl/WS-BaseNotification-1_3.xsd b/qpid/java/management/client/src/main/java/wsdl/WS-BaseNotification-1_3.xsd new file mode 100644 index 0000000000..9e10282759 --- /dev/null +++ b/qpid/java/management/client/src/main/java/wsdl/WS-BaseNotification-1_3.xsd @@ -0,0 +1,577 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/qpid/java/management/client/src/main/java/wsdl/WS-Resource-1_2.wsdl b/qpid/java/management/client/src/main/java/wsdl/WS-Resource-1_2.wsdl new file mode 100644 index 0000000000..ed1c309211 --- /dev/null +++ b/qpid/java/management/client/src/main/java/wsdl/WS-Resource-1_2.wsdl @@ -0,0 +1,54 @@ + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/qpid/java/management/client/src/main/java/wsdl/WS-ResourceLifetime-1_2.wsdl b/qpid/java/management/client/src/main/java/wsdl/WS-ResourceLifetime-1_2.wsdl new file mode 100644 index 0000000000..adea5800fc --- /dev/null +++ b/qpid/java/management/client/src/main/java/wsdl/WS-ResourceLifetime-1_2.wsdl @@ -0,0 +1,83 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/qpid/java/management/client/src/main/java/wsdl/WS-ResourceProperties-1_2.wsdl b/qpid/java/management/client/src/main/java/wsdl/WS-ResourceProperties-1_2.wsdl new file mode 100644 index 0000000000..5d9d7562f4 --- /dev/null +++ b/qpid/java/management/client/src/main/java/wsdl/WS-ResourceProperties-1_2.wsdl @@ -0,0 +1,395 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/qpid/java/management/client/src/main/java/wsdl/WS-ServiceGroup-1_2.wsdl b/qpid/java/management/client/src/main/java/wsdl/WS-ServiceGroup-1_2.wsdl new file mode 100644 index 0000000000..a75cd59728 --- /dev/null +++ b/qpid/java/management/client/src/main/java/wsdl/WS-ServiceGroup-1_2.wsdl @@ -0,0 +1,269 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/qpid/java/management/client/src/main/java/wsdl/WS-Topics-1_3.xsd b/qpid/java/management/client/src/main/java/wsdl/WS-Topics-1_3.xsd new file mode 100644 index 0000000000..df98513131 --- /dev/null +++ b/qpid/java/management/client/src/main/java/wsdl/WS-Topics-1_3.xsd @@ -0,0 +1,185 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + TopicPathExpression ::= TopicPath ( '|' TopicPath )* + TopicPath ::= RootTopic ChildTopicExpression* + RootTopic ::= NamespacePrefix? ('//')? (NCName | '*') + NamespacePrefix ::= NCName ':' + ChildTopicExpression ::= '/' '/'? (QName | NCName | '*'| '.') + + + + + + + + + + + + + The pattern allows strings matching the following EBNF: + ConcreteTopicPath ::= RootTopic ChildTopic* + RootTopic ::= QName + ChildTopic ::= '/' (QName | NCName) + + + + + + + + + + + + + The pattern allows strings matching the following EBNF: + RootTopic ::= QName + + + + + + + \ No newline at end of file diff --git a/qpid/java/management/client/src/main/java/wsdl/WSDM-MUWS-Part1-1_1.xsd b/qpid/java/management/client/src/main/java/wsdl/WSDM-MUWS-Part1-1_1.xsd new file mode 100644 index 0000000000..dd74c23681 --- /dev/null +++ b/qpid/java/management/client/src/main/java/wsdl/WSDM-MUWS-Part1-1_1.xsd @@ -0,0 +1,93 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/qpid/java/management/client/src/main/java/wsdl/WSDM-MUWS-Part2-1_1.xsd b/qpid/java/management/client/src/main/java/wsdl/WSDM-MUWS-Part2-1_1.xsd new file mode 100644 index 0000000000..51233a0989 --- /dev/null +++ b/qpid/java/management/client/src/main/java/wsdl/WSDM-MUWS-Part2-1_1.xsd @@ -0,0 +1,656 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/qpid/java/management/client/src/test/java/org/apache/qpid/management/TestConstants.java b/qpid/java/management/client/src/test/java/org/apache/qpid/management/TestConstants.java index d7ecd707fe..12ba1fab73 100644 --- a/qpid/java/management/client/src/test/java/org/apache/qpid/management/TestConstants.java +++ b/qpid/java/management/client/src/test/java/org/apache/qpid/management/TestConstants.java @@ -64,7 +64,4 @@ public interface TestConstants String YEARS = "years"; int SAMPLE_MIN_VALUE = 1; int SAMPLE_MAX_VALUE = 120; - - String DEFAULT_HOST = "localhost"; - int DEFAULT_PORT = 8080; } \ No newline at end of file diff --git a/qpid/java/management/client/src/test/java/org/apache/qpid/management/wsdm/EnhancedReflectionProxyHandler.java b/qpid/java/management/client/src/test/java/org/apache/qpid/management/wsdm/EnhancedReflectionProxyHandler.java index 732f110ba3..615d744546 100644 --- a/qpid/java/management/client/src/test/java/org/apache/qpid/management/wsdm/EnhancedReflectionProxyHandler.java +++ b/qpid/java/management/client/src/test/java/org/apache/qpid/management/wsdm/EnhancedReflectionProxyHandler.java @@ -29,8 +29,12 @@ import org.apache.qpid.management.wsdm.muse.serializer.ByteArraySerializer; import org.w3c.dom.Element; /** - * Custom implementation of Muse ReflectionProxyHandler that uses a base64 serializer - * for byte arrays. + * Custom implementation of Muse ReflectionProxyHandler + * that uses a base64 serializer for byte arrays. + * Note that this proxy handler is only needed for tests because it provides + * client side Base64 serializer capability. + * In a concrete scenario we don't mind what instrument the client is using in order to + * propertly serialize byte arrays. * * @author Andrea Gazzarini */ @@ -53,6 +57,7 @@ public class EnhancedReflectionProxyHandler extends ReflectionProxyHandler } } + @SuppressWarnings("unchecked") @Override protected Object deserialize(Element xml, Class theClass) throws SoapFault { diff --git a/qpid/java/management/client/src/test/java/org/apache/qpid/management/wsdm/ServerThread.java b/qpid/java/management/client/src/test/java/org/apache/qpid/management/wsdm/ServerThread.java index ff7d9b5a8a..395fe657c0 100644 --- a/qpid/java/management/client/src/test/java/org/apache/qpid/management/wsdm/ServerThread.java +++ b/qpid/java/management/client/src/test/java/org/apache/qpid/management/wsdm/ServerThread.java @@ -30,23 +30,39 @@ import org.mortbay.jetty.nio.SelectChannelConnector; import org.mortbay.jetty.webapp.WebAppContext; import org.mortbay.start.Monitor; +/** + * Web Server startup thread. + * It is used on adapter test case in order to start the embedded + * web server as a separated thread. + * + * @author Andrea Gazzarini + */ public class ServerThread extends Thread { private final Listener _lifecycleListener; - private Server server; + private Server _server; + + /** + * Builds a new server thread with the given lifecycle listener. + * + * @param listener the lifecycle listener. + */ ServerThread(Listener listener) { this._lifecycleListener = listener; } + /** + * Starts the server. + */ @Override public void run() { try { Monitor.monitor(); - server = new Server(); - server.setStopAtShutdown(true); + _server = new Server(); + _server.setStopAtShutdown(true); Connector connector=new SelectChannelConnector(); connector.setPort( @@ -54,11 +70,12 @@ public class ServerThread extends Thread System.getProperty(Names.ADAPTER_PORT_PROPERTY_NAME))); connector.setHost(System.getProperty(Names.ADAPTER_HOST_PROPERTY_NAME)); - server.setConnectors(new Connector[]{connector}); + _server.setConnectors(new Connector[]{connector}); WebAppContext webapp = new WebAppContext(); -// webapp.setExtractWAR(false); webapp.setContextPath("/qman"); + + // Additional web application descriptor containing test components. webapp.setDefaultsDescriptor("/org/apache/qpid/management/wsdm/web.xml"); String webApplicationPath = System.getProperty("qman.war"); @@ -66,17 +83,22 @@ public class ServerThread extends Thread webapp.setWar(rootFolderPath.toURI().toURL().toExternalForm()); webapp.addLifeCycleListener(_lifecycleListener); - server.setHandler(webapp); - server.start(); - server.join(); + _server.setHandler(webapp); + _server.start(); + _server.join(); } catch(Exception exception) { throw new RuntimeException(exception); } } + /** + * Shutdown the server. + * + * @throws Exception when a problem is encountered during shutdown. + */ public void shutdown() throws Exception { - server.stop(); + _server.stop(); } } diff --git a/qpid/java/management/client/src/test/java/org/apache/qpid/management/wsdm/WebApplicationLifeCycleListener.java b/qpid/java/management/client/src/test/java/org/apache/qpid/management/wsdm/WebApplicationLifeCycleListener.java index 3a0bbb608a..91c646467e 100644 --- a/qpid/java/management/client/src/test/java/org/apache/qpid/management/wsdm/WebApplicationLifeCycleListener.java +++ b/qpid/java/management/client/src/test/java/org/apache/qpid/management/wsdm/WebApplicationLifeCycleListener.java @@ -19,6 +19,7 @@ * */ package org.apache.qpid.management.wsdm; + import org.mortbay.component.LifeCycle; import org.mortbay.component.LifeCycle.Listener; @@ -26,6 +27,14 @@ import org.mortbay.component.LifeCycle.Listener; * Adapter class used to provide an empty (base) implementation of * Lifecycle listener interface. * + * Adapter test case needs to be informed about the lifecycle of the + * deployed QMan application. Only when its deployment is completed the test + * case can run successfully. + * + * So, following the same logic of Swng event model, this is an adapter that provides + * empty implementation of the listener interface (see for example MouseAdapter + * for mouse events listener) + * * @author Andrea Gazzarini */ public class WebApplicationLifeCycleListener implements Listener diff --git a/qpid/java/management/client/src/test/java/org/apache/qpid/management/wsdm/WsDmAdapterTest.java b/qpid/java/management/client/src/test/java/org/apache/qpid/management/wsdm/WsDmAdapterTest.java index 8a4434bee1..1e0bc4c131 100644 --- a/qpid/java/management/client/src/test/java/org/apache/qpid/management/wsdm/WsDmAdapterTest.java +++ b/qpid/java/management/client/src/test/java/org/apache/qpid/management/wsdm/WsDmAdapterTest.java @@ -49,7 +49,7 @@ import org.apache.muse.ws.addressing.soap.SoapFault; import org.apache.muse.ws.resource.remote.WsResourceClient; import org.apache.muse.ws.resource.sg.remote.ServiceGroupClient; import org.apache.qpid.management.Names; -import org.apache.qpid.management.TestConstants; +import org.apache.qpid.management.Protocol; import org.apache.qpid.management.wsdm.capabilities.Result; import org.apache.qpid.management.wsdm.muse.serializer.DateSerializer; import org.apache.qpid.management.wsdm.muse.serializer.InvocationResultSerializer; @@ -126,11 +126,11 @@ public class WsDmAdapterTest extends TestCase { System.setProperty( Names.ADAPTER_PORT_PROPERTY_NAME, - String.valueOf(TestConstants.DEFAULT_PORT)); + String.valueOf(Protocol.DEFAULT_QMAN_PORT_NUMBER)); System.setProperty( Names.ADAPTER_HOST_PROPERTY_NAME, - TestConstants.DEFAULT_HOST); + Protocol.DEFAULT_QMAN_HOSTNAME); server = new ServerThread(listener); server.start(); @@ -787,12 +787,7 @@ public class WsDmAdapterTest extends TestCase { */ private ServiceGroupClient getServiceGroupClient() { - URI address = URI.create( - "http://"+ - TestConstants.DEFAULT_HOST+ - ":"+ - TestConstants.DEFAULT_PORT+ - "/qman/services/adapter"); + URI address = URI.create(Protocol.DEFAULT_ENDPOINT_URI); return new ServiceGroupClient(new EndpointReference(address)); } -- cgit v1.2.1