aries-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From z..@apache.org
Subject svn commit: r1075106 [14/18] - in /aries/tags/samples-0.1-incubating: ./ ariestrader/ ariestrader/assemblies/ ariestrader/assemblies/ariestrader-all-eba/ ariestrader/assemblies/ariestrader-jdbc-eba/ ariestrader/assemblies/equinox-test-harness/ ariestra...
Date Sun, 27 Feb 2011 18:28:41 GMT
Added: aries/tags/samples-0.1-incubating/blog/blog-biz/src/main/java/org/apache/aries/samples/blog/biz/BlogEntryImpl.java
URL: http://svn.apache.org/viewvc/aries/tags/samples-0.1-incubating/blog/blog-biz/src/main/java/org/apache/aries/samples/blog/biz/BlogEntryImpl.java?rev=1075106&view=auto
==============================================================================
--- aries/tags/samples-0.1-incubating/blog/blog-biz/src/main/java/org/apache/aries/samples/blog/biz/BlogEntryImpl.java (added)
+++ aries/tags/samples-0.1-incubating/blog/blog-biz/src/main/java/org/apache/aries/samples/blog/biz/BlogEntryImpl.java Sun Feb 27 18:28:26 2011
@@ -0,0 +1,69 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.aries.samples.blog.biz;
+
+import java.util.Date;
+
+import org.apache.aries.samples.blog.api.BlogAuthor;
+import org.apache.aries.samples.blog.api.BlogEntry;
+import org.apache.aries.samples.blog.api.persistence.Entry;
+
+
+/** Implementation of a BlogPast */
+public class BlogEntryImpl implements BlogEntry
+{
+  public Entry theEntry;
+
+  public BlogEntryImpl(Entry blogEntry)
+  {
+    theEntry = blogEntry;
+  }
+
+  public BlogAuthor getAuthor()
+  {
+    return new BlogAuthorImpl(theEntry.getAuthor());
+    
+  }
+
+  public String getBody()
+  {
+    return theEntry.getBlogText();
+  }
+
+  public String getTitle()
+  {
+    return theEntry.getTitle();
+  }
+
+  public String getAuthorEmail()
+  {
+    return theEntry.getAuthor().getEmail();
+  }
+  
+  public Date getPublishDate()
+  {
+    return theEntry.getPublishDate();
+  }
+  
+  public long getId()
+  {
+    return theEntry.getId();
+  }
+
+}
\ No newline at end of file

Added: aries/tags/samples-0.1-incubating/blog/blog-biz/src/main/java/org/apache/aries/samples/blog/biz/BlogEntryManagerImpl.java
URL: http://svn.apache.org/viewvc/aries/tags/samples-0.1-incubating/blog/blog-biz/src/main/java/org/apache/aries/samples/blog/biz/BlogEntryManagerImpl.java?rev=1075106&view=auto
==============================================================================
--- aries/tags/samples-0.1-incubating/blog/blog-biz/src/main/java/org/apache/aries/samples/blog/biz/BlogEntryManagerImpl.java (added)
+++ aries/tags/samples-0.1-incubating/blog/blog-biz/src/main/java/org/apache/aries/samples/blog/biz/BlogEntryManagerImpl.java Sun Feb 27 18:28:26 2011
@@ -0,0 +1,162 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.aries.samples.blog.biz;
+
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.List;
+
+import org.apache.aries.samples.blog.api.BlogAuthor;
+import org.apache.aries.samples.blog.api.BlogEntry;
+import org.apache.aries.samples.blog.api.BlogEntryManager;
+import org.apache.aries.samples.blog.api.persistence.BlogPersistenceService;
+import org.apache.aries.samples.blog.api.persistence.Entry;
+
+
+
+public class BlogEntryManagerImpl implements BlogEntryManager
+{
+  private BlogPersistenceService persistenceService;
+  
+
+  // Injected via blueprint
+  public void setPersistenceService(BlogPersistenceService persistenceService)
+  {
+    this.persistenceService = persistenceService;
+  }
+  
+  
+  public void createBlogPost(String email, String title, String blogText, List<String> tags)
+  {
+    persistenceService.createBlogPost(email, title, blogText, tags);
+  }
+  
+  public Entry findBlogEntryByTitle(String title)
+  {
+    return persistenceService.findBlogEntryByTitle(title);
+  }
+  
+  public List<? extends BlogEntry> getAllBlogEntries()
+  {
+	  List<? extends Entry> entries = persistenceService.getAllBlogEntries();
+		return adaptEntries(entries);
+  }
+  
+  public List<? extends BlogEntry> getBlogEntries(int firstPostIndex, int noOfPosts)
+  { 
+	  List<? extends Entry> entries = persistenceService.getBlogEntries(firstPostIndex, noOfPosts);		   		      
+		return adaptEntries(entries);
+  }
+  
+  public List<? extends BlogEntry> getBlogsForAuthor(String emailAddress)
+  {
+		List <?extends Entry> entries= persistenceService.getBlogsForAuthor(emailAddress);
+		return adaptEntries(entries);
+    
+  }
+  
+  public List<? extends BlogEntry> getBlogEntriesModifiedBetween(String startDate, String endDate) throws ParseException
+  {
+    if(startDate == null || "".equals(startDate)) throw new IllegalArgumentException("A valid start date must be supplied");
+    if(endDate == null || "".equals(endDate)) throw new IllegalArgumentException("A valid end date must be supplied");
+    SimpleDateFormat sdf = new SimpleDateFormat("dd-MM-yyyy");
+    Date start = sdf.parse(startDate);
+    Date end = sdf.parse(endDate);
+	List <? extends Entry> entries = persistenceService.getBlogEntriesModifiedBetween(start, end);
+	return adaptEntries(entries);
+  }
+  
+  public int getNoOfPosts()
+  {
+    return persistenceService.getNoOfBlogEntries();
+  }
+  
+  public void removeBlogEntry(BlogAuthor a, String title, String publishDate) throws ParseException
+  {
+    if(a == null) throw new IllegalArgumentException("An author must be specified");
+    if(title == null) title = "";
+    if(publishDate == null) throw new IllegalArgumentException("The article must have a publication date");
+    Date pubDate = parseDate(publishDate);
+    long found = -920234218060948564L;
+    
+    for(BlogEntry b : a.getEntries()) {
+      if(title.equals(b.getTitle()) && pubDate.equals(b.getPublishDate())){
+        found = b.getId();
+        break;
+      }
+    }
+    persistenceService.removeBlogEntry(found);
+  }
+  
+  public void updateBlogEntry(BlogEntry originalEntry, BlogAuthor a, String title, String publishDate, String blogText, List<String> tags) throws ParseException
+  {
+	
+	if (originalEntry.getAuthor() == null
+			|| originalEntry.getAuthorEmail() == null)
+		throw new IllegalArgumentException("An author must be specified");
+	if (title == null)
+		title = "";
+	if (publishDate == null)
+		throw new IllegalArgumentException(
+				"The article must have a publication date");
+	long found = -920234218060948564L;
+	Date pubDate = parseDate(publishDate);
+	for (BlogEntry b : getBlogsForAuthor(originalEntry.getAuthorEmail()
+			)) {
+		if (title.equals(b.getTitle())
+				&& pubDate.equals(b.getPublishDate())) {
+			found = b.getId();
+			break;
+		}
+	}
+
+	if (found == -920234218060948564L)
+		throw new IllegalArgumentException("No blog entry could be found");
+
+	String email = a.getEmailAddress();
+
+	if (tags == null) {
+		tags = new ArrayList<String>();
+	}
+
+	Date updatedDate = new Date(System.currentTimeMillis());
+
+	persistenceService.updateBlogEntry(found, email, title, blogText, tags,
+			updatedDate);
+  }
+  
+  private Date parseDate(String dateString) throws ParseException
+  {
+    SimpleDateFormat sdf = new SimpleDateFormat("dd-MM-yyyy");
+    return sdf.parse(dateString);
+  }
+
+  
+  public BlogEntry getBlogPost(long id)
+  {
+    return new BlogEntryImpl(persistenceService.getBlogEntryById(id));
+  }
+  
+	private List <? extends BlogEntry> adaptEntries(List<? extends Entry> entries) {
+		return new BlogListAdapter<BlogEntry, Entry>(entries, BlogEntryImpl.class, Entry.class);
+  }
+	
+}
\ No newline at end of file

Added: aries/tags/samples-0.1-incubating/blog/blog-biz/src/main/java/org/apache/aries/samples/blog/biz/BlogImpl.java
URL: http://svn.apache.org/viewvc/aries/tags/samples-0.1-incubating/blog/blog-biz/src/main/java/org/apache/aries/samples/blog/biz/BlogImpl.java?rev=1075106&view=auto
==============================================================================
--- aries/tags/samples-0.1-incubating/blog/blog-biz/src/main/java/org/apache/aries/samples/blog/biz/BlogImpl.java (added)
+++ aries/tags/samples-0.1-incubating/blog/blog-biz/src/main/java/org/apache/aries/samples/blog/biz/BlogImpl.java Sun Feb 27 18:28:26 2011
@@ -0,0 +1,32 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.aries.samples.blog.biz;
+
+import org.apache.aries.samples.blog.api.Blog;
+
+
+/** Implementation of Blog */
+public class BlogImpl implements Blog
+{
+  
+  public String getBlogTitle()
+  {
+    return "Sample Blog";
+  }
+}
\ No newline at end of file

