KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > enhydra > shark > asap > SharkServiceImpl


1 /* SharkWebServiceImpl.java */
2
3 package org.enhydra.shark.asap;
4
5 import org.enhydra.shark.Shark;
6 import org.enhydra.shark.api.RootError;
7 import org.enhydra.shark.api.client.wfservice.*;
8
9 /**
10  * @author V.Puskas, S.Bojanic
11  * @version 0.2
12  */

13 public class SharkServiceImpl {
14
15    public static final String JavaDoc GROUPNAME = "test";
16
17    public static final String JavaDoc USERNAME = "admin";
18
19    public static final String JavaDoc PASSWD = "enhydra";
20
21    protected static final String JavaDoc XPDL_FILENAME = "test-BeanShell.xpdl";
22
23    public static final String JavaDoc DEFAULT_PROC_MGR = "test_bs#1#math_operations";
24
25    public static final String JavaDoc QSPN_PROCESS_DEFINITION = "procDef=";
26
27    public static final String JavaDoc QSPN_PACKAGE_ID = "packageId=";
28
29    public static final String JavaDoc QSPN_PROCESS_MANAGER = "procMgr=";
30
31    public static final String JavaDoc QSPN_PROCESS_INSTANCE = "procInst=";
32
33    //public static AsapPersistenceManager asapPersistenceManager;
34

35    //public static RequesterImpl sharkExternalRequester;
36

37    protected static ExecutionAdministration executionAdmin;
38
39    protected static AdminMisc adminMisc;
40
41    public static String JavaDoc factoryBindingAddress;
42
43    public static void main(String JavaDoc[] argv) {
44       try {
45          Shark.configure(argv[0]);
46          PackageAdministration pa = Shark.getInstance()
47             .getAdminInterface()
48             .getPackageAdministration();
49          RepositoryMgr rm = Shark.getInstance().getRepositoryManager();
50          UserGroupAdministration uga = Shark.getInstance()
51             .getAdminInterface()
52             .getUserGroupAdministration();
53          try {
54             if (!uga.doesGroupExist(GROUPNAME)) {
55                uga.createGroup("test", "test group");
56             }
57             if (!uga.doesUserExist(USERNAME)) {
58                uga.createUser(GROUPNAME, USERNAME, PASSWD, "Jane", "Doe", "");
59             }
60             String JavaDoc pkgId = rm.getPackageId(XPDL_FILENAME);
61             if (!pa.isPackageOpened(pkgId)) {
62                pa.openPackage(XPDL_FILENAME);
63             }
64
65          } catch (Throwable JavaDoc t) {
66             t.printStackTrace();
67          }
68
69          //asapPersistenceManager=new DODSAsapPersistenceManager();
70
//asapPersistenceManager.configure(Shark.getInstance().getProperties());
71

72          //sharkExternalRequester=new RequesterImpl();
73

74          adminMisc = Shark.getInstance().getAdminInterface().getAdminMisc();
75          adminMisc.connect(SharkServiceImpl.USERNAME);
76
77          executionAdmin = Shark.getInstance()
78             .getAdminInterface()
79             .getExecutionAdministration();
80          executionAdmin.connect(SharkServiceImpl.USERNAME,
81                                 SharkServiceImpl.PASSWD,
82                                 "",
83                                 "");
84
85          factoryBindingAddress = new SharkWebServiceLocator().getasapFactoryBindingAddress();
86          //restoreExternalRequester();
87
String JavaDoc[] args = new String JavaDoc[argv.length - 1];
88          for (int n = 1; n < argv.length; ++n) {
89             args[n - 1] = argv[n];
90          }
91          Class.forName("org.apache.axis.transport.http.SimpleAxisServer")
92             .getDeclaredMethod("main", new Class JavaDoc[] {
93                args.getClass()
94             })
95             .invoke(null, new Object JavaDoc[] {
96                args
97             });
98       } catch (Exception JavaDoc e) {
99          throw new RootError(e);
100       }
101    }
102
103    /*
104     * public static AsapPersistenceManager getAsapPersistenceManager () {
105     * return asapPersistenceManager; }
106     */

107
108    /*
109     * public static RequesterImpl getExternalRequester () { return
110     * sharkExternalRequester; }
111     */

112
113    public static AdminMisc getAdminMiscUtilities() {
114       return adminMisc;
115    }
116
117    public static ExecutionAdministration getExecAdmin() {
118       return executionAdmin;
119    }
120    //
121
// public static String getMyAddress() {
122
// String[] a = MessageContext.getCurrentContext()
123
// .getRequestMessage()
124
// .getMimeHeaders()
125
// .getHeader("X-Forwarded-Server");
126
// if (null != a && a.length > 0 && null != a[a.length - 1]) return
127
// a[a.length - 1];
128
// return myAddress;
129
// }
130

131    /*
132     * private static void restoreExternalRequester () throws
133     * RootException { ExecutionAdministration
134     * ea=Shark.getInstance().getAdminInterface().getExecutionAdministration();
135     * ea.connect(USERNAME,PASSWD,"",""); List
136     * l=asapPersistenceManager.getAllObservedProcesses(null); Iterator
137     * it=l.iterator(); while (it.hasNext()) { String
138     * procId=(String)it.next(); WfProcess proc=ea.getProcess(procId);
139     * proc.set_requester(sharkExternalRequester); } }
140     */

141
142 }
Popular Tags