Esempio n. 1
0
  /**
   * Checks if the Jboss installation has installed remote management package
   *
   * @return is remote management supported
   */
  public static boolean isRemoteManagementSupported(Lookup lookup) {
    JBDeploymentManager dm = lookup.lookup(JBDeploymentManager.class);
    if (dm == null) {
      return false;
    }
    try {
      dm.invokeRemoteAction(
          new JBRemoteAction<Boolean>() {

            @Override
            public Boolean action(
                MBeanServerConnection connection, JBoss5ProfileServiceProxy profileService)
                throws Exception {
              // FIXME is this refletion needed
              ObjectName searchPattern = new ObjectName("jboss.management.local:*");
              Method method =
                  connection
                      .getClass()
                      .getMethod("queryMBeans", new Class[] {ObjectName.class, QueryExp.class});
              method = fixJava4071957(method);
              Set managedObj = (Set) method.invoke(connection, new Object[] {searchPattern, null});

              return !managedObj.isEmpty();
            }
          });
    } catch (ExecutionException ex) {
      LOGGER.log(Level.INFO, null, ex);
    }

    return true;
  }
Esempio n. 2
0
  /**
   * Checks if the specified object is deployed in JBoss Application Server
   *
   * @return if specified object is deployed
   */
  public static boolean isObjectDeployed(JBDeploymentManager dm, final ObjectName searchPattern) {
    try {
      dm.invokeRemoteAction(
          new JBRemoteAction<Boolean>() {

            @Override
            public Boolean action(
                MBeanServerConnection connection, JBoss5ProfileServiceProxy profileService)
                throws Exception {
              // FIXME is this reflection really needed
              Method method =
                  connection
                      .getClass()
                      .getMethod("queryMBeans", new Class[] {ObjectName.class, QueryExp.class});
              method = fixJava4071957(method);
              Set managedObj = (Set) method.invoke(connection, new Object[] {searchPattern, null});

              return managedObj.size() > 0;
            }
          });
    } catch (ExecutionException ex) {
      LOGGER.log(Level.INFO, null, ex);
    }

    return false;
  }