Added: aries/tags/samples-0.1-incubating/blog/blog-biz/src/main/java/org/apache/aries/samples/blog/biz/BlogListAdapter.java
URL: http://svn.apache.org/viewvc/aries/tags/samples-0.1-incubating/blog/blog-biz/src/main/java/org/apache/aries/samples/blog/biz/BlogListAdapter.java?rev=1075106&view=auto
==============================================================================
--- aries/tags/samples-0.1-incubating/blog/blog-biz/src/main/java/org/apache/aries/samples/blog/biz/BlogListAdapter.java (added)
+++ aries/tags/samples-0.1-incubating/blog/blog-biz/src/main/java/org/apache/aries/samples/blog/biz/BlogListAdapter.java Sun Feb 27 18:28:26 2011
@@ -0,0 +1,165 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.aries.samples.blog.biz;
+
+import java.lang.reflect.Constructor;
+import java.lang.reflect.InvocationTargetException;
+import java.util.Collection;
+import java.util.Iterator;
+import java.util.List;
+import java.util.ListIterator;
+
+public class BlogListAdapter<F, B> implements List<F> {
+
+	private List<? extends B> backendList;
+	private Class<? extends F> frontendClazz;
+	private Class<B> backendClazz;
+
+	public BlogListAdapter(List<? extends B> backendList,
+			Class<? extends F> frontendClazz, Class<B> backendClazz) {
+		this.backendList = backendList;
+		this.frontendClazz = frontendClazz;
+		this.backendClazz = backendClazz;
+	}
+
+	public void add() {
+		throw new UnsupportedOperationException(
+				"Modifications to the list are not supported");
+	}
+
+	public boolean add(F e) {
+		throw new UnsupportedOperationException(
+				"Modifications to the list are not supported");
+	}
+
+	public void add(int index, F element) {
+		throw new UnsupportedOperationException(
+				"Modifications to the list are not supported");
+	}
+
+	public boolean addAll(Collection<? extends F> c) {
+		throw new UnsupportedOperationException(
+				"Modifications to the list are not supported");
+	}
+
+	public boolean addAll(int index, Collection<? extends F> c) {
+		throw new UnsupportedOperationException(
+				"Modifications to the list are not supported");
+	}
+
+	public void clear() {
+		throw new UnsupportedOperationException(
+				"Modifications to the list are not supported");
+
+	}
+
+	public boolean contains(Object o) {
+		throw new UnsupportedOperationException("Contains() is not supported");
+
+	}
+
+	public boolean containsAll(Collection<?> c) {
+		throw new UnsupportedOperationException(
+				"ContainsAll() is not supported");
+	}
+
+	public F get(int index) {
+		Constructor<F> c;
+		try {
+			c = (Constructor<F>) frontendClazz.getConstructor(backendClazz);
+			return c.newInstance(backendList.get(index));
+		} catch (Exception e) {
+			// TODO Auto-generated catch block
+			e.printStackTrace();
+		} 
+		return null;
+	}
+
+	public int indexOf(Object o) {
+		throw new UnsupportedOperationException("IndexOf() is not supported");
+	}
+
+	public boolean isEmpty() {
+		return backendList.isEmpty();
+	}
+
+	public Iterator iterator() {
+		return new BlogListIterator(backendList.listIterator(), frontendClazz,
+				backendClazz);
+	}
+
+	public int lastIndexOf(Object o) {
+		throw new UnsupportedOperationException(
+				"lastIndexOf() is not supported");
+	}
+
+	public ListIterator listIterator() {
+		return new BlogListIterator(backendList.listIterator(), frontendClazz,
+				backendClazz);
+	}
+
+	public ListIterator listIterator(int index) {
+		return new BlogListIterator(backendList.listIterator(index),
+				frontendClazz, backendClazz);
+	}
+
+	public boolean remove(Object o) {
+		throw new UnsupportedOperationException(
+				"Modifications to the list are not supported");
+	}
+
+	public F remove(int index) {
+		throw new UnsupportedOperationException(
+				"Modifications to the list are not supported");
+	}
+
+	public boolean removeAll(Collection c) {
+		throw new UnsupportedOperationException(
+				"Modifications to the list are not supported");
+	}
+
+	public boolean retainAll(Collection c) {
+		throw new UnsupportedOperationException(
+				"Modifications to the list are not supported");
+	}
+
+	public Object set(int index, Object element) {
+		throw new UnsupportedOperationException(
+				"Modifications to the list are not supported");
+	}
+
+	public int size() {
+		return backendList.size();
+	}
+
+	public List subList(int fromIndex, int toIndex) {
+		throw new UnsupportedOperationException("subList() is not supported");
+	}
+
+	public Object[] toArray() {
+		throw new UnsupportedOperationException("toArray() is not supported");
+	}
+
+	public Object[] toArray(Object[] a) {
+		throw new UnsupportedOperationException(
+				"toArray(Object[] a) is not supported");
+	}
+
+}
+

Added: aries/tags/samples-0.1-incubating/blog/blog-biz/src/main/java/org/apache/aries/samples/blog/biz/BlogListIterator.java
URL: http://svn.apache.org/viewvc/aries/tags/samples-0.1-incubating/blog/blog-biz/src/main/java/org/apache/aries/samples/blog/biz/BlogListIterator.java?rev=1075106&view=auto
==============================================================================
--- aries/tags/samples-0.1-incubating/blog/blog-biz/src/main/java/org/apache/aries/samples/blog/biz/BlogListIterator.java (added)
+++ aries/tags/samples-0.1-incubating/blog/blog-biz/src/main/java/org/apache/aries/samples/blog/biz/BlogListIterator.java Sun Feb 27 18:28:26 2011
@@ -0,0 +1,100 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.aries.samples.blog.biz;
+
+import java.lang.reflect.Constructor;
+import java.util.ListIterator;
+
+public class BlogListIterator<B, F> implements ListIterator<F> {
+
+	private ListIterator<? extends B> internalListIterator;
+
+	private Class<? extends F> frontendClazz;
+	private Class<B> backendClazz;
+
+	public BlogListIterator(ListIterator<? extends B> listIterator,
+			Class<? extends F> frontendClazz, Class<B> backendClazz) {
+		this.internalListIterator = listIterator;
+		this.frontendClazz = frontendClazz;
+		this.backendClazz = backendClazz;
+	}
+
+	public void add(Object e) {
+		throw new UnsupportedOperationException("");
+	}
+
+	public boolean hasNext() {
+		return internalListIterator.hasNext();
+	}
+
+	public boolean hasPrevious() {
+		return internalListIterator.hasPrevious();
+	}
+
+	public F next() {
+		try {
+			return getConstructor().newInstance(internalListIterator.next());
+		} catch (Exception e) {
+			// TODO Auto-generated catch block
+			e.printStackTrace();
+		}
+		return null;
+	}
+
+	public int nextIndex() {
+		return internalListIterator.nextIndex();
+	}
+
+	public F previous() {	
+		try {
+			return getConstructor().newInstance(internalListIterator.previous());
+		} catch (Exception e) {
+			// TODO Auto-generated catch block
+			e.printStackTrace();
+		}
+		return null;
+	}
+
+	public int previousIndex() {
+		// TODO Auto-generated method stub
+		return 0;
+	}
+
+	public void remove() {
+		throw new UnsupportedOperationException(
+				"Modifications to the list are not supported");
+	}
+
+	public void set(Object e) {
+		throw new UnsupportedOperationException(
+				"Modifications to the list are not supported");
+	}
+
+	private Constructor<F> getConstructor() {
+		Constructor<F> c;
+		try {
+			c = (Constructor<F>) frontendClazz.getConstructor(backendClazz);
+			return c;
+		} catch (Exception e) {
+			// TODO Auto-generated catch block
+			e.printStackTrace();
+		}
+		return null;
+	}
+}

Added: aries/tags/samples-0.1-incubating/blog/blog-biz/src/main/java/org/apache/aries/samples/blog/biz/BloggingServiceImpl.java
URL: http://svn.apache.org/viewvc/aries/tags/samples-0.1-incubating/blog/blog-biz/src/main/java/org/apache/aries/samples/blog/biz/BloggingServiceImpl.java?rev=1075106&view=auto
==============================================================================
--- aries/tags/samples-0.1-incubating/blog/blog-biz/src/main/java/org/apache/aries/samples/blog/biz/BloggingServiceImpl.java (added)
+++ aries/tags/samples-0.1-incubating/blog/blog-biz/src/main/java/org/apache/aries/samples/blog/biz/BloggingServiceImpl.java Sun Feb 27 18:28:26 2011
@@ -0,0 +1,127 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.aries.samples.blog.biz;
+
+import java.text.ParseException;
+import java.util.Arrays;
+import java.util.List;
+
+import org.apache.aries.samples.blog.api.BlogAuthor;
+import org.apache.aries.samples.blog.api.BlogAuthorManager;
+import org.apache.aries.samples.blog.api.BlogComment;
+import org.apache.aries.samples.blog.api.BlogCommentManager;
+import org.apache.aries.samples.blog.api.BlogEntry;
+import org.apache.aries.samples.blog.api.BlogEntryManager;
+import org.apache.aries.samples.blog.api.BloggingService;
+
+/** Implementation of the BloggingService */
+public class BloggingServiceImpl implements BloggingService {
+	private BlogEntryManager blogEntryManager;
+	private BlogAuthorManager blogAuthorManager;
+	private BlogCommentManager blogCommentManager;
+
+	// Injected via blueprint
+	public void setBlogEntryManager(BlogEntryManager blogPostManager) {
+		this.blogEntryManager = blogPostManager;
+	}
+
+	// Injected via blueprint
+	public void setBlogAuthorManager(BlogAuthorManager authorManager) {
+		this.blogAuthorManager = authorManager;
+	}
+	
+	// Injected via blueprint
+	public void setBlogCommentManager(BlogCommentManager commentManager) {
+		this.blogCommentManager = commentManager;
+	}
+
+
+	public String getBlogTitle() {
+		return new BlogImpl().getBlogTitle();
+	}
+
+	public BlogAuthor getBlogAuthor(String email) {
+		return blogAuthorManager.getAuthor(email);
+	}
+
+	public void createBlogAuthor(String email, String nickName, String name,
+			String bio, String dob) {
+		try {
+			blogAuthorManager.createAuthor(email, dob, name, nickName, bio);
+		} catch (ParseException e) {
+			// TODO Auto-generated catch block
+			e.printStackTrace();
+		}
+	}
+
+	public void updateBlogAuthor(String email, String nickName, String name,
+			String bio, String dob) {
+		try {
+			blogAuthorManager.updateAuthor(email, dob, name, nickName, bio);
+		} catch (ParseException e) {
+			// TODO Auto-generated catch block
+			e.printStackTrace();
+		}
+	}
+
+	public BlogEntry getPost(long id) {
+		return blogEntryManager.getBlogPost(id);
+	}
+
+	public List<? extends BlogEntry> getBlogEntries(int firstPostIndex,
+			int noOfPosts) {
+		return blogEntryManager.getBlogEntries(firstPostIndex, noOfPosts);
+
+	}
+
+	public List<? extends BlogEntry> getAllBlogEntries() {
+		return blogEntryManager.getAllBlogEntries();
+	}
+
+	public int getNoOfEntries() {
+		return blogEntryManager.getNoOfPosts();
+	}
+
+	public void createBlogEntry(String email, String title, String blogText,
+			String tags) {
+		blogEntryManager.createBlogPost(email, title, blogText, Arrays
+				.asList(tags.split(",")));
+	}
+
+	public void createBlogComment(String comment, String authorEmail, long id) {
+		blogCommentManager.createComment(comment, authorEmail, id);
+	}
+
+	public void deleteBlogComment(BlogComment comment) {
+		blogCommentManager.deleteComment(comment.getId());
+	}
+
+	public List<? extends BlogComment> getCommentsForEntry(BlogEntry entry) {
+		return blogCommentManager.getCommentsForPost(entry.getId());
+	}
+
+	public BlogEntry getBlogEntry(long id) {
+		return blogEntryManager.getBlogPost(id);
+	}
+	
+	public boolean isCommentingAvailable() {
+		return blogCommentManager.isCommentingAvailable();
+
+	}
+}
\ No newline at end of file

