ILOG JRules User Guide > Executing Rules > Tasks > Executing a Ruleset Using Rule Execution Server > Invoking a Ruleset Using a Stateful Rule Session > Getting the Provider Class for a Stateful Rule Session

The following sets of code show how to get the provider class from both a remote and a local client. A remote client is where the client does not run in the same JVM as the rule session. A local client is where the client runs in the same JVM as the rule session; for example, in a JSP page.

To get the provider for a remote client:

Properties jndiProperties = new Properties(); 
jndiProperties.load(new FileInputStream("jndi.properties"));
IlrRuleSessionProvider rsProvider = new
   IlrRuleSessionProviderFactory.Builder(
   IlrRuleSessionProviderFactory.REMOTE_RULESESSION_PROVIDER,
   jndiProperties).build();

To get the provider for a local client:

IlrRuleSessionProvider rsProvider = new
   IlrRuleSessionProviderFactory.Builder(
   IlrRuleSessionProviderFactory.MANAGED_RULESESSION_PROVIDER).build();

You can get the provider class for a local client that does not invoke an EJB, where the client does not run in the same JVM as the rule session and does not use the session as an EJB (for example, in a JSP page):

To get the provider for a local client that does not invoke an EJB:

IlrRuleSessionProvider rsProvider = new
   IlrRuleSessionProviderFactory.Builder(
   IlrRuleSessionProviderFactory.SIMPLE_RULESESSION_PROVIDER).build();

You can also get the provider class in a J2SE environment (where the rule sessions are not used in an application server context).

To get the provider class in a J2SE environment:

// It will print the XU logs on System.err 
PrintWriter loggerPrinter = new PrintWriter(System.err); 
IlrRuleSessionProvider rsProvider = new 
   IlrRuleSessionProviderFactory.Builder(
   IlrRuleSessionProviderFactory.J2SE_RULESESSION_PROVIDER)
   .setLogger(loggerPrinter).build();