com.force.sdk.codegen
Class ForceJPAClassGenerator

java.lang.Object
  extended by com.force.sdk.codegen.ForceJPAClassGenerator

public class ForceJPAClassGenerator
extends Object

Generator for Force.com JPA enabled Java classes.

This will generate a closed set of Force.com JPA enabled Java classes based on a list of Force.com schema object (SObject) names from a Force.com store (organization). For example, a caller wishing to generate a Java class for the Account object will get the Account Java class plus the all Java classes to which the Account class will refer (i.e. the Account object's references). If the first name in the list of schema object names is a single star ("*") then the generator will produce Java classes for all known objects in the Force.com store (organization).

A ForceJPAClassGenerator has a predetermined set of Force.com schema objects that will always be generated in addition to what is requested by the caller.

Author:
Tim Kral

Constructor Summary
ForceJPAClassGenerator(ForceConnectorConfig config, File destDir)
          Initializes a ForceJPAClassGenerator with a ForceConnectorConfig and a destination (project) directory.
ForceJPAClassGenerator(com.sforce.soap.partner.PartnerConnection conn, File destDir)
          Initializes a ForceJPAClassGenerator with a connection to the Force.com service and a destination (project) directory.
ForceJPAClassGenerator(String connectionName, File destDir)
          Initializes a ForceJPAClassGenerator with a named ForceConnectorConfig source and a destination (project) directory.
 
Method Summary
 int generateJPAClasses(List<String> objectNames)
          Execute the Java class generation.
 void setPackageName(String packageName)
          Sets the Java package name under which the Java classes will be generated.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ForceJPAClassGenerator

public ForceJPAClassGenerator(String connectionName,
                              File destDir)
                       throws com.sforce.ws.ConnectionException
Initializes a ForceJPAClassGenerator with a named ForceConnectorConfig source and a destination (project) directory.

The ForceJPAClassGenerator will obtain a connection to the Force.com service using the ForceConnectorConfig source. Generated Java classes will be written to the destination directory.

Parameters:
connectionName - a named ForceConnectorConfig source
destDir - the destination (project) directory to which the generated Java classes will be written
Throws:
com.sforce.ws.ConnectionException - if there is an error connecting to the Force.com service

ForceJPAClassGenerator

public ForceJPAClassGenerator(ForceConnectorConfig config,
                              File destDir)
                       throws com.sforce.ws.ConnectionException
Initializes a ForceJPAClassGenerator with a ForceConnectorConfig and a destination (project) directory.

The ForceJPAClassGenerator will obtain a connection to the Force.com service using the ForceConnectorConfig. Generated Java classes will be written to the destination directory.

Parameters:
config - a ForceConnectorConfig
destDir - the destination (project) directory to which the generated Java classes will be written
Throws:
com.sforce.ws.ConnectionException - if there is an error connecting to the Force.com service

ForceJPAClassGenerator

public ForceJPAClassGenerator(com.sforce.soap.partner.PartnerConnection conn,
                              File destDir)
Initializes a ForceJPAClassGenerator with a connection to the Force.com service and a destination (project) directory.

Generated Java classes will be written to the destination directory.

Parameters:
conn - a PartnerConnection to the Force.com service
destDir - the destination (project) directory to which the generated Java classes will be written
Method Detail

setPackageName

public void setPackageName(String packageName)
Sets the Java package name under which the Java classes will be generated.

Parameters:
packageName - a non null String which conforms to Java package naming standards

generateJPAClasses

public int generateJPAClasses(List<String> objectNames)
                       throws com.sforce.ws.ConnectionException,
                              IOException
Execute the Java class generation.

Parameters:
objectNames - the Force.com schema objects that are to be generated as Java classes (along with their references)
Returns:
the number of Force.com JPA enabled Java classes generated
Throws:
com.sforce.ws.ConnectionException - if an error occurs trying to connection to the Force.com service
IOException - if an error occurs trying to write out the generated Java classes


Copyright © 2011. All Rights Reserved.