From: Julio G. <ju...@us...> - 2004-03-17 15:11:25
|
Update of /cvsroot/smartfrog/core/smartfrog/src/org/smartfrog/sfcore/componentdescription In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv26122/smartfrog/src/org/smartfrog/sfcore/componentdescription Modified Files: ComponentDescriptionImpl.java Log Message: REF: new utitity methods for - create a Component description from a resource URL - load Parser using a resource URL. ADD: methods to merge DefaultProcessDescriptions with ProcessDescription. We need to refactor ProcessCompound to make use of it. Therefore, the call is commented. Index: ComponentDescriptionImpl.java =================================================================== RCS file: /cvsroot/smartfrog/core/smartfrog/src/org/smartfrog/sfcore/componentdescription/ComponentDescriptionImpl.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** ComponentDescriptionImpl.java 15 Mar 2004 19:17:07 -0000 1.3 --- ComponentDescriptionImpl.java 17 Mar 2004 15:01:25 -0000 1.4 *************** *** 43,46 **** --- 43,54 ---- import org.smartfrog.sfcore.security.SFClassLoader; + //For utility methods + import org.smartfrog.sfcore.parser.Phases; + import org.smartfrog.sfcore.parser.SFParser; + import org.smartfrog.sfcore.common.SmartFrogRuntimeException; + import java.rmi.RemoteException; + import java.io.InputStream; + + /** * Defines the context class used by Components. Context implementations *************** *** 552,554 **** --- 560,612 ---- } } + + /** + * Utility method that gets Component Description for URL after applying + * default parser phases + * + * @param String url to convert to ComponentDescription + * + * @return process compound description default phases Resolved + * + * @throws RemoteException In case of network/rmi error + * @throws SmartFrogRuntimeException In case of SmartFrog system error + */ + public static ComponentDescription getComponentDescription(String url) + throws SmartFrogException, RemoteException { + return getComponentDescription(url,null,null); + } + + + /** + * Utility method that gets Component Description for URL after applying + * some parser phases + * + * @param String url to convert to ComponentDescription + * @param Vector parser phases to apply. If the vector is null, then all + * the default phases are applied + * @param Rererence ref reference to resolve in Description. + * + * @return process compound description 'phases' Resolved + * + * @throws RemoteException In case of network/rmi error + * @throws SmartFrogRuntimeException In case of SmartFrog system error + */ + public static ComponentDescription getComponentDescription(String url, + Vector phases, Reference ref) + throws SmartFrogException, RemoteException { + + Phases descr = (new SFParser(url)).sfParseResource(url); + + if (phases==null) { + return descr.sfResolvePhases().sfAsComponentDescription(); + } else { + descr.sfResolvePhases(phases); + } + + if (ref==null) ref = new Reference (SmartFrogCoreKeys.SF_CONFIG); + + return (ComponentDescription) descr.sfAsComponentDescription().sfResolve(ref); + } + + } |