001 /*
002 *
003 * Licensed to the Apache Software Foundation (ASF) under one
004 * or more contributor license agreements. See the NOTICE file
005 * distributed with this work for additional information
006 * regarding copyright ownership. The ASF licenses this file
007 * to you under the Apache License, Version 2.0 (the
008 * "License"); you may not use this file except in compliance
009 * with the License. You may obtain a copy of the License at
010 *
011 * http://www.apache.org/licenses/LICENSE-2.0
012 *
013 * Unless required by applicable law or agreed to in writing,
014 * software distributed under the License is distributed on an
015 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
016 * KIND, either express or implied. See the License for the
017 * specific language governing permissions and limitations
018 * under the License.
019 *
020 */
021 package org.apache.qpid.management.jmx;
022
023 import javax.management.Notification;
024
025 import org.apache.qpid.management.Names;
026 import org.apache.qpid.management.domain.handler.impl.InvocationResult;
027 import org.apache.qpid.management.domain.services.SequenceNumberGenerator;
028
029 /**
030 * Q-Man JMX method invocation notification.
031 * This kind of notification is sent to interested listener by Q-Man when
032 * a method has been invoked (Method invocation request)
033 *
034 * @author Andrea Gazzarini
035 */
036 public class OperationHasBeenInvokedNotification extends Notification
037 {
038 private static final long serialVersionUID = -7755773156742412161L;
039 public static final String NOTIFICATION_TYPE = "org.apache.qpid.management.operation.invoked";
040
041 private final String _operationName;
042 private final Object [] _parameters;
043 private final String [] _signature;
044 private final Exception _exception;
045 private final InvocationResult _result;
046
047 /**
048 * Builds a new notification with the given parameters.
049 *
050 * @param type the notification type.
051 * @param operationName the operation name.
052 * @param params the operation parameters.
053 * @param signature the operation signature.
054 * @param exception the exception raised by the invocation.
055 */
056 public OperationHasBeenInvokedNotification(
057 String operationName,
058 Object[] parameters,
059 String [] signature,
060 Exception exception)
061 {
062 super(
063 NOTIFICATION_TYPE,
064 Names.APPLICATION_NAME,
065 SequenceNumberGenerator.getNextSequenceNumber());
066
067 this._operationName= operationName;
068 this._parameters = parameters;
069 this._signature = signature;
070 this._result = null;
071 this._exception = exception;
072 }
073
074 /**
075 * Builds a new notification with the given parameters.
076 *
077 * @param type the notification type.
078 * @param operationName the operation name.
079 * @param params the operation parameters.
080 * @param signature the operation signature.
081 * @param objectName the target mbean object name.
082 * @param result the invocation result.
083 */
084 public OperationHasBeenInvokedNotification(
085 String operationName,
086 Object[] parameters,
087 String [] signature,
088 InvocationResult result)
089 {
090 super(
091 NOTIFICATION_TYPE,
092 Names.APPLICATION_NAME,
093 SequenceNumberGenerator.getNextSequenceNumber());
094
095 this._operationName= operationName;
096 this._parameters = parameters;
097 this._signature = signature;
098 this._result = result;
099 this._exception = null;
100 }
101
102 /**
103 * Returns the exception raised by this notification
104 * referred operation.
105 *
106 * @return the exception raised by this notification referred operation.
107 */
108 public Exception getException()
109 {
110 return _exception;
111 }
112
113 /**
114 * Returns the exception raised by this notification
115 * referred operation.
116 *
117 * @return the exception raised by this notification referred operation.
118 */
119 public InvocationResult getResult()
120 {
121 return _result;
122 }
123
124 /**
125 * Returns the operation name.
126 *
127 * @return the operation name.
128 */
129 public String getOperationName()
130 {
131 return _operationName;
132 }
133
134 /**
135 * Returns the parameters used in method invocation.
136 *
137 * @return the parameters used in method invocation.
138 */
139 public Object [] getParameters()
140 {
141 return _parameters;
142 }
143
144 /**
145 * Returns the signature of the invoked operation.
146 *
147 * @return the signature of the invoked operation.
148 */
149 public String [] getSignature()
150 {
151 return _signature;
152 }
153
154 /**
155 * Returns a string representation of this notification.
156 *
157 * @return a string representation of this notification.
158 */
159 @Override
160 public String toString()
161 {
162 return new StringBuilder()
163 .append(getType())
164 .append(':')
165 .append(_operationName)
166 .toString();
167 }
168 }
|