/*---------------------------------------------------------------------------------
//
// Z and I Emulator for Transformation technology
//
// Module Name: RuntimeServicesExamples.java
//
// Description: Provides java code samples for accessing ZIETrans Rich Client Program
// Runtime Services.
//
*///-------------------------------------------------------------------------------
package com.ibm.hats;
import java.util.Collection;
import java.util.Iterator;
import com.ibm.hats.rcp.runtime.RcpRuntimePlugin;
import com.ibm.hats.runtime.services.IApplicationService;
import com.ibm.hats.runtime.services.IClientService;
import com.ibm.hats.runtime.services.IRuntimeService;
import com.ibm.hats.runtime.services.IServiceManager;
import com.ibm.hats.runtime.services.ISessionService;
import com.ibm.hats.runtime.services.ServiceType;
//---------------------------------------------------------------------------------
/** <code><B>
* Class Name: </B> RuntimeServicesExamples <B><BR>
* Class Type: </B> Normal <B><BR>
* Base Class: </B> None <B><BR>
* Intf Class: </B> None <B><BR>
* Description: </code></B> Rich Client Program Runtime Services java code samples.
*///-------------------------------------------------------------------------------
public class RuntimeServicesExamples
{
//-----------------------------| Constants |-----------------------------------
//-----------------------------| Variables |-----------------------------------
//-----------------------------------------------------------------------------
/**
* The default constructor.
*///---------------------------------------------------------------------------
public RuntimeServicesExamples()
{
super();
}
//-----------------------------------------------------------------------------
/**
* Provides an example of accessing each application service.
*///---------------------------------------------------------------------------
public void accessApplicationService()
{
Collection applicationServices = this.retrieveApplicationServices();
Iterator itApplicationServices = applicationServices.iterator();
while ( itApplicationServices.hasNext() )
{
IApplicationService aApplicationService = (IApplicationService)
itApplicationServices.next();
// Custom code goes here
}
}
//-----------------------------------------------------------------------------
/**
* Provides an example of accessing each client service. Currently, there is
// only one.
*///---------------------------------------------------------------------------
public void accessClientService()
{
Collection clientServices = this.retrieveClientServices();
Iterator itClientServices = clientServices.iterator();
while ( itClientServices.hasNext() )
{
IClientService aClientService = (IClientService)
itClientServices.next();
// Custom code goes here
}
}
//-----------------------------------------------------------------------------
/**
* Provides an example of accessing each runtime service. Currently, there is
// only one.
*///---------------------------------------------------------------------------
public void accessRuntimeService()
{
Collection runtimeServices = this.retrieveRuntimeServices();
Iterator itRuntimeServices = runtimeServices.iterator();
while ( itRuntimeServices.hasNext() )
{
IRuntimeService aRuntimeService = (IRuntimeService)
itRuntimeServices.next();
// Custom code goes here
}
}
//-----------------------------------------------------------------------------
/**
* Provides an example of accessing each session service.
*///---------------------------------------------------------------------------
public void accessSessionService()
{
Collection sessionServices = this.retrieveSessionServices();
Iterator itSessionServices = sessionServices.iterator();
while ( itSessionServices.hasNext() )
{
ISessionService aSessionService = (ISessionService)
itSessionServices.next();
// Custom code goes here
}
}
//-----------------------------------------------------------------------------
/**
* Retrieve the client service.
*
* @return The client service.
*///---------------------------------------------------------------------------
public IClientService getClientService( final String clientId )
{
return this.getServiceManager().getClientService( clientId );
}
//-----------------------------------------------------------------------------
/**
* Retrieve the runtime service.
*
* @return The runtime service.
*///---------------------------------------------------------------------------
public IRuntimeService getRuntimeService()
{
return this.getServiceManager().getRuntimeService();
}
//-----------------------------------------------------------------------------
/**
* Retrieve the service manager.
*
* @return The service manager.
*///---------------------------------------------------------------------------
public IServiceManager getServiceManager()
{
return RcpRuntimePlugin.getDefault().getServiceManager();
}
//-----------------------------------------------------------------------------
/**
* Provides an example of retrieving a Collection of current application
* service objects.
*
* @return A Collection of current application service objects.
*///---------------------------------------------------------------------------
public Collection retrieveApplicationServices()
{
IServiceManager manager = this.getServiceManager();
Collection applicationServices = manager.retrieveServiceEntries(
ServiceType.APPLICATION );
return applicationServices;
}
//------------------------------------------------------------------------------
/**
* Provides an example of retrieving a Collection of current client service
* objects. Currently, there is only one.
*
* @return A Collection of current client service objects.
*///----------------------------------------------------------------------------
public Collection retrieveClientServices()
{
IServiceManager manager = this.getServiceManager();
Collection clientServices = manager.retrieveServiceEntries(
ServiceType.CLIENT );
return clientServices;
}
//-----------------------------------------------------------------------------
/**
* Provides an example of retrieving a Collection of current runtime service
* objects. Currently, there is only one.
*
* @return A Collection of current runtime service objects.
*///---------------------------------------------------------------------------
public Collection retrieveRuntimeServices()
{
IServiceManager manager = this.getServiceManager();
Collection runtimeServices = manager.retrieveServiceEntries(
ServiceType.RUNTIME );
return runtimeServices;
}
//-----------------------------------------------------------------------------
/**
* Provides an example of retrieving a Collection of current session service
* objects.
*
* @return A Collection of current session service objects.
*///---------------------------------------------------------------------------
public Collection retrieveSessionServices()
{
IServiceManager manager = this.getServiceManager();
Collection sessionServices = manager.retrieveServiceEntries(
ServiceType.SESSION );
return sessionServices;
}
//-----------------------------------------------------------------------------
/**
* Provides an example of turning off border rendering for all input fields.
*
*
*///---------------------------------------------------------------------------
public int getControlClassStyle(class controlClass)
{
if (controlClass.equals(Text.class))
{
return 0;// super.getControlClassStyle(controlClass);
}
else
{
return super.getControlClassStyle(controlClass);
}
}