Package org.locationtech.udig.catalog

Examples of org.locationtech.udig.catalog.IService


    public List<IResolve> getResources( IProgressMonitor monitor ) throws Exception {
        if (!isPageComplete())
            return null;

        OracleServiceExtension creator = new OracleServiceExtension();
        IService service = creator.createService(null, getParams());
        service.getInfo(monitor); // load

        List<IResolve> servers = new ArrayList<IResolve>();
        servers.add(service);
        return servers;
    }
View Full Code Here


     * @throws MalformedURLException
     * @throws IOException
     */
    public static Layer createLayer(Map map, Class<? extends IService> desiredService, String serviceURL, String resourceURL, String name) throws MalformedURLException, IOException {
      List<IService> services = CatalogPlugin.getDefault().getServiceFactory().createService(new URL(serviceURL));
        IService s=null;
        for( IService service : services ) {
            if( service.getClass().isAssignableFrom(desiredService)){
                s=service;
                break;
            }
        }
       
        if( s==null )
            throw new AssertionError();
        if( !(s.resources(null).size()>0))
            throw new AssertionError();
       
      CatalogPlugin.getDefault().getLocalCatalog().add(s);
      List<IResolve> resources = CatalogPlugin.getDefault().getLocalCatalog().find(new URL(resourceURL), null);
      if( !(resources.size()>0) )
View Full Code Here

    public IService add( IService service ) throws UnsupportedOperationException {
        if (service == null || service.getIdentifier() == null)
            throw new NullPointerException("Cannot have a null id"); //$NON-NLS-1$
        ID id = service.getID();

        IService found = getById(IService.class, id, new NullProgressMonitor());

        if (found != null) {
            // clean up the service that was passed in
            try {
                service.dispose(new NullProgressMonitor());
View Full Code Here

    }
    public void replace( ID id, IService replacement ) throws UnsupportedOperationException {
        if (replacement == null || replacement.getIdentifier() == null || id == null) {
            throw new NullPointerException("Cannot have a null id"); //$NON-NLS-1$
        }
        final IService service = getServiceById(id);
        List<IResolveDelta> changes = new ArrayList<IResolveDelta>();
        List<IResolveDelta> childChanges = new ArrayList<IResolveDelta>();
        try {
            List< ? extends IGeoResource> newChildren = replacement.resources(null);
            List< ? extends IGeoResource> oldChildren = service.resources(null);
            if (oldChildren != null)
                for( IGeoResource oldChild : oldChildren ) {
                    String oldName = oldChild.getIdentifier().toString();

                    for( IGeoResource child : newChildren ) {
                        String name = child.getIdentifier().toString();
                        if (oldName.equals(name)) {
                            childChanges.add(new ResolveDelta(child, oldChild,
                                    IResolveDelta.NO_CHILDREN));
                            break;
                        }
                    }
                }
        } catch (IOException ignore) {
            // no children? Not a very good entry ..
        }
        changes.add(new ResolveDelta(service, replacement, childChanges));

        IResolveDelta deltas = new ResolveDelta(this, changes);
        IResolveChangeEvent event = new ResolveChangeEvent(this,
                IResolveChangeEvent.Type.PRE_DELETE, deltas);
        fire(event);
        services.remove(service);
        runInterceptor(service, ServiceInterceptor.REMOVED_ID);

        PlatformGIS.run(new IRunnableWithProgress(){

            public void run( IProgressMonitor monitor ) throws InvocationTargetException,
                    InterruptedException {
                try {
                    service.dispose(monitor);
                } catch (Throwable e) {
                    CatalogPlugin.log("error disposing of: " + service.getIdentifier(), e); //$NON-NLS-1$
                }
            }

        });

        services.add(replacement);
        runInterceptor(replacement, ServiceInterceptor.ADDED_ID);
        event = new ResolveChangeEvent(this, IResolveChangeEvent.Type.POST_CHANGE, deltas);

        if (!id.equals(replacement.getIdentifier())) {
            // the service has actually moved
            IService moved = new MovedService(id, replacement.getID());
            services.add(moved);
            runInterceptor(moved, ServiceInterceptor.ADDED_ID);
        }
        fire(event);
    }
View Full Code Here

     * @param monitor
     * @return Service used to access the provided url
     */
    public IService acquire( URL url, IProgressMonitor monitor ) throws IOException {
        List<IService> possible = new ArrayList<IService>();
        IService createdService = null;
       
        if (monitor == null)
            monitor = new NullProgressMonitor();

        monitor.beginTask("acquire", 100);
        monitor.subTask("acquire services");

        monitor.worked(10);
        try {

            possible = constructServices(url, monitor);

            if (possible.isEmpty()) {
                throw new IOException("Unable to connect to any service supporting " + url);
            }
           
            createdService = possible.get(0);
           
            try {
               
                add(createdService);// TODO don't clean this one up!
                return createdService;
            } catch (Throwable t) {
                // usually indicates an IOException as the service is unable to connect
                CatalogPlugin.trace("trouble connecting to " + createdService.getID(), t);
            }

        } finally {
            List<IService> members = checkMembers(possible);
           
            for( Iterator<IService> iterator = members.iterator(); iterator.hasNext(); ) {
                IService service = iterator.next();

                if (service.equals(createdService))
                    continue;

                service.dispose(new SubProgressMonitor(monitor, 10));
            }
            monitor.done();
        }
        return null; // unable to connect
    }
View Full Code Here

  }
 
  @Test(timeout = BLOCK)
  public void testCreateService() throws Exception {
    Map<String, Serializable> params = getServiceExtension().createParams(getTestURL());
    IService service = getServiceExtension().createService(getTestURL(), params);
    assertNotNull(service);
  }
View Full Code Here

  }
 
  @Test(timeout = BLOCK)
  public void testCreateServiceNullId() throws Exception {
    Map<String, Serializable> params = getServiceExtension().createParams(getTestURL());
    IService service = getServiceExtension().createService(null, params);
    assertNotNull(service);
  }
View Full Code Here

    assertNotNull(service);
  }
 
  @Test(timeout = BLOCK)
  public void testCreateServiceNullParams() throws Exception {
    IService service = getServiceExtension().createService(getTestURL(), null);
    assertNotNull(service);
  }
View Full Code Here

        }
        IServiceFactory serviceFactory = CatalogPlugin.getDefault().getServiceFactory();
        List<IService> candidates = serviceFactory.createService(url);
        try {
            for( Iterator<IService> i=candidates.iterator(); i.hasNext();){
                IService service = i.next();
                if (service.canResolve(type)) {
                    IService registered = local.add(service);
                    i.remove(); // don't clean this one up
                    return registered.getIdentifier();
                }
            }
        }
        finally {
            serviceFactory.dispose( candidates, null );
View Full Code Here

public class AddToCatalog implements IStartup {

    public void earlyStartup() {
        ICatalog localCatalog = CatalogPlugin.getDefault().getLocalCatalog();
        ID serviceUrl = new ID(MapGraphicService.SERVICE_URL);
        IService service = localCatalog.getById(IService.class, serviceUrl, ProgressManager.instance().get());
        if( service !=null )
            return;
       
        service=new MapGraphicService();
        localCatalog.add(service);
View Full Code Here

TOP

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

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.