Documentation for JIRA 4.3. Documentation for other versions of JIRA is available too.

    /**
     * get all the components for this project
     */
    public Collection getAllComponents() {
Long currentProjectId = (Long) ActionContext.getSession().get(SessionKeys.SELECTED_PROJECT);
GenericValue currentProject = (GenericValue) projectManager.getProject(currentProjectId);
        Collection components = new ArrayList(projectManager.getComponents(currentProject));
        return components;
    }