Package org.apache.stanbol.commons.stanboltools.datafileprovider

Examples of org.apache.stanbol.commons.stanboltools.datafileprovider.DataFileProvider


                comments.put(prop.getKey().toString(),prop.getValue().toString());
            }
        }
        InputStream is = null;
        for(Iterator<DataFileProvider> it = dataFileProviders.iterator();is == null && it.hasNext();){
            DataFileProvider dfp = it.next();
            try {
                is = dfp.getInputStream(null, resourceName, comments);
            }catch (IOException e) {
                //not found
            }
        }
        if(is != null || new File(managedSolrDir,parsedResourceName).isDirectory()){
View Full Code Here


                //a clone of the tracked resource
                Set<DataFileReference> resources;
                synchronized (trackedResources) {
                    resources = new HashSet<DataFileReference>(trackedResources.keySet());
                }
                DataFileProvider dataFileProvider = getDataFileProvider();
                if(dataFileProvider == null){
                    log.info("Currently no DataFileProvider available");
                } else {
                    log.debug("Track {} resources",resources.size());
                    for(DataFileReference resoruce : resources){
                        TrackingState resourceState;
                        synchronized (trackedResources) {
                            resourceState = trackedResources.get(resoruce);
                        }
                        if(log.isDebugEnabled()){
                            log.debug(" > {} (state:{})",resoruce.getName(),
                                resourceState != null ?
                                        resourceState.getTrackingState() != null ?
                                                resourceState.getTrackingState() : "none" :
                                                    null);
                        }
                        if(resourceState != null){ //might be null if removed in the meantime
                            STATE state;
                            if(dataFileProvider.isAvailable(resoruce.getBundleSymbolicName(),
                                    resoruce.getName(), resoruce.getProperties())){
                                state = STATE.AVAILABLE;
                            } else {
                                state = STATE.UNAVAILABLE;
                            }
View Full Code Here

            for(ServiceReference ref: refs) {
                final Object o = providersTracker.getService(ref);
                if(o == this) {
                    continue;
                }
                final DataFileProvider dfp = (DataFileProvider)o;
                try {
                    result = dfp.getInputStream(bundleSymbolicName, filename, comments);
                } catch (Exception e) {
                    //Exceptions thrown by an implementation should never
                    //affect the MainDataFileProvider
                    log.debug(String.format("Eception while searching DataFile %s by using provider %s (ignore)",
                        filename,dfp),e);
                }
                if(result == null) {
                    log.debug("{} does not provide file {}", dfp, filename);
                } else {
                    fileUrl = dfp.getClass().getName() + "://" + filename;
                    break; //break as soon as a resource was found
                }
            }
        } else {
            try {
View Full Code Here

            for(ServiceReference ref: refs) {
                final Object o = providersTracker.getService(ref);
                if(o == this) {
                    continue;
                }
                final DataFileProvider dfp = (DataFileProvider)o;
                try {
                    if(dfp.isAvailable(bundleSymbolicName, filename, comments)){
                        log.debug("{} does provide file {}", dfp, filename);
                        fileUrl = dfp.getClass().getName() + "://" + filename;
                        break;
                    }
                } catch (RuntimeException e) {
                    log.warn("Exception while checking availability of Datafile " +
                        "'{}' on DataFileProvider {}",filename,dfp);
View Full Code Here

                comments.put(prop.getKey().toString(),prop.getValue().toString());
            }
        }
        InputStream is = null;
        for(Iterator<DataFileProvider> it = dataFileProviders.iterator();is == null && it.hasNext();){
            DataFileProvider dfp = it.next();
            try {
                is = dfp.getInputStream(null, resourceName, comments);
            }catch (IOException e) {
                //not found
            }
        }
        if(is != null || new File(managedSolrDir,parsedResourceName).isDirectory()){
View Full Code Here

    public static final String FAKE_BUNDLE_SYMBOLIC_NAME = "FAKE_BUNDLE_SYMBOLIC_NAME";
    public static OpenNLP openNLP;
   
    @BeforeClass
    public static void initDataFileProvicer(){
        DataFileProvider dataFileProvider = new ClasspathDataFileProvider(FAKE_BUNDLE_SYMBOLIC_NAME);
        openNLP = new OpenNLP(dataFileProvider);
    }
View Full Code Here

                comments.put(prop.getKey().toString(),prop.getValue().toString());
            }
        }
        InputStream is = null;
        for(Iterator<DataFileProvider> it = dataFileProviders.iterator();is == null && it.hasNext();){
            DataFileProvider dfp = it.next();
            try {
                is = dfp.getInputStream(null, resourceName, comments);
            }catch (IOException e) {
                //not found
            }
        }
        if(is != null || new File(managedSolrDir,parsedResourceName).isDirectory()){
View Full Code Here

            for(ServiceReference ref: refs) {
                final Object o = providersTracker.getService(ref);
                if(o == this) {
                    continue;
                }
                final DataFileProvider dfp = (DataFileProvider)o;
                try {
                    result = dfp.getInputStream(bundleSymbolicName, filename, comments);
                } catch (Exception e) {
                    //Exceptions thrown by an implementation should never
                    //affect the MainDataFileProvider
                    log.debug(String.format("Eception while searching DataFile %s by using provider %s (ignore)",
                        filename,dfp),e);
                }
                if(result == null) {
                    log.debug("{} does not provide file {}", dfp, filename);
                } else {
                    fileUrl = dfp.getClass().getName() + "://" + filename;
                    break; //break as soon as a resource was found
                }
            }
        } else {
            result =  new FileInputStream(dataFile);
View Full Code Here

            for(ServiceReference ref: refs) {
                final Object o = providersTracker.getService(ref);
                if(o == this) {
                    continue;
                }
                final DataFileProvider dfp = (DataFileProvider)o;
                try {
                    if(dfp.isAvailable(bundleSymbolicName, filename, comments)){
                        log.debug("{} does provide file {}", dfp, filename);
                        fileUrl = dfp.getClass().getName() + "://" + filename;
                        break;
                    }
                } catch (RuntimeException e) {
                    log.warn("Exception while checking availability of Datafile " +
                        "'{}' on DataFileProvider {}",filename,dfp);
View Full Code Here

                //a clone of the tracked resource
                Set<DataFileReference> resources;
                synchronized (trackedResources) {
                    resources = new HashSet<DataFileReference>(trackedResources.keySet());
                }
                DataFileProvider dataFileProvider = getDataFileProvider();
                if(dataFileProvider == null){
                    log.info("Currently no DataFileProvider available");
                } else {
                    log.debug("Track {} resources",resources.size());
                    for(DataFileReference resoruce : resources){
                        TrackingState resourceState;
                        synchronized (trackedResources) {
                            resourceState = trackedResources.get(resoruce);
                        }
                        if(log.isDebugEnabled()){
                            log.debug(" > {} (state:{})",resoruce.getName(),
                                resourceState != null ?
                                        resourceState.getTrackingState() != null ?
                                                resourceState.getTrackingState() : "none" :
                                                    null);
                        }
                        if(resourceState != null){ //might be null if removed in the meantime
                            STATE state;
                            if(dataFileProvider.isAvailable(resoruce.getBundleSymbolicName(),
                                    resoruce.getName(), resoruce.getProperties())){
                                state = STATE.AVAILABLE;
                            } else {
                                state = STATE.UNAVAILABLE;
                            }
View Full Code Here

TOP

Related Classes of org.apache.stanbol.commons.stanboltools.datafileprovider.DataFileProvider

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.