[Commits] (bcm) allow the client code to specify a workspace name,
overriding the template's
commits at osafoundation.org
commits at osafoundation.org
Fri Apr 15 11:51:58 PDT 2005
Commit by: bcm
Modified files:
server/core/src/org/osaf/spring/jcr/JCRTemplate.java 1.3 1.4
server/core/src/org/osaf/spring/jcr/support/JCRDaoSupport.java 1.1 1.2
Log message:
allow the client code to specify a workspace name, overriding the template's
workspace name
ViewCVS links:
http://cvs.osafoundation.org/index.cgi/server/core/src/org/osaf/spring/jcr/JCRTemplate.java.diff?r1=text&tr1=1.3&r2=text&tr2=1.4
http://cvs.osafoundation.org/index.cgi/server/core/src/org/osaf/spring/jcr/support/JCRDaoSupport.java.diff?r1=text&tr1=1.1&r2=text&tr2=1.2
Index: server/core/src/org/osaf/spring/jcr/JCRTemplate.java
diff -u server/core/src/org/osaf/spring/jcr/JCRTemplate.java:1.3 server/core/src/org/osaf/spring/jcr/JCRTemplate.java:1.4
--- server/core/src/org/osaf/spring/jcr/JCRTemplate.java:1.3 Wed Mar 30 11:35:30 2005
+++ server/core/src/org/osaf/spring/jcr/JCRTemplate.java Fri Apr 15 11:51:57 2005
@@ -63,12 +63,19 @@
* ones. Allows for returning a result object, i.e. a domain
* object or a collection of domain objects.
*
- * Note: Callback code is not supposed to handle transactions
- * itself! Use an appropriate transaction manager (XXX). Nor does
- * callback code need to explicitly log out of the
+ * Note: Callback code does not need to explicitly log out of the
* <code>Session</code>; this method will handle that itself.
+ *
+ * @param callback the <code>JCRCallback</code> that executes
+ * the client operation
+ * @param workspaceName the name of the workspace to login to; if
+ * not provided, the workspace named by the
+ * <code>workspaceName</code> property will be used. If that
+ * property is also <code>null</code>, the repository's default
+ * workspace will be used.
*/
- public Object execute(JCRCallback callback)
+ public Object execute(JCRCallback callback,
+ final String workspaceName)
throws DataAccessException {
try {
Session session = null;
@@ -103,6 +110,30 @@
}
/**
+ * Execute the action specified by the given action object within
+ * a {@link javax.jcr.Session}. Application exceptions thrown by
+ * the action object get propagated to the caller (can only be
+ * unchecked). JCR exceptions are transformed into appropriate DAO
+ * ones. Allows for returning a result object, i.e. a domain
+ * object or a collection of domain objects.
+ *
+ * Note: Callback code does not need to explicitly log out of the
+ * <code>Session</code>; this method will handle that itself.
+ *
+ * The workspace logged into will be that named by the
+ * <code>workspaceName</code> property; if that property is
+ * <code>null</code>, the repository's default workspace will be
+ * used.
+ *
+ * @param callback the <code>JCRCallback</code> that executes
+ * the client operation
+ */
+ public Object execute(JCRCallback callback)
+ throws DataAccessException {
+ return execute(callback, this.workspaceName);
+ }
+
+ /**
* Sanity check the object's properties.
*/
public void afterPropertiesSet() {
@@ -112,8 +143,9 @@
if (getRepository() == null) {
throw new IllegalArgumentException("repository is required");
}
- // workspaceName can be null - causes Repository to choose the
- // default workspace
+ // workspaceName can be null - allows the workspace name to be
+ // set by <code>execute()</code>, defaults to
+ // <code>null</code> (the default workspace)
}
/**
Index: server/core/src/org/osaf/spring/jcr/support/JCRDaoSupport.java
diff -u server/core/src/org/osaf/spring/jcr/support/JCRDaoSupport.java:1.1 server/core/src/org/osaf/spring/jcr/support/JCRDaoSupport.java:1.2
--- server/core/src/org/osaf/spring/jcr/support/JCRDaoSupport.java:1.1 Tue Mar 22 17:29:24 2005
+++ server/core/src/org/osaf/spring/jcr/support/JCRDaoSupport.java Fri Apr 15 11:51:57 2005
@@ -8,14 +8,13 @@
/**
* Convenient super class for JCR data access objects.
*
- * This class requires a {@link JCRTemplate} to be set.
- *
* @author Brian Moseley
*/
public abstract class JCRDaoSupport {
private static final Log log = LogFactory.getLog(JCRDaoSupport.class);
private JCRTemplate template;
+ private String workspaceName;
/**
*/
@@ -28,4 +27,16 @@
public void setTemplate(JCRTemplate template) {
this.template = template;
}
+
+ /**
+ */
+ public String getWorkspaceName() {
+ return workspaceName;
+ }
+
+ /**
+ */
+ public void setWorkspaceName(String workspaceName) {
+ this.workspaceName = workspaceName;
+ }
}
More information about the Commits
mailing list