Skip navigation links
org.netbeans.api.intent 1.17

Intent API
Official

See: Description

Intent API 
Package Description
org.netbeans.api.intent
API for working with Intents, abstract descriptions of intended operations.
org.netbeans.spi.intent
SPI for Intent handlers.

Intent is an description of some intended operation. It is specified by action type (String) and a URI. When some Intent is executed, proper handler is chosen and it performs the actual operation.

Intents provide loose coupling between modules that may request an operation and modules that can perform it. They can be easily serialized, so they are suitable for distributed heterogenous systems.

IntentAPI

API for describing and executing intended operations.

IntentHandlerSPI

SPI for handlers that are able to invoke proper operation for specified intents.

What is New (see all changes)?

Use Cases

Create an Intent, execute it and wait for result
                    Future<Object> result = new Intent(Intent.ACTION_VIEW, new URI("scheme://path/")).execute();
    Object value = result.get();
            
            
Create an Intent and execute it with callback
                    new Intent(Intent.ACTION_VIEW, new URI("scheme://path/")).execute(new Callback() {
      void success(Object result) {
        // use the result somehow
      }
      void failure(Exception exception) {
        // report the failure somehow
      }
    });
            
            
Handle some Intent
                    @IntentHandlerRegistration(
                displayName = "Show my item in MyEditor",
                position = 800,
                uriPattern = "myscheme://.*",
                actions = {Intent.ACTION_VIEW, Intent.ACTION_EDIT}
    )
    public static Object handleIntent(Intent intent) {
        SomeType result = parseAndPerformIntentSomehow(intent);
        return result;
    }
            
            
Handle some Intent using Result object
                    @IntentHandlerRegistration(
                displayName = "Show my item in MyEditor",
                position = 800,
                uriPattern = "myscheme://.*",
                actions = "*"
    )
    public static void handleIntent(final Intent intent, final Result result) {
        // Move the execution to another thread. Do not wait for the result
        // here, just pass the result object.
        EventQueue.invokeLater(new Runnable() {
            public void run() {
                try {
                    Object result = doSomethingInEDT(intent);
                    result.setResult(e);
                } catch (Exception e) {
                    result.setException(e);
                }
            }
        });
    }
            
            

Exported Interfaces

This table lists all of the module exported APIs with defined stability classifications. It is generated based on answers to questions about the architecture of the module. Read them all...
Group of java interfaces
Interface NameIn/OutStabilitySpecified in What Document?
IntentAPIExportedOfficial .../netbeans/api/intent/package-summary.html

API for describing and executing intended operations.

IntentHandlerSPIExportedOfficial .../netbeans/spi/intent/package-summary.html

SPI for handlers that are able to invoke proper operation for specified intents.

Implementation Details

Where are the sources for the module?

The sources for the module are in the Apache Git repositories or in the GitHub repositories.

What do other modules need to do to declare a dependency on this one, in addition to or instead of a plain module dependency?

Standard module dependency is sufficient.

Read more about the implementation in the answers to architecture questions.

Skip navigation links
org.netbeans.api.intent 1.17