You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@qpid.apache.org by ag...@apache.org on 2009/01/15 08:26:22 UTC
svn commit: r734622 [2/5] - in /qpid/trunk/qpid/java/management/client: ./
etc/ src/main/java/ src/main/java/org/apache/qpid/management/
src/main/java/org/apache/qpid/management/configuration/
src/main/java/org/apache/qpid/management/domain/model/ src/...
Modified: qpid/trunk/qpid/java/management/client/src/main/java/org/apache/qpid/management/domain/model/QpidEntity.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/management/client/src/main/java/org/apache/qpid/management/domain/model/QpidEntity.java?rev=734622&r1=734621&r2=734622&view=diff
==============================================================================
--- qpid/trunk/qpid/java/management/client/src/main/java/org/apache/qpid/management/domain/model/QpidEntity.java (original)
+++ qpid/trunk/qpid/java/management/client/src/main/java/org/apache/qpid/management/domain/model/QpidEntity.java Wed Jan 14 23:26:19 2009
@@ -1,24 +1,3 @@
-/*
-*
- * 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.domain.model;
import java.util.HashMap;
@@ -28,26 +7,26 @@
import javax.management.AttributeList;
import javax.management.DynamicMBean;
import javax.management.MBeanInfo;
+import javax.management.NotificationBroadcasterSupport;
+import javax.management.ObjectName;
import javax.management.RuntimeOperationsException;
import org.apache.qpid.management.Messages;
+import org.apache.qpid.management.Names;
import org.apache.qpid.management.domain.model.type.Binary;
import org.apache.qpid.management.domain.services.QpidService;
+import org.apache.qpid.management.jmx.EntityLifecycleNotification;
import org.apache.qpid.transport.util.Logger;
/**
* Layer supertype for QMan entities.
- *
- * @author Andrea Gazzarini
*/
-public abstract class QpidEntity
+public abstract class QpidEntity extends NotificationBroadcasterSupport
{
/**
* Layer supertype for QMan managed bean entities.
- *
- * @author Andrea Gazzarini
*/
- abstract class QpidManagedEntity implements DynamicMBean
+ abstract class QManManagedEntity implements DynamicMBean
{
// After mbean is registered with the MBean server this collection holds the mbean attribute values.
Map<String,Object> _attributes = new HashMap<String, Object>();
@@ -114,8 +93,11 @@
final QpidPackage _parent;
MBeanInfo _metadata;
-
final QpidService _service;
+
+ protected ObjectName _objectName;
+
+ private final String _type;
/**
* Builds a new class with the given name and package as parent.
@@ -124,11 +106,12 @@
* @param hash the class schema hash.
* @param parentPackage the parent of this class.
*/
- QpidEntity(String className, Binary hash, QpidPackage parentPackage)
+ QpidEntity(String className, Binary hash, QpidPackage parentPackage,String type)
{
this._name = className;
this._parent = parentPackage;
this._hash = hash;
+ this._type = type;
this._service = new QpidService(_parent.getOwnerId());
_logger.debug(
@@ -138,6 +121,16 @@
_name);
}
+ public String getName()
+ {
+ return _name;
+ }
+
+ public String getPackageName()
+ {
+ return _parent.getName();
+ }
+
/**
* Internal method used to send a schema request for this entity.
*
@@ -145,7 +138,11 @@
*/
void requestSchema() throws Exception
{
- try
+
+ _objectName = JMX_SERVICE.createEntityDefinitionName(_parent.getName(), _name,_type);
+ JMX_SERVICE.registerEntityDefinition(_objectName,this,_parent.getName(),_name);
+
+ try
{
_service.connect();
_service.requestSchema(_parent.getName(), _name, _hash);
@@ -154,5 +151,13 @@
{
_service.close();
}
+
+ EntityLifecycleNotification notification = new EntityLifecycleNotification(
+ EntityLifecycleNotification.SCHEMA_REQUESTED,
+ _parent.getName(),
+ _name,
+ Names.CLASS,
+ _objectName);
+ sendNotification(notification);
}
}
Modified: qpid/trunk/qpid/java/management/client/src/main/java/org/apache/qpid/management/domain/model/QpidEvent.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/management/client/src/main/java/org/apache/qpid/management/domain/model/QpidEvent.java?rev=734622&r1=734621&r2=734622&view=diff
==============================================================================
--- qpid/trunk/qpid/java/management/client/src/main/java/org/apache/qpid/management/domain/model/QpidEvent.java (original)
+++ qpid/trunk/qpid/java/management/client/src/main/java/org/apache/qpid/management/domain/model/QpidEvent.java Wed Jan 14 23:26:19 2009
@@ -27,6 +27,7 @@
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
+import java.util.UUID;
import javax.management.Attribute;
import javax.management.AttributeList;
@@ -35,26 +36,25 @@
import javax.management.MBeanAttributeInfo;
import javax.management.MBeanException;
import javax.management.MBeanInfo;
+import javax.management.ObjectName;
import javax.management.ReflectionException;
import javax.management.RuntimeOperationsException;
import org.apache.qpid.management.Messages;
+import org.apache.qpid.management.Names;
import org.apache.qpid.management.domain.model.type.Binary;
+import org.apache.qpid.management.jmx.EntityLifecycleNotification;
import org.apache.qpid.transport.codec.BBDecoder;
/**
* Qpid event definition.
- *
- * @author Andrea Gazzarini
*/
-class QpidEvent extends QpidEntity
+class QpidEvent extends QpidEntity implements QpidEventMBean
{
/**
* State interface for this event definition.
* Each state is responsible to handle the injection of the data and / or schema.
- *
- * @author Andrea Gazzarini
*/
interface State
{
@@ -99,9 +99,10 @@
{
requestSchema();
_state = _schemaRequestedButNotYetInjected;
- } catch (Exception e)
+ } catch (Exception exception)
{
_logger.error(
+ exception,
Messages.QMAN_100015_UNABLE_TO_SEND_SCHEMA_REQUEST,
_parent.getName(),
_name);
@@ -116,7 +117,7 @@
*/
public void setSchema (List<Map<String, Object>> agumentDefinitions) throws UnableToBuildFeatureException
{
- throw new IllegalStateException("When a schema arrives it's not possible for this class to be in this state.");
+ throw new IllegalStateException("When a schema arrives it's not possible for this event to be in this state.");
}
};
@@ -155,12 +156,21 @@
_metadata = new MBeanInfo(_name,_name,attributesMetadata,null,null,null);
// Converting stored object instances into JMX MBean and removing raw instance data.
- for (QpidManagedEvent instance : _eventInstances)
+ for (QManManagedEvent instance : _eventInstances)
{
updateEventInstanceWithData(instance);
- JMX_SERVICE.registerEventInstance(instance,_parent.getOwnerId(),_parent.getName(),_name);
+ registerEventInstance(instance,_parent.getOwnerId(),_parent.getName(),_name);
}
_state = _schemaInjected;
+
+ EntityLifecycleNotification notification = new EntityLifecycleNotification(
+ EntityLifecycleNotification.SCHEMA_INJECTED,
+ _parent.getName(),
+ _name,
+ Names.EVENT,
+ _objectName);
+
+ sendNotification(notification);
}
};
@@ -177,9 +187,9 @@
*/
public void addNewEventData (byte[] rawData,long currentTimestamp, int severity)
{
- QpidManagedEvent instance = createEventInstance(rawData,currentTimestamp, severity);
+ QManManagedEvent instance = createEventInstance(rawData,currentTimestamp, severity);
updateEventInstanceWithData(instance);
- JMX_SERVICE.registerEventInstance(instance,_parent.getOwnerId(),_parent.getName(),_name);
+ registerEventInstance(instance,_parent.getOwnerId(),_parent.getName(),_name);
}
/**
@@ -197,7 +207,7 @@
*
* @author Andrea Gazzarini
*/
- class QpidManagedEvent extends QpidManagedEntity
+ class QManManagedEvent extends QManManagedEntity
{
@@ -211,7 +221,7 @@
*
* @param objectId the object identifier.
*/
- private QpidManagedEvent(byte [] data, long timestamp, int severity)
+ private QManManagedEvent(byte [] data, long timestamp, int severity)
{
this._rawEventData = data;
this._timestamp = timestamp;
@@ -284,7 +294,7 @@
private List<QpidProperty> _schemaOrderedArguments = new ArrayList<QpidProperty>();
Map<String, QpidProperty> _arguments = new HashMap<String, QpidProperty>();
- List<QpidManagedEvent> _eventInstances = new LinkedList<QpidManagedEvent>();
+ List<QManManagedEvent> _eventInstances = new LinkedList<QManManagedEvent>();
State _state = _schemaNotRequested;;
/**
@@ -296,7 +306,7 @@
*/
QpidEvent(String eventClassName, Binary hash, QpidPackage parentPackage)
{
- super(eventClassName,hash,parentPackage);
+ super(eventClassName,hash,parentPackage,Names.EVENT);
}
/**
@@ -393,9 +403,9 @@
* @param registration a flag indicating whenever the (new ) instance must be registered with MBean server.
* @return the object instance associated to the given identifier.
*/
- QpidManagedEvent createEventInstance(byte [] data, long timestamp, int severity)
+ QManManagedEvent createEventInstance(byte [] data, long timestamp, int severity)
{
- QpidManagedEvent eventInstance = new QpidManagedEvent(data, timestamp, severity);
+ QManManagedEvent eventInstance = new QManManagedEvent(data, timestamp, severity);
_eventInstances.add(eventInstance);
return eventInstance;
}
@@ -406,7 +416,7 @@
* @param instance the managed object instance.
* @param rawData the incoming configuration data which contains new values for instance properties.
*/
- void updateEventInstanceWithData(QpidManagedEvent instance)
+ void updateEventInstanceWithData(QManManagedEvent instance)
{
BBDecoder decoder = new BBDecoder();
decoder.init(ByteBuffer.wrap(instance._rawEventData));
@@ -441,6 +451,7 @@
{
_eventInstances.clear();
JMX_SERVICE.unregisterEvents();
+ JMX_SERVICE.unregisterClassDefinitions();
_service.close();
}
@@ -453,4 +464,30 @@
{
return _eventInstances.isEmpty();
}
+
+ /**
+ * Compose method used for registering an mbean (event) instance.
+ *
+ * @param instance the mbean event.
+ * @param brokerId the broker identifier.
+ * @param packageName the package name.
+ * @param eventClassName the event class name.
+ */
+ private void registerEventInstance(
+ QManManagedEvent instance,
+ UUID brokerId,
+ String packageName,
+ String eventClassName)
+ {
+ ObjectName objectName = JMX_SERVICE.registerEventInstance(instance,brokerId,packageName,eventClassName);
+
+ EntityLifecycleNotification notification = new EntityLifecycleNotification(
+ EntityLifecycleNotification.INSTANCE_ADDED,
+ packageName,
+ eventClassName,
+ Names.EVENT,
+ objectName);
+
+ sendNotification(notification);
+ }
}
Added: qpid/trunk/qpid/java/management/client/src/main/java/org/apache/qpid/management/domain/model/QpidEventMBean.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/management/client/src/main/java/org/apache/qpid/management/domain/model/QpidEventMBean.java?rev=734622&view=auto
==============================================================================
--- qpid/trunk/qpid/java/management/client/src/main/java/org/apache/qpid/management/domain/model/QpidEventMBean.java (added)
+++ qpid/trunk/qpid/java/management/client/src/main/java/org/apache/qpid/management/domain/model/QpidEventMBean.java Wed Jan 14 23:26:19 2009
@@ -0,0 +1,41 @@
+/*
+ *
+ * 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.domain.model;
+
+/**
+ * Management interface for Qpid entity class..
+ */
+public interface QpidEventMBean
+{
+ /**
+ * Retruns the name of the event.
+ *
+ * @return the name of the event.
+ */
+ String getName();
+
+ /**
+ * Returns the name of the package.
+ *
+ * @return the name of the package.
+ */
+ String getPackageName();
+}
\ No newline at end of file
Modified: qpid/trunk/qpid/java/management/client/src/main/java/org/apache/qpid/management/domain/model/QpidFeature.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/management/client/src/main/java/org/apache/qpid/management/domain/model/QpidFeature.java?rev=734622&r1=734621&r2=734622&view=diff
==============================================================================
--- qpid/trunk/qpid/java/management/client/src/main/java/org/apache/qpid/management/domain/model/QpidFeature.java (original)
+++ qpid/trunk/qpid/java/management/client/src/main/java/org/apache/qpid/management/domain/model/QpidFeature.java Wed Jan 14 23:26:19 2009
@@ -22,8 +22,6 @@
/**
* Layer Supertype for all qpid management features.
- *
- * @author Andrea Gazzarini
*/
abstract class QpidFeature
{
Modified: qpid/trunk/qpid/java/management/client/src/main/java/org/apache/qpid/management/domain/model/type/Binary.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/management/client/src/main/java/org/apache/qpid/management/domain/model/type/Binary.java?rev=734622&r1=734621&r2=734622&view=diff
==============================================================================
--- qpid/trunk/qpid/java/management/client/src/main/java/org/apache/qpid/management/domain/model/type/Binary.java (original)
+++ qpid/trunk/qpid/java/management/client/src/main/java/org/apache/qpid/management/domain/model/type/Binary.java Wed Jan 14 23:26:19 2009
@@ -24,7 +24,6 @@
import java.util.Arrays;
import java.util.UUID;
-import org.apache.qpid.management.messages.AmqpCoDec;
import org.apache.qpid.transport.codec.Encoder;
/**
@@ -90,7 +89,7 @@
this._bytes = bytes;
byte [] array = new byte [8];
System.arraycopy(_bytes, 0, array, 0, 8);
- _first = AmqpCoDec.unpack64(array);
+ _first = unpack64(array);
uuid = UUID.randomUUID();
}
@@ -148,4 +147,16 @@
{
return (_first & 281474708275200L) >> 28;
}
+
+ public final long unpack64(byte data[]) {
+ return (
+ ((long) (data[0] & 0xff) << 56) |
+ ((long)(data[1] & 0xff) << 48) |
+ ((long)(data[2] & 0xff) << 40) |
+ ((long)(data[3] & 0xff) << 32) |
+ ((long)(data[4] & 0xff) << 24) |
+ ((long)(data[5] & 0xff) << 16) |
+ ((long)(data[6] & 0xff) << 8) |
+ (long) data[7] & 0xff);
+ }
}
Modified: qpid/trunk/qpid/java/management/client/src/main/java/org/apache/qpid/management/domain/model/type/Map.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/management/client/src/main/java/org/apache/qpid/management/domain/model/type/Map.java?rev=734622&r1=734621&r2=734622&view=diff
==============================================================================
--- qpid/trunk/qpid/java/management/client/src/main/java/org/apache/qpid/management/domain/model/type/Map.java (original)
+++ qpid/trunk/qpid/java/management/client/src/main/java/org/apache/qpid/management/domain/model/type/Map.java Wed Jan 14 23:26:19 2009
@@ -36,7 +36,8 @@
return decoder.readMap();
}
- @Override
+ @SuppressWarnings("unchecked")
+ @Override
public void encode (Object value, Encoder encoder)
{
encoder.writeMap((java.util.Map<String, Object>)value);
Modified: qpid/trunk/qpid/java/management/client/src/main/java/org/apache/qpid/management/domain/services/BrokerMessageListener.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/management/client/src/main/java/org/apache/qpid/management/domain/services/BrokerMessageListener.java?rev=734622&r1=734621&r2=734622&view=diff
==============================================================================
--- qpid/trunk/qpid/java/management/client/src/main/java/org/apache/qpid/management/domain/services/BrokerMessageListener.java (original)
+++ qpid/trunk/qpid/java/management/client/src/main/java/org/apache/qpid/management/domain/services/BrokerMessageListener.java Wed Jan 14 23:26:19 2009
@@ -132,20 +132,26 @@
IMessageHandler handler = entry.getValue();
try
{
- handler.setDomainModel(_domainModel);
- _handlers.put(opcode, handler);
- } catch(Exception exception) {
- LOGGER.error(exception,Messages.QMAN_100004_HANDLER_INITIALIZATION_FAILURE, opcode);
- }
- }
+ handler.setDomainModel(_domainModel);
+ _handlers.put(opcode, handler);
+ } catch (Exception exception) {
+ LOGGER.error(exception,
+ Messages.QMAN_100004_HANDLER_INITIALIZATION_FAILURE,
+ opcode);
+ }
+ }
}
+
+
/**
- * Dispatches the given message to the appropriate handler.
- *
- * @param message the incoming message.
- * @throws IOException when the message content cannot be read.
- */
+ * Dispatches the given message to the appropriate handler.
+ *
+ * @param message
+ * the incoming message.
+ * @throws IOException
+ * when the message content cannot be read.
+ */
private void dispatch(Message message) throws IOException
{
ByteBuffer buffer = message.readData();
Modified: qpid/trunk/qpid/java/management/client/src/main/java/org/apache/qpid/management/domain/services/QMan.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/management/client/src/main/java/org/apache/qpid/management/domain/services/QMan.java?rev=734622&r1=734621&r2=734622&view=diff
==============================================================================
--- qpid/trunk/qpid/java/management/client/src/main/java/org/apache/qpid/management/domain/services/QMan.java (original)
+++ qpid/trunk/qpid/java/management/client/src/main/java/org/apache/qpid/management/domain/services/QMan.java Wed Jan 14 23:26:19 2009
@@ -26,7 +26,6 @@
import java.util.ArrayList;
import java.util.List;
import java.util.UUID;
-import java.util.Map.Entry;
import javax.management.Attribute;
import javax.management.AttributeList;
@@ -35,6 +34,9 @@
import javax.management.MBeanInfo;
import javax.management.MBeanOperationInfo;
import javax.management.MBeanParameterInfo;
+import javax.management.Notification;
+import javax.management.NotificationBroadcasterSupport;
+import javax.management.NotificationListener;
import javax.management.ReflectionException;
import org.apache.log4j.xml.DOMConfigurator;
@@ -43,21 +45,20 @@
import org.apache.qpid.management.configuration.BrokerAlreadyConnectedException;
import org.apache.qpid.management.configuration.BrokerConnectionData;
import org.apache.qpid.management.configuration.BrokerConnectionException;
-import org.apache.qpid.management.configuration.Configuration;
import org.apache.qpid.management.configuration.Configurator;
import org.apache.qpid.management.domain.model.JmxService;
import org.apache.qpid.transport.util.Logger;
/**
* Main entry point for starting Q-Man application.
- *
- * @author Andrea Gazzarini
*/
-public class QMan implements DynamicMBean
+public class QMan extends NotificationBroadcasterSupport implements DynamicMBean, NotificationListener
{
private final static Logger LOGGER = Logger.get(QMan.class);
private final List<ManagementClient> managementClients = new ArrayList<ManagementClient>();
+ private Configurator _configurator = new Configurator();
+
/**
* Starts QMan.
* @throws StartupFailureException when it's not possible to proceed with startup.
@@ -67,24 +68,11 @@
LOGGER.info(Messages.QMAN_000001_STARTING_QMAN);
LOGGER.info(Messages.QMAN_000002_READING_CONFIGURATION);
- Configurator configurator = new Configurator();
try
{
- configurator.configure();
- Configuration configuration = Configuration.getInstance();
- if (configuration.hasOneOrMoreBrokersDefined())
- {
- LOGGER.info(Messages.QMAN_000003_CREATING_MANAGEMENT_CLIENTS);
- for (Entry<UUID, BrokerConnectionData> entry : Configuration.getInstance().getConnectionInfos())
- {
- createManagementClient(entry.getKey(), entry.getValue());
- }
- } else
- {
- LOGGER.info(Messages.QMAN_000022_NO_BROKER_CONFIGURED);
- }
-
- registerQManService();
+ registerQManService();
+
+ _configurator.configure();
LOGGER.info(Messages.QMAN_000019_QMAN_STARTED);
} catch(Exception exception) {
@@ -92,26 +80,6 @@
throw new StartupFailureException(exception);
}
}
-
- /**
- * Creates a management client using the given data.
- *
- * @param brokerId the broker identifier.
- * @param data the broker connection data.
- */
- private void createManagementClient(UUID brokerId, BrokerConnectionData data)
- {
- try
- {
- ManagementClient client = new ManagementClient(brokerId,data);
- client.estabilishFirstConnectionWithBroker();
- managementClients.add(client);
-
- LOGGER.info(Messages.QMAN_000004_MANAGEMENT_CLIENT_CONNECTED,brokerId);
- } catch(StartupFailureException exception) {
- LOGGER.error(exception, Messages.QMAN_100017_UNABLE_TO_CONNECT,brokerId,data);
- }
- }
/**
* Connects Q-Man with a broker defined by the given parameter.
@@ -156,7 +124,7 @@
throw exception;
}
}
-
+
/**
* Stop Qman
*/
@@ -176,6 +144,16 @@
}
/**
+ * Injects the configurator on this QMan instance.
+ * That configutator later will be responsible to manage the configuration.
+ *
+ * @param configurator the configurator to be injected.
+ */
+ public void setConfigurator(Configurator configurator){
+ this._configurator = configurator;
+ }
+
+ /**
* Main method used for starting Q-Man.
*
* @param args the command line arguments.
@@ -349,6 +327,17 @@
{
return null;
}
+
+ /**
+ * Simply dispatches the incoming notification to registered listeners.
+ *
+ * @param notification the incoming notification.
+ * @param handback the context associated to this notification.
+ */
+ public void handleNotification(Notification notification, Object handback)
+ {
+ sendNotification(notification);
+ }
/**
* Registers QMan as an MBean on MBeanServer.
@@ -361,5 +350,25 @@
service.registerQManService(this);
LOGGER.info(Messages.QMAN_000023_QMAN_REGISTERED_AS_MBEAN);
- }
+ }
+
+ /**
+ * Creates a management client using the given data.
+ *
+ * @param brokerId the broker identifier.
+ * @param data the broker connection data.
+ */
+ public void createManagementClient(UUID brokerId, BrokerConnectionData data)
+ {
+ try
+ {
+ ManagementClient client = new ManagementClient(brokerId,data);
+ client.estabilishFirstConnectionWithBroker();
+ managementClients.add(client);
+
+ LOGGER.info(Messages.QMAN_000004_MANAGEMENT_CLIENT_CONNECTED,brokerId);
+ } catch(StartupFailureException exception) {
+ LOGGER.error(exception, Messages.QMAN_100017_UNABLE_TO_CONNECT,brokerId,data);
+ }
+ }
}
Added: qpid/trunk/qpid/java/management/client/src/main/java/org/apache/qpid/management/jmx/EntityLifecycleNotification.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/management/client/src/main/java/org/apache/qpid/management/jmx/EntityLifecycleNotification.java?rev=734622&view=auto
==============================================================================
--- qpid/trunk/qpid/java/management/client/src/main/java/org/apache/qpid/management/jmx/EntityLifecycleNotification.java (added)
+++ qpid/trunk/qpid/java/management/client/src/main/java/org/apache/qpid/management/jmx/EntityLifecycleNotification.java Wed Jan 14 23:26:19 2009
@@ -0,0 +1,137 @@
+/*
+ *
+ * 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.jmx;
+
+import javax.management.Notification;
+import javax.management.ObjectName;
+
+import org.apache.qpid.management.Names;
+import org.apache.qpid.management.domain.services.SequenceNumberGenerator;
+
+/**
+ * Q-Man JMX entity lifecycle notification.
+ * A notification is sent to interested listener by Q-Man on the following scenarios :
+ *
+ * <br> - A schema (class / event) has been requested (Schema request);
+ * <br> - A schema (class / event) has been injected (Schema response);
+ * <br> - A schema cannot be parsed (probably it is malformed);
+ * <br> - An object instance has been created (Instrumentation / Configuration response);
+ * <br> - An event instance has been created (Instrumentation / Configuration response);
+ * <br> - An object instance has been removed (Instrumentation / Configuration response);
+ * <br> - An event instance has been removed (Instrumentation / Configuration response);
+ */
+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 INSTANCE_ADDED = "org.apache.qpid.management.lifecycle.entity.instance.created";
+ public static final String INSTANCE_REMOVED = "org.apache.qpid.management.lifecycle.entity.instance.removed";
+
+ private String _packageName = Names.NOT_AVAILABLE;
+ private String _className = Names.NOT_AVAILABLE;
+ private String _classKind = Names.NOT_AVAILABLE;
+
+ private ObjectName _objectName;
+
+ /**
+ * Builds a new notification with the given parameters.
+ *
+ * @param type the notification type.
+ * @param sequenceNumber the sequence number.
+ * @param packageName the package name.
+ * @param className the class name.
+ * @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)
+ {
+ super(type,Names.APPLICATION_NAME,SequenceNumberGenerator.getNextSequenceNumber());
+ this._className = className;
+ this._packageName = packageName;
+ this._classKind = classKind;
+ this._objectName = objectName;
+ }
+
+ /**
+ * Returns the package name of object contained in this notification.
+ *
+ * @return the package name of object contained in this notification.
+ */
+ public String getPackageName()
+ {
+ return _packageName;
+ }
+
+ /**
+ * Returns the class name of object contained in this notification.
+ *
+ * @return the class name of object contained in this notification.
+ */
+ public String getClassName()
+ {
+ return _className;
+ }
+
+ /**
+ * Returns the class kind of object contained in this notification.
+ *
+ * @return the class kind of object contained in this notification.
+ * @see Names#CLASS
+ * @see Names#EVENT
+ */
+ public String getClassKind()
+ {
+ return _classKind;
+ }
+
+ /**
+ * Returns the object name of object contained in this notification.
+ *
+ * @return the object name of object contained in this notification.
+ */
+ public ObjectName getObjectName()
+ {
+ return _objectName;
+ }
+
+ /**
+ * Returns a string representation of this notification.
+ *
+ * @return a string representation of this notification.
+ */
+ @Override
+ public String toString()
+ {
+ return new StringBuilder()
+ .append(getType())
+ .append(':')
+ .append(_packageName)
+ .append('.')
+ .append(_className)
+ .append('@')
+ .append(_objectName)
+ .toString();
+ }
+}
\ No newline at end of file
Added: qpid/trunk/qpid/java/management/client/src/main/java/org/apache/qpid/management/jmx/OperationHasBeenInvokedNotification.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/management/client/src/main/java/org/apache/qpid/management/jmx/OperationHasBeenInvokedNotification.java?rev=734622&view=auto
==============================================================================
--- qpid/trunk/qpid/java/management/client/src/main/java/org/apache/qpid/management/jmx/OperationHasBeenInvokedNotification.java (added)
+++ qpid/trunk/qpid/java/management/client/src/main/java/org/apache/qpid/management/jmx/OperationHasBeenInvokedNotification.java Wed Jan 14 23:26:19 2009
@@ -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.jmx;
+
+import javax.management.Notification;
+
+import org.apache.qpid.management.Names;
+import org.apache.qpid.management.domain.handler.impl.InvocationResult;
+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)
+ */
+public class OperationHasBeenInvokedNotification extends Notification
+{
+ private static final long serialVersionUID = -7755773156742412161L;
+
+ public static final String OPERATION_INVOKED = "org.apache.qpid.management.operation.invoked";
+
+ private final String _operationName;
+ private final Object [] _parameters;
+ private final String [] _signature;
+ private final Exception _exception;
+ private final InvocationResult _result;
+
+ /**
+ * Builds a new notification with the given parameters.
+ *
+ * @param type the notification type.
+ * @param operationName the operation name.
+ * @param params the operation parameters.
+ * @param signature the operation signature.
+ * @param exception the exception raised by the invocation.
+ */
+ public OperationHasBeenInvokedNotification(String operationName, Object[] parameters, String [] signature, Exception exception)
+ {
+ super(OPERATION_INVOKED,Names.APPLICATION_NAME,SequenceNumberGenerator.getNextSequenceNumber());
+ this._operationName= operationName;
+ this._parameters = parameters;
+ this._signature = signature;
+ this._result = null;
+ this._exception = exception;
+
+ }
+
+ /**
+ * Builds a new notification with the given parameters.
+ *
+ * @param type the notification type.
+ * @param operationName the operation name.
+ * @param params the operation parameters.
+ * @param signature the operation signature.
+ * @param objectName the target mbean object name.
+ * @param result the invocation result.
+ */
+ public OperationHasBeenInvokedNotification(String operationName, Object[] parameters, String [] signature,InvocationResult result)
+ {
+ super(OPERATION_INVOKED,Names.APPLICATION_NAME,SequenceNumberGenerator.getNextSequenceNumber());
+ this._operationName= operationName;
+ this._parameters = parameters;
+ this._signature = signature;
+ this._result = result;
+ this._exception = null;
+ }
+
+ /**
+ * Returns the exception raised by this notification referred operation.
+ *
+ * @return the exception raised by this notification referred operation.
+ */
+ public Exception getException()
+ {
+ return _exception;
+ }
+
+ /**
+ * Returns the exception raised by this notification referred operation.
+ *
+ * @return the exception raised by this notification referred operation.
+ */
+ public InvocationResult getResult()
+ {
+ return _result;
+ }
+
+ /**
+ * Returns the operation name.
+ *
+ * @return the operation name.
+ */
+ public String getOperationName()
+ {
+ return _operationName;
+ }
+
+ /**
+ * Returns the parameters used in method invocation.
+ *
+ * @return the parameters used in method invocation.
+ */
+ public Object [] getParameters()
+ {
+ return _parameters;
+ }
+
+ /**
+ * Returns the signature of the invoked operation.
+ *
+ * @return the signature of the invoked operation.
+ */
+ public String [] getSignature()
+ {
+ return _signature;
+ }
+
+ /**
+ * Returns a string representation of this notification.
+ *
+ * @return a string representation of this notification.
+ */
+ @Override
+ public String toString()
+ {
+ return new StringBuilder()
+ .append(getType())
+ .append(':')
+ .append(_operationName)
+ .toString();
+ }
+}
\ No newline at end of file
Added: qpid/trunk/qpid/java/management/client/src/main/java/org/apache/qpid/management/servlet/ConnectQManToBroker.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/management/client/src/main/java/org/apache/qpid/management/servlet/ConnectQManToBroker.java?rev=734622&view=auto
==============================================================================
--- qpid/trunk/qpid/java/management/client/src/main/java/org/apache/qpid/management/servlet/ConnectQManToBroker.java (added)
+++ qpid/trunk/qpid/java/management/client/src/main/java/org/apache/qpid/management/servlet/ConnectQManToBroker.java Wed Jan 14 23:26:19 2009
@@ -0,0 +1,77 @@
+/*
+ *
+ * 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.servlet;
+
+import java.util.UUID;
+import java.util.Map.Entry;
+
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.apache.muse.core.platform.mini.MiniServlet;
+import org.apache.qpid.management.Messages;
+import org.apache.qpid.management.Names;
+import org.apache.qpid.management.configuration.BrokerConnectionData;
+import org.apache.qpid.management.configuration.Configuration;
+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
+ * to estabilish the connection(s) to the requested broker(s).
+ *
+ * @author Andrea Gazzarini
+ */
+public class ConnectQManToBroker extends MiniServlet
+{
+ private static final long serialVersionUID = 6149614872902682208L;
+ 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.
+ */
+ public void init()
+ {
+ Configuration configuration = Configuration.getInstance();
+ if (configuration.hasOneOrMoreBrokersDefined())
+ {
+ QMan qman = (QMan)getServletContext().getAttribute(Names.APPLICATION_NAME);
+
+ LOGGER.info(Messages.QMAN_000003_CREATING_MANAGEMENT_CLIENTS);
+ for (Entry<UUID, BrokerConnectionData> entry : Configuration.getInstance().getConnectionInfos())
+ {
+ qman.createManagementClient(entry.getKey(), entry.getValue());
+ }
+ } else {
+ LOGGER.info(Messages.QMAN_000022_NO_BROKER_CONFIGURED);
+ }
+ }
+
+ @Override
+ public void service(HttpServletRequest request, HttpServletResponse response) throws ServletException
+ {
+ throw new ServletException();
+ }
+}
\ No newline at end of file
Added: qpid/trunk/qpid/java/management/client/src/main/java/org/apache/qpid/management/servlet/QManLifeCycleManager.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/management/client/src/main/java/org/apache/qpid/management/servlet/QManLifeCycleManager.java?rev=734622&view=auto
==============================================================================
--- qpid/trunk/qpid/java/management/client/src/main/java/org/apache/qpid/management/servlet/QManLifeCycleManager.java (added)
+++ qpid/trunk/qpid/java/management/client/src/main/java/org/apache/qpid/management/servlet/QManLifeCycleManager.java Wed Jan 14 23:26:19 2009
@@ -0,0 +1,72 @@
+/*
+ *
+ * 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.servlet;
+
+import javax.servlet.ServletContext;
+import javax.servlet.ServletContextEvent;
+import javax.servlet.ServletContextListener;
+
+import org.apache.qpid.management.Names;
+import org.apache.qpid.management.domain.services.QMan;
+import org.apache.qpid.management.domain.services.StartupFailureException;
+
+/**
+ * QMan lifecycle management.
+ *
+ * @author Andrea Gazzarini
+ */
+public class QManLifeCycleManager implements ServletContextListener
+{
+ /**
+ * Stops QMan.
+ *
+ * @param event the application context event.
+ */
+ public void contextDestroyed(ServletContextEvent event)
+ {
+ ServletContext context = event.getServletContext();
+
+ QMan qman = (QMan) context.getAttribute(Names.APPLICATION_NAME);
+ qman.stop();
+
+ context.setAttribute(Names.APPLICATION_NAME, qman);
+ }
+
+ /**
+ * Starts QMan.
+ *
+ * @param event the application context event.
+ */
+ public void contextInitialized(ServletContextEvent event)
+ {
+ try
+ {
+ QMan qman = new QMan();
+ qman.start();
+
+ event.getServletContext().setAttribute(Names.APPLICATION_NAME, qman);
+ } catch (StartupFailureException exception)
+ {
+ // TODO : LOG ERROR.
+ exception.printStackTrace();
+ }
+ }
+}
\ No newline at end of file
Added: qpid/trunk/qpid/java/management/client/src/main/java/org/apache/qpid/management/servlet/WSDMAdapter.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/management/client/src/main/java/org/apache/qpid/management/servlet/WSDMAdapter.java?rev=734622&view=auto
==============================================================================
--- qpid/trunk/qpid/java/management/client/src/main/java/org/apache/qpid/management/servlet/WSDMAdapter.java (added)
+++ qpid/trunk/qpid/java/management/client/src/main/java/org/apache/qpid/management/servlet/WSDMAdapter.java Wed Jan 14 23:26:19 2009
@@ -0,0 +1,114 @@
+/*
+ *
+ * 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.servlet;
+
+import java.io.IOException;
+import java.io.PrintWriter;
+
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.apache.muse.util.xml.XmlUtils;
+import org.apache.qpid.management.Messages;
+import org.apache.qpid.management.wsdm.muse.engine.WSDMAdapterIsolationLayer;
+import org.apache.qpid.qman.debug.XmlDebugger;
+import org.apache.qpid.transport.util.Logger;
+import org.w3c.dom.Document;
+import org.xml.sax.SAXException;
+
+/**
+ * QMan Adapter facade.
+ * This is the main requestor entry point of the WS-DM connector / adapter.
+ * All WSDM requests will be handled (at higher level) by this servlet.
+ *
+ * @author Andrea Gazzarini
+ */
+public class WSDMAdapter extends HttpServlet
+{
+ private static final long serialVersionUID = 6149614872902682208L;
+ private final static Logger LOGGER = Logger.get(WSDMAdapter.class);
+ private WSDMAdapterIsolationLayer _isolationLayer;
+
+ @Override
+ public void init() throws ServletException {
+ _isolationLayer = new WSDMAdapterIsolationLayer(getServletContext());
+ _isolationLayer.initialize();
+ }
+
+ /**
+ * Accepts http requests containing a soap envelope (request) and therefore
+ * acts as the main entry point of whole WS process.
+ *
+ * @param request the http request.
+ * @param response the http response.
+ * @throws ServletException in case of application failure.
+ * @throws IOException in case of generic I/O failure.
+ */
+ @Override
+ protected void doPost(HttpServletRequest request,HttpServletResponse response) throws ServletException,IOException
+ {
+ PrintWriter writer = response.getWriter();
+
+ Document soapEnvelopeRequest = null;
+ String soapEnvelopeResposeAsString = null;
+
+ try
+ {
+ soapEnvelopeRequest = XmlUtils.createDocument(request.getInputStream());
+
+ Document soapEnvelopeResponse = _isolationLayer.handleRequest(soapEnvelopeRequest);
+ soapEnvelopeResposeAsString = XmlUtils.toString(soapEnvelopeResponse,false,true);
+
+ response.setContentType("text/xml");
+
+ writer.write(soapEnvelopeResposeAsString);
+ } catch (SAXException exception)
+ {
+ LOGGER.error(
+ exception,
+ Messages.QMAN_100019_REQ_OR_RES_MALFORMED);
+ throw new ServletException(exception);
+ } finally {
+ writer.flush();
+
+ XmlDebugger.debug(soapEnvelopeRequest);
+ XmlDebugger.debug(soapEnvelopeResposeAsString);
+ }
+ }
+
+ /**
+ * Stops QMan Adapter.
+ */
+ public void destroy()
+ {
+ try
+ {
+ _isolationLayer.shutdown();
+ } catch (Exception exception)
+ {
+ LOGGER.error(
+ exception,
+ Messages.QMAN_100022_ISOLATION_LAYER_SHUTDOWN_FAILURE);
+ }
+ }
+}
\ No newline at end of file
Added: qpid/trunk/qpid/java/management/client/src/main/java/org/apache/qpid/management/wsdm/capabilities/ArtifactsNotAvailableException.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/management/client/src/main/java/org/apache/qpid/management/wsdm/capabilities/ArtifactsNotAvailableException.java?rev=734622&view=auto
==============================================================================
--- qpid/trunk/qpid/java/management/client/src/main/java/org/apache/qpid/management/wsdm/capabilities/ArtifactsNotAvailableException.java (added)
+++ qpid/trunk/qpid/java/management/client/src/main/java/org/apache/qpid/management/wsdm/capabilities/ArtifactsNotAvailableException.java Wed Jan 14 23:26:19 2009
@@ -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 javax.management.ObjectName;
+
+/**
+ * Thrown when the artifacts related to a specific resource cannot be built.
+ *
+ * @author Andrea Gazzarini
+ */
+public class ArtifactsNotAvailableException extends Exception
+{
+ private static final long serialVersionUID = -9010460152421791926L;
+
+ private final WsArtifacts _artifacts;
+ private final ObjectName _objectName;
+
+ public ArtifactsNotAvailableException(WsArtifacts artifacts,Throwable cause, ObjectName objectName)
+ {
+ super(cause);
+ this._artifacts = artifacts;
+ this._objectName = objectName;
+ }
+
+ /**
+ * Returns a message that indicates which artifacts were built.
+ *
+ * @return a message that indicates which artifacts were built.
+ */
+ @Override
+ public String getMessage()
+ {
+ StringBuilder builder = new StringBuilder();
+ if (_artifacts == null)
+ {
+ return super.getMessage();
+ }
+
+ builder.append("Built artifacts for ")
+ .append(_objectName)
+ .append(" : ")
+ .append( (_artifacts.getWsdl() != null) ? "WSDL," : "")
+ .append( (_artifacts.getCapabilityClass() != null) ? "Capability Class," : "")
+ .append( (_artifacts.getResourceMetadataDescriptor() != null) ? "Resource Metadata Descriptor," : "");
+ return builder.toString();
+ }
+}
Added: qpid/trunk/qpid/java/management/client/src/main/java/org/apache/qpid/management/wsdm/capabilities/BuilderException.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/management/client/src/main/java/org/apache/qpid/management/wsdm/capabilities/BuilderException.java?rev=734622&view=auto
==============================================================================
--- qpid/trunk/qpid/java/management/client/src/main/java/org/apache/qpid/management/wsdm/capabilities/BuilderException.java (added)
+++ qpid/trunk/qpid/java/management/client/src/main/java/org/apache/qpid/management/wsdm/capabilities/BuilderException.java Wed Jan 14 23:26:19 2009
@@ -0,0 +1,41 @@
+/*
+ *
+ * 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;
+
+/**
+ * Thrown when a WSRF artifact (either WSDL or capability) cannot be built.
+ *
+ * @author Andrea Gazzarini
+ */
+public class BuilderException extends Exception
+{
+ private static final long serialVersionUID = -8267818907567906262L;
+
+ /**
+ * Builds a new exception with the given cause.
+ *
+ * @param cause the exception cause.
+ */
+ public BuilderException(Exception cause)
+ {
+ super(cause);
+ }
+}
\ No newline at end of file
Added: qpid/trunk/qpid/java/management/client/src/main/java/org/apache/qpid/management/wsdm/capabilities/IArtifactBuilder.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/management/client/src/main/java/org/apache/qpid/management/wsdm/capabilities/IArtifactBuilder.java?rev=734622&view=auto
==============================================================================
--- qpid/trunk/qpid/java/management/client/src/main/java/org/apache/qpid/management/wsdm/capabilities/IArtifactBuilder.java (added)
+++ qpid/trunk/qpid/java/management/client/src/main/java/org/apache/qpid/management/wsdm/capabilities/IArtifactBuilder.java Wed Jan 14 23:26:19 2009
@@ -0,0 +1,82 @@
+/*
+ *
+ * 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 javax.management.MBeanAttributeInfo;
+import javax.management.MBeanOperationInfo;
+import javax.management.ObjectName;
+
+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.
+ *
+ * @author Andrea Gazzarini
+ */
+public interface IArtifactBuilder
+{
+ /**
+ * The build process begin and the given parameter is the object name of the
+ * corresponding JMX entity.
+ *
+ * @throws BuilderException when the initialization fails.
+ */
+ void begin(ObjectName objectName) throws BuilderException;
+
+ /**
+ * Processes an attribute (its metadata) of the current MBean.
+ *
+ * @param attributeMetadata the attribute metadata.
+ * @throws BuilderException when the builder cannot parse the given metadata.
+ */
+ void onAttribute(MBeanAttributeInfo attributeMetadata) throws BuilderException;
+
+ /**
+ * Processes an operation (its metadata) of the current MBean.
+ *
+ * @param operationMetadata the operation metadata.
+ * @throws BuilderException when the builder cannot parse the given metadata.
+ */
+ void onOperation(MBeanOperationInfo operationMetadata) throws BuilderException;
+
+ /**
+ * Ends of the attributes section.
+ *
+ * @throws BuilderException when the builder encounter a problem during this phase..
+ */
+ void endAttributes() throws BuilderException;
+
+ /**
+ * Ends of the operations section.
+ *
+ * @throws BuilderException when the builder encounter a problem during this phase..
+ */
+ void endOperations() throws BuilderException;
+
+ /**
+ * Injects the adapter enviroment on this builder.
+ *
+ * @param environment the adapter environment.
+ */
+ void setEnvironment(Environment environment);
+}
\ No newline at end of file
Added: qpid/trunk/qpid/java/management/client/src/main/java/org/apache/qpid/management/wsdm/capabilities/MBeanCapability.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/management/client/src/main/java/org/apache/qpid/management/wsdm/capabilities/MBeanCapability.java?rev=734622&view=auto
==============================================================================
--- qpid/trunk/qpid/java/management/client/src/main/java/org/apache/qpid/management/wsdm/capabilities/MBeanCapability.java (added)
+++ qpid/trunk/qpid/java/management/client/src/main/java/org/apache/qpid/management/wsdm/capabilities/MBeanCapability.java Wed Jan 14 23:26:19 2009
@@ -0,0 +1,244 @@
+/*
+ *
+ * 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 java.lang.management.ManagementFactory;
+import java.lang.reflect.Array;
+
+import javax.management.Attribute;
+import javax.management.AttributeNotFoundException;
+import javax.management.InstanceNotFoundException;
+import javax.management.MBeanServer;
+import javax.management.ObjectName;
+import javax.xml.namespace.QName;
+
+import org.apache.muse.core.serializer.Serializer;
+import org.apache.muse.core.serializer.SerializerRegistry;
+import org.apache.muse.util.ReflectUtils;
+import org.apache.muse.util.xml.XmlUtils;
+import org.apache.muse.ws.addressing.soap.SoapFault;
+import org.apache.muse.ws.resource.basefaults.BaseFault;
+import org.apache.muse.ws.resource.basefaults.WsbfUtils;
+import org.apache.muse.ws.resource.impl.AbstractWsResourceCapability;
+import org.apache.muse.ws.resource.properties.ResourcePropertyCollection;
+import org.apache.qpid.management.wsdm.common.EntityInstanceNotFoundFault;
+import org.apache.qpid.management.wsdm.common.NoSuchAttributeFault;
+import org.apache.qpid.management.wsdm.common.QManFault;
+import org.apache.qpid.management.wsdm.muse.serializer.ByteArraySerializer;
+import org.w3c.dom.Element;
+
+/**
+ * Abstract capability used for centralize common behaviour of the QMan
+ * resource(s) related capabilities.
+ *
+ * @author Andrea Gazzarini
+ */
+public abstract class MBeanCapability extends AbstractWsResourceCapability
+{
+ private static final Element[] _NO_VALUES = new Element[0];
+
+ protected final MBeanServer _mxServer;
+ protected ObjectName _objectName;
+
+ /**
+ * Builds a new capability related to the given object name.
+ *
+ * @param objectName the name of the target object of this capability.
+ */
+ public MBeanCapability()
+ {
+ _mxServer = ManagementFactory.getPlatformMBeanServer();
+ }
+
+ /**
+ * Injects on this capability the object name of the target mbean.
+ *
+ * @param objectName the object name of the target mbean.
+ */
+ public void setResourceObjectName(ObjectName objectName)
+ {
+ this._objectName = objectName;
+ }
+
+ /**
+ * Returns the attribute value of a QMan managed object instance.
+ *
+ * @param attributeName the name of the attribute to be requested.
+ * @return the value for the requested attribute.
+ * @throws NoSuchAttributeFault when the requested attribute cannot be found
+ * on the given entity instance.
+ * @throws EntityInstanceNotFoundFault when the requested entity instance cannot
+ * be found.
+ * @throws QManFault in case of internal system failure.
+ */
+ protected Object getAttribute(String attributeName) throws QManFault
+ {
+ try
+ {
+ return _mxServer.getAttribute(_objectName, attributeName);
+ } catch (AttributeNotFoundException exception)
+ {
+ throw new NoSuchAttributeFault(
+ getWsResource().getEndpointReference(),
+ _objectName,
+ attributeName);
+ } catch (InstanceNotFoundException exception)
+ {
+ throw new EntityInstanceNotFoundFault(
+ getWsResource().getEndpointReference(),
+ _objectName);
+ } catch (Exception exception)
+ {
+ throw new QManFault(
+ getWsResource().getEndpointReference(),
+ exception);
+ }
+ }
+
+ /**
+ * Sets the value for the given attribute on this MBean (proxy).
+ *
+ * @param objectName
+ * the object name of the target instance (excluding the domain
+ * name).
+ * @param attributeName
+ * the name of the attribute to be requested.
+ * @param value
+ * the value for the requested attribute.
+ * @throws NoSuchAttributeFault
+ * when the requested attribute cannot be found on the given
+ * entity instance.
+ * @throws EntityInstanceNotFoundFault
+ * when the requested entity instance cannot be found.
+ * @throws QManFault
+ * in case of internal system failure.
+ */
+ protected void setAttribute(String attributeName, Object value) throws QManFault
+ {
+ try
+ {
+ _mxServer.setAttribute(_objectName, new Attribute(attributeName,
+ value));
+ } catch (AttributeNotFoundException exception)
+ {
+ throw new NoSuchAttributeFault(
+ getWsResource().getEndpointReference(),
+ _objectName,
+ attributeName);
+ } catch (InstanceNotFoundException exception)
+ {
+ throw new EntityInstanceNotFoundFault(
+ getWsResource().getEndpointReference(),
+ _objectName);
+ } catch (Exception exception)
+ {
+ throw new QManFault(
+ getWsResource().getEndpointReference(),
+ exception);
+ }
+ }
+
+ /**
+ *
+ * @param name
+ * @param value
+ * TODO TODO TODO!!! Vedi che poi fà co 'sto metodo che è un pò una monnezza!!!
+ * @return The XML representation of the resource property value(s).
+ *
+ */
+ @SuppressWarnings("unchecked")
+ protected Element[] getPropertyElements(QName name, Object value)
+ throws BaseFault {
+ //
+ // in this case, we have to determine if there IS a property
+ // and it's null, or there is no property
+ //
+ if (value == null) {
+ ResourcePropertyCollection props = getWsResource().getPropertyCollection();
+
+ //
+ // property is nillable - we say it exists. not 100% accurate,
+ // but as close as we're going to get
+ //
+ if (props.getSchema().isNillable(name))
+ return new Element[] { XmlUtils.createElement(name) };
+
+ //
+ // not nillable - must not exist
+ //
+ return _NO_VALUES;
+ }
+
+ //
+ // in all other cases, we determine the type of the property
+ // values and use that to serialize into XML
+ //
+ Object valuesArray = null;
+ Class type = null;
+
+ if (value.getClass().isArray()) {
+ // TODO : 'sta porcheria non va bene. L'ho inserita perché se il
+ // value è un array non vivne
+ // utilizzato il mio ByteArraySerializer ma array serializer che fa
+ // il serial degli elementi uno a uno : quindi
+ // cercava un serializer per "byte"
+ if (value.getClass() == byte[].class) {
+ Serializer serializer = new ByteArraySerializer();
+ try {
+ return new Element[] { serializer.toXML(value, name) };
+ } catch (SoapFault e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ }
+
+ valuesArray = value;
+ type = ReflectUtils.getClassFromArrayClass(value.getClass());
+ }
+
+ else {
+ valuesArray = new Object[] { value };
+ type = value.getClass();
+ }
+
+ int length = Array.getLength(valuesArray);
+ Element[] properties = new Element[length];
+
+ SerializerRegistry registry = SerializerRegistry.getInstance();
+ Serializer ser = registry.getSerializer(type);
+
+ for (int n = 0; n < length; ++n)
+ properties[n] = serializeValue(ser, Array.get(valuesArray, n), name);
+
+ return properties;
+ }
+
+ private Element serializeValue(Serializer ser, Object value, QName name) throws BaseFault
+ {
+ try {
+ return ser.toXML(value, name);
+ }
+
+ catch (SoapFault error) {
+ throw WsbfUtils.convertToFault(error);
+ }
+ }
+}
\ No newline at end of file
Added: qpid/trunk/qpid/java/management/client/src/main/java/org/apache/qpid/management/wsdm/capabilities/MBeanCapabilityBuilder.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/management/client/src/main/java/org/apache/qpid/management/wsdm/capabilities/MBeanCapabilityBuilder.java?rev=734622&view=auto
==============================================================================
--- qpid/trunk/qpid/java/management/client/src/main/java/org/apache/qpid/management/wsdm/capabilities/MBeanCapabilityBuilder.java (added)
+++ qpid/trunk/qpid/java/management/client/src/main/java/org/apache/qpid/management/wsdm/capabilities/MBeanCapabilityBuilder.java Wed Jan 14 23:26:19 2009
@@ -0,0 +1,181 @@
+/*
+ *
+ * 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 javassist.ClassClassPath;
+import javassist.ClassPool;
+import javassist.CtClass;
+import javassist.CtField;
+import javassist.CtMethod;
+import javassist.CtNewMethod;
+
+import javax.management.MBeanAttributeInfo;
+import javax.management.MBeanOperationInfo;
+import javax.management.ObjectName;
+import javax.xml.namespace.QName;
+
+import org.apache.muse.core.Environment;
+import org.apache.qpid.management.Names;
+import org.apache.qpid.management.wsdm.common.QManFault;
+
+public class MBeanCapabilityBuilder implements IArtifactBuilder{
+
+ private StringBuilder _properties = new StringBuilder("private static final QName[] PROPERTIES = new QName[]{ ");
+ private CtClass _capabilityClassDefinition;
+ private Class<MBeanCapability> _capabilityClass;
+
+ public void onAttribute(MBeanAttributeInfo attribute) throws BuilderException
+ {
+ String plainName = attribute.getName();
+
+ _properties.append("new QName(Names.NAMESPACE_URI, \"")
+ .append(attribute.getName())
+ .append("\", Names.PREFIX),");
+
+ String type = attribute.getType();
+ type = (type.startsWith("[B")) ? " byte[] " : type;
+
+ StringBuilder buffer = new StringBuilder()
+ .append("private ")
+ .append(type)
+ .append(' ')
+ .append(attribute.getName())
+ .append(';');
+ try
+ {
+ CtField field= CtField.make(buffer.toString(),_capabilityClassDefinition);
+ _capabilityClassDefinition.addField(field);
+
+ char firstLetter = Character.toUpperCase(plainName.charAt(0));
+ String nameForAccessors = firstLetter + plainName.substring(1);
+
+ if (attribute.isReadable())
+ {
+ buffer = new StringBuilder()
+ .append("public ")
+ .append(type)
+ .append(' ')
+ .append("get")
+ .append(nameForAccessors)
+ .append("() throws QManFault { return (").append(type).append(") getAttribute(\"")
+ .append(plainName)
+ .append("\"); }");
+
+ CtMethod getter = CtNewMethod.make(buffer.toString(),_capabilityClassDefinition);
+ _capabilityClassDefinition.addMethod(getter);
+ }
+
+ if (attribute.isWritable())
+ {
+ buffer = new StringBuilder()
+ .append("public void ")
+ .append("set")
+ .append(nameForAccessors)
+ .append("(")
+ .append(type)
+ .append(" newValue) throws QManFault {")
+ .append(" setAttribute(\"")
+ .append(plainName)
+ .append("\", newValue); }");
+
+ CtMethod setter = CtNewMethod.make(buffer.toString(),_capabilityClassDefinition);
+ _capabilityClassDefinition.addMethod(setter);
+ }
+ } catch(Exception exception)
+ {
+ System.err.println(buffer);
+ throw new BuilderException(exception);
+ }
+ }
+
+ /**
+ * First callback : this method is called at the begin of the director process.
+ * It contains builder initialization code.
+ *
+ * @throws BuilderException when the initialization fails.
+ */
+ public void begin(ObjectName objectName) throws BuilderException
+ {
+ String className = objectName.getKeyProperty(Names.CLASS);
+ ClassPool pool = ClassPool.getDefault();
+ pool.insertClassPath(new ClassClassPath(MBeanCapabilityBuilder.class));
+ pool.importPackage(QName.class.getPackage().getName());
+ pool.importPackage(ObjectName.class.getPackage().getName());
+ pool.importPackage(QManFault.class.getPackage().getName());
+ pool.importPackage(Names.class.getPackage().getName());
+ _capabilityClassDefinition = pool.makeClass("org.apache.qpid.management.wsdm.capabilities."+className);
+ try
+ {
+ _capabilityClassDefinition.setSuperclass(pool.get(MBeanCapability.class.getName()));
+ } catch(Exception exception)
+ {
+ throw new BuilderException(exception);
+ }
+ }
+
+ public void onOperation(MBeanOperationInfo operation)
+ {
+ // TODO
+ }
+
+ public Class<MBeanCapability> getCapabilityClass()
+ {
+ return _capabilityClass;
+ }
+
+ public void endAttributes() throws BuilderException
+ {
+ try
+ {
+ _properties.deleteCharAt(_properties.length()-1);
+ _properties.append("};");
+
+ CtField properties = CtField.make(_properties.toString(), _capabilityClassDefinition);
+ _capabilityClassDefinition.addField(properties);
+
+ CtMethod getPropertyNames = CtNewMethod.make(
+ "public QName[] getPropertyNames() { return PROPERTIES;}",
+ _capabilityClassDefinition);
+ _capabilityClassDefinition.addMethod(getPropertyNames);
+ } catch(Exception exception)
+ {
+ System.err.println(_properties);
+ throw new BuilderException(exception);
+ }
+ }
+
+ @SuppressWarnings("unchecked")
+ public void endOperations() throws BuilderException
+ {
+ try
+ {
+ _capabilityClass = _capabilityClassDefinition.toClass();
+ } catch (Exception exception)
+ {
+ throw new BuilderException(exception);
+ }
+ }
+
+ public void setEnvironment(Environment environment)
+ {
+ // N.A.
+ }
+}
\ No newline at end of file
Added: qpid/trunk/qpid/java/management/client/src/main/java/org/apache/qpid/management/wsdm/capabilities/QManAdapterCapability.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/management/client/src/main/java/org/apache/qpid/management/wsdm/capabilities/QManAdapterCapability.java?rev=734622&view=auto
==============================================================================
--- qpid/trunk/qpid/java/management/client/src/main/java/org/apache/qpid/management/wsdm/capabilities/QManAdapterCapability.java (added)
+++ qpid/trunk/qpid/java/management/client/src/main/java/org/apache/qpid/management/wsdm/capabilities/QManAdapterCapability.java Wed Jan 14 23:26:19 2009
@@ -0,0 +1,156 @@
+/*
+ *
+ * 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 java.lang.management.ManagementFactory;
+
+import javax.management.InstanceNotFoundException;
+import javax.management.MBeanServer;
+import javax.management.Notification;
+import javax.management.NotificationFilterSupport;
+import javax.management.NotificationListener;
+import javax.management.ObjectName;
+
+import org.apache.muse.core.AbstractCapability;
+import org.apache.muse.core.Resource;
+import org.apache.muse.core.ResourceManager;
+import org.apache.muse.core.serializer.SerializerRegistry;
+import org.apache.muse.ws.addressing.soap.SoapFault;
+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.serializer.ByteArraySerializer;
+import org.apache.qpid.transport.util.Logger;
+
+/**
+ * MBean Server capabilty interface implementor.
+ * Providers all the operations of the MBeanServer interface using the platform MBeanServer.
+*/
+public class QManAdapterCapability extends AbstractCapability
+{
+ private MBeanServer _mxServer;
+ private final static Logger LOGGER = Logger.get(QManAdapterCapability.class);
+
+ private WsArtifactsFactory _artifactsFactory;
+
+ private final NotificationListener listenerForNewInstances = new NotificationListener()
+ {
+ public void handleNotification(Notification notification, Object data)
+ {
+ EntityLifecycleNotification lifecycleNotification = (EntityLifecycleNotification) notification;
+ ObjectName eventSourceName = lifecycleNotification.getObjectName();
+ ThreadSessionManager.getInstance().getSession().setObjectName(eventSourceName);
+
+ try
+ {
+ LOGGER.debug(Messages.QMAN_200039_DEBUG_JMX_NOTIFICATION, notification);
+
+ ResourceManager resourceManager = getResource().getResourceManager();
+ Resource resource = resourceManager.createResource(Names.QMAN_RESOURCE_NAME);
+
+ WsArtifacts artifacts = _artifactsFactory.getArtifactsFor(resource,eventSourceName);
+ MBeanCapability capability = _artifactsFactory.createCapability(
+ artifacts.getCapabilityClass(),
+ eventSourceName);
+
+
+ ThreadSessionManager.getInstance().getSession().setWsdlDocument(artifacts.getWsdl());
+ ThreadSessionManager.getInstance().getSession().setResourceMetadataDescriptor(artifacts.getResourceMetadataDescriptor());
+
+// ResourceManager resourceManager = getResource().getResourceManager();
+//
+// Resource resource = resourceManager.createResource(Names.QMAN_RESOURCE_NAME);
+// resource.setWsdlPortType(Names.QMAN_RESOURCE_PORT_TYPE_NAME);
+ resource.addCapability(capability);
+ resource.initialize();
+ resourceManager.addResource(resource.getEndpointReference(), resource);
+ } catch (ArtifactsNotAvailableException exception)
+ {
+ LOGGER.error(exception,Messages.QMAN_100023_BUILD_WS_ARTIFACTS_FAILURE);
+ } catch (IllegalAccessException exception)
+ {
+ LOGGER.error(exception,Messages.QMAN_100024_CAPABILITY_INSTANTIATION_FAILURE,eventSourceName);
+ } catch (InstantiationException exception)
+ {
+ LOGGER.error(exception,Messages.QMAN_100024_CAPABILITY_INSTANTIATION_FAILURE,eventSourceName);
+ } catch (SoapFault exception)
+ {
+ LOGGER.error(exception,Messages.QMAN_100025_WSRF_FAILURE,eventSourceName);
+ } catch (Exception exception)
+ {
+ LOGGER.error(exception,Messages.QMAN_100025_WSRF_FAILURE,eventSourceName);
+ }
+
+ }
+ };
+
+ private final NotificationListener listenerForRemovedInstances = new NotificationListener()
+ {
+ public void handleNotification(Notification notification, Object data)
+ {
+ LOGGER.warn("TBD : Notification Listener for removed instances has not yet implemeted!");
+ }
+ };
+
+ @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());
+
+ try
+ {
+ _mxServer = ManagementFactory.getPlatformMBeanServer();
+ _artifactsFactory = new WsArtifactsFactory(getEnvironment(),_mxServer);
+
+ NotificationFilterSupport filterForNewInstances = new NotificationFilterSupport();
+ filterForNewInstances.enableType(EntityLifecycleNotification.INSTANCE_ADDED);
+
+ NotificationFilterSupport filterForRemovedInstances = new NotificationFilterSupport();
+ filterForNewInstances.enableType(EntityLifecycleNotification.INSTANCE_REMOVED);
+
+ _mxServer.addNotificationListener(Names.QMAN_OBJECT_NAME, listenerForNewInstances, filterForNewInstances, null);
+ _mxServer.addNotificationListener(Names.QMAN_OBJECT_NAME, listenerForRemovedInstances, filterForRemovedInstances, null);
+
+ try {
+ _mxServer.addNotificationListener(new ObjectName("A:A=1"), listenerForNewInstances, filterForNewInstances, null);
+ } catch (Exception exception) {
+ LOGGER.info(Messages.QMAN_000028_TEST_MODULE_NOT_FOUND);
+ }
+
+ } catch(InstanceNotFoundException exception)
+ {
+ // throw new QManNotRunningFault
+ throw new SoapFault(exception);
+ }
+ }
+
+ @SuppressWarnings("unchecked")
+ public void connect(String host, int port, String username, String password, String virtualHost) throws SoapFault
+ {
+
+ }
+}
\ No newline at end of file
Added: qpid/trunk/qpid/java/management/client/src/main/java/org/apache/qpid/management/wsdm/capabilities/QManMetadataExchangeCapability.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/management/client/src/main/java/org/apache/qpid/management/wsdm/capabilities/QManMetadataExchangeCapability.java?rev=734622&view=auto
==============================================================================
--- qpid/trunk/qpid/java/management/client/src/main/java/org/apache/qpid/management/wsdm/capabilities/QManMetadataExchangeCapability.java (added)
+++ qpid/trunk/qpid/java/management/client/src/main/java/org/apache/qpid/management/wsdm/capabilities/QManMetadataExchangeCapability.java Wed Jan 14 23:26:19 2009
@@ -0,0 +1,58 @@
+/*
+ *
+ * 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.util.xml.XmlUtils;
+import org.apache.muse.ws.resource.metadata.ext.WsrfMetadataExchange;
+import org.apache.muse.ws.wsdl.WsdlUtils;
+import org.apache.qpid.management.wsdm.muse.resources.QManWsResource;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+
+/**
+ * QMan resource metadata exchange.
+ * We cannot resuse the preexisting classes directly because the wsdl of the service instance
+ * is retrieved using a file path.
+ * Since the owner resource (QManWsResource) is dynamic (I mean, its interface is dynamic), the corresponding
+ * WSDL cannot defined at compile time but needs some changes when the resource is created.
+ * As part of that, the WSDL template found under wsdl folder is modified with the additional properties of the given
+ * resource. The metadata exchange capability must include those properties too.
+ *
+ * Note that this capability is appliable only to a QManWsResource.
+ *
+ * @author Andrea Gazzarini
+ */
+public class QManMetadataExchangeCapability extends WsrfMetadataExchange
+{
+ @Override
+ protected Element getWSDL()
+ {
+ QManWsResource resource = (QManWsResource) getResource();
+
+ Document wsdlDoc = resource.getWsdl();
+ Element wsdl = XmlUtils.getFirstElement(wsdlDoc);
+
+ WsdlUtils.removeWsdlReferences(wsdl);
+ WsdlUtils.removeSchemaReferences(wsdl);
+
+ return wsdl;
+ }
+}
\ No newline at end of file
Added: qpid/trunk/qpid/java/management/client/src/main/java/org/apache/qpid/management/wsdm/capabilities/RmdBuilder.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/management/client/src/main/java/org/apache/qpid/management/wsdm/capabilities/RmdBuilder.java?rev=734622&view=auto
==============================================================================
--- qpid/trunk/qpid/java/management/client/src/main/java/org/apache/qpid/management/wsdm/capabilities/RmdBuilder.java (added)
+++ qpid/trunk/qpid/java/management/client/src/main/java/org/apache/qpid/management/wsdm/capabilities/RmdBuilder.java Wed Jan 14 23:26:19 2009
@@ -0,0 +1,134 @@
+/*
+ *
+ * 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 java.util.ArrayList;
+import java.util.List;
+
+import javax.management.MBeanAttributeInfo;
+import javax.management.MBeanOperationInfo;
+import javax.management.ObjectName;
+
+import org.apache.muse.core.Environment;
+import org.apache.muse.util.xml.XmlUtils;
+import org.apache.muse.ws.resource.metadata.WsrmdConstants;
+import org.apache.qpid.management.Names;
+import org.apache.qpid.qman.debug.XmlDebugger;
+import org.w3c.dom.Element;
+
+/**
+ * Resource Metadata Descriptor Builder.
+ * It is used for build the metadata descriptor for properties of the
+ * incoming jmx object.
+ *
+ * @author Andrea Gazzarini
+ */
+class RmdBuilder implements IArtifactBuilder
+{
+ private List<Element> _metadataDescriptor = new ArrayList<Element>();
+
+ private ObjectName _objectName;
+
+ /**
+ * Nothing to be done here on this builder.
+ * Simply logs a message indicating the target object name.
+ *
+ * @param objectName the jmx name of the object that is going to be processed.
+ */
+ public void begin(ObjectName objectName)
+ {
+ this._objectName = objectName;
+ }
+
+ /**
+ * Nothing to be done here on this builder.
+ *
+ * @throws BuilderException never.
+ */
+ public void endAttributes()
+ {
+ // N.A. for this builder.
+ }
+
+ /**
+ * Nothing to be done here on this builder.
+ *
+ * @throws BuilderException never.
+ */
+ public void endOperations()
+ {
+ // N.A. for this builder.
+ }
+
+ /**
+ * Process a single attribute metadata.
+ * An attribute (that is, a property) represented by the corresponding incoming
+ * attribute metadata will generate an wsrmd:Property xml element with the constraints
+ * (initial values, static values, allowed values) contained on the metadata.
+ *
+ * @param attributeMetadata the attribute (jmx) metadata.
+ */
+ public void onAttribute(MBeanAttributeInfo attributeMetadata)
+ {
+ Element property = XmlUtils.createElement(WsrmdConstants.PROPERTY_QNAME);
+ property.setAttribute(Names.NAME_ATTRIBUTE, Names.PREFIX+":"+attributeMetadata.getName());
+ property.setAttribute(Names.MODIFIABILITY,
+ attributeMetadata.isWritable()
+ ? Names.READ_WRITE
+ : Names.READ_ONLY);
+ property.setAttribute(Names.MUTABILITY,Names.MUTABLE);
+
+ XmlDebugger.debug(_objectName, property);
+
+ _metadataDescriptor.add(property);
+ }
+
+ /**
+ * Nothing to be done here on this builder.
+ *
+ * @throws BuilderException never.
+ */
+ public void onOperation(MBeanOperationInfo operation)
+ {
+ // N.A. for this builder
+ }
+
+ /**
+ * Nothing to be done here on this builder.
+ *
+ * @throws BuilderException never.
+ */
+ public void setEnvironment(Environment environment)
+ {
+ // N.A. for this builder
+ }
+
+ /**
+ * Nothing to be done here on this builder.
+ *
+ * @throws BuilderException never.
+ */
+ public Element[] getResourceMetadataDescriptor()
+ {
+ Element [] properties = _metadataDescriptor.toArray(new Element[0]);
+ return properties;
+ }
+}
\ No newline at end of file