Metamerge logo
Search

Advanced Search
*
*
*
* HOME DOCUMENTS & RESOURCES DOWNLOADS EARLY TECH ACCESS SUPPORT FAQ KNOWN ISSUES OLD VERSIONS
*

Accessing your own Java classes

You can access your own Java classes from inside the Metamerge Integrator framework, as long as it contains public classes and methods. These libraries must be packaged into a .jar (or .zip) files and should be placed in your own subdirectory of the Metamerge jars directory:  Metamerge Integrator will find them there.   (You can also use the the CLASSPATH environment variable or the Java runtime environment extension folder, but both these methods are discouraged.  These methods will only let you call Metamerge classes from within your own classes if the loader happened to have loaded the Metamerge classes before your own).

If you are running the Server from the Admin Tool, you will have to restart the Admin Tool before it knows about new classes in the jars directory (and subdirectories).  

After having put the jar-files in the jars/ subdirectory, you need to assign a name to an instance of the class so you can refer to it  from within the Integrator.

The easiest way  (classes with a default constructor)

Use the Java Libraries tab under the Configuration of the Admin Tool. This will only work if your class has a default constructor (a constructor that does not take arguments). When adding a library, you must specify two parameters: the script object name (the name of the scripting object which will be an instance of your java class) and the java class name.

For example, you could have a Script Object Name being "mycls" while the Java Class would be my.java.classname. The mycls object would be available wherever the system object is available, as the system object is really an instance of the com.architech.function.userFunctions2 java class.

Classes without default constructor or that you want to instantiate yourself. 

In case you do not want to use the Java libraries tab (because you want to instantiate your class at a specific point of execution or your class does not have a default constructor)

1 Scripting in Javascript

1.1 Using a standard class (e.g which name starts with "java.")

Assuming you want to use the standard java.io.FileReader

 var javafile = new java.io.FileReader ( "myfile" );

1.2  Using non-standard classes (e.g a user class)

The 'Packages' root must be used for the framework to understand that the class is non-standard. For example, instantiating a class called my.Filereader will be done by typing

var myfile = new Packages.my.FileReader ("myfile");

2 Scripting in languages without new java.* 

When you script with a language that does not support the 'new java.*' instruction, you can use the the newObject (className) method found in the Metamerge Integrator system object:

var f = system.newObject ("java.io.File");

Note that in this case you will not be able to call the class constructor with parameters.

 

 

*
  Metamerge Integrator version 4.6 ©Copyright Metamerge AS 2000-2002 Last edited 2002-06-10 contact us