Added: aries/tags/samples-0.1-incubating/blog/blog-biz/src/main/resources/OSGI-INF/blueprint/blueprint.xml
URL: http://svn.apache.org/viewvc/aries/tags/samples-0.1-incubating/blog/blog-biz/src/main/resources/OSGI-INF/blueprint/blueprint.xml?rev=1075106&view=auto
==============================================================================
--- aries/tags/samples-0.1-incubating/blog/blog-biz/src/main/resources/OSGI-INF/blueprint/blueprint.xml (added)
+++ aries/tags/samples-0.1-incubating/blog/blog-biz/src/main/resources/OSGI-INF/blueprint/blueprint.xml Sun Feb 27 18:28:26 2011
@@ -0,0 +1,49 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+    Licensed to the Apache Software Foundation (ASF) under one or more
+    contributor license agreements.  See the NOTICE file distributed with
+    this work for additional information regarding copyright ownership.
+    The ASF licenses this file to You under the Apache License, Version 2.0
+    (the "License"); you may not use this file except in compliance with
+    the License.  You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+    Unless required by applicable law or agreed to in writing, software
+    distributed under the License is distributed on an "AS IS" BASIS,
+    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+    See the License for the specific language governing permissions and
+    limitations under the License.
+-->
+<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
+            xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+            xsi:schemaLocation="http://www.osgi.org/xmlns/blueprint/v1.0.0">
+
+  <bean id="blogAuthorManager" class="org.apache.aries.samples.blog.biz.BlogAuthorManagerImpl">
+    <property name="persistenceService" ref="persistenceManager"/>
+  </bean>
+  
+  <bean id="blogEntryManager" class="org.apache.aries.samples.blog.biz.BlogEntryManagerImpl">
+    <property name="persistenceService" ref="persistenceManager"/>
+  </bean>
+  
+  <bean id="blogCommentManager" class="org.apache.aries.samples.blog.biz.BlogCommentManagerImpl">
+    <property name="commentService" ref="commentPersistenceService"/>
+  </bean>
+ 
+  
+  <bean id="bloggingServiceComponent" class="org.apache.aries.samples.blog.biz.BloggingServiceImpl">
+    <property name="blogEntryManager" ref="blogEntryManager"/>
+    <property name="blogAuthorManager" ref="blogAuthorManager"/>
+  <property name="blogCommentManager" ref="blogCommentManager"/>
+  </bean>
+  
+  <service ref="bloggingServiceComponent" interface="org.apache.aries.samples.blog.api.BloggingService"/>
+
+  <reference id="persistenceManager" interface="org.apache.aries.samples.blog.api.persistence.BlogPersistenceService"/>
+
+  <reference id="commentPersistenceService" availability="optional" interface="org.apache.aries.samples.blog.api.comment.persistence.BlogCommentService">
+    <reference-listener ref="blogCommentManager" bind-method="blogServiceBound" unbind-method="blogServiceUnbound"/>
+  </reference>
+ 
+</blueprint>

Added: aries/tags/samples-0.1-incubating/blog/blog-datasource/pom.xml
URL: http://svn.apache.org/viewvc/aries/tags/samples-0.1-incubating/blog/blog-datasource/pom.xml?rev=1075106&view=auto
==============================================================================
--- aries/tags/samples-0.1-incubating/blog/blog-datasource/pom.xml (added)
+++ aries/tags/samples-0.1-incubating/blog/blog-datasource/pom.xml Sun Feb 27 18:28:26 2011
@@ -0,0 +1,75 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements.  See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership.  The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License.  You may obtain a copy of the License at
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on an
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied.  See the License for the
+ specific language governing permissions and limitations
+ under the License.
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+  <modelVersion>4.0.0</modelVersion>
+    <parent>
+        <groupId>org.apache.aries.samples.blog</groupId>
+        <artifactId>blog</artifactId>
+        <version>0.1-incubating</version>
+    </parent>
+  <groupId>org.apache.aries.samples.blog</groupId>
+  <artifactId>org.apache.aries.samples.blog.datasource</artifactId>
+  <name>Apache Aries blog sample transaction enlisting JDBC datasource</name>
+  <packaging>bundle</packaging>
+  <dependencies>
+        <dependency>
+          <groupId>org.apache.derby</groupId>
+          <artifactId>derby</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.aries.transaction</groupId>
+            <artifactId>org.apache.aries.transaction.blueprint</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.geronimo.components</groupId>
+            <artifactId>geronimo-transaction</artifactId>
+        </dependency>
+  </dependencies>
+  <build>
+   <resources>
+        <resource>
+            <targetPath>OSGI-INF/blueprint</targetPath>
+            <filtering>false</filtering>
+            <directory>${basedir}/src/main/resources/OSGI-INF/blueprint</directory>
+            <includes>
+                <include>*.xml</include>
+            </includes>
+        </resource>
+    </resources>
+        <plugins>
+            <plugin>
+                <groupId>org.apache.felix</groupId>
+                <artifactId>maven-bundle-plugin</artifactId>
+                <extensions>true</extensions>
+                <configuration>
+                    <instructions>
+                        <Import-Package>
+                            *
+                        </Import-Package>
+                        <Private-Package>
+                            org.apache.aries.samples.blog.datasource
+                        </Private-Package>
+                        <Bundle-SymbolicName>${pom.artifactId}</Bundle-SymbolicName>
+                    </instructions>
+                </configuration>
+            </plugin>
+        </plugins>
+  </build>
+</project>

Added: aries/tags/samples-0.1-incubating/blog/blog-datasource/src/main/resources/OSGI-INF/blueprint/dataSource.xml
URL: http://svn.apache.org/viewvc/aries/tags/samples-0.1-incubating/blog/blog-datasource/src/main/resources/OSGI-INF/blueprint/dataSource.xml?rev=1075106&view=auto
==============================================================================
--- aries/tags/samples-0.1-incubating/blog/blog-datasource/src/main/resources/OSGI-INF/blueprint/dataSource.xml (added)
+++ aries/tags/samples-0.1-incubating/blog/blog-datasource/src/main/resources/OSGI-INF/blueprint/dataSource.xml Sun Feb 27 18:28:26 2011
@@ -0,0 +1,46 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements.  See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership.  The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License.  You may obtain a copy of the License at
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on an
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied.  See the License for the
+ specific language governing permissions and limitations
+ under the License.
+-->
+<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
+            xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+            xsi:schemaLocation="http://www.osgi.org/xmlns/blueprint/v1.0.0"
+            default-activation="lazy">
+  
+  <bean id="derbyXADataSource" class="org.apache.derby.jdbc.EmbeddedXADataSource">
+    <property name="databaseName" value="blogDB"/>
+  </bean>
+  
+  <service id="xaDataSource" ref="derbyXADataSource" interface="javax.sql.XADataSource">
+  <service-properties>
+    <entry key="osgi.jndi.service.name" value="jdbc/blogdb"/>
+   </service-properties>
+  </service>
+
+  
+  <bean id="derbyDataSource" class="org.apache.derby.jdbc.EmbeddedDataSource">
+    <property name="databaseName" value="blogDB"/>
+  </bean>
+  
+  <service ref="derbyDataSource" interface="javax.sql.DataSource">
+   <service-properties>
+     <entry key="osgi.jndi.service.name" value="jdbc/blogdbnojta"/>
+   </service-properties>
+  </service>
+  
+</blueprint>

Added: aries/tags/samples-0.1-incubating/blog/blog-jdbc-eba/pom.xml
URL: http://svn.apache.org/viewvc/aries/tags/samples-0.1-incubating/blog/blog-jdbc-eba/pom.xml?rev=1075106&view=auto
==============================================================================
--- aries/tags/samples-0.1-incubating/blog/blog-jdbc-eba/pom.xml (added)
+++ aries/tags/samples-0.1-incubating/blog/blog-jdbc-eba/pom.xml Sun Feb 27 18:28:26 2011
@@ -0,0 +1,76 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+Licensed to the Apache Software Foundation (ASF) under one
+or more contributor license agreements.  See the NOTICE file
+distributed with this work for additional information
+regarding copyright ownership.  The ASF licenses this file
+to you under the Apache License, Version 2.0 (the
+"License"); you may not use this file except in compliance
+with the License.  You may obtain a copy of the License at
+
+  http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing,
+software distributed under the License is distributed on an
+"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+KIND, either express or implied.  See the License for the
+specific language governing permissions and limitations
+under the License.
+-->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+
+    <modelVersion>4.0.0</modelVersion>
+
+    <parent>
+        <groupId>org.apache.aries.samples.blog</groupId>
+        <artifactId>blog</artifactId>
+        <version>0.1-incubating</version>
+    </parent>
+
+    <groupId>org.apache.aries.samples.blog</groupId>
+    <artifactId>org.apache.aries.samples.blog.jdbc.eba</artifactId>
+    <name>Apache Aries Blog Sample EBA using JDBC</name>
+    <description>
+  This EBA contains the core bundles for the sample Blog application.  
+  It does not include all transitive dependencies, which need to
+  be provisioned during deployment.  It uses JDBC for the persistence layer.
+    </description>
+    <packaging>eba</packaging>
+
+    <dependencies>
+        <dependency>
+            <groupId>org.apache.aries.samples.blog</groupId>
+            <artifactId>org.apache.aries.samples.blog.api</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.aries.samples.blog</groupId>
+            <artifactId>org.apache.aries.samples.blog.web</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.aries.samples.blog</groupId>
+            <artifactId>org.apache.aries.samples.blog.biz</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.aries.samples.blog</groupId>
+            <artifactId>org.apache.aries.samples.blog.persistence.jdbc</artifactId>
+        </dependency>
+    </dependencies>
+
+    <build>
+        <plugins>
+            <plugin>
+                <groupId>org.apache.aries</groupId>
+                <artifactId>eba-maven-plugin</artifactId>
+                <extensions>true</extensions>
+                <configuration>
+                    <generateManifest>true</generateManifest>
+                    <instructions>
+                        <Application-SymbolicName>${pom.artifactId}</Application-SymbolicName>
+                    </instructions>
+                </configuration>
+            </plugin>
+        </plugins>
+    </build>
+</project>

Added: aries/tags/samples-0.1-incubating/blog/blog-jpa-eba/pom.xml
URL: http://svn.apache.org/viewvc/aries/tags/samples-0.1-incubating/blog/blog-jpa-eba/pom.xml?rev=1075106&view=auto
==============================================================================
--- aries/tags/samples-0.1-incubating/blog/blog-jpa-eba/pom.xml (added)
+++ aries/tags/samples-0.1-incubating/blog/blog-jpa-eba/pom.xml Sun Feb 27 18:28:26 2011
@@ -0,0 +1,76 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+Licensed to the Apache Software Foundation (ASF) under one
+or more contributor license agreements.  See the NOTICE file
+distributed with this work for additional information
+regarding copyright ownership.  The ASF licenses this file
+to you under the Apache License, Version 2.0 (the
+"License"); you may not use this file except in compliance
+with the License.  You may obtain a copy of the License at
+
+  http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing,
+software distributed under the License is distributed on an
+"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+KIND, either express or implied.  See the License for the
+specific language governing permissions and limitations
+under the License.
+-->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+
+    <modelVersion>4.0.0</modelVersion>
+
+    <parent>
+        <groupId>org.apache.aries.samples.blog</groupId>
+        <artifactId>blog</artifactId>
+        <version>0.1-incubating</version>
+    </parent>
+
+    <groupId>org.apache.aries.samples.blog</groupId>
+    <artifactId>org.apache.aries.samples.blog.jpa.eba</artifactId>
+    <name>Apache Aries Blog Sample EBA using JPA</name>
+    <description>
+  This EBA contains the core bundles for the sample Blog application.  
+  It does not include all transitive dependencies, which need to
+  be provisioned during deployment.  It uses JPA for the persistence layer.
+    </description>
+    <packaging>eba</packaging>
+
+    <dependencies>
+        <dependency>
+            <groupId>org.apache.aries.samples.blog</groupId>
+            <artifactId>org.apache.aries.samples.blog.api</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.aries.samples.blog</groupId>
+            <artifactId>org.apache.aries.samples.blog.web</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.aries.samples.blog</groupId>
+            <artifactId>org.apache.aries.samples.blog.biz</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.aries.samples.blog</groupId>
+            <artifactId>org.apache.aries.samples.blog.persistence.jpa</artifactId>
+        </dependency>
+    </dependencies>
+
+    <build>
+        <plugins>
+            <plugin>
+                <groupId>org.apache.aries</groupId>
+                <artifactId>eba-maven-plugin</artifactId>
+                <extensions>true</extensions>
+                <configuration>
+                    <generateManifest>true</generateManifest>
+                    <instructions>
+                        <Application-SymbolicName>${pom.artifactId}</Application-SymbolicName>
+                    </instructions>
+                </configuration>
+            </plugin>
+        </plugins>
+    </build>
+</project>

Added: aries/tags/samples-0.1-incubating/blog/blog-persistence-jdbc/pom.xml
URL: http://svn.apache.org/viewvc/aries/tags/samples-0.1-incubating/blog/blog-persistence-jdbc/pom.xml?rev=1075106&view=auto
==============================================================================
--- aries/tags/samples-0.1-incubating/blog/blog-persistence-jdbc/pom.xml (added)
+++ aries/tags/samples-0.1-incubating/blog/blog-persistence-jdbc/pom.xml Sun Feb 27 18:28:26 2011
@@ -0,0 +1,62 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+    Licensed to the Apache Software Foundation (ASF) under one or more
+    contributor license agreements.  See the NOTICE file distributed with
+    this work for additional information regarding copyright ownership.
+    The ASF licenses this file to You under the Apache License, Version 2.0
+    (the "License"); you may not use this file except in compliance with
+    the License.  You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+    Unless required by applicable law or agreed to in writing, software
+    distributed under the License is distributed on an "AS IS" BASIS,
+    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+    See the License for the specific language governing permissions and
+    limitations under the License.
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+
+    <modelVersion>4.0.0</modelVersion>
+
+    <parent>
+        <groupId>org.apache.aries.samples.blog</groupId>
+        <artifactId>blog</artifactId>
+        <version>0.1-incubating</version>
+    </parent>
+
+    <groupId>org.apache.aries.samples.blog</groupId>
+    <artifactId>org.apache.aries.samples.blog.persistence.jdbc</artifactId>
+    <name>Apache Aries blog sample persistence</name>
+    <packaging>bundle</packaging>
+
+    <dependencies>
+        <dependency>
+            <groupId>org.apache.aries.samples.blog</groupId>
+            <artifactId>org.apache.aries.samples.blog.api</artifactId>
+            <scope>provided</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.derby</groupId>
+            <artifactId>derby</artifactId>
+        </dependency>
+    </dependencies>
+
+    <build>
+        <plugins>
+            <plugin>
+                <groupId>org.apache.felix</groupId>
+                <artifactId>maven-bundle-plugin</artifactId>
+                <configuration>
+                    <instructions>
+                        <Bundle-SymbolicName>${pom.artifactId}</Bundle-SymbolicName>
+                        <Private-Package>org.apache.aries.samples.blog.persistence.jdbc.*</Private-Package>
+                        <Export-Package>!org.apache.aries.samples.blog.persistence.jdbc*</Export-Package>
+                    </instructions>
+                </configuration>
+            </plugin>
+        </plugins>
+    </build>
+
+</project>
+	

