String stName = name; ServiceType.Registry r = (ServiceType.Registry)Lookup.getDefault().lookup(ServiceType.Registry.class); for (int i = 1; r.find(stName) != null; i++) { stName = new StringBuffer(name.length() + 2). append(name).append('_').append(i).toString();
/** Find the service type implemented as a given class. * The whole registry is searched for a service type of that exact class (subclasses do not count). * <P> * This could be used during (de-)serialization * of a service type: only store its class name * and then try to find the type implemented by that class later. * * @param clazz the class of the service type looked for * @return the desired type or <code>null</code> if it does not exist * @deprecated Just use lookup. */ public ServiceType find (Class clazz) { Enumeration en = services (); while (en.hasMoreElements ()) { Object o = en.nextElement (); if (o.getClass () == clazz) { return (ServiceType)o; } } return null; }
/** Find the service type implemented as a given class. * The whole registry is searched for a service type of that exact class (subclasses do not count). * <P> * This could be used during (de-)serialization * of a service type: only store its class name * and then try to find the type implemented by that class later. * * @param clazz the class of the service type looked for * @return the desired type or <code>null</code> if it does not exist * @deprecated Just use lookup. */ public ServiceType find (Class clazz) { Enumeration en = services (); while (en.hasMoreElements ()) { Object o = en.nextElement (); if (o.getClass () == clazz) { return (ServiceType)o; } } return null; }
/** Find the service type implemented as a given class. * The whole registry is searched for a service type of that exact class (subclasses do not count). * <P> * This could be used during (de-)serialization * of a service type: only store its class name * and then try to find the type implemented by that class later. * * @param clazz the class of the service type looked for * @return the desired type or <code>null</code> if it does not exist * @deprecated Just use lookup. */ @Deprecated public ServiceType find(Class clazz) { Enumeration en = services(); while (en.hasMoreElements()) { Object o = en.nextElement(); if (o.getClass() == clazz) { return (ServiceType) o; } } return null; }
/** Find the service type implemented as a given class. * The whole registry is searched for a service type of that exact class (subclasses do not count). * <P> * This could be used during (de-)serialization * of a service type: only store its class name * and then try to find the type implemented by that class later. * * @param clazz the class of the service type looked for * @return the desired type or <code>null</code> if it does not exist * @deprecated Just use lookup. */ @Deprecated public ServiceType find(Class clazz) { Enumeration en = services(); while (en.hasMoreElements()) { Object o = en.nextElement(); if (o.getClass() == clazz) { return (ServiceType) o; } } return null; }
/** Find a service type of a supplied name in the registry. * <P> * This could be used during (de-)serialization * of a service type: only store its name * and then try to find the type later. * * @param name (display) name of service type to find * @return the desired type or <code>null</code> if it does not exist */ public ServiceType find (String name) { Enumeration en = services (); while (en.hasMoreElements ()) { ServiceType o = (ServiceType)en.nextElement (); if (name.equals (o.getName ())) { return o; } } return null; } }
/** Find a service type of a supplied name in the registry. * <P> * This could be used during (de-)serialization * of a service type: only store its name * and then try to find the type later. * * @param name (display) name of service type to find * @return the desired type or <code>null</code> if it does not exist */ public ServiceType find (String name) { Enumeration en = services (); while (en.hasMoreElements ()) { ServiceType o = (ServiceType)en.nextElement (); if (name.equals (o.getName ())) { return o; } } return null; } }
/** Find a service type of a supplied name in the registry. * <P> * This could be used during (de-)serialization * of a service type: only store its name * and then try to find the type later. * * @param name (display) name of service type to find * @return the desired type or <code>null</code> if it does not exist */ public ServiceType find(String name) { Enumeration en = services(); while (en.hasMoreElements()) { ServiceType o = (ServiceType) en.nextElement(); if (name.equals(o.getName())) { return o; } } return null; } }
/** Find a service type of a supplied name in the registry. * <P> * This could be used during (de-)serialization * of a service type: only store its name * and then try to find the type later. * * @param name (display) name of service type to find * @return the desired type or <code>null</code> if it does not exist */ public ServiceType find(String name) { Enumeration en = services(); while (en.hasMoreElements()) { ServiceType o = (ServiceType) en.nextElement(); if (name.equals(o.getName())) { return o; } } return null; } }
/** Override to specially look up no-op services. */ public ServiceType find (String name) { Map<String, ServiceType> lookupMap = name2Service; ServiceType ret; synchronized (lookupMap) { ret = lookupMap.get(name); } if (ret == null) { ret = super.find(name); synchronized (lookupMap) { lookupMap.put(name, ret); } } return ret; }
/** Get all available services that are assignable to the given superclass. * @param clazz the class that all services should be subclass of * @return an enumeration of all matching {@link ServiceType}s */ public <T extends ServiceType> Enumeration<T> services(final Class<T> clazz) { class IsInstance implements Enumerations.Processor<ServiceType,T> { public T process(ServiceType obj, Collection ignore) { return clazz.isInstance(obj) ? clazz.cast(obj) : null; } } return Enumerations.filter(services(), new IsInstance()); }
/** * Find the script type with requested name. * @param name (display) name of script type to find * @return the desired script type or <code>null</code> if it does not exist */ public static ScriptType find (String name) { ServiceType t = ((ServiceType.Registry)Lookup.getDefault().lookup(ServiceType.Registry.class)).find (name); if (t instanceof ScriptType) { return (ScriptType)t; } else { return null; } }
/** Get all available services that are assignable to the given superclass. * @param clazz the class that all services should be subclass of * @return an enumeration of all matching {@link ServiceType}s */ public Enumeration services (final Class clazz) { class IsInstance implements org.openide.util.Enumerations.Processor { public Object process (Object obj, java.util.Collection ignore) { return clazz.isInstance (obj) ? obj : null; } } return org.openide.util.Enumerations.filter (services (), new IsInstance ()); }
/** Get all available services that are assignable to the given superclass. * @param clazz the class that all services should be subclass of * @return an enumeration of all matching {@link ServiceType}s */ public Enumeration services (final Class clazz) { class IsInstance implements org.openide.util.Enumerations.Processor { public Object process (Object obj, java.util.Collection ignore) { return clazz.isInstance (obj) ? obj : null; } } return org.openide.util.Enumerations.filter (services (), new IsInstance ()); }
/** Get all available services that are assignable to the given superclass. * @param clazz the class that all services should be subclass of * @return an enumeration of all matching {@link ServiceType}s */ public <T extends ServiceType> Enumeration<T> services(final Class<T> clazz) { class IsInstance implements Enumerations.Processor<ServiceType,T> { public T process(ServiceType obj, Collection ignore) { return clazz.isInstance(obj) ? clazz.cast(obj) : null; } } return Enumerations.filter(services(), new IsInstance()); }