Package org.locationtech.udig.catalog

Examples of org.locationtech.udig.catalog.IResolveAdapterFactory


    public <T> T resolve(IResolve resolve, Class<T> targetClass, IProgressMonitor monitor)
            throws IOException {
        String targetTypeName = targetClass.getName();
       
        Map<String, IResolveAdapterFactory> available = getFactories(resolve.getClass());
        IResolveAdapterFactory factory = available.get(targetTypeName);
        if (factory != null) {
            // we found a factory directly responsible for this connection
            T connected = factory.adapt(resolve, targetClass, monitor);
            return connected;
        }
        else {
            List<IResolveAdapterFactory> genericFactories = factories.get(null);
            for( IResolveAdapterFactory fallback : genericFactories ){
View Full Code Here


    @Override
    public boolean canResolve(IResolve resolve, Class<?> targetClass) {
        Map<String, IResolveAdapterFactory> available = getFactories(resolve.getClass());
        String targetTypeName = targetClass.getName();
        IResolveAdapterFactory factory = available.get(targetTypeName);
        if (factory != null){
            // we found a factory directly responsible for this connection
            try {
                return factory.canAdapt(resolve, targetClass);
            } catch (Throwable t) {
                String msg = "IResolveAdapterFactory " + factory.getClass().getName()
                        + " canAdapt check failed:" + t;
                CatalogPlugin.trace(msg, t);
                return false; // factory was unable to function
            }
        }
View Full Code Here

     * Test method for {@link org.locationtech.udig.catalog.internal.ResolveManager#registerResolves(org.locationtech.udig.catalog.IResolveAdapterFactory)}.
     */
    @Test
    public void testRegisterResolves() {
        assertFalse(resolveManager.canResolve(service, Integer.class));
        IResolveAdapterFactory factory = new IResolveAdapterFactory() {

            public <T> T adapt(IResolve resolve, Class<T> adapter, IProgressMonitor monitor)
                    throws IOException {
                if( adapter == Integer.class ){
                    return adapter.cast( new Integer(1) );
View Full Code Here

    /**
     * Test method for {@link org.locationtech.udig.catalog.internal.ResolveManager#unregisterResolves(org.locationtech.udig.catalog.IResolveAdapterFactory, java.lang.Class)}.
     */
    @Test
    public void testUnregisterResolvesIResolveAdapterFactoryClass() {
        IResolveAdapterFactory factory = new IResolveAdapterFactory(){
           
            public <T> T adapt( IResolve resolve, Class<T> adapter, IProgressMonitor monitor ) throws IOException {
                if( adapter == Integer.class ){
                    return adapter.cast( Integer.valueOf(1) );                  
                }
View Full Code Here

          // check the configuration information before making a factory
          if( isResolvableType( element, resolve ) &&
            isTargetTypeSupported(element, adapter)){
            // Use the extension point information as a quick sanity check to ensure
            // the factory is relevant to the problem at hand
            IResolveAdapterFactory factory = getResolveAdapterFactory( entry );
            if( factory.canAdapt( resolve, adapter) ){
              return true;
            }
          }
        }
        catch( RuntimeException ignore ){
          // problem encountered with entry; depending
          // on the problem we may consider disabling the entry
          // and logging a warning?
          CatalogPlugin.log( ignore.getLocalizedMessage(), ignore );
        }
      }
     
      // Go through registered factories second, ensuring that
      // XML can always override something that has been hard coded
      //
      for( IResolveAdapterFactory factory : registeredFactories ) {
        try {
          Set<Class<?>> ignoreSet = exceptions.get(factory);
          if( ignoreSet != null && ignoreSet.contains(adapter) ){
            continue; // skip this as it is listed as an exception
          }
          if( factory.canAdapt( resolve, adapter)){
            return true;
          }
        }
        catch( RuntimeException ignore ){
          // problem encountered with factory; depending
View Full Code Here

            // Okay that optimisation failed; lets use the platform facilities
            // like a good RCP programmer
            try {             
              // only way to check is to actually make the factory, and use
              // the factory's class loader to grab the target class
              IResolveAdapterFactory factory = getResolveAdapterFactory( element );
              if( factory instanceof BrokenIResolveAdapaterFactory){
                // not even this factory can be loaded ... skip
                continue;
              }
              ClassLoader classLoader = factory.getClass().getClassLoader();
                if( classLoader != null ){
                  Class< ? > resolvedClass = classLoader.loadClass(resolveType);
                  if( target.isAssignableFrom(resolvedClass) ){
                        return true;
                    }
View Full Code Here

    protected IResolveAdapterFactory getResolveAdapterFactory( Map.Entry<IConfigurationElement,IResolveAdapterFactory> entry ){
      synchronized (factories) {
        if( entry.getValue() != null ) return entry.getValue();

        IConfigurationElement element = entry.getKey();
        IResolveAdapterFactory factory;
          try {
            factory= (IResolveAdapterFactory)
              element.createExecutableExtension("class"); //$NON-NLS-1$         
          } catch (CoreException e) {
            CatalogPlugin.log( e.toString(), e );
View Full Code Here

      }
    }

    protected IResolveAdapterFactory getResolveAdapterFactory(IConfigurationElement element) {
        synchronized (factories) {
            IResolveAdapterFactory factory = factories.get(element);
            if (factory != null)
                return factory;

            try {
                factory = (IResolveAdapterFactory) element.createExecutableExtension("class"); //$NON-NLS-1$         
View Full Code Here

            // check the configuration information before making a factory
            if( isResolvableType( element, resolve ) &&
              isTargetTypeSupported(element, adapter)){
              // Use the extension point information as a quick sanity check to ensure
              // the factory is relevant to the problem at hand
              IResolveAdapterFactory factory = getResolveAdapterFactory( entry );
              if( factory.canAdapt( resolve, adapter)){
                // we think we can do this one...
                IProgressMonitor subMonitor = SubMonitor.convert(monitor, factory.getClass().getCanonicalName(), 10 );
              Object value = factory.adapt( resolve, adapter, subMonitor );
              if( value != null ){
                return adapter.cast( value );
              }
              }
              else {
                monitor.worked(10);
              }
            }
            else {
              monitor.worked(10);
            }
          }
          catch( RuntimeException ignore ){
            // problem encountered with entry; depending
            // on the problem we may consider disabling the entry
            // and logging a warning?
            CatalogPlugin.log( ignore.getLocalizedMessage(), ignore );
          }
        }
       
        // Go through registered factories second, ensuring that
        // XML can always override something that has been hard coded
        //
        for( IResolveAdapterFactory factory : registeredFactories ) {
          try {
            Set<Class<?>> ignoreSet = exceptions.get(factory);
            if( ignoreSet != null && ignoreSet.contains(adapter) ){
              monitor.worked(10);
              continue; // skip this as it is listed as an exception
            }
            if( factory.canAdapt( resolve, adapter)){
              // we think we can do this one...
              IProgressMonitor subMonitor = SubMonitor.convert(monitor, factory.getClass().getCanonicalName(), 10 );
            Object value = factory.adapt( resolve, adapter, subMonitor );
            if( value != null ){
              return adapter.cast( value );
            }
            }
            else {
View Full Code Here

TOP

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

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.