Search in sources :

Example 96 with MBeanException

use of javax.management.MBeanException in project karaf by apache.

the class BundlesMBeanImpl method resolve.

public void resolve(String bundleId) throws MBeanException {
    try {
        List<Bundle> bundles = selectBundles(bundleId);
        getFrameworkWiring().resolveBundles(bundles);
    } catch (Exception e) {
        throw new MBeanException(null, e.toString());
    }
}
Also used : Bundle(org.osgi.framework.Bundle) NotCompliantMBeanException(javax.management.NotCompliantMBeanException) MBeanException(javax.management.MBeanException) NotCompliantMBeanException(javax.management.NotCompliantMBeanException) MBeanException(javax.management.MBeanException)

Example 97 with MBeanException

use of javax.management.MBeanException in project karaf by apache.

the class BundlesMBeanImpl method getDiag.

@Override
public TabularData getDiag() throws MBeanException {
    try {
        CompositeType diagType = new CompositeType("Diag", "OSGi Bundle Diag", new String[] { "Name", "Status", "Diag" }, new String[] { "Bundle Name", "Current Status", "Diagnostic" }, new OpenType[] { SimpleType.STRING, SimpleType.STRING, SimpleType.STRING });
        TabularType tableType = new TabularType("Diagnostics", "Tables of all bundles diagnostic", diagType, new String[] { "Name" });
        TabularData table = new TabularDataSupport(tableType);
        Bundle[] bundles = bundleContext.getBundles();
        for (Bundle bundle : bundles) {
            BundleInfo bundleInfo = bundleService.getInfo(bundle);
            String name = ShellUtil.getBundleName(bundle);
            String status = bundleInfo.getState().toString();
            String diag = bundleService.getDiag(bundle);
            CompositeData data = new CompositeDataSupport(diagType, new String[] { "Name", "Status", "Diag" }, new Object[] { name, status, diag });
            table.put(data);
        }
        return table;
    } catch (Exception e) {
        throw new MBeanException(null, e.toString());
    }
}
Also used : BundleInfo(org.apache.karaf.bundle.core.BundleInfo) TabularDataSupport(javax.management.openmbean.TabularDataSupport) Bundle(org.osgi.framework.Bundle) TabularType(javax.management.openmbean.TabularType) CompositeData(javax.management.openmbean.CompositeData) CompositeDataSupport(javax.management.openmbean.CompositeDataSupport) NotCompliantMBeanException(javax.management.NotCompliantMBeanException) MBeanException(javax.management.MBeanException) NotCompliantMBeanException(javax.management.NotCompliantMBeanException) MBeanException(javax.management.MBeanException) CompositeType(javax.management.openmbean.CompositeType) TabularData(javax.management.openmbean.TabularData)

Example 98 with MBeanException

use of javax.management.MBeanException in project karaf by apache.

the class BundlesMBeanImpl method getBundles.

public TabularData getBundles() throws MBeanException {
    try {
        CompositeType bundleType = new CompositeType("Bundle", "OSGi Bundle", new String[] { "ID", "Name", "Symbolic Name", "Version", "Start Level", "State", "Update Location" }, new String[] { "ID of the Bundle", "Name of the Bundle", "Symbolic Name of the Bundle", "Version of the Bundle", "Start Level of the Bundle", "Current State of the Bundle", "Update location of the Bundle" }, new OpenType[] { SimpleType.LONG, SimpleType.STRING, SimpleType.STRING, SimpleType.STRING, SimpleType.INTEGER, SimpleType.STRING, SimpleType.STRING });
        TabularType tableType = new TabularType("Bundles", "Tables of all bundles", bundleType, new String[] { "ID" });
        TabularData table = new TabularDataSupport(tableType);
        Bundle[] bundles = bundleContext.getBundles();
        for (Bundle bundle : bundles) {
            try {
                BundleInfo info = bundleService.getInfo(bundle);
                String bundleStateString = info.getState().toString();
                CompositeData data = new CompositeDataSupport(bundleType, new String[] { "ID", "Name", "Symbolic Name", "Version", "Start Level", "State", "Update Location" }, new Object[] { info.getBundleId(), info.getName(), info.getSymbolicName(), info.getVersion(), info.getStartLevel(), bundleStateString, info.getUpdateLocation() });
                table.put(data);
            } catch (Exception e) {
                LOG.error(e.getMessage(), e);
            }
        }
        return table;
    } catch (Exception e) {
        throw new MBeanException(null, e.toString());
    }
}
Also used : BundleInfo(org.apache.karaf.bundle.core.BundleInfo) TabularDataSupport(javax.management.openmbean.TabularDataSupport) Bundle(org.osgi.framework.Bundle) TabularType(javax.management.openmbean.TabularType) CompositeData(javax.management.openmbean.CompositeData) CompositeDataSupport(javax.management.openmbean.CompositeDataSupport) NotCompliantMBeanException(javax.management.NotCompliantMBeanException) MBeanException(javax.management.MBeanException) NotCompliantMBeanException(javax.management.NotCompliantMBeanException) MBeanException(javax.management.MBeanException) CompositeType(javax.management.openmbean.CompositeType) TabularData(javax.management.openmbean.TabularData)