Added: aries/tags/samples-0.1-incubating/blog/blog-persistence-jdbc/src/main/java/org/apache/aries/samples/blog/persistence/jdbc/BlogPersistenceServiceImpl.java
URL: http://svn.apache.org/viewvc/aries/tags/samples-0.1-incubating/blog/blog-persistence-jdbc/src/main/java/org/apache/aries/samples/blog/persistence/jdbc/BlogPersistenceServiceImpl.java?rev=1075106&view=auto
==============================================================================
--- aries/tags/samples-0.1-incubating/blog/blog-persistence-jdbc/src/main/java/org/apache/aries/samples/blog/persistence/jdbc/BlogPersistenceServiceImpl.java (added)
+++ aries/tags/samples-0.1-incubating/blog/blog-persistence-jdbc/src/main/java/org/apache/aries/samples/blog/persistence/jdbc/BlogPersistenceServiceImpl.java Sun Feb 27 18:28:26 2011
@@ -0,0 +1,659 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.aries.samples.blog.persistence.jdbc;
+
+import java.sql.Connection;
+import java.sql.PreparedStatement;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.text.ParseException;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.List;
+
+import javax.sql.DataSource;
+
+import org.apache.aries.samples.blog.api.persistence.BlogPersistenceService;
+import org.apache.aries.samples.blog.persistence.jdbc.entity.AuthorImpl;
+import org.apache.aries.samples.blog.persistence.jdbc.entity.EntryImpl;
+
+/**
+ * This class is the implementation of the blogPersistenceService
+ */
+public class BlogPersistenceServiceImpl implements BlogPersistenceService {
+	private DataSource dataSource;
+	
+
+	/**
+	 * set data source
+	 */
+	public void setDataSource(DataSource dataSource) {
+		this.dataSource = dataSource;
+	}
+
+	/**
+	 * Create an author record
+	 * 
+	 * @param a
+	 *            The author object to be created
+	 * @throws ParseException
+	 * @throws ParseException
+	 */
+	public void createAuthor(String email, Date dob, String name,
+			String displayName, String bio) {
+		
+		
+		try {
+			Connection connection = dataSource.getConnection();
+			String sql = "INSERT INTO AUTHOR VALUES (?,?,?,?,?)";
+			
+			PreparedStatement ppsm = connection.prepareStatement(sql);
+			ppsm.setString(1, email);
+			ppsm.setString(2, bio);
+			ppsm.setString(3, displayName);
+			if (dob != null)
+				ppsm.setDate(4, new java.sql.Date(dob.getTime()));
+			else
+				ppsm.setDate(4, null);
+			ppsm.setString(5, name);
+			int insertRows = ppsm.executeUpdate();
+			ppsm.close();
+			connection.close();
+			
+			if (insertRows != 1)
+				throw new IllegalArgumentException("The Author " + email
+						+ " cannot be inserted.");
+		} catch (SQLException e) {
+			e.printStackTrace();
+			throw new IllegalArgumentException(e.getMessage());
+		}
+
+	}
+
+	/**
+	 * Create a blog entry record
+	 * 
+	 * @param a 
+	 * 			The author
+	 * @param title 
+	 * 			The title of the post
+	 * @param blogText 
+	 * 			The text of the post
+	 * @param tags
+	 * 
+	 */
+	public void createBlogPost(String authorEmail, String title, String blogText,
+			List<String> tags) {
+		
+		AuthorImpl a = getAuthor(authorEmail);
+		
+		if(title == null) title = "";
+		Date publishDate = new Date(System.currentTimeMillis());
+		if(tags == null) tags = new ArrayList<String>();
+		
+
+		try {
+			Connection connection = dataSource.getConnection();
+			// let's find the max id from the blogentry table
+			String sql = "SELECT max(id) FROM BLOGENTRY";
+			PreparedStatement ppsm = connection.prepareStatement(sql);
+			ResultSet rs = ppsm.executeQuery();
+			// we only expect to have one row returned
+			rs.next();
+
+			long max_id = rs.getLong(1);
+			ppsm.close();
+			
+			long post_id = max_id + 1;
+			sql = "INSERT INTO BLOGENTRY VALUES (?,?,?,?,?,?)";
+			
+		    ppsm = connection.prepareStatement(sql);
+			ppsm.setLong(1, post_id);
+			ppsm.setString(2, blogText);
+			if (publishDate != null)
+				ppsm
+						.setDate(3, new java.sql.Date(publishDate
+								.getTime()));
+			else
+				ppsm.setDate(3, null);
+			ppsm.setString(4, title);
+			
+		    ppsm.setDate(5, null);
+			ppsm.setString(6, a.getEmail());
+			int rows = ppsm.executeUpdate();
+			if (rows != 1)
+				throw new IllegalArgumentException(
+						"The blog entry record cannot be inserted: "
+								+ blogText);
+			ppsm.close();
+			
+			// insert a row in the relationship table
+
+			sql = "INSERT INTO Author_BlogEntry VALUES (?,?)";
+			ppsm = connection.prepareStatement(sql);
+			ppsm.setString(1, a.getEmail());
+			ppsm.setLong(2, post_id);
+
+			rows = ppsm.executeUpdate();
+			ppsm.close();
+			connection.close();
+			
+			if (rows != 1)
+				throw new IllegalArgumentException(
+						"The Author_BlogEntry record cannot be inserted: "
+								+ a.getEmail() + " , " + post_id);
+
+		} catch (SQLException sqle) {
+			sqle.printStackTrace();
+		}
+
+	}
+
+	/**
+	 * Find the blog entry record with the specified title
+	 * 
+	 * @param The title to be searched
+	 * @return The blogEntry record
+	 */
+	public EntryImpl findBlogEntryByTitle(String title) {
+
+		EntryImpl be = null;
+
+		String sql = "SELECT * FROM BlogEntry e WHERE e.title = '" + title
+				+ "'";
+
+		List<EntryImpl> blogEntries = findBlogs(sql);
+		
+		// just return the first blog entry for the time being
+		if ((blogEntries != null) && (blogEntries.size() > 0))
+			be = blogEntries.get(0);
+		return be;
+	}
+
+	/**
+	 * Return all author records in the Author table
+	 * 
+	 * @return the list of Author records
+	 */
+	public List<AuthorImpl> getAllAuthors() {
+		String sql = "SELECT * FROM Author";
+
+		List<AuthorImpl> list = findAuthors(sql);
+
+		return list;
+	}
+
+	/**
+	 * Return all blog entry records from BlogEntry table with the most recent
+	 * published blog entries first
+	 * 
+	 * @return a list of blogEntry object
+	 */
+	public List<EntryImpl> getAllBlogEntries() {
+		String sql = "SELECT * FROM BlogEntry b ORDER BY b.publishDate DESC";
+
+		List<EntryImpl> list = findBlogs(sql);
+
+		return list;
+	}
+
+	/**
+	 * Return the number of the blog entry records
+	 * 
+	 * @return the number of the blog Entry records
+	 */
+	public int getNoOfBlogEntries() {
+
+		int count = 0;
+
+		String sql = "SELECT count(*) FROM BLOGENTRY";
+		try {
+			Connection connection = dataSource.getConnection();
+			PreparedStatement ppsm = connection.prepareStatement(sql);
+			ResultSet rs = ppsm.executeQuery();
+			// we only expect to have one row returned
+			rs.next();
+			count = rs.getInt(1);
+			ppsm.close();
+			connection.close();
+
+		} catch (SQLException sqle) {
+			sqle.printStackTrace();
+		}
+		return count;
+	}
+
+	/**
+	 * Return the portion of blog Entries
+	 * 
+	 * @param firstPostIndex
+	 *            The index of the first blog entry to be returned
+	 * @param noOfPosts
+	 *            The number of blog entry to be returned
+	 * @return The list of the blog entry record
+	 */
+	public List<EntryImpl> getBlogEntries(int firstPostIndex, int noOfPosts) {
+		String sql = "SELECT * FROM BlogEntry b ORDER BY b.publishDate DESC";
+		List<EntryImpl> emptyList = new ArrayList<EntryImpl>();
+		List<EntryImpl> blogs = findBlogs(sql);
+		// we only return a portion of the list
+		if (blogs == null)
+			return emptyList;
+		// We need to make sure we won't throw IndexOutOfBoundException if the
+		// supplied
+		// index is out of the list range
+		int maximumIndex = blogs.size();
+		// if the first index is minus or greater than the last item index of
+		// the list, return an empty list
+		if ((firstPostIndex < 0) || (noOfPosts <= 0)
+				|| (firstPostIndex > maximumIndex))
+			return emptyList;
+		// return the required number of the blog entries or the available blog
+		// entries
+		int lastIndex = noOfPosts + firstPostIndex;
+		// we need to make sure we return the blog entries at most up to the
+		// final record
+
+		return (blogs.subList(firstPostIndex,
+				(lastIndex > maximumIndex) ? maximumIndex : lastIndex));
+
+	}
+
+	/**
+	 * Return the author with the specified email address
+	 * 
+	 * @param emailAddress
+	 *            The email address
+	 * @return The author record
+	 */
+	public AuthorImpl getAuthor(String emailAddress) {
+		String sql = "SELECT * FROM AUTHOR a where a.email='" + emailAddress
+				+ "'";
+		List<AuthorImpl> authors = findAuthors(sql);
+
+		if (authors.size() == 0)
+			return null;
+		else if (authors.size() > 1)
+			throw new IllegalArgumentException(
+					"Email address should be unique per author");
+
+		return authors.get(0); // just return the first author
+	}
+
+	/**
+	 * Return the blog entries modified between the date range of [start, end]
+	 * 
+	 * @param start
+	 *            The start date
+	 * @param end
+	 *            The end date
+	 * @return The list of blog entries
+	 */
+	public List<EntryImpl> getBlogEntriesModifiedBetween(Date start, Date end) {
+
+		// String sql = "SELECT * FROM BlogEntry b WHERE (b.updatedDate >= " +
+		// startTS +" AND b.updatedDate <= " + endTS + ") OR (b.publishDate >= "
+		// +startTS + " AND b.publishDate <= " + endTS +
+		// ") ORDER BY b.publishDate ASC";
+		String sql = "SELECT * FROM BlogEntry b WHERE (Date(b.updatedDate) BETWEEN '"
+				+ start
+				+ "' AND '"
+				+ end
+				+ "') OR (Date(b.publishDate) BETWEEN '"
+				+ start
+				+ "' AND  '"
+				+ end + "') ORDER BY b.publishDate ASC";
+
+		return findBlogs(sql);
+
+	}
+
+	/**
+	 * Return a list of blog entries belonging to the author with the specified
+	 * email address
+	 * 
+	 * @param emailAddress
+	 *            the author's email address
+	 * @return The list of blog entries
+	 */
+	public List<EntryImpl> getBlogsForAuthor(String emailAddress) {
+
+		String sql = "SELECT * FROM BlogEntry b WHERE b.AUTHOR_EMAIL='"
+				+ emailAddress + "'";
+		return findBlogs(sql);
+	}
+
+	/**
+	 * Update the author record
+	 * 
+	 * @param email
+	 * 			The email associated with an author
+	 * @param dob
+	 * 			The author's date of birth
+	 * @param name
+	 * 			the author's name
+	 * @param displayName
+	 * 			The displayName
+	 * @param bio
+	 * 			The aouthor's bio
+	 */
+	public void updateAuthor(String email, Date dob, String name,
+			String displayName, String bio) {
+
+		
+		String sql = "UPDATE AUTHOR a SET bio = ?, displayName = ?, dob = ?, name =? WHERE email ='"
+				+ email + "'";
+		int updatedRows = 0;
+		try {
+			Connection connection = dataSource.getConnection();
+			PreparedStatement ppsm = connection.prepareStatement(sql);
+			ppsm.setString(1, bio);
+			ppsm.setString(2, displayName);
+			if (dob != null)
+				ppsm.setDate(3, new java.sql.Date(dob.getTime()));
+			else
+				ppsm.setDate(3, null);
+			ppsm.setString(4, name);
+			updatedRows = ppsm.executeUpdate();
+			
+			ppsm.close();
+			connection.close();
+			
+			if (updatedRows != 1)
+				throw new IllegalArgumentException("The Author " + email
+						+ " cannot be updated.");
+		} catch (SQLException e) {
+			e.printStackTrace();
+		}
+	}
+
+	/**
+	 * Update the blog entry record
+	 * 
+	 * 
+	 */
+	public void updateBlogEntry(long id, String email, String title, String blogText, List<String> tags, Date updatedDate) {
+		
+		if (id == -1)
+			throw new IllegalArgumentException(
+					"Not a BlogEntry returned by this interface");
+		EntryImpl b = getBlogEntryById(id);
+		String sql_se = "SELECT * FROM BLOGENTRY bp WHERE bp.id = " + id;
+		String email_old = null;
+		// let's find out the email address for the blog post to see whether the
+		// table Author_BlogEntry needs to be updated
+		// if the email is updated, we need to update the table Author_BlogEntry
+		// to reflect the change.
+		try {
+			Connection connection = dataSource.getConnection();
+			PreparedStatement ppsm = connection.prepareStatement(sql_se);
+			ResultSet rs = ppsm.executeQuery();
+			// there should be just one record
+			rs.next();
+			email_old = rs.getString("AUTHOR_EMAIL");
+			ppsm.close();
+			connection.close();
+		} catch (SQLException sqle) {
+			sqle.printStackTrace();
+		}
+		String sql = "UPDATE BLOGENTRY bp SET bp.blogText = ?, bp.publishDate = ?, bp.title = ?, bp.updatedDate = ?, bp.AUTHOR_EMAIL = ? where bp.id = "
+				+ id;
+		int updatedRows = 0;
+		
+		try {
+			Connection connection = dataSource.getConnection();
+			PreparedStatement ppsm = connection.prepareStatement(sql);
+			ppsm.setString(1, blogText);
+			if (b.getPublishDate() != null)
+				ppsm
+						.setDate(2, new java.sql.Date(b.getPublishDate()
+								.getTime()));
+			else
+				ppsm.setDate(2, null);
+			ppsm.setString(3, b.getTitle());
+			if (b.getUpdatedDate() != null)
+				ppsm
+						.setDate(4, new java.sql.Date(b.getUpdatedDate()
+								.getTime()));
+			else
+				ppsm.setDate(4, null);
+
+			ppsm.setString(5, email);
+			updatedRows = ppsm.executeUpdate();
+			
+			ppsm.close();
+			
+			connection.close();
+
+			if (updatedRows != 1)
+				throw new IllegalArgumentException("The Blog " + b.getId()
+						+ " cannot be updated.");
+		} catch (SQLException e) {
+			e.printStackTrace();
+		}
+
+		// if the email address is changed, we need to need to update the
+		// relationship table Author_BlogEntry
+		if ((email_old != null) && (!!!email_old.equals(email))) {
+			// update the table Author_BlogEntry
+			String sql_ab = "UDPATE Author_BlogEntry ab SET ab.AUTHOR_EMAIL = '"
+					+ email + "'";
+			updatedRows = 0;
+			try {
+				Connection connection = dataSource.getConnection();
+				PreparedStatement ppsm = connection.prepareStatement(sql_ab);
+				updatedRows = ppsm.executeUpdate();
+				ppsm.close();
+                connection.close();
+				if (updatedRows != 1)
+					throw new IllegalArgumentException(
+							"The Author_BlogEntry with the postsID "
+									+ b.getId() + " cannot be updated.");
+			} catch (SQLException e) {
+				e.printStackTrace();
+			}
+		}
+	}
+
+	/**
+	 * Delete the author record with the specified email address
+	 * 
+	 * @param emailAddress
+	 *            The author's email address
+	 * 
+	 */
+	public void removeAuthor(String emailAddress) {
+
+		// we need to remove the author and its blog entries
+
+		try {
+			String sql = "DELETE FROM BLOGENTRY bp WHERE bp.AUTHOR_EMAIL = '"
+					+ emailAddress + "'";
+			Connection connection = dataSource.getConnection();
+			PreparedStatement ppsm = connection.prepareStatement(sql);
+			ppsm.executeUpdate();
+			ppsm.close();
+			
+			// delete the records from Author_BlogEntry
+			sql = "DELETE FROM Author_BlogEntry ab WHERE ab.AUTHOR_EMAIL = '"
+					+ emailAddress + "'";
+			ppsm = connection.prepareStatement(sql);
+			ppsm.executeUpdate();
+			ppsm.close();
+
+			// delete the author record
+			sql = "DELETE FROM Author a WHERE a.EMAIL = '" + emailAddress + "'";
+			ppsm = connection.prepareStatement(sql);
+			ppsm.executeUpdate();
+			ppsm.close();
+			connection.close();
+
+		} catch (SQLException sqle) {
+			sqle.printStackTrace();
+		}
+
+	}
+
+	/**
+	 * Delete the blog entry record specified by the blogEntry
+	 * 
+	 * @param blogEntry
+	 *            the blog entry record to be deleted
+	 */
+	public void removeBlogEntry(long id) {
+		if (id == -1)
+			throw new IllegalArgumentException(
+					"Not a BlogEntry returned by this interface");
+
+		try {
+			String sql = "DELETE FROM BLOGENTRY bp WHERE bp.id = "
+					+ id;
+			Connection connection = dataSource.getConnection();
+			PreparedStatement ppsm = connection.prepareStatement(sql);
+			ppsm.executeUpdate();
+			ppsm.close();
+			// We also need to delete the records from Author_BlogEntry, as this
+			// table is a kind of link between author and blogentry record
+			sql = "DELETE FROM Author_BlogEntry ab WHERE ab.POSTS_ID = "
+					+ id;
+			ppsm = connection.prepareStatement(sql);
+			ppsm.executeUpdate();
+			ppsm.close();
+			connection.close();
+
+		} catch (SQLException sqle) {
+			sqle.printStackTrace();
+		}
+
+	}
+
+	/**
+	 * Return the blog entry record with the specified id
+	 * 
+	 * @param postId
+	 *            The blogEntry record id
+	 */
+	public EntryImpl getBlogEntryById(long postId) {
+		String sql = "SELECT * FROM BlogEntry b WHERE b.id = " + postId;
+		List<EntryImpl> blogs = findBlogs(sql);
+		if (blogs.size() == 0)
+			return null;
+		if (blogs.size() > 1)
+			throw new IllegalArgumentException("Blog id is not unique");
+		return blogs.get(0);
+	}
+
+	/**
+	 * Return a list of authors with the sql query
+	 * 
+	 * @param sql
+	 *            The SQL query
+	 * @return A list of author records
+	 */
+	private List<AuthorImpl> findAuthors(String sql) {
+		List<AuthorImpl> authorList = new ArrayList<AuthorImpl>();
+
+		try {
+			Connection connection = dataSource.getConnection();
+			PreparedStatement ppsm = connection.prepareStatement(sql);
+
+			ResultSet ars = ppsm.executeQuery();
+
+			while (ars.next()) {
+				AuthorImpl ar = new AuthorImpl();
+				ar.setBio(ars.getString("bio"));
+				ar.setDisplayName(ars.getString("displayName"));
+				ar.setDob(ars.getDate("dob"));
+				String email = ars.getString("email");
+				ar.setEmail(email);
+				ar.setName(ars.getString("name"));
+
+				// let's find the blog entries for the author
+				String sql_be = "SELECT * FROM BLOGENTRY be WHERE be.AUTHOR_EMAIL = '"
+						+ email + "'";
+				PreparedStatement ppsm2 = connection.prepareStatement(sql_be);
+				ResultSet rs = ppsm2.executeQuery();
+
+				List<EntryImpl> blogs = new ArrayList<EntryImpl>();
+				while (rs.next()) {
+					EntryImpl blog = new EntryImpl();
+					blog.setAuthor(ar);
+					blog.setId(rs.getLong("id"));
+					blog.setBlogText(rs.getString("blogText"));
+					blog.setPublishDate(rs.getDate("publishDate"));
+					blog.setTitle(rs.getString("title"));
+					blog.setUpdatedDate(rs.getDate("updatedDate"));
+					blogs.add(blog);
+				}
+				ar.setEntries(blogs);
+				authorList.add(ar);
+				ppsm2.close();
+			}
+		    ppsm.close();
+			connection.close();
+		} catch (Exception e) {
+			e.printStackTrace();
+		}
+		return authorList;
+	}
+
+	/**
+	 * Return a list of blog entries with the sql query
+	 * 
+	 * @param sql
+	 *            The sql query to be executed
+	 * @return a list of blogEntry records
+	 */
+	private List<EntryImpl> findBlogs(String sql) {
+		List<EntryImpl> blogEntryList = new ArrayList<EntryImpl>();
+
+		try {
+			Connection connection = dataSource.getConnection();
+			PreparedStatement ppsm = connection.prepareStatement(sql);
+			ResultSet blogrs = ppsm.executeQuery();
+
+			while (blogrs.next()) {
+				EntryImpl be = new EntryImpl();
+				be.setId(blogrs.getLong("id"));
+				be.setBlogText(blogrs.getString("blogText"));
+				be.setPublishDate(blogrs.getDate("publishDate"));
+				be.setTitle(blogrs.getString("title"));
+				be.setUpdatedDate(blogrs.getDate("updatedDate"));
+				// find the author email address
+				String author_email = blogrs.getString("AUTHOR_EMAIL");
+				String author_sql = "SELECT * FROM Author a WHERE a.email ='"
+						+ author_email + "'";
+				List<AuthorImpl> authors = findAuthors(author_sql);
+				// there should be just one entry, as email is the primary key
+				// for the Author table
+				if (authors.size() != 1)
+					throw new IllegalArgumentException(
+							"We got more than one author with the same email address. This is wrong");
+				else
+					be.setAuthor(authors.get(0));
+				blogEntryList.add(be);
+			}
+			ppsm.close();
+			connection.close();
+		} catch (Exception e) {
+			e.printStackTrace();
+		}
+		return blogEntryList;
+	}
+}

