Menu

[6ce0e2]: / README  Maximize  Restore  History

Download this file

123 lines (81 with data), 3.6 kB

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
  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
	
	
    
Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.