If you want to define the Connection class as a finder object, you must create a finder object that implements the ObjectFinder interface. This exposes the object as a scripting object but does not add it to the inventory tree.

Procedure

  1. Create a Connection class as a finder object or modify the Connection.java file in the model directory.
    @Component 
    @Qualifier(value = "connection") 
    @Scope(value = "prototype") 
    public class Connection implements Findable { 
    ... 
        @Override 
        public Sid getInternalId() { 
            return getConnectionInfo().getId(); 
        } 
        @Override 
        public void setInternalId(Sid id) { 
            // do nothing, we set the Id in the constructor 
        } 
    ... 
    } 
    Note: If you want the platform to query objects by a filter, the Connection class must implement the Findable interface.
  2. Under the {plug-in-home}/o11nplugin-redis-core/src/main/java/com/vmware/o11n/plugin/redis folder, create a directory with name finder.
  3. Create the finder and save it as a ConnectionFinder.java file in the finder directory.
    package com.vmware.o11n.plugin.redis.finder; 
    import java.util.Collection; 
    import java.util.LinkedList; 
    import java.util.List; 
    import org.springframework.beans.factory.annotation.Autowired; 
    import com.vmware.o11n.plugin.redis.config.ConnectionRepository; 
    import com.vmware.o11n.plugin.redis.model.Connection; 
    import com.vmware.o11n.sdk.modeldriven.FoundObject; 
    import com.vmware.o11n.sdk.modeldriven.ObjectFinder; 
    import com.vmware.o11n.sdk.modeldriven.PluginContext; 
    import com.vmware.o11n.sdk.modeldriven.Sid; 
    public class ConnectionFinder implements ObjectFinder<Connection> { 
      
      
        @Autowired 
        private ConnectionRepository connectionRepository; 
        /* 
         * When a connection is found, we need to assign an ID. However, the 
         * Connection has its own ID, so we don't need to do anything here, aside 
         * from return the connection. 
         */ 
        @Override 
        public Sid assignId(Connection obj, Sid relatedObject) { 
            return obj.getInternalId(); 
        } 
        /* 
         * Finds the connection by ID 
         */ 
        @Override 
        public Connection find(PluginContext ctx, String type, Sid id) { 
            return connectionRepository.findLiveConnection(id); 
        } 
          
        @Override 
        public List<FoundObject<Connection>> query(PluginContext ctx, String type, String query) { 
            Collection<Connection> allConnections = connectionRepository.findAll(); 
            List<FoundObject<Connection>> result = new LinkedList<>(); 
            boolean returnAll = "".equals(query); 
            for (Connection connection : allConnections) { 
                if (returnAll || connection.getName().toLowerCase().startsWith(query.toLowerCase())) { 
                    FoundObject<Connection> foundObject = new FoundObject<>(connection); 
                    result.add(foundObject); 
                } 
            } 
            return result; 
        } 
    } 
    Note: You can inject ConnectionRepository directly to the finder.
    The find method is invoked every time the platform retrieves a Connection by its ID. When the plug-in returns a model object to the platform, it uses assignedId. The assignedId method sets an ID to the object that is returned to the platform. You can use this ID to restore the object later.
  4. Expose the finder object as a scripting object, by defining it in CustomMapping.
    wrap(Connection.class).andFind().using(ConnectionFinder.class).withIcon("connection.png"); 
  5. Build the plug-in.
  6. Install the modified version of the plug-in on the Automation Orchestrator server.
  7. Log in to the Automation Orchestrator Client.
  8. From the left navigational panel, select API Explorer.
  9. Expand the Redis entry, and browse through the API elements.
    The Connection object is exposed as a scripting object and is also defined as a type, or a findable object. You can set this type as an input, output, or a variable of a workflow.