Added: aries/tags/samples-0.1-incubating/blog/blog-persistence-jdbc/src/main/java/org/apache/aries/samples/blog/persistence/jdbc/entity/AuthorImpl.java
URL: http://svn.apache.org/viewvc/aries/tags/samples-0.1-incubating/blog/blog-persistence-jdbc/src/main/java/org/apache/aries/samples/blog/persistence/jdbc/entity/AuthorImpl.java?rev=1075106&view=auto
==============================================================================
--- aries/tags/samples-0.1-incubating/blog/blog-persistence-jdbc/src/main/java/org/apache/aries/samples/blog/persistence/jdbc/entity/AuthorImpl.java (added)
+++ aries/tags/samples-0.1-incubating/blog/blog-persistence-jdbc/src/main/java/org/apache/aries/samples/blog/persistence/jdbc/entity/AuthorImpl.java Sun Feb 27 18:28:26 2011
@@ -0,0 +1,125 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.aries.samples.blog.persistence.jdbc.entity;
+
+import java.util.Date;
+import java.util.List;
+
+import org.apache.aries.samples.blog.api.persistence.Author;
+
+
+
+/**
+ * This class represents a blog post Author
+ */
+
+public class AuthorImpl implements Author
+{
+  /** The author's email address */
+
+
+  private String email;
+
+  /** The author's full name */
+  private String name;
+  /** The display name for this author */
+  private String displayName;
+  /** A short bio for this author */
+  private String bio;  
+  /** The Author's date of birth */
+  private Date dob;
+
+  /** The blog entries posted by this user */
+
+  private List<EntryImpl> posts;
+
+  /** Get the author's email address */
+  public String getEmail()
+  {
+    return email;
+  }
+
+  /** Set the author's email address */
+  public void setEmail(String email)
+  {
+    this.email = email;
+  }
+
+  /** Get the author's full name */
+  public String getName()
+  {
+    return name;
+  }
+
+  /** Set the author's full name */
+  public void setName(String name)
+  {
+    this.name = name;
+  }
+
+  /** Get the author's displayed name */
+  public String getDisplayName()
+  {
+    return displayName;
+  }
+
+  /** Set the author's displayed name */
+  public void setDisplayName(String displayName)
+  {
+    this.displayName = displayName;
+  }
+
+  /** Get the author's biographical information */
+  public String getBio()
+  {
+    return bio;
+  }
+
+  /** Set the author's biographical information */
+  public void setBio(String bio)
+  {
+    this.bio = bio;
+  }
+
+  /** Get the author's date of birth */
+  public Date getDob()
+  {
+    return dob;
+  }
+
+  /** Set the author's date of birth */
+  public void setDob(Date dob)
+  {
+    this.dob = dob;
+  }
+
+  /** Get the author's blog posts */
+  public List<EntryImpl> getEntries()
+  {
+    return posts;
+  }
+
+  /** Set the author's blog posts */
+  public void setEntries(List<EntryImpl> posts)
+  {
+    this.posts = posts;
+  }
+
+}

