org.openide.util.lookup 8.19.1

org.openide.util.lookup
Annotation Type NamedServiceDefinition


@Retention(value=RUNTIME)
@Target(value=ANNOTATION_TYPE)
public @interface NamedServiceDefinition

Annotation to simplify creation and add robustness to usage of various named service registration annotations. For example the @ URLStreamHandlerRegistration annotation uses the NamedServiceDefinition as:

 @NamedServiceDefinition(path="URLStreamHandler/@protocol()", serviceType=URLStreamHandler.class)
 
The above instructs the annotation processor that handles NamedServiceDefinitions to verify the annotated type is subclass of URLStreamHandler and if so, register it into URLStreamHandler/@protocol where the value of @protocol() is replaced by the value of annotation's protocol attribute. The registration can later be found by using Lookups.forPath("URLStreamHandler/ftp") (in case the protocol was ftp).

Since:
8.14
See Also:
ServiceProvider.path()

Required Element Summary
 String path
          Path to register the annotation to, so it can later be found by using Lookups.forPath(theSamePath).
 Class<?>[] serviceType
          Type, or array of types that the registered type has to implement.
 
Optional Element Summary
 String position
          Name of attribute that specifies position.
 

Element Detail

serviceType

public abstract Class<?>[] serviceType
Type, or array of types that the registered type has to implement. The annotated type needs to register at least one of the enumerated classes.


path

public abstract String path
Path to register the annotation to, so it can later be found by using Lookups.forPath(theSamePath). The path may reference attributes of the annotated annotation by prefixing them with @. To reuse attribute named location one can for example use "how/to/get/to/@location()s/please" These attributes must be of type String or array of Strings (then one registration is performed per each string in the array).

position

public abstract String position
Name of attribute that specifies position. By default the system tries to find int position() attribute in the defined annotation and use it to specify the order of registrations. In case a different attribute should be used to specify the position, one can be provide its name by specifying non-default here. Should the position be ignored, specify empty string.

Parameters:
name - of attribute in the annotated annotation to use for defining position of the registration. The attribute should return int value.
Default:
"-"

org.openide.util.lookup 8.19.1

Built on February 14 2013.  |  Portions Copyright 1997-2013 Oracle. All rights reserved.