Example 99 with MBeanException

use of javax.management.MBeanException in project karaf by apache.

the class ObrMBeanImpl method getBundles.

public TabularData getBundles() throws MBeanException {
    try {
        CompositeType bundleType = new CompositeType("OBR Resource", "Bundle available in the OBR", new String[] { "presentationname", "symbolicname", "version" }, new String[] { "Presentation Name", "Symbolic Name", "Version" }, new OpenType[] { SimpleType.STRING, SimpleType.STRING, SimpleType.STRING });
        TabularType tableType = new TabularType("OBR Resources", "Table of all resources/bundles available in the OBR", bundleType, new String[] { "symbolicname", "version" });
        TabularData table = new TabularDataSupport(tableType);
        Resource[] resources = repositoryAdmin.discoverResources("(|(presentationname=*)(symbolicname=*))");
        for (Resource resource : resources) {
            try {
                CompositeData data = new CompositeDataSupport(bundleType, new String[] { "presentationname", "symbolicname", "version" }, new Object[] { resource.getPresentationName(), resource.getSymbolicName(), resource.getVersion().toString() });
                table.put(data);
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
        return table;
    } catch (Exception e) {
        throw new MBeanException(null, e.toString());
    }
}
Also used : TabularDataSupport(javax.management.openmbean.TabularDataSupport) TabularType(javax.management.openmbean.TabularType) CompositeData(javax.management.openmbean.CompositeData) CompositeDataSupport(javax.management.openmbean.CompositeDataSupport) Resource(org.apache.felix.bundlerepository.Resource) NotCompliantMBeanException(javax.management.NotCompliantMBeanException) MBeanException(javax.management.MBeanException) NotCompliantMBeanException(javax.management.NotCompliantMBeanException) InvalidSyntaxException(org.osgi.framework.InvalidSyntaxException) MBeanException(javax.management.MBeanException) CompositeType(javax.management.openmbean.CompositeType) TabularData(javax.management.openmbean.TabularData)

Example 100 with MBeanException

use of javax.management.MBeanException in project ddf by codice.

the class ResourceDownloadActionEndpointTest method testDownloadToLocalSiteUnexpectedTargetExceptionWrappedInMBeanException.

@Test
public void testDownloadToLocalSiteUnexpectedTargetExceptionWrappedInMBeanException() throws Exception {
    // Setup
    setupMockTemplate(null, FAILURE_MESSAGE);
    setupMockHandlebars(null);
    setupMockResourceDownloadMBeanWithException(new MBeanException(new RuntimeException(), ""));
    ResourceDownloadActionEndpoint resourceDownloadEndpoint = createResourceDownloadActionEndpoint();
    // Perform Test
    Response response = resourceDownloadEndpoint.copyToLocalSite(SOURCE_ID, METACARD_ID);
    assertThat(response.getEntity(), is(String.format(HTML_TEMPLATE, FAILURE_MESSAGE)));
    assertThat(response.getStatus(), is(Status.INTERNAL_SERVER_ERROR.getStatusCode()));
    verify(mockResourceDownloadMBeanProxy).copyToLocalSite(SOURCE_ID, METACARD_ID);
}
Also used : Response(javax.ws.rs.core.Response) MBeanException(javax.management.MBeanException) Test(org.junit.Test)

Aggregations

MBeanException (javax.management.MBeanException)101 ReflectionException (javax.management.ReflectionException)47 InstanceNotFoundException (javax.management.InstanceNotFoundException)39 AttributeNotFoundException (javax.management.AttributeNotFoundException)32 NotCompliantMBeanException (javax.management.NotCompliantMBeanException)31 ObjectName (javax.management.ObjectName)31 InvalidAttributeValueException (javax.management.InvalidAttributeValueException)25 InvocationTargetException (java.lang.reflect.InvocationTargetException)18 MalformedObjectNameException (javax.management.MalformedObjectNameException)17 RuntimeOperationsException (javax.management.RuntimeOperationsException)17 ServiceNotFoundException (javax.management.ServiceNotFoundException)17 RuntimeErrorException (javax.management.RuntimeErrorException)14 Attribute (javax.management.Attribute)12 Method (java.lang.reflect.Method)10 DynamicMBean (javax.management.DynamicMBean)10 ListenerNotFoundException (javax.management.ListenerNotFoundException)10 Descriptor (javax.management.Descriptor)9 MalformedURLException (java.net.MalformedURLException)7 MBeanRegistrationException (javax.management.MBeanRegistrationException)7 MBeanServer (javax.management.MBeanServer)7