Added: aries/tags/samples-0.1-incubating/blog/blog-persistence-jdbc/src/main/java/org/apache/aries/samples/blog/persistence/jdbc/entity/EntryImpl.java
URL: http://svn.apache.org/viewvc/aries/tags/samples-0.1-incubating/blog/blog-persistence-jdbc/src/main/java/org/apache/aries/samples/blog/persistence/jdbc/entity/EntryImpl.java?rev=1075106&view=auto
==============================================================================
--- aries/tags/samples-0.1-incubating/blog/blog-persistence-jdbc/src/main/java/org/apache/aries/samples/blog/persistence/jdbc/entity/EntryImpl.java (added)
+++ aries/tags/samples-0.1-incubating/blog/blog-persistence-jdbc/src/main/java/org/apache/aries/samples/blog/persistence/jdbc/entity/EntryImpl.java Sun Feb 27 18:28:26 2011
@@ -0,0 +1,147 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.aries.samples.blog.persistence.jdbc.entity;
+
+import java.util.Date;
+import java.util.List;
+
+import org.apache.aries.samples.blog.api.persistence.Entry;
+
+
+
+/**
+ * This class represents a blog entry
+ */
+
+public class EntryImpl implements Entry
+{
+  /** An auto-generated primary key */
+
+  private Long id;
+
+  /** The author of the blog post */
+
+  private AuthorImpl author;
+
+  /** The date the post was published */
+  private Date publishDate;
+  /** The date the post was last updated */
+  private Date updatedDate;
+  /** The title of the post */
+  private String title;
+  /** Tags associated with the post */
+  private List<String> tags;
+  /** The text of the blog */
+
+  private String blogText;
+
+  /** Get the author of this blog post */
+  public AuthorImpl getAuthor()
+  {
+    return author;
+  }
+
+  /** Set the author of this blog post */
+  public void setAuthor(AuthorImpl author)
+  {
+    this.author = author;
+  }
+
+  /** Get the publish date of this blog post */
+  public Date getPublishDate()
+  {
+    return publishDate;
+  }
+
+  /** Set the publish date of this blog post */
+  public void setPublishDate(Date publishDate)
+  {
+    this.publishDate = publishDate;
+  }
+
+  /** Get the title of this blog post */
+  public String getTitle()
+  {
+    return title;
+  }
+
+  /** Set the title of this blog post */ 
+  public void setTitle(String title)
+  {
+    this.title = title;
+  }
+
+
+  /** Get the tags for this blog post */
+  public List<String> getTags()
+  {
+    return tags;
+  }
+
+  /** Set the tags for this blog post */
+  public void setTags(List<String> tags)
+  {
+    this.tags = tags;
+  }
+
+  /** Get the text for this blog post */
+  public String getBlogText()
+  {
+    return blogText;
+  }
+
+  /** Set the text for this blog post */
+  public void setBlogText(String blogText)
+  {
+    this.blogText = blogText;
+  }
+
+  /** get the Blog post id */
+  public long getId()
+  {
+    return id;
+  }
+
+  /** Set the id */
+  public void setId(Long id)
+  {
+    this.id = id;
+  }
+
+  /**
+   * @return The date of the last update to this blog
+   *         or null if it has never been modified
+   */
+  public Date getUpdatedDate()
+  {
+    return updatedDate;
+  }
+
+  /**
+   * Set the date that the blog post was last updated
+   * 
+   * @param updatedDate
+   */
+  public void setUpdatedDate(Date updatedDate)
+  {
+    this.updatedDate = updatedDate;
+  }
+
+
+}

Added: aries/tags/samples-0.1-incubating/blog/blog-persistence-jdbc/src/main/resources/OSGI-INF/blueprint/blueprint.xml
URL: http://svn.apache.org/viewvc/aries/tags/samples-0.1-incubating/blog/blog-persistence-jdbc/src/main/resources/OSGI-INF/blueprint/blueprint.xml?rev=1075106&view=auto
==============================================================================
--- aries/tags/samples-0.1-incubating/blog/blog-persistence-jdbc/src/main/resources/OSGI-INF/blueprint/blueprint.xml (added)
+++ aries/tags/samples-0.1-incubating/blog/blog-persistence-jdbc/src/main/resources/OSGI-INF/blueprint/blueprint.xml Sun Feb 27 18:28:26 2011
@@ -0,0 +1,34 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+    Licensed to the Apache Software Foundation (ASF) under one or more
+    contributor license agreements.  See the NOTICE file distributed with
+    this work for additional information regarding copyright ownership.
+    The ASF licenses this file to You under the Apache License, Version 2.0
+    (the "License"); you may not use this file except in compliance with
+    the License.  You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+    Unless required by applicable law or agreed to in writing, software
+    distributed under the License is distributed on an "AS IS" BASIS,
+    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+    See the License for the specific language governing permissions and
+    limitations under the License.
+-->
+
+<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
+			xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+            xsi:schemaLocation="http://www.osgi.org/xmlns/blueprint/v1.0.0">
+            
+  <bean id="datasource" class="org.apache.derby.jdbc.EmbeddedConnectionPoolDataSource">
+     <property name="databaseName" value="blogDB"/>
+  </bean>
+
+  <bean id="persistenceImpl" class="org.apache.aries.samples.blog.persistence.jdbc.BlogPersistenceServiceImpl" activation="lazy">
+   <property name="dataSource" ref="datasource" />
+  </bean>
+
+  <service ref="persistenceImpl" interface="org.apache.aries.samples.blog.api.persistence.BlogPersistenceService"/>
+ 
+ 
+</blueprint>
\ No newline at end of file

