Creo™ Schematics 4.0 Help Center > Customizing Creo Schematics Using Java APIs > About Creating Customized Code Using Java
  
About Creating Customized Code Using Java
You can create customized code using the Java packages provided with Creo Schematics.
rsdesigner.design
rsdesigner.component
rsdesigner.uiextension
The method used by customized Java classes to communicate with the application is referred to as the Java Gateway.
The Application Programmer’s Interface (API) provided by the Java packages is documented in the Creo Schematics API Guide.
Using the Java Packages
You can use the Java packages to perform a number of tasks:
Obtain the current design object and query it for parameters or obtain lists of objects using the following methods:
Requesting a set of objects by class.
Using the Design.select() method and setting parameters and condition lists. You can use pre- and post-filter methods for more customized querying.
Provide user-defined label and report functions to return specialized information.
Calculate derived parameter values using user-defined functions.
Create forms and dialog boxes for additional interaction with report results by adding Swing objects in your customized code.
Modify parameters of artifacts as they are being set on objects.
Control whether connections can be made between components and fibers.
Depending on the intended result, you can employ user-defined methods in the following ways:
From a customized Java button
From labels
From reports
From derived parameters
When artifacts are instanced
When validating a change to a PropertySet
Before a endcap is created
After a connection is made
Thread Safety
To provide thread safety, all calls to the Java Gateway are synchronized and monitored so that only one thread can access the Java Gateway at a time. Therefore, only one thread can access the system at a time.
* 
Because a user or a trail file can close the design between calls to the Java Gateway, the design object can become invalid. Use the Design.getSynchronizeObject() method to overcome this restriction. The Design.getSynchronizeObject() method returns an object that can be synchronized with, to ensure that the next set of calls to the Java Gateway is carried out as one unit.
For example, the following code uses the keyword, synchronized. This usage ensures that the actions of obtaining the current design object and performing queries on that object are performed as one unit with no interaction from other threads (or the user).
synchronized (Design.getSynchronizeObject ())
{
 /*
we need to synchronize on the VM because we (or a
trail file!) may end up closing the design between
the obtaining of the design and looping
over the elements in the design
*/
//we need the design object so we can then get
//the list of blocks
 //System.out.println ("get the design class");
Design design = Design.getCurrentDesign ();
Iterator selectResults = design.select ( …);
//work through the results of the select query
while (selectResults.hasNext ())
{
 //perform some actions on the result
}
}