Save This Page
Home » openejb-3.1.2-src » org.apache » openejb » mgmt » [javadoc | source]
    1   /**
    2    * Licensed to the Apache Software Foundation (ASF) under one or more
    3    * contributor license agreements.  See the NOTICE file distributed with
    4    * this work for additional information regarding copyright ownership.
    5    * The ASF licenses this file to You under the Apache License, Version 2.0
    6    * (the "License"); you may not use this file except in compliance with
    7    * the License.  You may obtain a copy of the License at
    8    *
    9    * http://www.apache.org/licenses/LICENSE-2.0
   10    *
   11    * Unless required by applicable law or agreed to in writing, software
   12    * distributed under the License is distributed on an "AS IS" BASIS,
   13    * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   14    * See the License for the specific language governing permissions and
   15    * limitations under the License.
   16    */
   17   package org.apache.openejb.mgmt;
   18   
   19   import java.util.List;
   20   import java.util.Set;
   21   
   22   import javax.ejb.RemoteHome;
   23   import javax.ejb.Stateless;
   24   import javax.management.Attribute;
   25   import javax.management.AttributeList;
   26   import javax.management.AttributeNotFoundException;
   27   import javax.management.InstanceNotFoundException;
   28   import javax.management.IntrospectionException;
   29   import javax.management.InvalidAttributeValueException;
   30   import javax.management.MBeanException;
   31   import javax.management.MBeanInfo;
   32   import javax.management.MBeanServer;
   33   import javax.management.MBeanServerFactory;
   34   import javax.management.ObjectName;
   35   import javax.management.QueryExp;
   36   import javax.management.ReflectionException;
   37   import javax.management.j2ee.ListenerRegistration;
   38   import javax.management.j2ee.ManagementHome;
   39   
   40   @Stateless(name = "MEJB")
   41   @RemoteHome(ManagementHome.class)
   42   public class MEJBBean {
   43                                            
   44       MBeanServer mbeanServer;
   45   
   46       public MEJBBean() {
   47           List mbeanServers = MBeanServerFactory.findMBeanServer(null);
   48           if (mbeanServers.size() > 0) {
   49               mbeanServer = (MBeanServer) mbeanServers.get(0);
   50           } else {
   51               mbeanServer = MBeanServerFactory.createMBeanServer();
   52           }
   53       }
   54   
   55       public Object getAttribute(ObjectName objectName, String string) throws MBeanException, AttributeNotFoundException, InstanceNotFoundException, ReflectionException {
   56           return mbeanServer.getAttribute(objectName, string);
   57       }
   58   
   59       public AttributeList getAttributes(ObjectName objectName, String[] strings) throws InstanceNotFoundException, ReflectionException {
   60           return mbeanServer.getAttributes(objectName, strings);
   61       }
   62   
   63       public String getDefaultDomain() {
   64           return mbeanServer.getDefaultDomain();
   65       }
   66   
   67       public Integer getMBeanCount() {
   68           return mbeanServer.getMBeanCount();
   69       }
   70   
   71       public MBeanInfo getMBeanInfo(ObjectName objectName) throws IntrospectionException, InstanceNotFoundException, ReflectionException {
   72           return mbeanServer.getMBeanInfo(objectName);
   73       }
   74   
   75       public Object invoke(ObjectName objectName, String string, Object[] objects, String[] strings) throws InstanceNotFoundException, MBeanException, ReflectionException {
   76           return mbeanServer.invoke(objectName, string, objects, strings);
   77       }
   78   
   79       public boolean isRegistered(ObjectName objectName) {
   80           return mbeanServer.isRegistered(objectName);
   81       }
   82   
   83       public Set queryNames(ObjectName objectName, QueryExp queryExp) {
   84           return mbeanServer.queryNames(objectName, queryExp);
   85       }
   86   
   87       public void setAttribute(ObjectName objectName, Attribute attribute) throws InstanceNotFoundException, AttributeNotFoundException, InvalidAttributeValueException, MBeanException, ReflectionException {
   88           mbeanServer.setAttribute(objectName, attribute);
   89       }
   90   
   91       public AttributeList setAttributes(ObjectName objectName, AttributeList attributeList) throws InstanceNotFoundException, ReflectionException {
   92           return mbeanServer.setAttributes(objectName, attributeList);
   93       }
   94   
   95       public ListenerRegistration getListenerRegistry() {
   96           return null;
   97       }
   98   }

Save This Page
Home » openejb-3.1.2-src » org.apache » openejb » mgmt » [javadoc | source]