Tamino Server Extension implementation

Hello!

I’ve created a Tamino Server Extension as a Java class.I have 3 questions:

1. Is it possible to pass parameters to the extension?
2. Is it possible to know when a create or update operation occured( both use “process”)?
3. Is it possible in the extension to know in what Schema has occured the process,delete,query operation if more schemas have mapped the same extension.

Please give me a hint.
Thank you

Hi,

To answer your questions:

1) for Query functions: yes, you can pass as many parameters as you want,
for Mapping functions, which I suppose you asked for: no, but there are passed some values implicitly (see 2)

2) I think this is only possible by managing an own collection via process/query/delete callbacks where you collect info on existing objects

3) There are two parameters coming with all mapping functions: ObjectId and ElementId, the former indicating which node bears the mapping (in fact this is the node_id defined in ino:collection), the later being the ino:id of the object (this will enable registering all objects, to answer your question 2). So you know the node, and if you look into ino:collection you also know the schema.

For further information I’d like to refer to the manual, especially for parameters of Server Extension functions and for using callbacks.

I hope this will help you,

Julius Geppert

Hello Julius!

Can you be more specific?

1.I need parameters to configure the extension like: a path to a file, a socket host and port, etc., sometyhing where my extension class methods will write.

2.The map-in method is called AFTER process operation so if I look for the document with object_id in the map-in method I’ll find it there!
I can’t use map-out function here because using process with an ino:id it will update that document if it exists.
I didn’t understand what you suggested,please be more specific.

3.Thank you for the answer,is cool and works.

Please reply.
Thank you again very much for your help.

Hello,

Here come some code snippings that I hope will help you.

1) For configuration purposes you might use (static) class variables, which can be configured by query functions like this:

code:

public class MySXS extends ASXJBase {
// TODO: Enter class variables here.

static int count;

public mySXS () {
// TODO: enter SXS initialization here.
count = 1;
}

public String resetCount (int value)
{
// reset counter
count = value;
return (“count reset to " + value);
}
}


Depending on your needs (settings valid for one/all users/sessions/…) your solution might be more sophisticated.


2) What I meant was that you might use a doctype serving as list of object_id/element_id, e.g. in collection MyList, doctype entry you have entries like

<object_id>2456</object_id>
<element_id>14</element_id>

You then might use code like

code:
  

public void mapin (int object_id, int element_id, String document, StringBuffer nodeinfo)
{
// TODO: Add your SXF implementation here:

// check if update (entry exists) or insert (entry doesn’t exist)
StringBuffer Response = new StringBuffer();
SxsXMLXql (“MyList”,“entry[object_id=” + object_id.toString() + " and " + element_id=” + element_id.toString() + “]”, Response);
… // check return value

// process information to collection MyList:
StringBuffer Response = new StringBuffer();
SxsXMLProcess (“MyList”,"<object_id>" + object_id + “</object_id><element_id>” + element_id +
“</element_id>”, Response);

}

public void onDelete (int object_id, int element_id, String nodeinfo)
{
// TODO: Add your SXF implementation here:

// delete also information from element list
SxsXMLDelete (“MyList”,“entry[object_id=” + object_id.toString() + " and " + element_id=" + element_id.toString() + “]”, Response);


If you find the object_id/element_id in the list, you know it is an update.


Regards,

Julius Geppert

Hello Julius!

Thank you for your help, it was really welcomed!
Creating a new MyList doctype and using SxsXMLSql
helped and my no.2 question was answered.

But I need the answer for the first question!
Check the code bellow:

code:

public class TaminoSocket extends ASXJBase{

// Static member variables to keep information not yet committed
private static ArrayList logList = new ArrayList();
private Socket s;
private static String host=“127.0.0.1”;
private static int port=15812;
private DataOutputStream out;
private DataInputStream in;

public TaminoSocket(){
try{
s=new Socket(host,port);
out=new DataOutputStream(s.getOutputStream());
in=new DataInputStream(s.getInputStream());
}
catch(Exception e){
this.writeLog(“const error:”+e.toString());
}
}

public int sxsJEvent(int state){
try{
//out=new DataOutputStream(s.getOutputStream());
String response="";
switch (state){
case XML_COMMIT:
{
if(out!=null){
Iterator it=logList.iterator();
while(it.hasNext()){
out.writeUTF((String)it.next()); …


The problem is that the host & port parameters are hardcoded!How can I get these parameters for my socket?!I don’t know now which host and port is going to be used by a client!

Thank you for the trouble.

Hello rapo,

I am no Java expert, nor do I exactly know, what you are trying to do. But if the host/port might change with every session or request, a class variable won’t suit your needs, you should prefer an instance variable.

Furthermore, I don’t know what an ‘user’ might be in this context. If it is an application, you could provide a query function ‘setMyHostAndPort(, )’ to have these values set.

If this isn’t appropiate, you might like to examine the session context. Unfortunately, there is only a stub for a system callback SxsSystem(USERURL, response), which is not yet implemented due to lack of use cases. If you really need this function, which seems to be quite obvious, please contact Software AG support for this request.

Best regards,

Julius Geppert

Hi,

Thank you.In the Java API section I found that I could create another schema that contains host and port data.

Well, I tryied that and now I got another problem.I want to parse the response StringBufer using a Docuverse DOM but the SXS Java Tool and the server can’t find the .jar even it is the classpath.

I wanna use other pakages in my extension, is it possible?

Hi rapo,

This is what the support system says:

quote:

*************** RESOLUTION ***************
Extend the entry in value ‘java classpath’ of the registry key
HKEY_LOCAL_MACHINE/SOFTWARE/Software AG/Tamino/n.n.n.n/SXS
where n.n.n.n is the Tamino version no.
The entry should contain any class path resp. .jar file needed to run the
java class of the SXF.
After a restart of the database the value becomes active.

Julius Geppert