The following code uses the Enterprise JavaBeans (EJB) transport protocol with WebSphere Application Server.
- In the code pane, immediately after the package line (that
is, after the first line of code), insert the following code:
// Import.
import java.util.Iterator;
import javax.security.auth.Subject;
import com.filenet.api.collection.ObjectStoreSet;
import com.filenet.api.core.Connection;
import com.filenet.api.core.Domain;
import com.filenet.api.core.Factory;
import com.filenet.api.core.ObjectStore;
import com.filenet.api.util.UserContext;
- In the code pane, within the class definition (such as
within the public class P8Connector definition),
insert the following code, substituting the placeholders with actual
values for your environment:
public static void main(String[] args)
{
// Set connection parameters; substitute for the placeholders.
String uri = "iiop://<hostname>:2809/FileNet/Engine";
String username = "<username>";
String password = "<password>";
// Make connection.
Connection conn = Factory.Connection.getConnection(uri);
Subject subject = UserContext.createSubject(conn, username, password, null);
UserContext.get().pushSubject(subject);
try
{
// Get default domain.
Domain domain = Factory.Domain.fetchInstance(conn, null, null);
System.out.println("Domain: " + domain.get_Name());
// Get object stores for domain.
ObjectStoreSet osSet = domain.get_ObjectStores();
ObjectStore store;
Iterator osIter = osSet.iterator();
while (osIter.hasNext() == true)
{
store = (ObjectStore) osIter.next();
System.out.println("Object store: " + store.get_Name());
}
System.out.println("Connection to Content Platform Engine successful");
}
finally
{
UserContext.get().popSubject();
}
}
- In the Eclipse menu bar, click .
- If the Problems pane is not already open, click the Show
View icon in the lower left corner of Eclipse, and click Problems.
- If your workspace preference is not set to build automatically,
click in the Eclipse menu bar.
If your code does not compile, verify that you: