Access Keys:
Skip to content (Access Key - 0)

Adding Custom Service Properties


In this section we will show how to add a property that can be configured at deployment time of our service and then later accessed during runtime of the service.

Table of Contents


Adding the Property


  • In Introduce in the Modify Service Interface window, Select the Service Properties tab.
  • You will see a list of several service properties which were added by the Data Service creation process to configure various aspects of the service infrastructure and query processor. We will now add a property that we can use in some of our methods. For this example we will add the service property maxGenes.
    • In the key text field enter the name of the property maxGenes
    • and in the value field enter a default value of 10.
Adding Service Property


  • Now click theAddbutton and you will see the new property and its default value has been added to the list of service properties.
  • Click theSavebutton so that the service can be updated.

Using the Property


We will now use this property to limit the number of genes we will return from the* findGenesSharePathways* method.

  • Open for editing the C:\CaGridTutorialService\src\gov\nih\nci\cagrid\tutorial\service\CaGridTutorialServiceImpl.java file.
  • Modify the file as follows:

After

		if (rList == null || rList.size() <= 0) {
				throw new gov.nih.nci.cagrid.tutorial.stubs.types.NoSharedPathwayGenesFound();
			}

Add

		int maxGenes =0;
			try {
				maxGenes = Integer.valueOf(ServiceConfiguration.getConfiguration().getMaxGenes()).intValue();
			} catch (Exception e) {
				e.printStackTrace();
				throw new RemoteException("Problem determining maxGenes.");
			}
			try{
				if (rList.size() > maxGenes) {
					gov.nih.nci.cabio.domain.Gene[] geneArray = new gov.nih.nci.cabio.domain.Gene[maxGenes];
					System.arraycopy(rList.toArray(), 0, geneArray, 0, maxGenes);
					return geneArray;
				}
			} catch (Exception e) {
				e.printStackTrace();
				throw new RemoteException("Problem limiting maxGenes.");
			}

Save the modified source file.

Edit the Client to Cause the Exception


  • Open for editing the file C:\CaGridTutorialService\src\gov\nih\nci\cagrid\tutorial\client\CaGridTutorialServiceClient.java
  • In the main method replace the "I Love CaGrid" text with "BRCA1".
  • Save the modified file.

Re-Deploying the Service


  • Click the Deploy Service button at the top of the Introduce portal. Using the file selection dialog, browse to the root directory of the tutorial service. When the service deployment dialog appears, set the Deployment Location to GLOBUS_LOCATION using the drop down provided. You will notice that the service property maxGenes is now a configurable parameter at deployment time. We can either change the value now or use the default value that is shown.
    Deploying the Service

Re-Start the Service Container


  • Using a new command prompt, change to the Globus location directory and start up Globus. (If globus is already running, be sure to terminate it before you proceed with starting another one.)

%> cd %GLOBUS_LOCATION%\bin
%> globus-start-container.bat -containerDesc ..\..\certificates\security-descriptor.xml

Invoke the Client


  • Upon running the client you should see the following output:
 $ ant runClient -Dservice.url=https://localhost:8443/wsrf/services/cagrid/
CaGridTutorialService
Buildfile: build.xml

setGlobus:

checkGlobus:
     [echo] Globus: C:\training\cagrid-training\ws-core-4.0.3

defineClasspaths:

runClient:
     [echo] Connecting to service: https://localhost:8443/wsrf/services/cagrid/CaGridTutorialService
     [java] JVM args ignored when same JVM is used.
     [java] Running the Grid Service Client
     [java] HDAC2
     [java] RAD17
     [java] CCNB1
     [java] CHEK1
     [java] BRCA2
     [java] GTF2F1
     [java] YWHAQ
     [java] GADD45A
     [java] NFKBIA
     [java] RAD50

BUILD SUCCESSFUL
Total time: 10 seconds
Last edited by
Sarah Honacki (1172 days ago)
Adaptavist Theme Builder Powered by Atlassian Confluence