Skip to content

Commit

Permalink
Easy service creation with inferred types
Browse files Browse the repository at this point in the history
  • Loading branch information
ghelmling committed Feb 12, 2010
1 parent 54131ce commit 72893fb
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 7 deletions.
14 changes: 7 additions & 7 deletions README.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
=====================
Meetup.Beeno Overview
Beeno Overview
=====================

The native Java API for HBase provides fairly low level access to your
Expand All @@ -23,7 +23,7 @@ Sample entity class::
/**
* Simple entity class with mapped properties
*/
@HBaseEntity(name="test_simple")
@HEntity(name="test_simple")
public static class SimpleEntity {
String id;
String stringProperty;
Expand Down Expand Up @@ -78,7 +78,7 @@ method-level annotations on methods conforming to JavaBeans property
conventions.


@HBaseEntity( name="*tablename*" )
@HEntity( name="*tablename*" )
This class-level annotation defines which HBase table is used to store
the entity's data. This is required.

Expand Down Expand Up @@ -198,18 +198,18 @@ Some query examples from the feeds implementation.

Find all items related to a discussion::

FeedItemService service = new FeedItemService(DiscussionItem.class);
EntityService<DiscussionItem> service = EntityService.create(DiscussionItem.class);
Query query =
service.query(DiscussionItem.class)
service.query()
.using( Criteria.eq("threadId", threadId) );
List items = query.execute();


Find first 5 greetings from a given member::

FeedItemService service = new FeedItemService();
EntityService<GreetingItem> service = EntityService.create(GreetingItem.class);
Query query =
service.query(opts)
service.query()
.using( Criteria.eq("memberId", memberId) )
.where( Criteria.eq(“itemType”, “chapter_greeting”) )
.limit( 5 );
Expand Down
9 changes: 9 additions & 0 deletions src/java/meetup/beeno/EntityService.java
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,15 @@ public class EntityService<T> {
defaultCollections.put(SortedSet.class, TreeSet.class);
}


/**
* Factory method for easy instantiation without overly verbose java
* generics typing.
*/
public static <T> EntityService<T> create(Class<T> itemType) {
return new EntityService<T>(itemType);
}

protected Class<T> clazz;
private EntityInfo defaultInfo;

Expand Down

0 comments on commit 72893fb

Please sign in to comment.