001: package com.sun.portal.fabric.mbeans;
002:
003: import java.lang.*;
004: import java.util.*;
005:
006: import javax.management.remote.JMXConnector;
007: import javax.management.MBeanServerConnection;
008: import javax.management.ObjectName;
009:
010: import com.sun.portal.admin.server.PASModule;
011: import com.sun.portal.admin.server.AdminServerUtil;
012: import com.sun.portal.admin.server.mbeans.PSResource;
013: import com.sun.portal.admin.common.context.PortalDomainContext;
014: import com.sun.portal.admin.common.context.PSConfigContext;
015: import com.sun.portal.admin.common.util.AdminUtil;
016: import com.sun.portal.admin.common.PSMBeanException;
017:
018: import com.sun.portal.fabric.tasks.scheduler.SchedulerTask;
019:
020: public class Scheduler extends PSResource implements SchedulerMBean {
021:
022: private ObjectName objectName = null;
023: private String psDir = null;
024:
025: public void init(PSConfigContext cc, PortalDomainContext pdc,
026: List path) {
027: super .init(cc, pdc, path);
028: psDir = cc.getPSBaseDir();
029:
030: try {
031: objectName = AdminUtil.getResourceMBeanObjectName(TYPE,
032: path);
033: } catch (Exception e) {
034: }
035: }
036:
037: public Boolean schedule(List actions) throws PSMBeanException {
038: SchedulerTask schedulerTask = new SchedulerTask(cc);
039: schedulerTask.schedule((ArrayList) actions);
040: return Boolean.TRUE;
041: }
042:
043: public Boolean schedule(String host, List actions)
044: throws PSMBeanException, java.net.UnknownHostException {
045: if (!AdminUtil.isLocal(host)) {
046: try {
047: JMXConnector jmxc = AdminServerUtil
048: .getJMXConnector(host);
049: MBeanServerConnection msc = jmxc
050: .getMBeanServerConnection();
051: Object[] params = { host, actions };
052: String[] signatures = { "java.lang.String",
053: "java.util.List" };
054: Boolean result = (Boolean) msc.invoke(objectName,
055: "schedule", params, signatures);
056: jmxc.close();
057: return result;
058: } catch (Exception e) {
059: throw new PSMBeanException("Scheduler:schedule", e
060: .toString(), e);
061: }
062: } else {
063: SchedulerTask schedulerTask = new SchedulerTask(cc);
064: schedulerTask.schedule((ArrayList) actions);
065: return Boolean.TRUE;
066: }
067: }
068:
069: public Boolean unschedule(List actions) throws PSMBeanException {
070: SchedulerTask schedulerTask = new SchedulerTask(cc);
071: schedulerTask.unschedule((ArrayList) actions);
072: return Boolean.TRUE;
073: }
074:
075: public Boolean unschedule(String host, List actions)
076: throws PSMBeanException, java.net.UnknownHostException {
077: if (!AdminUtil.isLocal(host)) {
078: try {
079: JMXConnector jmxc = AdminServerUtil
080: .getJMXConnector(host);
081: MBeanServerConnection msc = jmxc
082: .getMBeanServerConnection();
083: Object[] params = { host, actions };
084: String[] signatures = { "java.lang.String",
085: "java.util.List" };
086: Boolean result = (Boolean) msc.invoke(objectName,
087: "unschedule", params, signatures);
088: jmxc.close();
089: return result;
090: } catch (Exception e) {
091: throw new PSMBeanException("Scheduler:unschedule", e
092: .toString(), e);
093: }
094: } else {
095: SchedulerTask schedulerTask = new SchedulerTask(cc);
096: schedulerTask.unschedule((ArrayList) actions);
097: return Boolean.TRUE;
098: }
099: }
100:
101: public ArrayList getSchedules(String command)
102: throws PSMBeanException {
103: SchedulerTask schedulerTask = new SchedulerTask(cc);
104: return schedulerTask.getSchedules(command);
105: }
106:
107: public ArrayList getSchedules(String host, String command)
108: throws PSMBeanException, java.net.UnknownHostException {
109: if (!AdminUtil.isLocal(host)) {
110: try {
111: JMXConnector jmxc = AdminServerUtil
112: .getJMXConnector(host);
113: MBeanServerConnection msc = jmxc
114: .getMBeanServerConnection();
115: Object[] params = { host, command };
116: String[] signatures = { "java.lang.String",
117: "java.lang.String" };
118: ArrayList result = (ArrayList) msc.invoke(objectName,
119: "getSchedules", params, signatures);
120: jmxc.close();
121: return result;
122: } catch (Exception e) {
123: throw new PSMBeanException("Scheduler:getSchedules", e
124: .toString(), e);
125: }
126: } else {
127: SchedulerTask schedulerTask = new SchedulerTask(cc);
128: return schedulerTask.getSchedules(command);
129: }
130: }
131:
132: public String getPSDir() throws PSMBeanException,
133: java.net.UnknownHostException {
134: return psDir;
135: }
136:
137: }
|