Package org.locationtech.udig.catalog

Examples of org.locationtech.udig.catalog.ServiceExtension


                name=element.getAttribute("id"); //$NON-NLS-1$
            }

           
            try{
                ServiceExtension extension = (ServiceExtension) element.createExecutableExtension("class"); //$NON-NLS-1$
                if( extension instanceof ServiceExtension2 ){
                    ServiceExtension2 e2=(ServiceExtension2) extension;
                    if( params!=null ){
                        data.add(new Data( id, name, e2.reasonForFailure(params)) );
                    }else{


        assertTrue("Test Directory", directory.isDirectory());

        File shapefile = new File(new File(directory, "internal"), "australia.shp");
        assertTrue("Sample File", shapefile.isFile());

        ServiceExtension factory = new ShpServiceExtension();
        Map<String, Serializable> params = factory.createParams(shapefile.toURI().toURL());
        service = factory.createService(null, params);

        List<IGeoResource> members = (List<IGeoResource>) service
                .resources(new NullProgressMonitor());
        resource = members.get(0);

        }
        List<IService> candidates = new LinkedList<IService>();
        if( !available.isEmpty()){
            for( Map.Entry<ServiceExtension, Map<String, Serializable>> candidateEntry : available.entrySet() ) {
                String extentionIdentifier = candidateEntry.getKey().getClass().getName();
                ServiceExtension serviceExtension = candidateEntry.getKey();
                Map<String, Serializable> connectionParameters = candidateEntry.getValue();
                try {
                    IService sevice = serviceExtension.createService(null, connectionParameters);
                    CatalogImpl.runInterceptor(sevice, ServiceInterceptor.CREATED_ID);
                    candidates.add(sevice);
//                    List<IService> service = createService(connectionParameters);
//                    if (service != null && !service.isEmpty()) {
//                        for( IService created : service ){
//                            CatalogImpl.runInterceptor(created, ServiceInterceptor.CREATED_ID);
//                            candidates.add(created);
//                        }
//                    }
                } catch (Throwable deadService) {
                    CatalogPlugin.log(extentionIdentifier + " could not create service", deadService); //$NON-NLS-1$
                }
            }
        }
        if( candidates.isEmpty() && !generic.isEmpty()){
            // add generic entries if needed
            for(ServiceExtension serviceExtension : generic) {
                try {
                    Map<String, Serializable> connectionParameters = serviceExtension.createParams(targetUrl);
                    if (connectionParameters != null) {
                        IService service = serviceExtension.createService(null, connectionParameters);
                        CatalogImpl.runInterceptor(service, ServiceInterceptor.CREATED_ID);
                        candidates.add(service);
    //                    List<IService> service = createService(connectionParameters);
    //                    if (service != null && !service.isEmpty()) {                   
    //                        for( IService created : service ){
    //                            CatalogImpl.runInterceptor(created, ServiceInterceptor.CREATED_ID);
    //                            candidates.add(created);
    //                        }
    //                    }
                    }
                } catch (Throwable deadService) {
                    CatalogPlugin.log(serviceExtension.getClass().getName() + " could not create service", deadService); //$NON-NLS-1$
                }
            }
        }
        return candidates;
    }

TOP

Related Classes of org.locationtech.udig.catalog.ServiceExtension

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.