Read Me
Repository Beans API v 0.01
$Date:$
-------------------------------
Repository Beans is a toolkit for abstracting ATG Repositories into POJOs.
By using Repository Beans a developer may develop against ATG Repositories,
but retain the benefits of coding against POJOs.
This README assumes that you have some familiarity developing ATG applications.
Getting Started
------------------------
Download repository beans:
http://sourceforge.net/project/showfiles.php?group_id=180278
( If you are reading this you have probably already done this step! )
Extract the archive.
1. Update your module to include repository beans.
TODO (Ship repository beans as an ATG module for simplified installation)
Include repositorybeans-X.X.jar in the classpath of your ATG Module.
For example, include this entry in your modules META-INF/MANIFEST.MF
ATG-Class-Path: lib/repositorybeans-0.1.jar
Include repositorybeans-config-X.X.jar in the configpath of your ATG Module.
ATG-Config-Path: config/repositorybeans-config-0.1.jar
Define an ATG repository. Let's use the default ATG ProfileAdapterRepository for this example.
2. Define a POJO through which your application will communicate with the repository.
This POJO may be a class or an interface. POJO generation from a repository definition
is not yet implemented but it should be soon!
/**
* Interface for getting at the firstname and lastname
* properties of a "profile" repository item.
* Setter and Getter method names should match
* repository item property names.
*/
public interface Person {
public String setFirstname(String pName);
public String getFirstname();
public String setLastname(String pName);
public String getLastname();
}
3. Register your POJO for the given repository item
RepositoryBeans rbeans = (RepositoryBeans)Nucleus.getGlobalNucleus().resolveName("/atg/repository/beans/RepositoryBeans");
rbeans.register("/atg/userprofiling/ProfileAdapterRepository", "profile", Person.class);
4. Get an instance of your POJO
Person person = (Person) rbeans.newInstance("/atg/userprofiling/ProfileAdapterRepository", "profile");
// BTW person can be cast to atg.repository.beans.RepositoryBean or atg.repository.RepositoryItem
5. Update the first name property
RepositoryBean bean = (atg.repository.beans.RepositoryBean) person;
// include transaction handling
try {
bean.begin();
person.setFirstname("New First Name");
} finally {
bean.end();
}
6. Query for a Person by last name. Note query string is RQL (Repository Query Language).
String [] args = {"Jones"};
Collection c = rbeans.find("lastName = ?0", args, Person.class);
Iterator iter = c.iterator();
while (iter.hasNext()) {
Person person = (Person)iter.next();
System.out.println("Found person by last name" + person.getLastname()
+ ","
+ person.getFirstname();
}
Examples
------------------------
Take a look at unit test code for example usage.
In particular
src/test/java/atg/repository/beans/RepositoryBeansTest.java
Compatability
------------------------
Should work with ATG versions 5.X and higher.
Help
------------------------
Project Website:
http://repositorybeans.sourceforge.net/
Java Docs:
http://repositorybeans.sourceforge.net/apidocs/index.html
Filing Bugs:
http://sourceforge.net/tracker/?group_id=180278
Mailing List:
repositorybeans-general@lists.sourceforge.net
Subscribe/Unsubscribe URL:
https://lists.sourceforge.net/lists/listinfo/repositorybeans-general