Search in sources :

Example 6 with ContentStore

use of org.eclipse.ceylon.cmr.spi.ContentStore in project ceylon by eclipse.

the class DefaultNode method getContent.

@Override
@SuppressWarnings("unchecked")
public <T> T getContent(Class<T> contentType) throws IOException {
    if (File.class.equals(contentType)) {
        synchronized (this) {
            if (handle != null)
                return (T) handle.getContentAsFile();
        }
        final ContentStore cs = findService(ContentStore.class);
        ContentHandle ch = cs.getContent(this);
        if (ch == null) {
            ch = HANDLE_MARKER;
        }
        synchronized (this) {
            handle = ch;
        }
        return (T) ch.getContentAsFile();
    } else {
        return super.getContent(contentType);
    }
}
Also used : ContentHandle(org.eclipse.ceylon.cmr.spi.ContentHandle) ContentStore(org.eclipse.ceylon.cmr.spi.ContentStore)

Example 7 with ContentStore

use of org.eclipse.ceylon.cmr.spi.ContentStore in project ceylon by eclipse.

the class DefaultNode method getSize.

@Override
public long getSize() throws IOException {
    synchronized (this) {
        if (handle != null)
            return handle.getSize();
    }
    final ContentStore cs = findService(ContentStore.class);
    ContentHandle ch = cs.getContent(this);
    if (ch == null) {
        ch = HANDLE_MARKER;
    }
    synchronized (this) {
        handle = ch;
    }
    return ch.getSize();
}
Also used : ContentHandle(org.eclipse.ceylon.cmr.spi.ContentHandle) ContentStore(org.eclipse.ceylon.cmr.spi.ContentStore)

Aggregations

ContentHandle (org.eclipse.ceylon.cmr.spi.ContentHandle)7 ContentStore (org.eclipse.ceylon.cmr.spi.ContentStore)7 OpenNode (org.eclipse.ceylon.cmr.spi.OpenNode)2 File (java.io.File)1 CmrRepository (org.eclipse.ceylon.cmr.api.CmrRepository)1 ModuleVersionDetails (org.eclipse.ceylon.cmr.api.ModuleVersionDetails)1 ModuleVersionQuery (org.eclipse.ceylon.cmr.api.ModuleVersionQuery)1 ModuleVersionResult (org.eclipse.ceylon.cmr.api.ModuleVersionResult)1