1   /**
2    * Copyright (c) 2000-2010 Liferay, Inc. All rights reserved.
3    *
4    * The contents of this file are subject to the terms of the Liferay Enterprise
5    * Subscription License ("License"). You may not use this file except in
6    * compliance with the License. You can obtain a copy of the License by
7    * contacting Liferay, Inc. See the License for the specific language governing
8    * permissions and limitations under the License, including but not limited to
9    * distribution rights of the Software.
10   *
11   *
12   *
13   */
14  
15  package com.liferay.portal.kernel.management.jmx;
16  
17  import com.liferay.portal.kernel.management.ManageActionException;
18  
19  import javax.management.Attribute;
20  import javax.management.MBeanServer;
21  import javax.management.ObjectName;
22  
23  /**
24   * <a href="SetAttributeAction.java.html"><b><i>View Source</i></b></a>
25   *
26   * @author Shuyang Zhou
27   */
28  public class SetAttributeAction extends BaseJMXManageAction<Void> {
29  
30      public SetAttributeAction(
31          ObjectName objectName, String name, Object value) {
32  
33          _objectName = objectName;
34          _name = name;
35          _value = value;
36      }
37  
38      public Void action() throws ManageActionException {
39          try {
40              MBeanServer mBeanServer = getMBeanServer();
41  
42              mBeanServer.setAttribute(_objectName, new Attribute(_name, _value));
43  
44              return null;
45          }
46          catch (Exception e) {
47              throw new ManageActionException(e);
48          }
49      }
50  
51      private String _name;
52      private ObjectName _objectName;
53      private Object _value;
54  
55  }