Package org.jdesktop.wonderland.common

Examples of org.jdesktop.wonderland.common.AssetURI


     * Utility routine that attempts to load the asset from the cache and sets
     * the success or failure information in the asset. Returns the asset
     * upon success, and null upon failure.
     */
    private Asset loadAssetFromCache(Asset asset, String originalChecksum) {
        AssetURI assetURI = asset.getAssetURI();
        String uriString = assetURI.toExternalForm();
        String checksum = asset.getChecksum();

        // Attempt to load the asset from the cache. If it fails, then
        // we set the failure information and notify any listeners and
        // return.
View Full Code Here


                    Logger logger = Logger.getLogger(AssetManager.class.getName());
                    AssetManager assetManager = AssetManager.getAssetManager();

                    // Create the AssetURI and Asset to use to load. Just
                    // use the localhost:8080 as the server name and port
                    AssetURI assetURI = AssetURI.uriFactory(uris[j]);
                    assetURI.setServerHostAndPort("localhost:8080");

                    // Wait for the asset to load and print out the result
                    Asset asset = assetManager.getAsset(assetURI);
                    assetManager.waitForAsset(asset);
                    logger.fine("Failure info: " + asset.getFailureInfo());
                    if (asset.getLocalCacheFile() == null) {
                        logger.fine("Local Cache File: null");
                    }
                    else {
                        logger.fine("Local Cache File: " + asset.getLocalCacheFile().getAbsolutePath());
                    }
                    logger.fine("Done with: " + assetURI.toString());
                }
            };
            threads[i].start();
        }
View Full Code Here

        /**
         * Downloads the asset from the server and returns the asset upon success
         * or null upon failure
         */
        private Object doAssetDownload() {
            AssetURI assetURI = asset.getAssetURI();
            String uriString = assetURI.toExternalForm();

            // Keep a copy of the original asset checksum. Sometimes (e.g. in
            // the case of HTTP if-modified-since) the "checksum" can change
            // after we have downloaded. We need to make sure we remove the
            // proper thing from the "loading" and "loaded" lists.
View Full Code Here

        // Convert into a list of assets and put in the list
        for (AssetDBRecord record : recordList) {
            // Generate a new AssetURI class based upon the string uri, if
            // it exists
            AssetURI recordURI = AssetURI.uriFactory(record.assetURI);
            if (recordURI == null) {
                continue;
            }

            // Now generate a new Asset class
View Full Code Here

     * @param assetRecord The database record of the asset
     * @return The new Asset, or null upon error
     */
    public Asset assetFactory(AssetDBRecord assetRecord) {
        // Use the known set of AssetURI classes to generate one
        AssetURI assetURI = AssetURI.uriFactory(assetRecord.assetURI);
        if (assetURI == null) {
            logger.warning("Unable to find AssetURI class for " + assetRecord.assetURI);
            return null;
        }

View Full Code Here

    public void tearDown() {
    }

    public void testCachePath() {
        try {
            AssetURI assetURI1 = new AssetURI("http://www.foo.net/models/mymodel.gz");
            System.out.println("For: " + assetURI1.toString() + ", cache file=" + assetURI1.getRelativeCachePath());
           
            AssetURI assetURI2 = new AssetURI("models/mymodel.gz");
            System.out.println("For: " + assetURI2.toString() + ", cache file=" + assetURI2.getRelativeCachePath());
           
            AssetURI assetURI3 = new AssetURI("wlm://mpk20/models/mymodel.gz");
            System.out.println("For: " + assetURI3.toString() + ", cache file=" + assetURI3.getRelativeCachePath());          
        } catch (java.lang.Exception excp) {
        }
    }
View Full Code Here

        for (int i = 0; i < urls.length; i++) {
            final int j = i;
            threads[i] = new Thread() {
                public void run() {
                    try {
                        AssetURI assetURI = new AssetURI(urls[j]);
                        Asset asset = assetManager.getAsset(assetURI, AssetType.FILE);
                        assertTrue(assetManager.waitForAsset(asset));
                        assertNull(asset.getFailureInfo());
                        assertNotNull(asset.getLocalCacheFile());
                        System.out.println("Done with: " + assetURI.toString());
                    } catch (java.net.URISyntaxException excp) {
                        System.out.println(excp.toString());
                    }
                }
            };
View Full Code Here

     * @throw MalformedURLException Upon error forming the URL
     */
    public static URL getAssetURL(String uri, Cell cell) throws MalformedURLException {
        // First try to form an AssetURI class given the uri string. If none
        // exists, then return the uri directly as a URL
        AssetURI assetURI = AssetURI.uriFactory(uri);
        if (assetURI == null) {
            logger.warning("Unable to find AssetURI object for " + uri);
            return new URL(uri);
        }

        // From the cell, find out what the associated wonderland session is
        // and fetch the server host name and port from that
        WonderlandSession session = cell.getCellCache().getSession();
        ServerSessionManager manager = session.getSessionManager();
        if (manager == null) {
            logger.warning("Unable to find manager for session " + session);
            return new URL(uri);
        }
        String serverHostAndPort = manager.getServerNameAndPort();

        // Annotate the URI with the host name and port from the session and
        // return as a URL
        assetURI.setServerHostAndPort(serverHostAndPort);
        return assetURI.toURL();
    }
View Full Code Here

     * @throw MalformedURLException Upon error forming the URL
     */
    public static URL getAssetURL(String uri) throws MalformedURLException {
        // First try to form an AssetURI class given the uri string. If none
        // exists, then return the uri directly as a URL
        AssetURI assetURI = AssetURI.uriFactory(uri);
        if (assetURI == null) {
            logger.warning("Unable to find AssetURI object for " + uri);
            return new URL(uri);
        }

        // Use the primary login session to determine the server host and port
        // name
        ServerSessionManager manager = LoginManager.getPrimary();
        if (manager == null) {
            logger.warning("No primary login session for " + uri);
            return new URL(uri);
        }
        String serverHostAndPort = manager.getServerNameAndPort();

        // Annotate the URI with the host name and port from the session and
        // return as a URL
        assetURI.setServerHostAndPort(serverHostAndPort);
        return assetURI.toURL();
    }
View Full Code Here

     * @throw MalformedURLException Upon error forming the URL
     */
    public static URL getAssetURL(String uri, String serverNameAndPort) throws MalformedURLException {
        // First try to form an AssetURI class given the uri string. If none
        // exists, then return the uri directly as a URL
        AssetURI assetURI = AssetURI.uriFactory(uri);
        if (assetURI == null) {
            logger.warning("Unable to find AssetURI object for " + uri);
            return new URL(uri);
        }

        // Annotate the URI with the host name and port from the session and
        // return as a URL
        assetURI.setServerHostAndPort(serverNameAndPort);
        return assetURI.toURL();
    }
View Full Code Here

TOP

Related Classes of org.jdesktop.wonderland.common.AssetURI

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.