Overview
The PublishingServer and InDesign / pdf renderer support a number of tags, which are replaced by actual values when executing a cscript or statement.
Which tags are available and which values are applied to the tags, depends on the calling environment. Furthermore, some of the tags are processed on client side (i.e. InDesign or pdf renderer).
This document provides a consolidated overview of tags available in cscript and statements in a Publishing Server environment. Detailed information about tags in InDesign / pdf renderer context can also be found in the documentation shipped with the InDesign Plugins.Requirements
This documentation is valid for PublishingServer version 4.1.6 and priint:comet InDesign Plug-Ins / pdf renderer version 4.1.6
Script and Statement Classes
Which tags are supported depends on the script resp. statement type and the calling environment.
SOAP Statements
Typically, in a placeholder context, we don't run cscripts but send a "SOAP statement" directly to the server.
This statement is preprocessed on client side (InDesign or pdf renderer), i.e.: certain tags are replaced.
The following example shows a typical load statement of a placeholder configured with PublishingServer / ISON:
call stringlist plugin(globalName='DataProviderManager',methodName='get')[<Session.Id>,'_KeyValueOfBucket',<Model.Id>,<Entity.Id>,<resultEntityId>,<Record.Id>,<Record.GroupId>,'','',<xml.country>,<xml.language>,'',<xml.publication>,'','',<xml.documentId>,{}, <Java.ResultClass>]:placeholder#268520655#get
Tags replaced on Client Side
When run in placeholder load context, the statement is preprocessed on client side and certain tags (i.e. keys enclosed by < >) are replaced with values of the actual calling environment.
The tags replaced on client side are set bold in the following statement snippet:
call stringlist plugin(globalName='DataProviderManager',methodName='get')[<Session.Id>,'_KeyValueOfBucket',<Model.Id>,<Entity.Id>,<resultEntityId>,<Record.Id>,<Record.GroupId>,'','',<xml.country>,<xml.language>,'',<xml.publication>,'','',<xml.documentId>,{}, <Java.ResultClass>]:placeholder#268520655#get
A list of tags supported on client side can be found below. Please also refer to the priint:comet Plug-Ins documentation, placeholder section, which provides additional information about replacing rules (quoted, unquoted, built-in string functions etc.) and maybe updated list of available tags.
Tags replaced on Server Side
The tags marked bold in the following statement snippet are replaced on server side. A list of tags supported on server side by common server modules including explanation can be found below.
There is no general rule, if and which tags are supported on Server Side. This depends on the invocation target, in this case this is the get method of the DataProviderManager.
call stringlist plugin(globalName='DataProviderManager',methodName='get')[<Session.Id>,'_KeyValueOfBucket',<Model.Id>,<Entity.Id>,<resultEntityId>,<Record.Id>,<Record.GroupId>,'','',<xml.country>,<xml.language>,'',<xml.publication>,'','',<xml.documentId>,{}, <Java.ResultClass>]:placeholder#268520655#get
CScript
The equivalent cscript for the placeholder load statement example above would be
int main () { String str = string::alloc (); int result = server::load_placeholder_str(str); if (result == 0) { textmodel::replace(string::get(str)); } string::release(str); return result; }
Tags replaced on Client Side
There are no obvious tags in this example, all replacements are done silently in the background. Though, using a script and the server::load_placeholder_str function allows overriding certain values. To pass the ID of the parent record to the server, rather than the ID of the record itself, we could consider something like:
int main () { String str = string::alloc (); int result = server::load_placeholder_str(str, "Record.Id", "<Record.ParentId>"); // doesn't work as expected! if (result == 0) { textmodel::replace(string::get(str)); } string::release(str); return result; }
Unfortunately, this doesn't work. Tags replaced on client side are generally supportet in statements only, not in cscript.
We must use a cscript equivalent - either a global variable defined for certain call environments or a cscript function call. The solution in this case would be:
int main () { String str = string::alloc (); int result = server::load_placeholder_str(str, "Record.Id", gPSParentRecordId); if (result == 0) { textmodel::replace(string::get(str)); } string::release(str); return result; }
The list of supported tags below also contains cscript equivalents, if available. For detailed information, please also refer to the priint:comet Plug-Ins documentation, placeholder section.
Tags replaced on Server Side
There is no general rule, if and which tags are replaced on Server Side. Like said above, this depends on the invocation target. In the following example, <Model.Id> is replaced by PublishingServer, because the invocation target is the DataProviderManager.get method and the <Model.Id> tag is supported by this method:
int main () { String str = string::alloc (); int result = server::load_placeholder_str(str, "Model.Id", "<Model.Id>"); if (result == 0) { textmodel::replace(string::get(str)); } string::release(str); return result; }
The following example shows the principle of tag replacements on Server Side. As obvious (and said above), this is subject of the invocation target - which can also be a 3d party / custom Plugin method, so there is no general rule, if and which tags are supported on server side.
package com.priint.pubserver.example; @Stateless(mappedName=Tags.MAPPED_NAME) @LocalBean @PubServerPlugin public class Tags extends PluginControlDefault { public static final String MAPPED_NAME = "com.priint.pubserver.example.Tags"; @PubServerMethod(type=PluginMethod.MethodType.GENERIC) @CometCScriptFunction public String getBaseDirectory( @PubServerMethodParameter(name="designator") String designator) { return designator.replaceAll("<User.Home>", System.getProperty("user.home")); } }
In a cscript, this method could be called like this:
#include "[pubserver]/plugin/com.priint.pubserver.example.Tags.c" int main() { char * path = getBaseDirectory("<User.Home>"); // ... further processing ... return 0; }
In a statement, the <User.Home> tag would also be replaced on server side:
call stringlist plugin(globalName='com.priint.pubserver.example.Tags',methodName='getBaseDirectory')['<User.Home>']
Tags replaced on Client Side (InDesign / PDF Renderer)
This section lists tags and there cscript equivalents grouped by calling environment. Please also refer to the Plugin / PDF Renderer documentation (either the offline version shipped with the Plugins or online).
All Statements / Scripts
Tag | Type | cscript equivalent | Description |
---|---|---|---|
<document> | char* | document::name() | name of InDesign / W2ML document |
<folder> | char* | document::folder() | parent folder of the document using system path delimiter |
<folderX> | char* | document::folderX() | parent folder of the document using '/' as path delimiter |
<path> | char* | document::path() | full path of the document using system path delimiter |
<path9> | char* | document::path9() | full path of the document using Mac OS 9 path delimiter |
<pathX> | char* | document::pathX() | full path of the document using '/' as path delimiter |
<page> | int | page::get(gFrame) | 1-based page number of the page, on which the current placeholder is located or, if not in placeholder context (i.e. gFrame==0), number of the selected (active) page of the front document |
<pagestr> | char* | page::get_str(buffer, gFrame) | 1-based page name as referred to in InDesign of the page, on which the current placeholder is located or, if not in placeholder context (i.e. gFrame == 0), name of the selected (active) page of the front document |
<layer> | char* | layer::get_name(gFrame) | name of the currently selected / active layer or name of the layer, on which gFrame is located on |
<layer.1..3> | char* | -- | part of the layer name. The layer name can consist of up to 3 segments separated by hash signs ('#'), enabling targeted access to each segment. Main field of application are context criteria (such as language, country etc.) in a PublishingServer environment. Example: if the script is run in the context of a placeholder, which is located on a layer named CH#de, values for the layer tags are
|
<pages> | int | document::pages() | number of pages in the current document |
<documentID> | int | document::getid() | ID of the document |
<documentID2> | int | document::getid() | ID2 of the document |
<documentID3> | int | document::getid() | ID3 of the document |
<documentSTRINGID> | char* | document::getid() | stringId of the document |
<application> | char* | system::app_path() | full path of the running application |
<plugins> | char* | system::plugin_path() | path of the application plugin folder |
<comet> | char* | file::uncurtain("$COMET") | full path of the currently running Comet Plugins |
<xmlfolder> | char* | file::uncurtain("$CACHE") | full path of XML offline folder, if connected to a XML project |
<cache> | char* | file::uncurtain("$CACHE") | full path of comet cache folder |
<now> | char* | system::now(...) | current date and time in the format specified by user preferences or cscript argument |
<date> | char* | system::now(...) | current date |
<time> | char* | system::now(...) | current time |
<day> | int | day of year | |
<month> | int | month of year | |
<year> | int | year | |
<hour> | int | hour | |
<minute> | int | minute | |
<second> | int | second | |
<dayOfWeek> | int | day of week | |
<dayOfYear> | int | day of year | |
<weekOfYear> | int | week of year | |
<date_sep> | char* | system::date_sep() | separated for dates |
<time_sep> | char* | system::time_sep() | separator for times |
<am> | char* | system::AM() | symbol for the first half of day |
<pm> | char* | syatem::PM() | symbol for the second half of day |
<os> | char* | system::os() | whether the system is Mac OS X, Windows or Linux |
<version> | char* | system::comet_version() | version of the comet plugins currently running |
<version> | int | system::version() | InDesign version currently running, e.g. 13 for Inesign CC 2018 |
<is_server> | int | system::is_server() | 1, if the script is executed with InDesignServer or pdf renderer, 0 otherwise |
<author> | char* | - | author of the Comet Software |
<vendor> | char* | - | vendor of the software currently used |
<currency> | char* | system::currency() | Mac OS only, symbol of the currency configured for system |
<host> | char* | system::host() | computer name |
<login> | char* | system::login() | system login name |
<lang> | char* | system::language() | system language |
<tcpip> | char* | system::tcpip() | IP address of the computer |
<macid> | char* | system::macid() | MAC address of the computer |
<user> | char* | soap::user() or sql::user() | user / login of the current data connection |
<userid> | int | sql::userid() | ID of the current user, only for SQL / database connections |
<server> | char* | soap::server() or sql::server() | address / name of the soap service or name of the database connection |
<database> | char* | sql::database() | name of the database, only for SQL / database connections |
<client> | char* | soap::client() or sql::client() | current project name or client |
<encoding> | int | soap::charset() or sql::charset() | encoding used for the current data connection. For SOAP / PubServer connections, this will generally be UTF8 Possible values:
|
<xml.identifier> | char* | xml::get_document_attribute(0, identifier, ...) | Access to XML attributes of the root element of the document. These attributes can be set manually in InDesign or by methods of the module xml, e. g. xml::set_document_attribute. identifier designates the name of the attribute |
Placeholder and TableInsert Statements / Scripts
Tag | Type | cscript equivalent | Description |
---|---|---|---|
<ID> | int | gRecordID | 1st id of the record linked with the placeholder |
<ID2> | int | gRecordID2 | 2nd id of the record linked with the placeholder |
<ID3> | int | gRecordID3 | 3d id of the record linked with the placeholder |
<STRINGID> | char* | gRecordStringID | String id of the record linked with the placeholder |
<STRINGID1..3> | char* | gRecordStringID + strtoken(...) | nth token of a multi string id or RootTableRecordStringID / ColumnRecordStringID / RowRecordStringID |
<Record.Id> | char* | gPSRecordId | id of the data record, PublishingServer connections only |
<Record.GroupId> | char* | gPSGroupId | Group id of the data record, PublishingServer connections only |
<Entity.Id> | char* | gPSEntityId | Entity identifier of the record, PublishingServer connections only |
<Entity.Class> | char* | gPSEntityClass | Entity class of the record, PublishingServer connections only |
<Record.ParentId> | char* | gPSParentRecordId | id of the data records parent, PublishingServer connections only |
<Record.ParentGroupId> | char* | gPSParentGroupId | Group id of the data records parent, PublishingServer connections only |
<Entity.ParentId> | char* | gPParentSEntityId | Entity identifier of the records parent, PublishingServer connections only |
<Entity.ParentClass> | char* | gPSParentEntityClass | Entity class of the records parent, PublishingServer connections only |
<text> <textplus> | char* | textmodel::gettext() with format parameter kExportPlain or kExportPlusPlain | text of the placeholder. The 'plus' variant also replaces all automatic page numbers, paragraph names and footnote markers by their current values. |
<text_notypografics> <textplus_notypografics> | char* | textmodel::gettext() with format parameter kExportPlainNoTypografics or kExportPlusPlainNoTypografics | text of the placeholder with all typografic quotes replaced by "normal" quotes. The 'plus' variant also replaces all automatic page numbers, paragraph names and footnote markers by their current values. |
<taggedtext> | char* | textmodel::gettext() with format parameter kExportTagged | text of the placeholder in InDesign TaggedText format. When exporting, the settings ASCII, Windows line delimiter, extended are used. |
<tttext> | char* | textmodel::gettext() with format parameter kExportTT | text of placeholder in Werk II %!TT format. When exporting, the settings ASCII, Windows line delimiter, extended are used. Paragraph and character style will not be exported. |
<w2text> | char* | textmodel::gettext() with format parameter kExportW2 | text of placeholder in Werk II %!TT format. When exporting, the settings ASCII, Windows line delimiter, extended are used. The export includes the text placeholders of the document text. |
<unitext> <unitextplus> | char* | textmodel::gettext() with format kExportUnitext or kExportPlusUnitext | pure text export, all special characters (ASCII > 127) are encoded in the form \00FC. The 'plus' variant also replaces all automatic page numbers, paragraph names and footnote markers by their current values. |
<xunitext> <xmlunitext> <unitextplus> <xmlunitextplus> | char* | textmodel::gettext() with format kExportXUnitext, kExportPlusXUnitext, kExportXMLUnitext or kExportPlusXMLUnitext | pure text export, all special characters are encoded in the form <0x00FC>. The 'plus' variant also replaces all automatic page numbers, paragraph names and footnote markers by their current values. |
<rtftext> | char* | textmodel::gettext() with format kExportRTF | text of the placeholder in RTF format |
<xhtml> | char* | textmodel::gettext() with format kExportHTMLWithStyles | text of placeholder in xhtml format |
<textlen> | int | strlen() or strsize() of text obtained with textmodel::gettext() | length of the current placeholder text in characters / letters |
TableInsert Statements / Scripts
In addition to the tags listed in the section before, in table insert statements or scripts, the following tags are available:
Tag | Type | cscript equivalent | Description |
---|---|---|---|
<RootTableRecordID> | int | gRootTableRecordID | ID of the record linked with the table |
<RootTableRecordID2> | int | gRootTableRecordID2 | 2nd ID of the record linked with the table |
<RootTableRecordID3> | int | gRootTableRecordID3 | 3d ID of the record linked with the table |
<RootTableRecordStringID> | char* | gRootTableRecordStringID | String ID of the record linked with the table |
<ColumnRecordID> | int | gColumnRecordID | ID of the record linked with the column |
<ColumnRecordID2> | int | gColumnRecordID2 | 2nd ID of the record linked with the column |
<ColumnRecordID3> | int | gColumnRecordID3 | 3d ID of the record linked with the column |
<ColumnRecordStringID> | char* | gColumnRecordStringID | String ID of the record linked with the column |
<RowRecordID> | int | gRowRecordID | ID of the record linked with the row |
<RowRecordID2> | int | gRowRecordID2 | 2nd ID of the record linked with the row |
<RowRecordID3> | int | gRowRecordID3 | 3d ID of the record linked with the row |
<RowRecordStringID> | char* | gRowRecordStringID | String ID of the record linked with the row |
<CellRecordID> | int | gCellRecordID | ID of the record linked with the cell |
<CellRecordID2> | int | gCellRecordID2 | 2nd ID of the record linked with the cell |
<CellRecordID3> | int | gCellRecordID3 | 3d ID of the record linked with the cell |
<CellRecordStringID> | char* | gCellRecordStringID | String ID of the record linked with the cell |
Other Calling Environment
Various global variables resp. tags are available in scripts and statements executed from the panel menu (Panelstatements, Panelscripts), popup menus (e.g. find statements, preview statements), triggered by placeholders / build scripts (e.g. layout rules and conditions) etc..
In a PublishingServer environment, statements are generally compiled from annotated Java methods deployed as PubServerMethods or configuration settings, therefore no custom tags can be added to these statements.
In cscripts, all global variables documented in the Plugin documentation for the appropriate panel can be used. Please refer to the following documents:
- Layout Rules and Conditions
- Product Panel
- Publication Panel
- Placing URLs
- Template related Scripts
- Statements Overview
- Script Types
Tags replaced on Server Side
On Server Side, tags are used to initialize certain parameters of Java methods with values from the current calling context. As on client side, it depends on the calling environment, if and which tags are supported.
General Rules
- tags are supported for parameters of PubServerMethods
- the parameter must be annotated as @PubServerMethodParameter
- the defaultValue attribute of the PubServerMethodParameter annotation must be set to the tag value
@PubServerMethod(type=PluginMethod.MethodType.GENERIC) public void doSomething( @PubServerMethodParameter(defaultValue="<Session.Id>") String sessionId) { }or better
@PubServerMethod(type=PluginMethod.MethodType.GENERIC) public void doSomething( // use constant from SDK com.priint.pubvserver.parameterparser.ParameterTags // instead of string literal: @PubServerMethodParameter(defaultValue=ParameterTags.Tag.SESSION_ID) String sessionId) { }If this method is somehow called via the CometBridge (i.e. triggered by a request sent from InDesign / PDF Renderer), the parameter value is set to the ID of the current session.
General supported Tags
Note: the following tags are generally supported for method calls somehow initiated by the CometBridge (i.e. triggered by a request sent from InDesign / PDF Renderer).
If called from other context, e.g. a 3d party Java Plugin, they may be undefined.
Tag | Type | Constant Name | Description |
---|---|---|---|
<Session.Id> | String | ParameterTags.Tag.SESSION_ID | ID of the current session |
<Model.Id> | String | ParameterTags.Tag.MODEL_ID | Identifier of the entity model linked with the project |
<Project.Identifier> | String | ParameterTags.Tag.PROJECT_IDENTIFIER | Identifier of the comet project |
Tags supported in DataQuery Methods
The following tags are defined, if a DataQuery method call was initiated by the DataProviderManager. This is usually the case for placeholder statements (load, store, sync...).
If called from other context, e.g. a 3d party Java Plugin, they may be undefined.
Tag | Type | Constant Name | Description |
---|---|---|---|
<Entity.Context> | Context | ParameterTags.Tag.ENTITY_CONTEXT | Context object |
<Entity.ContextAssortment> | String | ParameterTags.Tag.ENTITY_CONTEXT_ASSORTMENT | the context assortment |
<Entity.ContextCountry> | String | ParameterTags.Tag.ENTITY_CONTEXT_COUNTRY | the context country |
<Entity.ContextLanguage> | String | ParameterTags.Tag.ENTITY_CONTEXT_LANGUAGE | the context language |
<Entity.ContextWell> | String | ParameterTags.Tag.ENTITY_CONTEXT_WELL | the context well |
<Entity.ContextMarket> | String | ParameterTags.Tag.ENTITY_CONTEXT_MARKET | the context market |
<Entity.ContextTargetgroup> | String | ParameterTags.Tag.ENTITY_CONTEXT_TARGETGROUP | the context target group |
<Document.Id> | String | ParameterTags.Tag.DOCUMENT_ID | id of the current document |
<Document.Publication> | String | ParameterTags.Tag.DOCUMENT_PUBLICATION | current publication, usually id of the root publication |
<Record.Id> | String | ParameterTags.Tag.RECORD_ID | id of the record being processed |
<Record.GroupId> | String | ParameterTags.Tag.RECORD_GROUPID | group id of the record being processed |
<Entity.Id> | String | ParameterTags.Tag.ENTITY_ID | identifier of the entity of the current record |
<Entity.ResultId> | String | ParameterTags.Tag.ENTITY_RESULTID | requested result entities |
<Record.SearchStr> | String | ParameterTags.Tag.RECORD_SEARCHSTR | search string |
<Document.Publication> | String | ParameterTags.Tag.DOCUMENT_PUBLICATION | current publication, usually id of the root publication |
<DataProvider.Parameters> | String | ParameterTags.Tag.DATAPROVIDER_PARAMETERS | dynamic parameters passed to the DataProvider method, e.g. from function variables |
Tags supported in DataMapping Methods
In DataMapping methods, all tags available for DataQuery methods are supported plus the <Entity.ResultList> tag.
If called from other than DataProvider context, e.g. a 3d party Java Plugin, they may be undefined.
Tag | Type | Constant Name | Description |
---|---|---|---|
<Entity.ResultList> | List<? extends EntityData> | ParameterTags.Tag.ENTITY_RESULTLIST | result from data query object |
Tags supported in DataProcessing Methods
In DataProcessing methods, all tags available for DataQuery methods are supported except for <DataProvider.Parameters>
If called from other than DataProvider context, e.g. a 3d party Java Plugin, they may be undefined.
Tags supported in Table of Contents (ToC) Query Methods
Table of Contents requests are handled by a separate data provider. The following tags are defined for query and mapping methods called within Table of Contents context:
Tag | Type | Constant Name | Description |
---|---|---|---|
<Entity.Context> | Context | ParameterTags.Tag.ENTITY_CONTEXT | Context object |
<Document.Name> | String | ParameterTags.Tag.DOCUMENT_NAME | name of the current document |
<Document.Path> | String | ParameterTags.Tag.DOCUMENT_PATH | local path of the current document |
<Document.PublicationId> | String | ParameterTags.Tag.DOCUMENT_PUBLICATION_ID | id of the current document (in other context <Document.Id>!) |
<Document.Id> | String | ParameterTags.Tag.DOCUMENT_ID | id of the current document introduced in 4.1.6 / Build 1931 |
<Document.Publication> | String | ParameterTags.Tag.DOCUMENT_PUBLICATION | current publication, usually id of the root publication |
<Record.Id> | String | ParameterTags.Tag.RECORD_ID | id of the record being processed |
<Record.GroupId> | String | ParameterTags.Tag.RECORD_GROUPID | group id of the record being processed |
<Entity.Id> | String | ParameterTags.Tag.ENTITY_ID | identifier of the entity of the current record |
<Entity.Class> | String | ParameterTags.Tag.ENTITY_CLASS | entity class of the current record |
<Entity.ResultId> | String | ParameterTags.Tag.ENTITY_RESULTID | requested result entities |
<Record.ParentId> | String | ParameterTags.ParentTag.RECORD_ID | parent id of the record being processed |
<Record.ParentGroupId> | String | ParameterTags.ParentTag.RECORD_GROUPID | parent group id of the record being processed |
<Entity.ParentId> | String | ParameterTags.ParentTag.ENTITY_ID | identifier of the parents entity of the current record |
<Entity.ParentClass> | String | ParameterTags.ParentTag.ENTITY_CLASS | parent entity class of the current record |
Tags supported in Find Statements
Beside the standard tags, some specifid tags are supported in Java methods called as find statement.
Tag | Type | Constant Name | Description |
---|---|---|---|
<Entity.Context> | Context | ParameterTags.Tag.ENTITY_CONTEXT | Context object |
<Find.Value1> | String | ParameterTags.Tag.FIND_VALUE1 | value from the first search input field |
<Find.Value2> | String | ParameterTags.Tag.FIND_VALUE2 | value from the second search input field |
<Find.Value3> | String | ParameterTags.Tag.FIND_VALUE3 | value from the third search input field |
<Find.Value4> | String | ParameterTags.Tag.FIND_VALUE4 | value from the fourth search input field |
Tags supported in Preview Statements
The following tags are supported in Java methods called as preview statements:
Tag | Type | Constant Name | Description |
---|---|---|---|
<Entity.Context> | Context | ParameterTags.Tag.ENTITY_CONTEXT | Context object |
<Record.Id> | String | ParameterTags.Tag.RECORD_ID | id of the record being processed |
<Record.GroupId> | String | ParameterTags.Tag.RECORD_GROUPID | group id of the record being processed |
<Entity.Id> | String | ParameterTags.Tag.ENTITY_ID | identifier of the entity of the record being processed |
<Entity.Class> | String | ParameterTags.Tag.ENTITY_CLASS | class of the entity of the record being processed |
<Find.Value1> | String | ParameterTags.Tag.FIND_VALUE1 | value of the first search input field |
<Find.Value2> | String | ParameterTags.Tag.FIND_VALUE2 | value of the second search input field |
<Method.Key> | String | ParameterTags.Tag.METHOD_KEY | signature of the method being called |
<Entity.ResultList> | List | ParameterTags.Tag.ENTITY_RESULTLIST | result of preview query, if a custom data mapping method is called |
Custom Tags / Tags supported in CScript methods
The example above illustrates simple implementation of other tags than general supported tags in Java methods called in other context.
If your method is supposed to be called from other context (than described above), you can also use other tags, from SDK or custom defined, as defaultValue of the PubServerMethodParameter annotation. The following example shows the principle:
Custom Application
package com.priint.pubserver.samplecode; import java.util.HashMap; import java.util.Map; import com.priint.pubserver.exception.PubServerException; import com.priint.pubserver.parameterparser.ParameterInterpreter; public class CustomApplication { public Object callService() throws PubServerException { String callString = "plugin(" + "globalName='" + ServicePlugin.MAPPED_NAME + "'," + "methodName='calculateChecksum')" + "[<Custom.InputData>]"; byte[] bytes = new byte[]{}; Map<String,Object> constants = new HashMap<>(); constants.put("<Custom.InputData>", bytes); return ParameterInterpreter.interpret(callString, constants); } }
Example Plugin
package com.priint.pubserver.samplecode; import javax.ejb.LocalBean; import javax.ejb.Stateless; import com.priint.pubserver.plugin.PluginControlDefault; import com.priint.pubserver.plugin.PluginMethod; import com.priint.pubserver.plugin.annotation.PubServerMethod; import com.priint.pubserver.plugin.annotation.PubServerMethodParameter; import com.priint.pubserver.plugin.annotation.PubServerPlugin; import com.priint.pubserver.plugin.interfaces.PluginControl; @Stateless(mappedName=ServicePlugin.MAPPED_NAME) @LocalBean @PubServerPlugin public class ServicePlugin extends PluginControlDefault implements PluginControl { public static final String MAPPED_NAME = "com.priint.pubserver.samplecode.ServicePlugin"; @PubServerMethod(type=PluginMethod.MethodType.GENERIC) public long calculateChecksum( @PubServerMethodParameter(defaultValue="<Custom.InputData>") byte[] data) { long checksum = 0; // ... calculation ... return checksum; } }
The benefit of using tags on the method invocation code is, that you can pass non-primitive types (i.e. other than int, long, double, String etc.) to Plugin methodcalls via the ParameterInterpreter, see Calling Java Plugin and static Methods with the ParameterInterpreter for details.
The benefit of using tags in the target method implementation (as defaultValue attribute of the PubServerMethodParameter annotation) is shown in the following example.
By following the contract for the defaultValue attribute tag, all that has to be done in the client application is using the appropriate key for the entry in the constants map. All methods following this contract can be called in the same way.
package com.priint.pubserver.samplecode; import java.util.HashMap; import java.util.List; import java.util.Map; import com.priint.pubserver.exception.PubServerException; import com.priint.pubserver.parameterparser.ParameterInterpreter; import com.priint.pubserver.plugin.PluginControlDefault; import com.priint.pubserver.plugin.PluginManagerLocal; import com.priint.pubserver.plugin.PluginMethod; import com.priint.pubserver.plugin.PluginUtils; import com.priint.pubserver.util.Constants; public class CustomApplication { public Object callService(String methodName) throws PubServerException { byte[] bytes = new byte[]{}; Map<String,Object> constants = new HashMap<>(); constants.put("<Custom.InputData>", bytes); PluginManagerLocal pluginManager = PluginUtils.getPlugin( Constants.MANAGER_PLUGIN, PluginControlDefault.getSessionId(), PluginManagerLocal.class); List<PluginMethod> availableMethods = pluginManager.getPluginMethodsOfPlugin(ServicePlugin.MAPPED_NAME); for (PluginMethod method : availableMethods) { // or whatever criteria to find suitable method... if (method.getMethodName().equals(methodName)) { return ParameterInterpreter.interpret(method, constants); } } return null; } }