/** * Check with 'depmonitor' MBean if a given directory is a depmonitor directory * @param dir the name of the given directory * @param domainName current domain name * @param serverName current server name * @return true if the given directory is a depmonitor directory * @throws ManagementException */ public static boolean isDepmonitorDir(final String dir, final String domainName, final String serverName) throws ManagementException { ObjectName on = JonasObjectName.deployableMonitorService(domainName); Object[] params = {dir}; String[] sign = {"java.lang.String"}; return (Boolean) JonasManagementRepr.invoke(on, "isDepmonitorDir", params, sign, serverName); }
/** * Get the deployment repositories from 'depmonitor' MBean. * @param domainName * @param serverName * @return the current URL repositories. */ public static String[] getDepmonitorDirs(final String domainName, final String serverName) throws ManagementException { ArrayList<String> result = new ArrayList<String> (); ObjectName on = JonasObjectName.deployableMonitorService(domainName); if (on != null) { String[] dirs = (String[]) JonasManagementRepr.getAttribute(on, "directoryNames", serverName); for (String dir : dirs) { result.add(dir); } Collections.sort(result); } return result.toArray(new String[result.size()]); }
/** * Return true if a given service is in 'development' mode for a given server managed in the domain. * @param serviceName The service name, for example "depmonitor". * @param serverName Target server name. * @return true if a given service is in 'development' mode, false otherwise * @throws Exception */ public boolean developmentMode(final String serviceName, final String serverName) throws Exception { ObjectName on = null; String attribute = "development"; Object resultObj = null; boolean result; try { on = JonasObjectName.deployableMonitorService(getDomainName()); resultObj = JonasManagementRepr.getAttribute(on, attribute, serverName); } catch (Exception e) { throw new Exception("Could not get attribute \"" + attribute + " for service \"" + serviceName + "\" on server \"" + serverName + "\""); } if (resultObj != null) { result = ((Boolean) resultObj).booleanValue(); } else { throw new Exception("Got null attribute \"" + attribute + " for service \"" + serviceName + "\" on server \"" + serverName + "\""); } return result; }