0001: /*
0002: * Copyright 2005 Joe Walker
0003: *
0004: * Licensed under the Apache License, Version 2.0 (the "License");
0005: * you may not use this file except in compliance with the License.
0006: * You may obtain a copy of the License at
0007: *
0008: * http://www.apache.org/licenses/LICENSE-2.0
0009: *
0010: * Unless required by applicable law or agreed to in writing, software
0011: * distributed under the License is distributed on an "AS IS" BASIS,
0012: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
0013: * See the License for the specific language governing permissions and
0014: * limitations under the License.
0015: */
0016: package jsx3.net;
0017:
0018: import org.directwebremoting.ScriptBuffer;
0019: import org.directwebremoting.proxy.ScriptProxy;
0020: import org.directwebremoting.proxy.io.Context;
0021:
0022: /**
0023: * This class is used in conjunction with the XML Mapping Utility to provide transactional support for those services using XML-based messaging.
0024: Support includes those services defined via Schema, XML, XHTML, and WSDL (SOAP). In practice a developer would open General InterfaceŞ Builder
0025: to access the XML Mapping Utility. They would then point the utility at a "pattern master" (i.e., WSDL, Schema, XML, etc) and begin using its
0026: visual tools to bind application objects to nodes in the XML messages to be sent and received.
0027: The output from the Mapping Utility is referred to as a mapping rule set. This rule set is an XML document based upon the Common Exchange Format (CXF)
0028: and defines the information necessary to support transactional data mapping. Many of the APIs available to the Service class allow the devloper to
0029: dynamically update various static values that were set using the XML Mapping Utility.
0030: * @author Joe Walker [joe at getahead dot org]
0031: * @author DRAPGEN - Dwr Reverse Ajax Proxy GENerator
0032: */
0033: public class Service extends jsx3.lang.Object {
0034: /**
0035: * All reverse ajax proxies need context to work from
0036: * @param scriptProxy The place we are writing scripts to
0037: * @param context The script that got us to where we are now
0038: */
0039: public Service(Context context, String extension,
0040: ScriptProxy scriptProxy) {
0041: super (context, extension, scriptProxy);
0042: }
0043:
0044: /**
0045: * instance initializer
0046: * @param strRulesURL The resolved URI for the rules document (a CXF document).
0047: Note: since this class is lazily loaded as of v3.2, the preferred method of instantiating this class is by calling the <code>loadResource</code>
0048: method on the context server (<code>jsx3.app.Server</code>) instance. This ensures proper URL resolution while also establishing the
0049: appropriate server context.
0050: * @param strOperationName name of operation to call. This is only required if the rules file was generated via a WSDL.
0051: * @param strOutboundURL address of a sample outbound message to use as opposed to the one generated by the tool
0052: * @param strInboundURL when the project is run in static mode (as defined by the 'project deployment options' dialog),
0053: this document is used to simulate a typical server response
0054: */
0055: public Service(String strRulesURL, String strOperationName,
0056: String strOutboundURL, String strInboundURL) {
0057: super ((Context) null, (String) null, (ScriptProxy) null);
0058: ScriptBuffer script = new ScriptBuffer();
0059: script.appendCall("new Service", strRulesURL, strOperationName,
0060: strOutboundURL, strInboundURL);
0061: setInitScript(script);
0062: }
0063:
0064: /**
0065: * event type for successful response
0066: */
0067: public static final String ON_SUCCESS = "onSuccess";
0068:
0069: /**
0070: * event type for unsuccessful response
0071: */
0072: public static final String ON_ERROR = "onError";
0073:
0074: /**
0075: * Event type published when the response is still not ready after the specified timeout period.
0076: */
0077: public static final String ON_TIMEOUT = "onTimeout";
0078:
0079: /**
0080: * Event type published each time a rule with one or more restrictions fails during message generation. The following named properties are available on the event object:
0081:
0082:
0083: rule the rule node
0084:
0085: message the message node
0086:
0087: target this jsx3.net.Service instance
0088:
0089: type the type of restriction that caused the invalidation event to be publsihed. For example, pattern.
0090:
0091: value the value for the type. For example if type is pattern, then [A-Z]*
0092: */
0093: public static final String ON_INVALID = "onInvalid";
0094:
0095: /**
0096: * Event type published each time a mapping rule is used to create a node, locate a node, or map to a node.
0097:
0098:
0099: target this jsx3.net.Service instance
0100:
0101: rule the rule node being processed
0102:
0103: action the action being performed by the rule. For example, Create Node, Map to Cache, Invalidate Node, etc.
0104:
0105: description a description of the 'action'. For example, this.eval(setValue(2));
0106:
0107:
0108: level the log level (e.g., 'severity' level) for the message. For example, 6 would signify a 'Trace' level event.
0109: */
0110: public static final String ON_PROCESS_RULE = "onProcessRule";
0111:
0112: /**
0113: * Returns a CR-LF delimited list of supported namespaces and thei related prefix (as defined by the Object, jsx3.net.Service.ns). Any nodes in a rules document (CXF) that implements one of the namespaces listed by this function, should implement the corresponding namespace prefix as also detailed here.
0114: */
0115: @SuppressWarnings("unchecked")
0116: public void getSupportedNamespaces(
0117: org.directwebremoting.proxy.Callback<String> callback) {
0118: ScriptBuffer script = new ScriptBuffer();
0119: String callbackPrefix = "";
0120:
0121: if (callback != null) {
0122: callbackPrefix = "var reply = ";
0123: }
0124:
0125: script.appendCall(callbackPrefix + getContextPath()
0126: + "getSupportedNamespaces");
0127:
0128: if (callback != null) {
0129: String key = org.directwebremoting.extend.CallbackHelper
0130: .saveCallback(callback, String.class);
0131: script
0132: .appendCall("__System.activateCallback", key,
0133: "reply");
0134: }
0135:
0136: getScriptProxy().addScript(script);
0137: }
0138:
0139: /**
0140: * Gets the URL for the rules file to use (a CXF document). This rules file will be used by the Service instance to generate, send, receive and process XML messages
0141: */
0142: @SuppressWarnings("unchecked")
0143: public void getRulesURL(
0144: org.directwebremoting.proxy.Callback<String> callback) {
0145: ScriptBuffer script = new ScriptBuffer();
0146: String callbackPrefix = "";
0147:
0148: if (callback != null) {
0149: callbackPrefix = "var reply = ";
0150: }
0151:
0152: script.appendCall(callbackPrefix + getContextPath()
0153: + "getRulesURL");
0154:
0155: if (callback != null) {
0156: String key = org.directwebremoting.extend.CallbackHelper
0157: .saveCallback(callback, String.class);
0158: script
0159: .appendCall("__System.activateCallback", key,
0160: "reply");
0161: }
0162:
0163: getScriptProxy().addScript(script);
0164: }
0165:
0166: /**
0167: * Sets the URL for the rules file to use (a CXF document). This rules file will be used by the Service instance to generate, send, receive and process XML messages
0168: * @param strRulesURL
0169: * @return reference to self
0170: */
0171: public jsx3.net.Service setRulesURL(String strRulesURL) {
0172: ScriptBuffer script = new ScriptBuffer();
0173: script
0174: .appendCall(getContextPath() + "setRulesURL",
0175: strRulesURL);
0176: getScriptProxy().addScript(script);
0177: return this ;
0178: }
0179:
0180: /**
0181: * Sets the document that will serve as the container for the message generated by doCall and/or getServiceMessage.
0182: This is a useful way to dynamically assemble documents by chaining multiple service instances, using the output from one service as the input to another.
0183: For example, when a SOAP Envelope requires both a SOAP Header as well as a SOAP Body, this method allows the Envelope to be assembled via a
0184: two-step process of first adding mapped content to the Body, followed by a call to add mapped content to the Header.
0185: Note that this method takes precedence over the static stub document url referenced in the rules file as well as
0186: any call to setOutboundStubURL. Use this method in conjunction with setOutboundStubPath to
0187: point to the specific location in the document where the generated message should be appended.
0188: * @param objDocument
0189: * @return reference to self
0190: */
0191: public jsx3.net.Service setOutboundStubDocument(
0192: jsx3.xml.CdfDocument objDocument) {
0193: ScriptBuffer script = new ScriptBuffer();
0194: script.appendCall(getContextPath() + "setOutboundStubDocument",
0195: objDocument);
0196: getScriptProxy().addScript(script);
0197: return this ;
0198: }
0199:
0200: /**
0201: * Gets URL for the base stub to use for the request message (the XML document to contain the generated document)
0202: */
0203: @SuppressWarnings("unchecked")
0204: public void getOutboundStubURL(
0205: org.directwebremoting.proxy.Callback<String> callback) {
0206: ScriptBuffer script = new ScriptBuffer();
0207: String callbackPrefix = "";
0208:
0209: if (callback != null) {
0210: callbackPrefix = "var reply = ";
0211: }
0212:
0213: script.appendCall(callbackPrefix + getContextPath()
0214: + "getOutboundStubURL");
0215:
0216: if (callback != null) {
0217: String key = org.directwebremoting.extend.CallbackHelper
0218: .saveCallback(callback, String.class);
0219: script
0220: .appendCall("__System.activateCallback", key,
0221: "reply");
0222: }
0223:
0224: getScriptProxy().addScript(script);
0225: }
0226:
0227: /**
0228: * Sets the URL to the document that will serve as the container for the message generated by doCall and/or getServiceMessage.
0229: Overrides the static setting stored in the rules file. Use this method in conjunction with setOutboundStubPath to
0230: point to the specific location in the document where the generated message should be appended.
0231: * @param strURL URL for the document. Note that this URL will be resolved relative to the context server.
0232: For example, if the project directory for the context server is 'test', then the following inputs (all of which are valid) are
0233: equivalent: <code>jsxapp://test/xml/typical.xml</code>, <b>and</b> <code>xml/typical.xml</code>, <b>and</b> <code>JSXAPPS/test/xml/typical.xml</code>
0234: * @return reference to self
0235: */
0236: public jsx3.net.Service setOutboundStubURL(String strURL) {
0237: ScriptBuffer script = new ScriptBuffer();
0238: script.appendCall(getContextPath() + "setOutboundStubURL",
0239: strURL);
0240: getScriptProxy().addScript(script);
0241: return this ;
0242: }
0243:
0244: /**
0245: * Gets the namespace for the server/project to run the service instance within. If a namespace isn't provided, the system will look for the first
0246: application and use its namespace. If no applications exist, the namespace will be completely ignored.
0247: */
0248: @SuppressWarnings("unchecked")
0249: public void getNamespace(
0250: org.directwebremoting.proxy.Callback<String> callback) {
0251: ScriptBuffer script = new ScriptBuffer();
0252: String callbackPrefix = "";
0253:
0254: if (callback != null) {
0255: callbackPrefix = "var reply = ";
0256: }
0257:
0258: script.appendCall(callbackPrefix + getContextPath()
0259: + "getNamespace");
0260:
0261: if (callback != null) {
0262: String key = org.directwebremoting.extend.CallbackHelper
0263: .saveCallback(callback, String.class);
0264: script
0265: .appendCall("__System.activateCallback", key,
0266: "reply");
0267: }
0268:
0269: getScriptProxy().addScript(script);
0270: }
0271:
0272: /**
0273: * Returns the server that this service runs in, as set by the setNamespace() method.
0274: */
0275: @SuppressWarnings("unchecked")
0276: public jsx3.app.Server getServer() {
0277: String extension = "getServer().";
0278: try {
0279: java.lang.reflect.Constructor<jsx3.app.Server> ctor = jsx3.app.Server.class
0280: .getConstructor(Context.class, String.class,
0281: ScriptProxy.class);
0282: return ctor.newInstance(this , extension, getScriptProxy());
0283: } catch (Exception ex) {
0284: throw new IllegalArgumentException("Unsupported type: "
0285: + jsx3.app.Server.class.getName());
0286: }
0287: }
0288:
0289: /**
0290: * Sets the namespace for the server/project to run the service instance within.
0291: * @param namespace the server (preferred) or the namespace of the server.
0292: * @return this object
0293: */
0294: public jsx3.net.Service setNamespace(jsx3.app.Server namespace) {
0295: ScriptBuffer script = new ScriptBuffer();
0296: script.appendCall(getContextPath() + "setNamespace", namespace);
0297: getScriptProxy().addScript(script);
0298: return this ;
0299: }
0300:
0301: /**
0302: * Sets the namespace for the server/project to run the service instance within.
0303: * @param namespace the server (preferred) or the namespace of the server.
0304: * @return this object
0305: */
0306: public jsx3.net.Service setNamespace(String namespace) {
0307: ScriptBuffer script = new ScriptBuffer();
0308: script.appendCall(getContextPath() + "setNamespace", namespace);
0309: getScriptProxy().addScript(script);
0310: return this ;
0311: }
0312:
0313: /**
0314: * Gets XPath address for the node in the outbound stub document to which to append the generated message.
0315: * @param callback Valid XSL path
0316: */
0317: @SuppressWarnings("unchecked")
0318: public void getOutboundStubPath(
0319: org.directwebremoting.proxy.Callback<String> callback) {
0320: ScriptBuffer script = new ScriptBuffer();
0321: String callbackPrefix = "";
0322:
0323: if (callback != null) {
0324: callbackPrefix = "var reply = ";
0325: }
0326:
0327: script.appendCall(callbackPrefix + getContextPath()
0328: + "getOutboundStubPath");
0329:
0330: if (callback != null) {
0331: String key = org.directwebremoting.extend.CallbackHelper
0332: .saveCallback(callback, String.class);
0333: script
0334: .appendCall("__System.activateCallback", key,
0335: "reply");
0336: }
0337:
0338: getScriptProxy().addScript(script);
0339: }
0340:
0341: /**
0342: * Sets XPath address for the node in the outbound stub document to which to append the generated message.
0343: Overrides the static setting in the rules file.
0344: * @param strPath Valid XSL path. For example, <code>/SOAP-ENV:Envelope/SOAP-ENV:Body</code>
0345: * @return reference to self
0346: */
0347: public jsx3.net.Service setOutboundStubPath(String strPath) {
0348: ScriptBuffer script = new ScriptBuffer();
0349: script.appendCall(getContextPath() + "setOutboundStubPath",
0350: strPath);
0351: getScriptProxy().addScript(script);
0352: return this ;
0353: }
0354:
0355: /**
0356: * Gets the URL for a "typical", XML-formatted server resonse document. This document is then used when the project is
0357: run in static mode (as defined by the Project Deployment Options).
0358: */
0359: @SuppressWarnings("unchecked")
0360: public void getInboundURL(
0361: org.directwebremoting.proxy.Callback<String> callback) {
0362: ScriptBuffer script = new ScriptBuffer();
0363: String callbackPrefix = "";
0364:
0365: if (callback != null) {
0366: callbackPrefix = "var reply = ";
0367: }
0368:
0369: script.appendCall(callbackPrefix + getContextPath()
0370: + "getInboundURL");
0371:
0372: if (callback != null) {
0373: String key = org.directwebremoting.extend.CallbackHelper
0374: .saveCallback(callback, String.class);
0375: script
0376: .appendCall("__System.activateCallback", key,
0377: "reply");
0378: }
0379:
0380: getScriptProxy().addScript(script);
0381: }
0382:
0383: /**
0384: * Sets the URL for a "typical", XML-formatted server resonse document. This document is then used when the project is
0385: run in static mode (as defined by the Project Settings dialog). Overrides the static setting in the rules file.
0386: * @param strInboundURL Alternate URL for the "typical" Service response. Note that this URL will be resolved
0387: relative to the context server. For example, if the project directory for the context server is 'test',
0388: then the following inputs (all of which are valid) are equivalent: <code>jsxapp://test/xml/typical.xml</code>,
0389: <b>and</b> <code>xml/typical.xml</code>, <b>and</b> <code>JSXAPPS/test/xml/typical.xml</code>
0390: * @return reference to self
0391: */
0392: public jsx3.net.Service setInboundURL(String strInboundURL) {
0393: ScriptBuffer script = new ScriptBuffer();
0394: script.appendCall(getContextPath() + "setInboundURL",
0395: strInboundURL);
0396: getScriptProxy().addScript(script);
0397: return this ;
0398: }
0399:
0400: /**
0401: * Gets URL for a 'typical' XML-formatted request document to send to the server; when this is set, the mapper does not even attempt to generate a document. Instead, this document is sent directly to the server without any processing. Useful for testing requests that never change
0402: */
0403: @SuppressWarnings("unchecked")
0404: public void getOutboundURL(
0405: org.directwebremoting.proxy.Callback<String> callback) {
0406: ScriptBuffer script = new ScriptBuffer();
0407: String callbackPrefix = "";
0408:
0409: if (callback != null) {
0410: callbackPrefix = "var reply = ";
0411: }
0412:
0413: script.appendCall(callbackPrefix + getContextPath()
0414: + "getOutboundURL");
0415:
0416: if (callback != null) {
0417: String key = org.directwebremoting.extend.CallbackHelper
0418: .saveCallback(callback, String.class);
0419: script
0420: .appendCall("__System.activateCallback", key,
0421: "reply");
0422: }
0423:
0424: getScriptProxy().addScript(script);
0425: }
0426:
0427: /**
0428: * Sets the URL for a static XML-formatted request document to send to the Service. Note that when this is set, the mapper does not even
0429: attempt to generate a request document via the rules file. Instead, the static request document is sent directly to the remote Service
0430: without any processing. This is useful for requests that never change or as a means to test whether a Service is working, using a known, valid input.
0431: * @param strOutboundURL Alternate URL for the static request to send. Note that this URL will be resolved relative
0432: to the context server. For example, if the project directory for the context server is 'test', then the following inputs
0433: (all of which are valid) are equivalent: <code>jsxapp://test/xml/typical.xml</code>, <b>and</b> <code>xml/typical.xml</code>,
0434: <b>and</b> <code>JSXAPPS/test/xml/typical.xml</code>
0435: * @return reference to self
0436: */
0437: public jsx3.net.Service setOutboundURL(String strOutboundURL) {
0438: ScriptBuffer script = new ScriptBuffer();
0439: script.appendCall(getContextPath() + "setOutboundURL",
0440: strOutboundURL);
0441: getScriptProxy().addScript(script);
0442: return this ;
0443: }
0444:
0445: /**
0446: * Gets the name of the operation to use within a multi-operation rules file. Note: Rules created via a WSDL often have multiple named operations. Rules files generated without a WSDL contain no named operations, and instead use a single transaction.
0447: */
0448: @SuppressWarnings("unchecked")
0449: public void getOperationName(
0450: org.directwebremoting.proxy.Callback<String> callback) {
0451: ScriptBuffer script = new ScriptBuffer();
0452: String callbackPrefix = "";
0453:
0454: if (callback != null) {
0455: callbackPrefix = "var reply = ";
0456: }
0457:
0458: script.appendCall(callbackPrefix + getContextPath()
0459: + "getOperationName");
0460:
0461: if (callback != null) {
0462: String key = org.directwebremoting.extend.CallbackHelper
0463: .saveCallback(callback, String.class);
0464: script
0465: .appendCall("__System.activateCallback", key,
0466: "reply");
0467: }
0468:
0469: getScriptProxy().addScript(script);
0470: }
0471:
0472: /**
0473: * Sets the name of the operation to use within a multi-operation rules file. Note: Rules created via a WSDL often have multiple operations
0474: * @param strOperationName operation name
0475: * @return reference to self
0476: */
0477: public jsx3.net.Service setOperationName(String strOperationName) {
0478: ScriptBuffer script = new ScriptBuffer();
0479: script.appendCall(getContextPath() + "setOperationName",
0480: strOperationName);
0481: getScriptProxy().addScript(script);
0482: return this ;
0483: }
0484:
0485: /**
0486: * Returns the rules document used by the Service instance (a CXF document)
0487: */
0488: @SuppressWarnings("unchecked")
0489: public jsx3.xml.CdfDocument getRulesXML() {
0490: String extension = "getRulesXML().";
0491: try {
0492: java.lang.reflect.Constructor<jsx3.xml.CdfDocument> ctor = jsx3.xml.CdfDocument.class
0493: .getConstructor(Context.class, String.class,
0494: ScriptProxy.class);
0495: return ctor.newInstance(this , extension, getScriptProxy());
0496: } catch (Exception ex) {
0497: throw new IllegalArgumentException("Unsupported type: "
0498: + jsx3.xml.CdfDocument.class.getName());
0499: }
0500: }
0501:
0502: /**
0503: * Returns the rules document used by the Service instance (a CXF document)
0504: * @param returnType The expected return type
0505: */
0506: @SuppressWarnings("unchecked")
0507: public <T> T getRulesXML(Class<T> returnType) {
0508: String extension = "getRulesXML().";
0509: try {
0510: java.lang.reflect.Constructor<T> ctor = returnType
0511: .getConstructor(Context.class, String.class,
0512: ScriptProxy.class);
0513: return ctor.newInstance(this , extension, getScriptProxy());
0514: } catch (Exception ex) {
0515: throw new IllegalArgumentException(
0516: "Unsupported return type: " + returnType.getName());
0517: }
0518: }
0519:
0520: /**
0521: * Dereferences the parsed rules tree (a jsx3.xml.Document instance) managed by this Service instance, forcing a reload of the document from disk the next time the rules document is requested
0522: * @return reference to self
0523: */
0524: @SuppressWarnings("unchecked")
0525: public jsx3.net.Service resetRulesTree() {
0526: String extension = "resetRulesTree().";
0527: try {
0528: java.lang.reflect.Constructor<jsx3.net.Service> ctor = jsx3.net.Service.class
0529: .getConstructor(Context.class, String.class,
0530: ScriptProxy.class);
0531: return ctor.newInstance(this , extension, getScriptProxy());
0532: } catch (Exception ex) {
0533: throw new IllegalArgumentException("Unsupported type: "
0534: + jsx3.net.Service.class.getName());
0535: }
0536: }
0537:
0538: /**
0539: * Gets user name to send as part of the http request (for servers requiring http authentication)
0540: */
0541: @SuppressWarnings("unchecked")
0542: public void getUserName(
0543: org.directwebremoting.proxy.Callback<String> callback) {
0544: ScriptBuffer script = new ScriptBuffer();
0545: String callbackPrefix = "";
0546:
0547: if (callback != null) {
0548: callbackPrefix = "var reply = ";
0549: }
0550:
0551: script.appendCall(callbackPrefix + getContextPath()
0552: + "getUserName");
0553:
0554: if (callback != null) {
0555: String key = org.directwebremoting.extend.CallbackHelper
0556: .saveCallback(callback, String.class);
0557: script
0558: .appendCall("__System.activateCallback", key,
0559: "reply");
0560: }
0561:
0562: getScriptProxy().addScript(script);
0563: }
0564:
0565: /**
0566: * Sets the user name to send with the posting (for those sites requiring http authentication)
0567: * @param strName user name
0568: * @return reference to self
0569: */
0570: public jsx3.net.Service setUserName(String strName) {
0571: ScriptBuffer script = new ScriptBuffer();
0572: script.appendCall(getContextPath() + "setUserName", strName);
0573: getScriptProxy().addScript(script);
0574: return this ;
0575: }
0576:
0577: /**
0578: * Gets password to send as part of the http request (for servers requiring http authentication)
0579: */
0580: @SuppressWarnings("unchecked")
0581: public void getUserPass(
0582: org.directwebremoting.proxy.Callback<String> callback) {
0583: ScriptBuffer script = new ScriptBuffer();
0584: String callbackPrefix = "";
0585:
0586: if (callback != null) {
0587: callbackPrefix = "var reply = ";
0588: }
0589:
0590: script.appendCall(callbackPrefix + getContextPath()
0591: + "getUserPass");
0592:
0593: if (callback != null) {
0594: String key = org.directwebremoting.extend.CallbackHelper
0595: .saveCallback(callback, String.class);
0596: script
0597: .appendCall("__System.activateCallback", key,
0598: "reply");
0599: }
0600:
0601: getScriptProxy().addScript(script);
0602: }
0603:
0604: /**
0605: * Sets the password to send with the posting (for those sites requiring http authentication)
0606: * @param strPass password for user
0607: * @return reference to self
0608: */
0609: public jsx3.net.Service setUserPass(String strPass) {
0610: ScriptBuffer script = new ScriptBuffer();
0611: script.appendCall(getContextPath() + "setUserPass", strPass);
0612: getScriptProxy().addScript(script);
0613: return this ;
0614: }
0615:
0616: /**
0617: * Gets the jsx3.net.HttpRequest instance that performs the transaction with the remote service (the transport object for the message).
0618: */
0619: @SuppressWarnings("unchecked")
0620: public jsx3.net.Request getRequest() {
0621: String extension = "getRequest().";
0622: try {
0623: java.lang.reflect.Constructor<jsx3.net.Request> ctor = jsx3.net.Request.class
0624: .getConstructor(Context.class, String.class,
0625: ScriptProxy.class);
0626: return ctor.newInstance(this , extension, getScriptProxy());
0627: } catch (Exception ex) {
0628: throw new IllegalArgumentException("Unsupported type: "
0629: + jsx3.net.Request.class.getName());
0630: }
0631: }
0632:
0633: /**
0634: * Call this method after the service has responded to get a parsed instance of the server's XML response
0635: */
0636: @SuppressWarnings("unchecked")
0637: public jsx3.xml.CdfDocument getInboundDocument() {
0638: String extension = "getInboundDocument().";
0639: try {
0640: java.lang.reflect.Constructor<jsx3.xml.CdfDocument> ctor = jsx3.xml.CdfDocument.class
0641: .getConstructor(Context.class, String.class,
0642: ScriptProxy.class);
0643: return ctor.newInstance(this , extension, getScriptProxy());
0644: } catch (Exception ex) {
0645: throw new IllegalArgumentException("Unsupported type: "
0646: + jsx3.xml.CdfDocument.class.getName());
0647: }
0648: }
0649:
0650: /**
0651: * Call this method after the service has responded to get a parsed instance of the server's XML response
0652: * @param returnType The expected return type
0653: */
0654: @SuppressWarnings("unchecked")
0655: public <T> T getInboundDocument(Class<T> returnType) {
0656: String extension = "getInboundDocument().";
0657: try {
0658: java.lang.reflect.Constructor<T> ctor = returnType
0659: .getConstructor(Context.class, String.class,
0660: ScriptProxy.class);
0661: return ctor.newInstance(this , extension, getScriptProxy());
0662: } catch (Exception ex) {
0663: throw new IllegalArgumentException(
0664: "Unsupported return type: " + returnType.getName());
0665: }
0666: }
0667:
0668: /**
0669: * Sets a parsed instance of the response document as soon as it returns from the server returned from the service; otherwise null
0670: * @param objXML
0671: */
0672: public void setInboundDocument(jsx3.xml.CdfDocument objXML) {
0673: ScriptBuffer script = new ScriptBuffer();
0674: script.appendCall(getContextPath() + "setInboundDocument",
0675: objXML);
0676: getScriptProxy().addScript(script);
0677: }
0678:
0679: /**
0680: * Call this method after 'doCall' has been called to get a parsed instance of the request document--what was actually sent to the remote service
0681: */
0682: @SuppressWarnings("unchecked")
0683: public jsx3.xml.CdfDocument getOutboundDocument() {
0684: String extension = "getOutboundDocument().";
0685: try {
0686: java.lang.reflect.Constructor<jsx3.xml.CdfDocument> ctor = jsx3.xml.CdfDocument.class
0687: .getConstructor(Context.class, String.class,
0688: ScriptProxy.class);
0689: return ctor.newInstance(this , extension, getScriptProxy());
0690: } catch (Exception ex) {
0691: throw new IllegalArgumentException("Unsupported type: "
0692: + jsx3.xml.CdfDocument.class.getName());
0693: }
0694: }
0695:
0696: /**
0697: * Call this method after 'doCall' has been called to get a parsed instance of the request document--what was actually sent to the remote service
0698: * @param returnType The expected return type
0699: */
0700: @SuppressWarnings("unchecked")
0701: public <T> T getOutboundDocument(Class<T> returnType) {
0702: String extension = "getOutboundDocument().";
0703: try {
0704: java.lang.reflect.Constructor<T> ctor = returnType
0705: .getConstructor(Context.class, String.class,
0706: ScriptProxy.class);
0707: return ctor.newInstance(this , extension, getScriptProxy());
0708: } catch (Exception ex) {
0709: throw new IllegalArgumentException(
0710: "Unsupported return type: " + returnType.getName());
0711: }
0712: }
0713:
0714: /**
0715: * Gets the URL for the service endpoint where the request will be sent
0716: */
0717: @SuppressWarnings("unchecked")
0718: public void getEndpointURL(
0719: org.directwebremoting.proxy.Callback<String> callback) {
0720: ScriptBuffer script = new ScriptBuffer();
0721: String callbackPrefix = "";
0722:
0723: if (callback != null) {
0724: callbackPrefix = "var reply = ";
0725: }
0726:
0727: script.appendCall(callbackPrefix + getContextPath()
0728: + "getEndpointURL");
0729:
0730: if (callback != null) {
0731: String key = org.directwebremoting.extend.CallbackHelper
0732: .saveCallback(callback, String.class);
0733: script
0734: .appendCall("__System.activateCallback", key,
0735: "reply");
0736: }
0737:
0738: getScriptProxy().addScript(script);
0739: }
0740:
0741: /**
0742: * Sets the URL for the service endpoint where the request will be sent. Overrides the endpoint specified in the rules file.
0743: * @param strAlternateURL
0744: * @return reference to self
0745: */
0746: public jsx3.net.Service setEndpointURL(String strAlternateURL) {
0747: ScriptBuffer script = new ScriptBuffer();
0748: script.appendCall(getContextPath() + "setEndpointURL",
0749: strAlternateURL);
0750: getScriptProxy().addScript(script);
0751: return this ;
0752: }
0753:
0754: /**
0755: * Gets the method for the request. Default is POST
0756: * @param callback one of: GET or POST
0757: */
0758: @SuppressWarnings("unchecked")
0759: public void getMethod(
0760: org.directwebremoting.proxy.Callback<String> callback) {
0761: ScriptBuffer script = new ScriptBuffer();
0762: String callbackPrefix = "";
0763:
0764: if (callback != null) {
0765: callbackPrefix = "var reply = ";
0766: }
0767:
0768: script.appendCall(callbackPrefix + getContextPath()
0769: + "getMethod");
0770:
0771: if (callback != null) {
0772: String key = org.directwebremoting.extend.CallbackHelper
0773: .saveCallback(callback, String.class);
0774: script
0775: .appendCall("__System.activateCallback", key,
0776: "reply");
0777: }
0778:
0779: getScriptProxy().addScript(script);
0780: }
0781:
0782: /**
0783: * Sets the method for the request different than the one described in the rules file.
0784: * @param METHOD one of: GET or POST
0785: */
0786: public void setMethod(String METHOD) {
0787: ScriptBuffer script = new ScriptBuffer();
0788: script.appendCall(getContextPath() + "setMethod", METHOD);
0789: getScriptProxy().addScript(script);
0790: }
0791:
0792: /**
0793: * Generates the request message (if applicable) and sends to the remote service.
0794: * @param bCancelIfInvalid If true, the remote service will not be called if the message does not pass validation while being generated.
0795: * @param callback true if the message passed all validation rules while being generated.
0796: */
0797: @SuppressWarnings("unchecked")
0798: public void doCall(boolean bCancelIfInvalid,
0799: org.directwebremoting.proxy.Callback<Boolean> callback) {
0800: ScriptBuffer script = new ScriptBuffer();
0801: String callbackPrefix = "";
0802:
0803: if (callback != null) {
0804: callbackPrefix = "var reply = ";
0805: }
0806:
0807: script.appendCall(callbackPrefix + getContextPath() + "doCall",
0808: bCancelIfInvalid);
0809:
0810: if (callback != null) {
0811: String key = org.directwebremoting.extend.CallbackHelper
0812: .saveCallback(callback, Boolean.class);
0813: script
0814: .appendCall("__System.activateCallback", key,
0815: "reply");
0816: }
0817:
0818: getScriptProxy().addScript(script);
0819: }
0820:
0821: /**
0822: * Sets an HTTP Request header on the request. Set before calling, doCall()
0823: * @param strName name for header parameter
0824: * @param strValue value for the header parameter
0825: */
0826: public void setRequestHeader(String strName, String strValue) {
0827: ScriptBuffer script = new ScriptBuffer();
0828: script.appendCall(getContextPath() + "setRequestHeader",
0829: strName, strValue);
0830: getScriptProxy().addScript(script);
0831: }
0832:
0833: /**
0834: * Specifies how long to wait for the service to respond before cancelling the call. Subscribes to the ON_TIMEOUT event
0835: * @param intTimeout number of milliseconds to wait befor publishing the ON_TIMEOUT event.
0836: * @param objHandler if an object, the instance to notify of events (objFunction is required); if a string, the JSX id of the instance to notify of events (objFunction is required), must exist in the same Server; if a function, the function to call to notify of events (objFunction ignored)
0837: * @param objFunction if objHandler is a string or object then the function to call on that instance. either a function or a string that is the name of a method of the instance
0838: * @return reference to self
0839: */
0840: public jsx3.net.Service setTimeout(int intTimeout,
0841: jsx3.lang.Object objHandler, String objFunction) {
0842: ScriptBuffer script = new ScriptBuffer();
0843: script.appendCall(getContextPath() + "setTimeout", intTimeout,
0844: objHandler, objFunction);
0845: getScriptProxy().addScript(script);
0846: return this ;
0847: }
0848:
0849: /**
0850: * Specifies how long to wait for the service to respond before cancelling the call. Subscribes to the ON_TIMEOUT event
0851: * @param intTimeout number of milliseconds to wait befor publishing the ON_TIMEOUT event.
0852: * @param objHandler if an object, the instance to notify of events (objFunction is required); if a string, the JSX id of the instance to notify of events (objFunction is required), must exist in the same Server; if a function, the function to call to notify of events (objFunction ignored)
0853: * @param objFunction if objHandler is a string or object then the function to call on that instance. either a function or a string that is the name of a method of the instance
0854: * @return reference to self
0855: */
0856: public jsx3.net.Service setTimeout(int intTimeout,
0857: org.directwebremoting.proxy.CodeBlock objHandler,
0858: org.directwebremoting.proxy.CodeBlock objFunction) {
0859: ScriptBuffer script = new ScriptBuffer();
0860: script.appendCall(getContextPath() + "setTimeout", intTimeout,
0861: objHandler, objFunction);
0862: getScriptProxy().addScript(script);
0863: return this ;
0864: }
0865:
0866: /**
0867: * Specifies how long to wait for the service to respond before cancelling the call. Subscribes to the ON_TIMEOUT event
0868: * @param intTimeout number of milliseconds to wait befor publishing the ON_TIMEOUT event.
0869: * @param objHandler if an object, the instance to notify of events (objFunction is required); if a string, the JSX id of the instance to notify of events (objFunction is required), must exist in the same Server; if a function, the function to call to notify of events (objFunction ignored)
0870: * @param objFunction if objHandler is a string or object then the function to call on that instance. either a function or a string that is the name of a method of the instance
0871: * @return reference to self
0872: */
0873: public jsx3.net.Service setTimeout(int intTimeout,
0874: String objHandler,
0875: org.directwebremoting.proxy.CodeBlock objFunction) {
0876: ScriptBuffer script = new ScriptBuffer();
0877: script.appendCall(getContextPath() + "setTimeout", intTimeout,
0878: objHandler, objFunction);
0879: getScriptProxy().addScript(script);
0880: return this ;
0881: }
0882:
0883: /**
0884: * Specifies how long to wait for the service to respond before cancelling the call. Subscribes to the ON_TIMEOUT event
0885: * @param intTimeout number of milliseconds to wait befor publishing the ON_TIMEOUT event.
0886: * @param objHandler if an object, the instance to notify of events (objFunction is required); if a string, the JSX id of the instance to notify of events (objFunction is required), must exist in the same Server; if a function, the function to call to notify of events (objFunction ignored)
0887: * @param objFunction if objHandler is a string or object then the function to call on that instance. either a function or a string that is the name of a method of the instance
0888: * @return reference to self
0889: */
0890: public jsx3.net.Service setTimeout(int intTimeout,
0891: org.directwebremoting.proxy.CodeBlock objHandler,
0892: String objFunction) {
0893: ScriptBuffer script = new ScriptBuffer();
0894: script.appendCall(getContextPath() + "setTimeout", intTimeout,
0895: objHandler, objFunction);
0896: getScriptProxy().addScript(script);
0897: return this ;
0898: }
0899:
0900: /**
0901: * Specifies how long to wait for the service to respond before cancelling the call. Subscribes to the ON_TIMEOUT event
0902: * @param intTimeout number of milliseconds to wait befor publishing the ON_TIMEOUT event.
0903: * @param objHandler if an object, the instance to notify of events (objFunction is required); if a string, the JSX id of the instance to notify of events (objFunction is required), must exist in the same Server; if a function, the function to call to notify of events (objFunction ignored)
0904: * @param objFunction if objHandler is a string or object then the function to call on that instance. either a function or a string that is the name of a method of the instance
0905: * @return reference to self
0906: */
0907: public jsx3.net.Service setTimeout(int intTimeout,
0908: jsx3.lang.Object objHandler,
0909: org.directwebremoting.proxy.CodeBlock objFunction) {
0910: ScriptBuffer script = new ScriptBuffer();
0911: script.appendCall(getContextPath() + "setTimeout", intTimeout,
0912: objHandler, objFunction);
0913: getScriptProxy().addScript(script);
0914: return this ;
0915: }
0916:
0917: /**
0918: * Specifies how long to wait for the service to respond before cancelling the call. Subscribes to the ON_TIMEOUT event
0919: * @param intTimeout number of milliseconds to wait befor publishing the ON_TIMEOUT event.
0920: * @param objHandler if an object, the instance to notify of events (objFunction is required); if a string, the JSX id of the instance to notify of events (objFunction is required), must exist in the same Server; if a function, the function to call to notify of events (objFunction ignored)
0921: * @param objFunction if objHandler is a string or object then the function to call on that instance. either a function or a string that is the name of a method of the instance
0922: * @return reference to self
0923: */
0924: public jsx3.net.Service setTimeout(int intTimeout,
0925: String objHandler, String objFunction) {
0926: ScriptBuffer script = new ScriptBuffer();
0927: script.appendCall(getContextPath() + "setTimeout", intTimeout,
0928: objHandler, objFunction);
0929: getScriptProxy().addScript(script);
0930: return this ;
0931: }
0932:
0933: /**
0934: * Resets the rules tree to default state (with all 'skip' flags removed) from those rules that were skipped during the previous transaction
0935: * @return reference to self
0936: */
0937: @SuppressWarnings("unchecked")
0938: public jsx3.net.Service resetRules() {
0939: String extension = "resetRules().";
0940: try {
0941: java.lang.reflect.Constructor<jsx3.net.Service> ctor = jsx3.net.Service.class
0942: .getConstructor(Context.class, String.class,
0943: ScriptProxy.class);
0944: return ctor.newInstance(this , extension, getScriptProxy());
0945: } catch (Exception ex) {
0946: throw new IllegalArgumentException("Unsupported type: "
0947: + jsx3.net.Service.class.getName());
0948: }
0949: }
0950:
0951: /**
0952: * Gets the request message specific to the MESSAGETYPE (input, output, fault). Typically only used for input (outbound) messages, but can be used for simulating a server response for output and fault (in the case of a SOAP transaction, fault) messages
0953: * @param MESSAGETYPE one of: input, output, or fault. If this value is provided, the server will generate test data for all nodes lacking a mapped or scripted value
0954: * @param strShellURL relative URL to message shell to use as the starting container to put content into. Note that calling <code>setOutboundStubURL</code> or <code>setOutboundStubDocument</code> in conjunction with <code>setOutboundStubPath</code>
0955: are preferred to passing this parameter, since they provide much greater control. Also note that this value is stored statically in the rules document when the rules document is first created via the XML Mapping Utility.
0956: */
0957: @SuppressWarnings("unchecked")
0958: public jsx3.xml.CdfDocument getServiceMessage(String MESSAGETYPE,
0959: String strShellURL) {
0960: String extension = "getServiceMessage(\"" + MESSAGETYPE
0961: + "\", \"" + strShellURL + "\").";
0962: try {
0963: java.lang.reflect.Constructor<jsx3.xml.CdfDocument> ctor = jsx3.xml.CdfDocument.class
0964: .getConstructor(Context.class, String.class,
0965: ScriptProxy.class);
0966: return ctor.newInstance(this , extension, getScriptProxy());
0967: } catch (Exception ex) {
0968: throw new IllegalArgumentException("Unsupported type: "
0969: + jsx3.xml.CdfDocument.class.getName());
0970: }
0971: }
0972:
0973: /**
0974: * Gets the request message specific to the MESSAGETYPE (input, output, fault). Typically only used for input (outbound) messages, but can be used for simulating a server response for output and fault (in the case of a SOAP transaction, fault) messages
0975: * @param MESSAGETYPE one of: input, output, or fault. If this value is provided, the server will generate test data for all nodes lacking a mapped or scripted value
0976: * @param strShellURL relative URL to message shell to use as the starting container to put content into. Note that calling <code>setOutboundStubURL</code> or <code>setOutboundStubDocument</code> in conjunction with <code>setOutboundStubPath</code>
0977: are preferred to passing this parameter, since they provide much greater control. Also note that this value is stored statically in the rules document when the rules document is first created via the XML Mapping Utility.
0978: * @param returnType The expected return type
0979: */
0980: @SuppressWarnings("unchecked")
0981: public <T> T getServiceMessage(String MESSAGETYPE,
0982: String strShellURL, Class<T> returnType) {
0983: String extension = "getServiceMessage(\"" + MESSAGETYPE
0984: + "\", \"" + strShellURL + "\").";
0985: try {
0986: java.lang.reflect.Constructor<T> ctor = returnType
0987: .getConstructor(Context.class, String.class,
0988: ScriptProxy.class);
0989: return ctor.newInstance(this , extension, getScriptProxy());
0990: } catch (Exception ex) {
0991: throw new IllegalArgumentException(
0992: "Unsupported return type: " + returnType.getName());
0993: }
0994: }
0995:
0996: /**
0997: * Gets the HTTP response code (i.e., 200, 404, 500, etc). This will be the response code provided by the bound jsx3.net.Request instance
0998: used for the transport. However, if setStatus has been called on the Service instance, the value supplied by the developer will be used instead.
0999: */
1000: @SuppressWarnings("unchecked")
1001: public void getStatus(
1002: org.directwebremoting.proxy.Callback<Integer> callback) {
1003: ScriptBuffer script = new ScriptBuffer();
1004: String callbackPrefix = "";
1005:
1006: if (callback != null) {
1007: callbackPrefix = "var reply = ";
1008: }
1009:
1010: script.appendCall(callbackPrefix + getContextPath()
1011: + "getStatus");
1012:
1013: if (callback != null) {
1014: String key = org.directwebremoting.extend.CallbackHelper
1015: .saveCallback(callback, Integer.class);
1016: script
1017: .appendCall("__System.activateCallback", key,
1018: "reply");
1019: }
1020:
1021: getScriptProxy().addScript(script);
1022: }
1023:
1024: /**
1025: * Sets the HTTP response code (i.e., 200, 404, 500, etc). Typically, the Service instance determines this value by querying the bound request instance
1026: (jsx3.net.Request) returned by the method, [service_instance].getRequest(). However, calling this method will override
1027: normal operation by forcing a valid/invalid state that affects methdods relying on the HTTP status
1028: such as doInboundMap. This is particularly useful for SOAP services that provide alternate processing
1029: instructions and mappings when a Fault occurs as well as when running tests in Static mode.
1030: * @param intStatus
1031: */
1032: public void setStatus(int intStatus) {
1033: ScriptBuffer script = new ScriptBuffer();
1034: script.appendCall(getContextPath() + "setStatus", intStatus);
1035: getScriptProxy().addScript(script);
1036: }
1037:
1038: /**
1039: * Gets the mode (static jsx3.Boolean.FALSE or live jsx3.Boolean.TRUE).
1040: */
1041: @SuppressWarnings("unchecked")
1042: public void getMode(
1043: org.directwebremoting.proxy.Callback<Boolean> callback) {
1044: ScriptBuffer script = new ScriptBuffer();
1045: String callbackPrefix = "";
1046:
1047: if (callback != null) {
1048: callbackPrefix = "var reply = ";
1049: }
1050:
1051: script
1052: .appendCall(callbackPrefix + getContextPath()
1053: + "getMode");
1054:
1055: if (callback != null) {
1056: String key = org.directwebremoting.extend.CallbackHelper
1057: .saveCallback(callback, Boolean.class);
1058: script
1059: .appendCall("__System.activateCallback", key,
1060: "reply");
1061: }
1062:
1063: getScriptProxy().addScript(script);
1064: }
1065:
1066: /**
1067: * Sets the mode (static jsx3.Boolean.FALSE or live jsx3.Boolean.TRUE). Overrides the default setting for the context Server
1068: instance within which this Service instnace is running. (NOTE: This setting is accessible at the server level via the Project Settings dialog.)
1069: Setting this value to jsx3.Boolean.FALSE, forces a test document
1070: to be used to simulate a "typical" server response, instead of actually sending a request to a remote service. This is useful when setting up
1071: test environments as well as providing "live" interactions when the remote server may not be available.
1072: * @param MODE
1073: */
1074: public void setMode(Boolean MODE) {
1075: ScriptBuffer script = new ScriptBuffer();
1076: script.appendCall(getContextPath() + "setMode", MODE);
1077: getScriptProxy().addScript(script);
1078: }
1079:
1080: /**
1081: * Applies all inbound mappings, using the server response document as the source for the operation. Although this method is called once automatically, it can be called at any time to reapply the mapping rules.
1082: Example usage:
1083: var oService = new jsx3.net.Service();
1084: oService.setInboundDocument(objSomeDocumentIManuallyWantToLoad);
1085: oService.doInboundMap();
1086: */
1087: public void doInboundMap() {
1088: ScriptBuffer script = new ScriptBuffer();
1089: script.appendCall(getContextPath() + "doInboundMap");
1090: getScriptProxy().addScript(script);
1091: }
1092:
1093: /**
1094: * Compiles the CXF rules for this service instance to an equivalent XSLT document. This enables
1095: much faster performance than using the DOM-based iterator (default) to convert the XML response
1096: document into a CDF Document type. Note that this process only supports the map types
1097: CDF Document, CDF Record, and CDF Attribute. Only one CDF Document
1098: can be declared per Operation. Otherwise the compilation will fail.
1099: All other mapping types will be ignored and will not be converted into an XSLT equivalent. Also note
1100: that the order of a set of sibling mapping rules does not proscribe proper processing by way of
1101: sequence. This means that any order of sibling mapping rules will result in appropriate processing, regardless of the
1102: sibling node order returned from the given service. This facilitates nested record structures in that
1103: attributes can first be applied to a given record before child elements (e.g., a 'record') are added.
1104: Stated otherwise, any rule that has a descendant rule that would created a nested 'record' node should follow
1105: all sibling mapping rules that would create an 'attribute' entity. Call this method immediately before/after doCall
1106: for best performance.
1107: * @return XSLT document
1108: */
1109: @SuppressWarnings("unchecked")
1110: public jsx3.xml.CdfDocument compile() {
1111: String extension = "compile().";
1112: try {
1113: java.lang.reflect.Constructor<jsx3.xml.CdfDocument> ctor = jsx3.xml.CdfDocument.class
1114: .getConstructor(Context.class, String.class,
1115: ScriptProxy.class);
1116: return ctor.newInstance(this , extension, getScriptProxy());
1117: } catch (Exception ex) {
1118: throw new IllegalArgumentException("Unsupported type: "
1119: + jsx3.xml.CdfDocument.class.getName());
1120: }
1121: }
1122:
1123: /**
1124: * Compiles the CXF rules for this service instance to an equivalent XSLT document. This enables
1125: much faster performance than using the DOM-based iterator (default) to convert the XML response
1126: document into a CDF Document type. Note that this process only supports the map types
1127: CDF Document, CDF Record, and CDF Attribute. Only one CDF Document
1128: can be declared per Operation. Otherwise the compilation will fail.
1129: All other mapping types will be ignored and will not be converted into an XSLT equivalent. Also note
1130: that the order of a set of sibling mapping rules does not proscribe proper processing by way of
1131: sequence. This means that any order of sibling mapping rules will result in appropriate processing, regardless of the
1132: sibling node order returned from the given service. This facilitates nested record structures in that
1133: attributes can first be applied to a given record before child elements (e.g., a 'record') are added.
1134: Stated otherwise, any rule that has a descendant rule that would created a nested 'record' node should follow
1135: all sibling mapping rules that would create an 'attribute' entity. Call this method immediately before/after doCall
1136: for best performance.
1137: * @param returnType The expected return type
1138: * @return XSLT document
1139: */
1140: @SuppressWarnings("unchecked")
1141: public <T> T compile(Class<T> returnType) {
1142: String extension = "compile().";
1143: try {
1144: java.lang.reflect.Constructor<T> ctor = returnType
1145: .getConstructor(Context.class, String.class,
1146: ScriptProxy.class);
1147: return ctor.newInstance(this , extension, getScriptProxy());
1148: } catch (Exception ex) {
1149: throw new IllegalArgumentException(
1150: "Unsupported return type: " + returnType.getName());
1151: }
1152: }
1153:
1154: /**
1155: * Publishes an event to all subscribed objects.
1156: * @param objEvent the event, should have at least a field 'subject' that is the event id, another common field is 'target' (target will default to this instance)
1157: * @param callback the number of listeners to which the event was broadcast
1158: */
1159: @SuppressWarnings("unchecked")
1160: public void publish(jsx3.lang.Object objEvent,
1161: org.directwebremoting.proxy.Callback<Integer> callback) {
1162: ScriptBuffer script = new ScriptBuffer();
1163: String callbackPrefix = "";
1164:
1165: if (callback != null) {
1166: callbackPrefix = "var reply = ";
1167: }
1168:
1169: script
1170: .appendCall(callbackPrefix + getContextPath()
1171: + "publish", objEvent);
1172:
1173: if (callback != null) {
1174: String key = org.directwebremoting.extend.CallbackHelper
1175: .saveCallback(callback, Integer.class);
1176: script
1177: .appendCall("__System.activateCallback", key,
1178: "reply");
1179: }
1180:
1181: getScriptProxy().addScript(script);
1182: }
1183:
1184: /**
1185: * Subscribes an object or function to a type of event published by this object.
1186:
1187: As of version 3.4 a string value for objHandler is deprecated.
1188: * @param strEventId the event type(s).
1189: * @param objHandler if an object, the instance to notify of events (objFunction is required); if a string, the JSX id of the instance to notify of events (objFunction is required), must exist in the same Server; if a function, the function to call to notify of events (objFunction ignored)
1190: * @param objFunction if objHandler is a string or object then the function to call on that instance. either a function or a string that is the name of a method of the instance
1191: */
1192: public void subscribe(Object[] strEventId,
1193: jsx3.lang.Object objHandler,
1194: org.directwebremoting.proxy.CodeBlock objFunction) {
1195: ScriptBuffer script = new ScriptBuffer();
1196: script.appendCall(getContextPath() + "subscribe", strEventId,
1197: objHandler, objFunction);
1198: getScriptProxy().addScript(script);
1199: }
1200:
1201: /**
1202: * Subscribes an object or function to a type of event published by this object.
1203:
1204: As of version 3.4 a string value for objHandler is deprecated.
1205: * @param strEventId the event type(s).
1206: * @param objHandler if an object, the instance to notify of events (objFunction is required); if a string, the JSX id of the instance to notify of events (objFunction is required), must exist in the same Server; if a function, the function to call to notify of events (objFunction ignored)
1207: * @param objFunction if objHandler is a string or object then the function to call on that instance. either a function or a string that is the name of a method of the instance
1208: */
1209: public void subscribe(String strEventId, String objHandler,
1210: String objFunction) {
1211: ScriptBuffer script = new ScriptBuffer();
1212: script.appendCall(getContextPath() + "subscribe", strEventId,
1213: objHandler, objFunction);
1214: getScriptProxy().addScript(script);
1215: }
1216:
1217: /**
1218: * Subscribes an object or function to a type of event published by this object.
1219:
1220: As of version 3.4 a string value for objHandler is deprecated.
1221: * @param strEventId the event type(s).
1222: * @param objHandler if an object, the instance to notify of events (objFunction is required); if a string, the JSX id of the instance to notify of events (objFunction is required), must exist in the same Server; if a function, the function to call to notify of events (objFunction ignored)
1223: * @param objFunction if objHandler is a string or object then the function to call on that instance. either a function or a string that is the name of a method of the instance
1224: */
1225: public void subscribe(String strEventId, String objHandler,
1226: org.directwebremoting.proxy.CodeBlock objFunction) {
1227: ScriptBuffer script = new ScriptBuffer();
1228: script.appendCall(getContextPath() + "subscribe", strEventId,
1229: objHandler, objFunction);
1230: getScriptProxy().addScript(script);
1231: }
1232:
1233: /**
1234: * Subscribes an object or function to a type of event published by this object.
1235:
1236: As of version 3.4 a string value for objHandler is deprecated.
1237: * @param strEventId the event type(s).
1238: * @param objHandler if an object, the instance to notify of events (objFunction is required); if a string, the JSX id of the instance to notify of events (objFunction is required), must exist in the same Server; if a function, the function to call to notify of events (objFunction ignored)
1239: * @param objFunction if objHandler is a string or object then the function to call on that instance. either a function or a string that is the name of a method of the instance
1240: */
1241: public void subscribe(Object[] strEventId, String objHandler,
1242: String objFunction) {
1243: ScriptBuffer script = new ScriptBuffer();
1244: script.appendCall(getContextPath() + "subscribe", strEventId,
1245: objHandler, objFunction);
1246: getScriptProxy().addScript(script);
1247: }
1248:
1249: /**
1250: * Subscribes an object or function to a type of event published by this object.
1251:
1252: As of version 3.4 a string value for objHandler is deprecated.
1253: * @param strEventId the event type(s).
1254: * @param objHandler if an object, the instance to notify of events (objFunction is required); if a string, the JSX id of the instance to notify of events (objFunction is required), must exist in the same Server; if a function, the function to call to notify of events (objFunction ignored)
1255: * @param objFunction if objHandler is a string or object then the function to call on that instance. either a function or a string that is the name of a method of the instance
1256: */
1257: public void subscribe(Object[] strEventId,
1258: jsx3.lang.Object objHandler, String objFunction) {
1259: ScriptBuffer script = new ScriptBuffer();
1260: script.appendCall(getContextPath() + "subscribe", strEventId,
1261: objHandler, objFunction);
1262: getScriptProxy().addScript(script);
1263: }
1264:
1265: /**
1266: * Subscribes an object or function to a type of event published by this object.
1267:
1268: As of version 3.4 a string value for objHandler is deprecated.
1269: * @param strEventId the event type(s).
1270: * @param objHandler if an object, the instance to notify of events (objFunction is required); if a string, the JSX id of the instance to notify of events (objFunction is required), must exist in the same Server; if a function, the function to call to notify of events (objFunction ignored)
1271: * @param objFunction if objHandler is a string or object then the function to call on that instance. either a function or a string that is the name of a method of the instance
1272: */
1273: public void subscribe(Object[] strEventId,
1274: org.directwebremoting.proxy.CodeBlock objHandler,
1275: org.directwebremoting.proxy.CodeBlock objFunction) {
1276: ScriptBuffer script = new ScriptBuffer();
1277: script.appendCall(getContextPath() + "subscribe", strEventId,
1278: objHandler, objFunction);
1279: getScriptProxy().addScript(script);
1280: }
1281:
1282: /**
1283: * Subscribes an object or function to a type of event published by this object.
1284:
1285: As of version 3.4 a string value for objHandler is deprecated.
1286: * @param strEventId the event type(s).
1287: * @param objHandler if an object, the instance to notify of events (objFunction is required); if a string, the JSX id of the instance to notify of events (objFunction is required), must exist in the same Server; if a function, the function to call to notify of events (objFunction ignored)
1288: * @param objFunction if objHandler is a string or object then the function to call on that instance. either a function or a string that is the name of a method of the instance
1289: */
1290: public void subscribe(String strEventId,
1291: jsx3.lang.Object objHandler, String objFunction) {
1292: ScriptBuffer script = new ScriptBuffer();
1293: script.appendCall(getContextPath() + "subscribe", strEventId,
1294: objHandler, objFunction);
1295: getScriptProxy().addScript(script);
1296: }
1297:
1298: /**
1299: * Subscribes an object or function to a type of event published by this object.
1300:
1301: As of version 3.4 a string value for objHandler is deprecated.
1302: * @param strEventId the event type(s).
1303: * @param objHandler if an object, the instance to notify of events (objFunction is required); if a string, the JSX id of the instance to notify of events (objFunction is required), must exist in the same Server; if a function, the function to call to notify of events (objFunction ignored)
1304: * @param objFunction if objHandler is a string or object then the function to call on that instance. either a function or a string that is the name of a method of the instance
1305: */
1306: public void subscribe(Object[] strEventId,
1307: org.directwebremoting.proxy.CodeBlock objHandler,
1308: String objFunction) {
1309: ScriptBuffer script = new ScriptBuffer();
1310: script.appendCall(getContextPath() + "subscribe", strEventId,
1311: objHandler, objFunction);
1312: getScriptProxy().addScript(script);
1313: }
1314:
1315: /**
1316: * Subscribes an object or function to a type of event published by this object.
1317:
1318: As of version 3.4 a string value for objHandler is deprecated.
1319: * @param strEventId the event type(s).
1320: * @param objHandler if an object, the instance to notify of events (objFunction is required); if a string, the JSX id of the instance to notify of events (objFunction is required), must exist in the same Server; if a function, the function to call to notify of events (objFunction ignored)
1321: * @param objFunction if objHandler is a string or object then the function to call on that instance. either a function or a string that is the name of a method of the instance
1322: */
1323: public void subscribe(Object[] strEventId, String objHandler,
1324: org.directwebremoting.proxy.CodeBlock objFunction) {
1325: ScriptBuffer script = new ScriptBuffer();
1326: script.appendCall(getContextPath() + "subscribe", strEventId,
1327: objHandler, objFunction);
1328: getScriptProxy().addScript(script);
1329: }
1330:
1331: /**
1332: * Subscribes an object or function to a type of event published by this object.
1333:
1334: As of version 3.4 a string value for objHandler is deprecated.
1335: * @param strEventId the event type(s).
1336: * @param objHandler if an object, the instance to notify of events (objFunction is required); if a string, the JSX id of the instance to notify of events (objFunction is required), must exist in the same Server; if a function, the function to call to notify of events (objFunction ignored)
1337: * @param objFunction if objHandler is a string or object then the function to call on that instance. either a function or a string that is the name of a method of the instance
1338: */
1339: public void subscribe(String strEventId,
1340: jsx3.lang.Object objHandler,
1341: org.directwebremoting.proxy.CodeBlock objFunction) {
1342: ScriptBuffer script = new ScriptBuffer();
1343: script.appendCall(getContextPath() + "subscribe", strEventId,
1344: objHandler, objFunction);
1345: getScriptProxy().addScript(script);
1346: }
1347:
1348: /**
1349: * Subscribes an object or function to a type of event published by this object.
1350:
1351: As of version 3.4 a string value for objHandler is deprecated.
1352: * @param strEventId the event type(s).
1353: * @param objHandler if an object, the instance to notify of events (objFunction is required); if a string, the JSX id of the instance to notify of events (objFunction is required), must exist in the same Server; if a function, the function to call to notify of events (objFunction ignored)
1354: * @param objFunction if objHandler is a string or object then the function to call on that instance. either a function or a string that is the name of a method of the instance
1355: */
1356: public void subscribe(String strEventId,
1357: org.directwebremoting.proxy.CodeBlock objHandler,
1358: String objFunction) {
1359: ScriptBuffer script = new ScriptBuffer();
1360: script.appendCall(getContextPath() + "subscribe", strEventId,
1361: objHandler, objFunction);
1362: getScriptProxy().addScript(script);
1363: }
1364:
1365: /**
1366: * Subscribes an object or function to a type of event published by this object.
1367:
1368: As of version 3.4 a string value for objHandler is deprecated.
1369: * @param strEventId the event type(s).
1370: * @param objHandler if an object, the instance to notify of events (objFunction is required); if a string, the JSX id of the instance to notify of events (objFunction is required), must exist in the same Server; if a function, the function to call to notify of events (objFunction ignored)
1371: * @param objFunction if objHandler is a string or object then the function to call on that instance. either a function or a string that is the name of a method of the instance
1372: */
1373: public void subscribe(String strEventId,
1374: org.directwebremoting.proxy.CodeBlock objHandler,
1375: org.directwebremoting.proxy.CodeBlock objFunction) {
1376: ScriptBuffer script = new ScriptBuffer();
1377: script.appendCall(getContextPath() + "subscribe", strEventId,
1378: objHandler, objFunction);
1379: getScriptProxy().addScript(script);
1380: }
1381:
1382: /**
1383: * Unsubscribe an object or function from an event published by this object.
1384:
1385: As of version 3.4 a string value for objHandler is deprecated.
1386: * @param strEventId the event type(s).
1387: * @param objHandler the value of objHandler passed to subscribe
1388: */
1389: public void unsubscribe(String strEventId,
1390: jsx3.lang.Object objHandler) {
1391: ScriptBuffer script = new ScriptBuffer();
1392: script.appendCall(getContextPath() + "unsubscribe", strEventId,
1393: objHandler);
1394: getScriptProxy().addScript(script);
1395: }
1396:
1397: /**
1398: * Unsubscribe an object or function from an event published by this object.
1399:
1400: As of version 3.4 a string value for objHandler is deprecated.
1401: * @param strEventId the event type(s).
1402: * @param objHandler the value of objHandler passed to subscribe
1403: */
1404: public void unsubscribe(Object[] strEventId,
1405: jsx3.lang.Object objHandler) {
1406: ScriptBuffer script = new ScriptBuffer();
1407: script.appendCall(getContextPath() + "unsubscribe", strEventId,
1408: objHandler);
1409: getScriptProxy().addScript(script);
1410: }
1411:
1412: /**
1413: * Unsubscribe an object or function from an event published by this object.
1414:
1415: As of version 3.4 a string value for objHandler is deprecated.
1416: * @param strEventId the event type(s).
1417: * @param objHandler the value of objHandler passed to subscribe
1418: */
1419: public void unsubscribe(String strEventId,
1420: org.directwebremoting.proxy.CodeBlock objHandler) {
1421: ScriptBuffer script = new ScriptBuffer();
1422: script.appendCall(getContextPath() + "unsubscribe", strEventId,
1423: objHandler);
1424: getScriptProxy().addScript(script);
1425: }
1426:
1427: /**
1428: * Unsubscribe an object or function from an event published by this object.
1429:
1430: As of version 3.4 a string value for objHandler is deprecated.
1431: * @param strEventId the event type(s).
1432: * @param objHandler the value of objHandler passed to subscribe
1433: */
1434: public void unsubscribe(String strEventId, String objHandler) {
1435: ScriptBuffer script = new ScriptBuffer();
1436: script.appendCall(getContextPath() + "unsubscribe", strEventId,
1437: objHandler);
1438: getScriptProxy().addScript(script);
1439: }
1440:
1441: /**
1442: * Unsubscribe an object or function from an event published by this object.
1443:
1444: As of version 3.4 a string value for objHandler is deprecated.
1445: * @param strEventId the event type(s).
1446: * @param objHandler the value of objHandler passed to subscribe
1447: */
1448: public void unsubscribe(Object[] strEventId, String objHandler) {
1449: ScriptBuffer script = new ScriptBuffer();
1450: script.appendCall(getContextPath() + "unsubscribe", strEventId,
1451: objHandler);
1452: getScriptProxy().addScript(script);
1453: }
1454:
1455: /**
1456: * Unsubscribe an object or function from an event published by this object.
1457:
1458: As of version 3.4 a string value for objHandler is deprecated.
1459: * @param strEventId the event type(s).
1460: * @param objHandler the value of objHandler passed to subscribe
1461: */
1462: public void unsubscribe(Object[] strEventId,
1463: org.directwebremoting.proxy.CodeBlock objHandler) {
1464: ScriptBuffer script = new ScriptBuffer();
1465: script.appendCall(getContextPath() + "unsubscribe", strEventId,
1466: objHandler);
1467: getScriptProxy().addScript(script);
1468: }
1469:
1470: /**
1471: * Unsubscribes all subscribed objects to a type of event published by this object.
1472: * @param strEventId the event type
1473: */
1474: public void unsubscribeAll(String strEventId) {
1475: ScriptBuffer script = new ScriptBuffer();
1476: script.appendCall(getContextPath() + "unsubscribeAll",
1477: strEventId);
1478: getScriptProxy().addScript(script);
1479: }
1480:
1481: }
|