001: package org.enhydra.shark;
002:
003: import java.io.File;
004: import java.util.Properties;
005:
006: import org.enhydra.shark.api.RootError;
007: import org.enhydra.shark.api.client.wfmc.wapi.WAPI;
008: import org.enhydra.shark.api.client.wfservice.AdminMisc;
009: import org.enhydra.shark.api.client.wfservice.AdminMiscExt;
010: import org.enhydra.shark.api.client.wfservice.ExecutionAdministration;
011: import org.enhydra.shark.api.client.wfservice.ExecutionAdministrationExt;
012: import org.enhydra.shark.api.client.wfservice.NameValue;
013: import org.enhydra.shark.api.client.wfservice.PackageAdministration;
014: import org.enhydra.shark.api.client.wfservice.SharkConnection;
015: import org.enhydra.shark.api.client.wfservice.SharkInterface;
016: import org.enhydra.shark.api.client.wfservice.XPDLBrowser;
017: import org.enhydra.shark.api.client.xpil.XPILHandler;
018: import org.enhydra.shark.api.common.ActivityFilterBuilder;
019: import org.enhydra.shark.api.common.AssignmentFilterBuilder;
020: import org.enhydra.shark.api.common.EventAuditFilterBuilder;
021: import org.enhydra.shark.api.common.ProcessFilterBuilder;
022: import org.enhydra.shark.api.common.ProcessMgrFilterBuilder;
023: import org.enhydra.shark.api.common.ResourceFilterBuilder;
024:
025: import com.lutris.util.Config;
026:
027: /**
028: * The main engine class. The client application first has to call one of the static
029: * methods configure() (which will initialize shark), and then static getInstance() method
030: * of this class to get one and only one instance of this class. After that, clients can
031: * call other methods for getting appropriate interfaces.
032: *
033: * @version 1.2
034: * @author Sasa Bojanic
035: * @author Vladimir Puskas
036: */
037: public final class Shark implements SharkInterface {
038:
039: private static SharkInterface theEngine;
040:
041: private static String implClassName = "org.enhydra.shark.SharkEngineManager";
042:
043: private static Shark me;
044:
045: static {
046: me = new Shark();
047: }
048:
049: // ////////////////////////////////////////////////////////////////
050: // Configuration methods
051: // ////////////////////////////////////////////////////////////////
052: public static void configure(Properties props) {
053: try {
054: _conf(props);
055: // shark.configure(props);
056: } catch (Exception e) {
057: throw new RootError(e);
058: }
059: }
060:
061: public static void configure(String filePath) {
062: try {
063: _conf(filePath);
064: // shark.configure(filePath);
065: } catch (Exception e) {
066: throw new RootError(e);
067: }
068: }
069:
070: public static void configure(File configFile) {
071: try {
072: _conf(configFile);
073: // shark.configure(configFile);
074: } catch (Exception e) {
075: throw new RootError(e);
076: }
077: }
078:
079: public static void configure() {
080: try {
081: Class.forName(implClassName).getMethod("configure",
082: new Class[] {}).invoke(null, new Object[] {});
083: // shark.configure();
084: } catch (Exception e) {
085: throw new RootError(e);
086: }
087: }
088:
089: public static void configure(Config config) {
090: try {
091: _conf(config);
092: // shark.configure(config);
093: } catch (Exception e) {
094: throw new RootError(e);
095: }
096: }
097:
098: public static boolean isConfigured() {
099: try {
100: return ((Boolean) Class.forName(implClassName).getMethod(
101: "isConfigured", new Class[] {}).invoke(null,
102: new Object[] {})).booleanValue();
103: // shark.configure();
104: } catch (Exception e) {
105: throw new RootError(e);
106: }
107: }
108:
109: public static Shark getInstance() {
110: if (null == theEngine)
111: try {
112: theEngine = (SharkInterface) Class.forName(
113: implClassName).getDeclaredMethod("getInstance",
114: new Class[] {}).invoke(null, new Object[] {});
115: // Class.forName(implClassName)
116: // .getMethod("getInstance", new Class[]
117: // {})
118: // .invoke(null, new Object[] {});
119: } catch (Exception e) {
120: throw new RootError(e);
121: }
122: return me;
123: }
124:
125: private static void _conf(Object configuration) throws Exception {
126: Class.forName(implClassName).getMethod("configure",
127: new Class[] { configuration.getClass() }).invoke(null,
128: new Object[] { configuration });
129: }
130:
131: private Shark() {
132: }
133:
134: // ////////////////////////////////////////////////////////////////
135: // SharkInterface API implementation
136: // ////////////////////////////////////////////////////////////////
137: public AdminMisc getAdminMisc() throws Exception {
138: return theEngine.getAdminMisc();
139: }
140:
141: public AdminMiscExt getAdminMiscExtension() throws Exception {
142: return theEngine.getAdminMiscExtension();
143: }
144:
145: public ExecutionAdministration getExecutionAdministration()
146: throws Exception {
147: return theEngine.getExecutionAdministration();
148: }
149:
150: public ExecutionAdministrationExt getExecutionAdministrationExtension()
151: throws Exception {
152: return theEngine.getExecutionAdministrationExtension();
153: }
154:
155: public PackageAdministration getPackageAdministration()
156: throws Exception {
157: return theEngine.getPackageAdministration();
158: }
159:
160: public SharkConnection getSharkConnection() throws Exception {
161: return theEngine.getSharkConnection();
162: }
163:
164: public ActivityFilterBuilder getActivityFilterBuilder()
165: throws Exception {
166: return theEngine.getActivityFilterBuilder();
167: }
168:
169: public AssignmentFilterBuilder getAssignmentFilterBuilder()
170: throws Exception {
171: return theEngine.getAssignmentFilterBuilder();
172: }
173:
174: public EventAuditFilterBuilder getEventAuditFilterBuilder()
175: throws Exception {
176: return theEngine.getEventAuditFilterBuilder();
177: }
178:
179: public ProcessFilterBuilder getProcessFilterBuilder()
180: throws Exception {
181: return theEngine.getProcessFilterBuilder();
182: }
183:
184: public ProcessMgrFilterBuilder getProcessMgrFilterBuilder()
185: throws Exception {
186: return theEngine.getProcessMgrFilterBuilder();
187: }
188:
189: public ResourceFilterBuilder getResourceFilterBuilder()
190: throws Exception {
191: return theEngine.getResourceFilterBuilder();
192: }
193:
194: public XPDLBrowser getXPDLBrowser() throws Exception {
195: return theEngine.getXPDLBrowser();
196: }
197:
198: public XPILHandler getXPILHandler() throws Exception {
199: return theEngine.getXPILHandler();
200: }
201:
202: public NameValue[] getProperties() throws Exception {
203: return theEngine.getProperties();
204: }
205:
206: public WAPI getWAPIConnection() throws Exception {
207: return theEngine.getWAPIConnection();
208: }
209:
210: public Object getPlugIn(String name) throws Exception {
211: return theEngine.getPlugIn(name);
212: }
213:
214: }
|