You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@cocoon.apache.org by vg...@apache.org on 2006/10/02 08:36:49 UTC

svn commit: r451891 - in /cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms: binding/ binding/library/ formmodel/library/

Author: vgritsenko
Date: Sun Oct  1 23:36:48 2006
New Revision: 451891

URL: http://svn.apache.org/viewvc?view=rev&rev=451891
Log:
cleanup

Modified:
    cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/binding/JXPathBindingManager.java
    cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/binding/library/Library.java
    cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/binding/library/LibraryManager.java
    cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/binding/library/LibraryManagerImpl.java
    cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/formmodel/library/LibraryManager.java

Modified: cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/binding/JXPathBindingManager.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/binding/JXPathBindingManager.java?view=diff&rev=451891&r1=451890&r2=451891
==============================================================================
--- cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/binding/JXPathBindingManager.java (original)
+++ cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/binding/JXPathBindingManager.java Sun Oct  1 23:36:48 2006
@@ -228,7 +228,9 @@
 
             boolean flag = false;
             if (context.getLocalLibrary() == null) {
+                // FIXME Use newLibrary()?
                 Library lib = new Library(libraryManager);
+                lib.enableLogging(getLogger());
                 context.setLocalLibrary(lib);
                 lib.setAssistant(getBuilderAssistant());
                 lib.setSourceURI(LocationAttributes.getURI(configElm));

Modified: cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/binding/library/Library.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/binding/library/Library.java?view=diff&rev=451891&r1=451890&r2=451891
==============================================================================
--- cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/binding/library/Library.java (original)
+++ cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/binding/library/Library.java Sun Oct  1 23:36:48 2006
@@ -22,6 +22,7 @@
 
 import org.apache.avalon.framework.service.ServiceException;
 import org.apache.avalon.framework.service.ServiceManager;
+import org.apache.avalon.framework.logger.AbstractLogEnabled;
 
 import org.apache.cocoon.forms.binding.Binding;
 import org.apache.cocoon.forms.binding.BindingManager;
@@ -35,7 +36,7 @@
 /**
  * @version $Id$
  */
-public class Library {
+public class Library extends AbstractLogEnabled {
 
 	public static final String SEPARATOR = ":";
 
@@ -53,10 +54,6 @@
 	protected JXPathBindingManager.Assistant assistant;
 
 
-    public Library(ServiceManager sm) throws ServiceException {
-        manager = (LibraryManager) sm.lookup(LibraryManager.ROLE);
-	}
-
 	public Library(LibraryManager lm) {
 		manager = lm;
 	}
@@ -98,7 +95,7 @@
 		try {
 			// library keys may not contain ":"!
             if ((!inclusions.containsKey(key) || key.indexOf(SEPARATOR) > -1)
-                    && manager.getLibrary(sourceURI, this.sourceURI) != null) {
+                    && manager.load(sourceURI, this.sourceURI) != null) {
                 inclusions.put(key, new Dependency(sourceURI));
                 return true;
             }
@@ -124,7 +121,7 @@
         if (librarykey != null) {
             if (inclusions.containsKey(librarykey)) {
                 try {
-                    return manager.getLibrary(((Dependency) inclusions.get(librarykey)).dependencySourceURI, sourceURI).getBinding(definitionkey);
+                    return manager.load(((Dependency) inclusions.get(librarykey)).dependencySourceURI, sourceURI).getBinding(definitionkey);
                 } catch (Exception e) {
                     throw new LibraryException("Couldn't get Library key='" + librarykey + "' source='" + inclusions.get(librarykey) + "", e);
                 }
@@ -155,7 +152,9 @@
         binding.setEnclosingLibrary(this);
 
         definitions.put(binding.getId(), binding);
-        manager.debug(this + ": Put binding with id: " + binding.getId());
+        if (getLogger().isDebugEnabled()) {
+            getLogger().debug(this + ": Put binding with id: " + binding.getId());
+        }
     }
 
 
@@ -169,14 +168,14 @@
 		public Dependency(String dependencySourceURI) throws Exception {
 			this.dependencySourceURI = dependencySourceURI;
 
-			Library lib = manager.getLibrary(this.dependencySourceURI,sourceURI);
+			Library lib = manager.load(this.dependencySourceURI,sourceURI);
 			this.shared = lib.shared;
 		}
 
 		public boolean isValid() throws LibraryException {
             try {
-                if (manager.libraryInCache(dependencySourceURI, sourceURI)) {
-                    Library lib = manager.getLibrary(dependencySourceURI, sourceURI);
+                if (manager.get(dependencySourceURI, sourceURI)) {
+                    Library lib = manager.load(dependencySourceURI, sourceURI);
 
                     if (this.shared == lib.shared) {
                         return true;

Modified: cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/binding/library/LibraryManager.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/binding/library/LibraryManager.java?view=diff&rev=451891&r1=451890&r2=451891
==============================================================================
--- cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/binding/library/LibraryManager.java (original)
+++ cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/binding/library/LibraryManager.java Sun Oct  1 23:36:48 2006
@@ -18,8 +18,8 @@
 
 /**
  * The work interface for the LibraryManager, the class that
- * manages all used library definitions so they can be shared between
- * forms.
+ * manages all used form binding library definitions so they can be shared
+ * between forms.
  *
  * @version $Id$
  */
@@ -27,12 +27,46 @@
 
 	String ROLE = LibraryManager.class.getName();
 
-	Library getLibrary(String librarysource) throws Exception;
-	Library getLibrary(String librarysource, String relative) throws Exception;
-	Library getNewLibrary();
+    /**
+     * Create new instance of the {@link Library}.
+     * @return new library instance
+     */
+    Library newLibrary();
 
-	boolean libraryInCache(String librarysource) throws Exception;
-	boolean libraryInCache(String librarysource, String relative) throws Exception;
+    /**
+     * Loads (and caches) a library from specified source URI.
+     *
+     * @param sourceURI URI of the library source.
+     * @return Library loaded from the source URI.
+     */
+	Library load(String sourceURI) throws Exception;
 
-	void debug(String msg);
+    /**
+     * Loads (and caches) a library from specified source URI, resolved relative
+     * to the base URI.
+     *
+     * @param sourceURI Relative URI of the library source.
+     * @param baseURI Base URI of the library source.
+     * @return Library loaded from the source URI.
+     */
+	Library load(String sourceURI, String baseURI) throws Exception;
+
+    /**
+     * Get the cached instance of the library loaded from the specified source
+     * URI.
+     *
+     * @param sourceURI URI of the library source.
+     * @return Cached instance of the library, or null if it was not loaded.
+     */
+	boolean get(String sourceURI) throws Exception;
+
+    /**
+     * Get the cached instance of the library loaded from the specified source
+     * URI, resolved relative to the base URI.
+     *
+     * @param sourceURI Relative URI of the library source.
+     * @param baseURI Base URI of the library source.
+     * @return Cached instance of the library, or null if it was not loaded.
+     */
+	boolean get(String sourceURI, String baseURI) throws Exception;
 }

Modified: cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/binding/library/LibraryManagerImpl.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/binding/library/LibraryManagerImpl.java?view=diff&rev=451891&r1=451890&r2=451891
==============================================================================
--- cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/binding/library/LibraryManagerImpl.java (original)
+++ cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/binding/library/LibraryManagerImpl.java Sun Oct  1 23:36:48 2006
@@ -72,11 +72,11 @@
         // read config to "preload" libraries
     }
 
-    public boolean libraryInCache(String librarysource) throws Exception {
-    	return libraryInCache(librarysource,null);
+    public boolean get(String librarysource) throws Exception {
+    	return get(librarysource,null);
     }
 
-    public boolean libraryInCache(String librarysource, String relative) throws Exception {
+    public boolean get(String librarysource, String relative) throws Exception {
     	SourceResolver sourceResolver = null;
         Source source = null;
 
@@ -121,11 +121,11 @@
         return result;
     }
 
-    public Library getLibrary(String librarysource) throws Exception {
-    	return getLibrary(librarysource,null);
+    public Library load(String librarysource) throws Exception {
+    	return load(librarysource,null);
     }
 
-	public Library getLibrary(String librarysource, String relative) throws Exception {
+	public Library load(String librarysource, String relative) throws Exception {
 		SourceResolver sourceResolver = null;
         Source source = null;
         Document libraryDocument = null;
@@ -157,7 +157,7 @@
                     inputSource.setSystemId(source.getURI());
                     libraryDocument = DomHelper.parse(inputSource, this.serviceManager);
 
-                    lib = getNewLibrary();
+                    lib = newLibrary();
                     lib.buildLibrary(libraryDocument.getDocumentElement());
 
                     this.cacheManager.set(lib,source,PREFIX);
@@ -177,9 +177,10 @@
         return lib;
 	}
 
-	public Library getNewLibrary() {
+	public Library newLibrary() {
 		Library lib = new Library(this);
-		lib.setAssistant(this.bindingManager.getBuilderAssistant());
+        lib.enableLogging(getLogger());
+        lib.setAssistant(this.bindingManager.getBuilderAssistant());
 
         if(getLogger().isDebugEnabled())
         	getLogger().debug("Created new library! "+lib);

Modified: cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/formmodel/library/LibraryManager.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/formmodel/library/LibraryManager.java?view=diff&rev=451891&r1=451890&r2=451891
==============================================================================
--- cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/formmodel/library/LibraryManager.java (original)
+++ cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/formmodel/library/LibraryManager.java Sun Oct  1 23:36:48 2006
@@ -18,8 +18,8 @@
 
 /**
  * The work interface for the LibraryManager, the class that
- * manages all used library definitions so they can be shared between
- * forms.
+ * manages all used form model library definitions so they can be shared
+ * between forms.
  *
  * @version $Id$
  */