001: package org.enhydra.shark.client.utilities;
002:
003: import java.lang.reflect.Method;
004:
005: import org.enhydra.shark.api.client.wfmc.wapi.WAPI;
006: import org.enhydra.shark.api.client.wfservice.AdminMisc;
007: import org.enhydra.shark.api.client.wfservice.AdminMiscExt;
008: import org.enhydra.shark.api.client.wfservice.ExecutionAdministration;
009: import org.enhydra.shark.api.client.wfservice.ExecutionAdministrationExt;
010: import org.enhydra.shark.api.client.wfservice.NameValue;
011: import org.enhydra.shark.api.client.wfservice.PackageAdministration;
012: import org.enhydra.shark.api.client.wfservice.SharkConnection;
013: import org.enhydra.shark.api.client.wfservice.SharkInterface;
014: import org.enhydra.shark.api.client.wfservice.XPDLBrowser;
015: import org.enhydra.shark.api.client.xpil.XPILHandler;
016: import org.enhydra.shark.api.common.ActivityFilterBuilder;
017: import org.enhydra.shark.api.common.AssignmentFilterBuilder;
018: import org.enhydra.shark.api.common.EventAuditFilterBuilder;
019: import org.enhydra.shark.api.common.ProcessFilterBuilder;
020: import org.enhydra.shark.api.common.ProcessMgrFilterBuilder;
021: import org.enhydra.shark.api.common.ResourceFilterBuilder;
022: import org.enhydra.shark.api.common.SharkConstants;
023:
024: /**
025: * @author Vladimir Radisic
026: * @version 1.0
027: */
028:
029: public class SharkWSFactory implements SharkInterface {
030:
031: private String wsUrl = "http://localhost:8080/sharkWebServices";
032:
033: private static String LOCATOR_CLASS_PACKAGE_PREFIX = "org.enhydra.shark.ejb.client.ws.";
034:
035: private static String EJB_ENDPOINT_SUFFIX = "EJBEndpoint";
036:
037: private static String SERVICE_LOCATOR_SUFFIX = "ServiceLocator";
038:
039: private static String PORT_SUFFIX = "Port";
040:
041: public SharkWSFactory() {
042: }
043:
044: public SharkWSFactory(String wsUrlPr) {
045: if (wsUrlPr != null && wsUrlPr.endsWith("/"))
046: this .wsUrl = wsUrlPr.substring(0, wsUrlPr.length() - 1);
047: else
048: this .wsUrl = wsUrlPr;
049: }
050:
051: protected Object getEndpointPort(String name)
052: throws java.lang.Exception {
053: String endpoint = this .wsUrl + "/" + name;
054: String serviceLocatorClassName = LOCATOR_CLASS_PACKAGE_PREFIX
055: + name + EJB_ENDPOINT_SUFFIX + SERVICE_LOCATOR_SUFFIX;
056: String getEndpointPortMethodName = "get" + name
057: + EJB_ENDPOINT_SUFFIX + PORT_SUFFIX;
058: Class slc = Class.forName(serviceLocatorClassName);
059: Object service = slc.newInstance();
060: Method mth = slc.getMethod(getEndpointPortMethodName,
061: new Class[] { java.net.URL.class });
062: Object port = mth.invoke(service,
063: new Object[] { new java.net.URL(endpoint) });
064: return port;
065: }
066:
067: public SharkConnection getSharkConnection()
068: throws java.lang.Exception {
069: return null;
070: }
071:
072: public WAPI getWAPIConnection() throws java.lang.Exception {
073: return (WAPI) getEndpointPort("WAPI");
074: }
075:
076: public PackageAdministration getPackageAdministration()
077: throws java.lang.Exception {
078: return (PackageAdministration) getEndpointPort("PackageAdministration");
079: }
080:
081: public ExecutionAdministration getExecutionAdministration()
082: throws java.lang.Exception {
083: return (ExecutionAdministration) getEndpointPort("ExecutionAdministration");
084: }
085:
086: public ExecutionAdministrationExt getExecutionAdministrationExtension()
087: throws java.lang.Exception {
088: return (ExecutionAdministrationExt) getEndpointPort("ExecutionAdministrationExt");
089: }
090:
091: public AdminMisc getAdminMisc() throws java.lang.Exception {
092: return (AdminMisc) getEndpointPort("AdminMisc");
093: }
094:
095: public AdminMiscExt getAdminMiscExtension()
096: throws java.lang.Exception {
097: return (AdminMiscExt) getEndpointPort("AdminMiscExt");
098: }
099:
100: public XPDLBrowser getXPDLBrowser() throws java.lang.Exception {
101: return (XPDLBrowser) getEndpointPort("XPDLBrowser");
102: }
103:
104: public ActivityFilterBuilder getActivityFilterBuilder()
105: throws java.lang.Exception {
106: return (ActivityFilterBuilder) getEndpointPort("ActivityFilterBuilder");
107: }
108:
109: public AssignmentFilterBuilder getAssignmentFilterBuilder()
110: throws java.lang.Exception {
111: return (AssignmentFilterBuilder) getEndpointPort("AssignmentFilterBuilder");
112: }
113:
114: public EventAuditFilterBuilder getEventAuditFilterBuilder()
115: throws java.lang.Exception {
116: return (EventAuditFilterBuilder) getEndpointPort("EventAuditFilterBuilder");
117: }
118:
119: public ProcessFilterBuilder getProcessFilterBuilder()
120: throws java.lang.Exception {
121: return (ProcessFilterBuilder) getEndpointPort("ProcessFilterBuilder");
122: }
123:
124: public ProcessMgrFilterBuilder getProcessMgrFilterBuilder()
125: throws java.lang.Exception {
126: return (ProcessMgrFilterBuilder) getEndpointPort("ProcessMgrFilterBuilder");
127: }
128:
129: public ResourceFilterBuilder getResourceFilterBuilder()
130: throws java.lang.Exception {
131: return (ResourceFilterBuilder) getEndpointPort("ResourceFilterBuilder");
132: }
133:
134: public XPILHandler getXPILHandler() throws java.lang.Exception {
135: return (XPILHandler) getEndpointPort("XPILHandler");
136: }
137:
138: public NameValue[] getProperties() throws java.lang.Exception {
139: /** @todo Implement this org.enhydra.shark.api.client.wfservice.SharkInterface method */
140: throw new java.lang.UnsupportedOperationException(
141: "Method getProperties() not yet implemented.");
142: }
143:
144: public Object getPlugIn(String parm1) throws java.lang.Exception {
145:
146: Object plugIn = null;
147:
148: if (SharkConstants.possiblePluginNames.contains(parm1)) {
149: if (parm1.equals(SharkConstants.PLUGIN_APPLICATION_MAPPING)) {
150: return getEndpointPort("ApplicationMappingMgrAdmin");
151: } else if (parm1
152: .equals(SharkConstants.PLUGIN_PARTICIPANT_MAPPING)) {
153: return getEndpointPort("ParticipantMappingMgrAdmin");
154: } else if (parm1.equals(SharkConstants.PLUGIN_USER_GROUP)) {
155: return getEndpointPort("UserGroupManagerAdmin");
156: } else {
157: throw new java.lang.UnsupportedOperationException(
158: "There is no plug-in for name " + parm1);
159: }
160:
161: }
162: return plugIn;
163:
164: }
165:
166: }
|