IBM®
Skip to main content
    Country/region [select]      Terms of use
 
 
    
     Home      Products      Services & solutions      Support & downloads      My account     
 
developerworks > My developerWorks >  Dashboard > WebSphere eXtreme Scale V6.1 User Guide > ... > Environment > Installation for a standalone J2SE application
developerWorks
Log In   View a printable version of the current page.
Overview Connect Spaces Forums Wikis
Installation for a standalone J2SE application
Added by bnewport, last edited by Chris.D.Johnson on Feb 07, 2008  (view change)
Labels: 
(None)

Getting Started Examples Reference API documentation

See the WebSphere eXtreme Scale Wiki for links to eXtreme Scale Version 7.0 documentation.
If you log in with your developerWorks ID, you can leave comments and feedback for the development team.

Setup

If you want to use ObjectGrid alone in a simple Jave 2 Platform Standard Edition (J2SE)  environment, you must have two jars: ogclient.jar and cglib.jar. These jars must be placed on the classpath of your JVM. The following section demonstrates how to write a simple Hello World program in a Windows environment, using ObjectGrid in a standalone environment. Use this example to learn, experiment with, or to write a complete application.

If the JVM is not an IBM JVM then please make sure the IBM ORB is present as detailed in Using a non-IBM JDK or JRE with ObjectGrid.

Simple ObjectGrid Application

In a J2SE environment, use one of the createObjectGrid methods on the ObjectGridManager interface as the mechanism for creating a core ObjectGrid to run in the current process.

The following code defines an entity named Person to use with the ObjectGrid: 

Person.java
import com.ibm.websphere.projector.annotations.Entity;
import com.ibm.websphere.projector.annotations.Id;

@Entity
public class Person
{
  @Id String ssn;
  String name;
}

See the ObjectGrid ObjectGrid API documentation for more information on the ObjectGrid programming model found in the following application code:

HelloWorld.java
import com.ibm.websphere.objectgrid.ObjectGrid;
import com.ibm.websphere.objectgrid.ObjectGridManagerFactory;
import com.ibm.websphere.objectgrid.Session;
import com.ibm.websphere.objectgrid.em.EntityManager;

public class HelloWorld
{
  static public void main(String[] argv)
    throws Exception
  {
    // boiler plate to get a standalone grid reference
    ObjectGrid grid = ObjectGridManagerFactory.getObjectGridManager().createObjectGrid();

    grid.registerEntities(new Class[] { Person.class });

    // get a session and then an em
    Session sess = grid.getSession();
    EntityManager em = sess.getEntityManager();

    // insert a Person
    em.getTransaction().begin();
    Person p = new Person();
    p.ssn = "1232";
    p.name = "Pedro Platinum";
    em.persist(p);
    em.getTransaction().commit();

    // get it back
    em.getTransaction().begin();
    p = (Person)em.find(Person.class, "1232");
    System.out.println("Person name is " + p.name);
    em.getTransaction().commit();

    System.exit(0);
  }
}

Running the Simple Application

From the command-line, use the following command to launch the previous application:

helloWorld.bat
java -classpath .;c:\xd61\ogclient.jar;C:\xd61\cglib.jar HelloWorld

This example assumes a Java 5 JVM is on the path, ogclient.jar and cglib.jar are in the directory c:\xd61, and the classes are in the current directory.

Starting and stopping an ObjectGrid container

See the Embedded server API topic for details on how to programmatically stop and start ObjectGrid containers in the dynamic deployment topology.

Enabling ObjectGrid FFDC in a non-WebSphere Application Server process

First Failure Data Capture files (FFDC) is a troubleshooting tool that logs exceptions and failures to a directory in the objectgridRoot/logs/ffdc directory. Each unique unexpected exception encountered by ObjectGrid will result in a new incident log file. A specific exception only creates a single incident so that the directory doesn't fill up if something happens in a loop for example. FFDC is very useful for troubleshooting problems

FFDC is disabled by default when running ObjectGrid in a non-WebSphere process (a Java SE process). To enable FFDC, add the following three files to your application's classpath:

If using a non-WebSphere application server or an application framework, the properties files can be copied into an application specific directory. For example, for Java EE web modules, you can copy the three FFDC files into the WEB-INF/classes directory.

Additional Information

Wiki Disclaimer and License
© Copyright IBM Corporation 2007,2009. All Rights Reserved.


 
    About IBM Privacy Contact