Added: aries/tags/samples-0.1-incubating/blog/blog-persistence-jpa/pom.xml
URL: http://svn.apache.org/viewvc/aries/tags/samples-0.1-incubating/blog/blog-persistence-jpa/pom.xml?rev=1075106&view=auto
==============================================================================
--- aries/tags/samples-0.1-incubating/blog/blog-persistence-jpa/pom.xml (added)
+++ aries/tags/samples-0.1-incubating/blog/blog-persistence-jpa/pom.xml Sun Feb 27 18:28:26 2011
@@ -0,0 +1,126 @@
+<?xml version="1.0" encoding="UTF-8"?>
+	<!--
+		Licensed to the Apache Software Foundation (ASF) under one or more
+		contributor license agreements. See the NOTICE file distributed with
+		this work for additional information regarding copyright ownership.
+		The ASF licenses this file to You under the Apache License, Version
+		2.0 (the "License"); you may not use this file except in compliance
+		with the License. You may obtain a copy of the License at
+
+		http://www.apache.org/licenses/LICENSE-2.0 Unless required by
+		applicable law or agreed to in writing, software distributed under the
+		License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
+		CONDITIONS OF ANY KIND, either express or implied. See the License for
+		the specific language governing permissions and limitations under the
+		License.
+	-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+
+	<modelVersion>4.0.0</modelVersion>
+
+	<parent>
+		<groupId>org.apache.aries.samples.blog</groupId>
+		<artifactId>blog</artifactId>
+		<version>0.1-incubating</version>
+	</parent>
+
+	<groupId>org.apache.aries.samples.blog</groupId>
+	<artifactId>org.apache.aries.samples.blog.persistence.jpa</artifactId>
+	<name>Apache Aries blog sample persistence</name>
+	<packaging>bundle</packaging>
+
+	<build>
+		<plugins>
+			<plugin>
+				<groupId>org.apache.felix</groupId>
+				<artifactId>maven-bundle-plugin</artifactId>
+				<configuration>
+					<instructions>
+						<Meta-Persistence>META-INF/persistence.xml</Meta-Persistence>
+                        <Bundle-SymbolicName>${pom.artifactId}</Bundle-SymbolicName>
+						<Private-Package>org.apache.aries.samples.blog.persistence.jpa.*</Private-Package>
+                        <Export-Package>!org.apache.aries.samples.blog.persistence.jpa.*</Export-Package>
+					</instructions>
+				</configuration>
+			</plugin>
+			<plugin>
+				<groupId>org.apache.maven.plugins</groupId>
+				<artifactId>maven-antrun-plugin</artifactId>
+				<executions>
+					<execution>
+						<phase>compile</phase>
+						<configuration>
+							<tasks>
+								<path id="enhance.path.ref">
+									<fileset dir="${project.build.outputDirectory}">
+										<include name="AuthorImpl.class" />
+										<include name="EntryImpl.class" /> 
+									</fileset>
+								</path>
+								<pathconvert property="enhance.files" refid="enhance.path.ref" pathsep=" " />
+								<java classname="org.apache.openjpa.enhance.PCEnhancer">
+									<arg line="-p persistence.xml" />
+									<arg line="${enhance.files}" />
+									<classpath>
+										<path refid="maven.dependency.classpath" />
+										<path refid="maven.compile.classpath" />
+									</classpath>
+								</java>
+							</tasks>
+						</configuration>
+						<goals>
+							<goal>run</goal>
+						</goals>
+					</execution>
+				</executions>
+			</plugin>
+
+		</plugins>
+	</build>
+
+	<dependencies>
+		<dependency>
+			<groupId>org.apache.aries.samples.blog</groupId>
+			<artifactId>org.apache.aries.samples.blog.api</artifactId>
+			<scope>provided</scope>
+		</dependency>
+		<dependency>
+			<groupId>org.apache.derby</groupId>
+			<artifactId>derby</artifactId>
+		</dependency>
+		<dependency>
+			<groupId>org.apache.geronimo.specs</groupId>
+			<artifactId>geronimo-jpa_2.0_spec</artifactId>
+		</dependency>
+		<dependency>
+			<groupId>org.apache.geronimo.specs</groupId>
+			<artifactId>geronimo-jta_1.1_spec</artifactId>
+		</dependency>
+
+		<dependency>
+			<groupId>org.apache.openjpa</groupId>
+			<artifactId>openjpa</artifactId>
+		</dependency>
+
+
+		<!-- OpenJPA PCEnhancer depends -->
+		<dependency>
+			<groupId>net.sourceforge.serp</groupId>
+			<artifactId>serp</artifactId>
+			<scope>provided</scope>
+		</dependency>
+		<dependency>
+			<groupId>commons-lang</groupId>
+			<artifactId>commons-lang</artifactId>
+			<scope>provided</scope>
+		</dependency>
+		<dependency>
+			<groupId>commons-collections</groupId>
+			<artifactId>commons-collections</artifactId>
+			<scope>provided</scope>
+		</dependency>
+		<!-- end OpenJPA PCEnhancer depends -->
+
+	</dependencies>
+
+</project>

Added: aries/tags/samples-0.1-incubating/blog/blog-persistence-jpa/src/main/java/org/apache/aries/samples/blog/persistence/jpa/BlogPersistenceServiceImpl.java
URL: http://svn.apache.org/viewvc/aries/tags/samples-0.1-incubating/blog/blog-persistence-jpa/src/main/java/org/apache/aries/samples/blog/persistence/jpa/BlogPersistenceServiceImpl.java?rev=1075106&view=auto
==============================================================================
--- aries/tags/samples-0.1-incubating/blog/blog-persistence-jpa/src/main/java/org/apache/aries/samples/blog/persistence/jpa/BlogPersistenceServiceImpl.java (added)
+++ aries/tags/samples-0.1-incubating/blog/blog-persistence-jpa/src/main/java/org/apache/aries/samples/blog/persistence/jpa/BlogPersistenceServiceImpl.java Sun Feb 27 18:28:26 2011
@@ -0,0 +1,216 @@
+
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.aries.samples.blog.persistence.jpa;
+
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.List;
+
+import javax.persistence.EntityManager;
+import javax.persistence.PersistenceContext;
+import javax.persistence.Query;
+import javax.sql.DataSource;
+
+import org.apache.aries.samples.blog.api.persistence.BlogPersistenceService;
+import org.apache.aries.samples.blog.api.persistence.Entry;
+import org.apache.aries.samples.blog.persistence.jpa.entity.AuthorImpl;
+import org.apache.aries.samples.blog.persistence.jpa.entity.EntryImpl;
+
+/**
+ * This class is the implementation of the blogPersistenceService
+ */
+public class BlogPersistenceServiceImpl implements BlogPersistenceService {
+
+	private EntityManager em;
+	private DataSource dataSource;
+	
+	public BlogPersistenceServiceImpl() {
+	}
+
+	
+	//@PersistenceContext(unitName = "blogExample")
+	public void setEntityManager(EntityManager e) {
+		em = e;
+	}
+	
+	public void setDataSource(DataSource dataSource) {
+		this.dataSource = dataSource;
+	}
+
+
+	public void createAuthor(String email, Date dob, String name,
+			String displayName, String bio) {
+		AuthorImpl a = new AuthorImpl();
+		a.setEmail(email);
+		a.setName(name);
+		a.setDisplayName(displayName);
+		a.setBio(bio);
+		a.setDob(dob);
+		em.persist(a);
+		
+	}
+
+	public void createBlogPost(String authorEmail, String title,
+			String blogText, List<String> tags) {
+	
+		AuthorImpl a = em.find(AuthorImpl.class, authorEmail);
+		EntryImpl b = new EntryImpl();
+
+		Date publishDate = new Date(System.currentTimeMillis());
+
+		b.setBlogText(blogText);
+		b.setAuthor(a);
+		b.setTitle((title == null) ? "" : title);
+		b.setPublishDate(publishDate);
+		b.setTags((tags == null) ? new ArrayList<String>() : tags);
+
+		a.updateEntries(b);
+		em.persist(b);		
+		em.merge(b.getAuthor());
+		//Uncomment this line to verify that datasources have been enlisted.
+		//The data base should not contain the blog post even though it has been persisted.
+		//throw new RuntimeException();
+	}
+
+	public Entry findBlogEntryByTitle(String title) {
+		Query q = em
+				.createQuery("SELECT e FROM BLOGENTRY e WHERE e.title = ?1");
+		q.setParameter(1, title);
+		Entry b = (Entry) q.getSingleResult();
+		return b;
+	}
+
+	public List<AuthorImpl> getAllAuthors() {
+		@SuppressWarnings("unchecked")
+		List<AuthorImpl> list = em.createQuery("SELECT a FROM AUTHOR a")
+				.getResultList();
+
+		return list;
+	}
+
+	public List<EntryImpl> getAllBlogEntries() {
+		@SuppressWarnings("unchecked")
+		List<EntryImpl> list = em.createQuery(
+				"SELECT b FROM BLOGENTRY b ORDER BY b.publishDate DESC")
+				.getResultList();
+		return list;
+		
+	}
+
+	public int getNoOfBlogEntries() {
+		Number n = (Number) em.createQuery(
+				"SELECT COUNT(b) FROM BLOGENTRY b").getSingleResult();
+		return n.intValue();
+	}
+
+	public List<EntryImpl> getBlogEntries(int firstPostIndex, int noOfPosts) {
+		Query q = em
+				.createQuery("SELECT b FROM BLOGENTRY b ORDER BY b.publishDate DESC");
+		q.setFirstResult(firstPostIndex);
+		q.setMaxResults(noOfPosts);
+
+		@SuppressWarnings("unchecked")
+		List<EntryImpl> list = q.getResultList();
+
+		return list;
+	}
+
+	public AuthorImpl getAuthor(String emailAddress) {
+		AuthorImpl a = em.find(AuthorImpl.class, emailAddress);
+		return a;
+	}
+
+	public List<EntryImpl> getBlogEntriesModifiedBetween(Date start, Date end) {
+		Query q = em
+				.createQuery("SELECT b FROM BLOGENTRY b WHERE (b.updatedDate >= :start AND b.updatedDate <= :end) OR (b.publishDate >= :start AND b.publishDate <= :end) ORDER BY b.publishDate ASC");
+		q.setParameter("start", start);
+		q.setParameter("end", end);
+
+		@SuppressWarnings("unchecked")
+		List<EntryImpl> list = q.getResultList();
+
+		return list;
+	}
+	
+	public List<EntryImpl> getBlogsForAuthor(String emailAddress) {
+
+		List<EntryImpl> list = em.find(AuthorImpl.class, emailAddress)
+				.getEntries();
+		
+		return list;
+
+	}
+
+	public void updateAuthor(String email, Date dob, String name,
+			String displayName, String bio) {
+		AuthorImpl a = em.find(AuthorImpl.class, email);
+		a.setEmail(email);
+		a.setName(name);
+		a.setDisplayName(displayName);
+		a.setBio(bio);
+		a.setDob(dob);
+		em.merge(a);
+	}
+	
+	public void updateBlogEntry(long id, String email, String title,
+			String blogText, List<String> tags, Date updatedDate) {
+		EntryImpl b = em.find(EntryImpl.class, id);
+		b.setTitle(title);
+		b.setBlogText(blogText);
+		b.setTags(tags);
+		b.setUpdatedDate(updatedDate);
+
+		em.merge(b);
+	}
+
+	public void removeAuthor(String emailAddress) {
+		em.remove(em.find(AuthorImpl.class, emailAddress));
+	}
+
+	public void removeBlogEntry(long id) {
+		EntryImpl b = em.find(EntryImpl.class, id);
+		b = em.merge(b);
+		b.getAuthor().getEntries().remove(b);
+
+		em.remove(em.merge(b));
+		em.merge(b.getAuthor());
+
+	}
+
+	public EntryImpl getBlogEntryById(long postId) {
+		EntryImpl b =  em.find(EntryImpl.class, postId);
+		return b;
+	}
+
+	public void setPublishDate (long postId, Date date) {
+		//Added for testing
+		EntryImpl b = em.find(EntryImpl.class, postId);
+		b.setPublishDate(date);	
+		em.merge(b);
+	}
+	
+	public void setUpdatedDate (long postId, Date date) {
+		//Added for testing
+		EntryImpl b = em.find(EntryImpl.class, postId);
+		b.setUpdatedDate(date);	
+		em.merge(b);
+	}
+}



Mime
View raw message