Skip to main content
Jump to: navigation, search

Mylyn/Incubator/Generic Industrial Connector/Configuring Industrial Connector using Nothing

< Mylyn‎ | Incubator‎ | Generic Industrial Connector
Revision as of 14:06, 17 February 2009 by (Talk | contribs) (Step 4: Implement IPersistor)

This page describes how you can implement a Mylyn connector in 5 minutes using your computers memory as the persistance medium.

Step 1: Get the Source

Point your favorit SVN client towards


and get all the projects.

Step 2: Create a Fragment Project

Create a fragment project for your connector with the org.eclipse.mylyn.industrial.core project as the host.

Step 3: Create a connector.xml

This is going to be moved to the extension point mechanism in a very near future version. For now, create a connector.xml file in the root of your project with the following contents:

<?xml version="1.0" encoding="UTF-8"?>
<connector	xmlns="ptth://">
	<repository name="Memory">
		<persistor name="Memory">
			<property name="can-create-new-task" value="true" />
			<property name="can-create-task-from-key" value="true" />
			<property name="can-query-repository" value="true" />
			<property name="can-synchronize-tasks" value="true" />
 			<property name="can-get-attachments" value="true" />
 			<property name="can-post-attachments" value="true" />

There is already a reference project called org.eclipse.mylyn.industrial.demo.memory where you can also view the comments in this file.

Step 4: Implement IPersistor

Make an extension to org.eclipse.mylyn.industrial.core.persistor and open the class that you have typed in there. Make sure the name of this class appears in the config.xml described in step 3.

Now implement the following class:

 * Copyright (c) 2008 Industrial TSI and Maarten Meijer.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * Contributors:
 *    Industrial TSI - initial API and implementation

package org.eclipse.mylyn.industrial.demo.memory;    

import java.sql.SQLException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Calendar;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set; 

import org.eclipse.core.runtime.CoreException;
import org.eclipse.mylyn.industrial.core.dto.IndustrialAttachment;
import org.eclipse.mylyn.industrial.core.dto.IndustrialComment;
import org.eclipse.mylyn.industrial.core.dto.IndustrialQueryParams;
import org.eclipse.mylyn.industrial.core.dto.IndustrialTask;
import org.eclipse.mylyn.industrial.core.persistence.IPersistor;
import org.eclipse.mylyn.tasks.core.TaskRepository; 

 * On-The-Fly (Memory) implementation of the interface
 * org.eclipse.mylyn.industrial.core.persistence.IPersistor
 * @author Wim Jongman
 * @since 0.8.0

The first part just contains some fields we are going to use as our storage medium and the default constructor.

public class MemoryPersistor implements IPersistor {

	private HashMap<String, IndustrialTask> tasks = new HashMap<String, IndustrialTask>();

	private HashMap<String, ArrayList<IndustrialComment>> comments = new HashMap<String, ArrayList<IndustrialComment>>();

	private Map<String, byte[]> blobs = new HashMap<String, byte[]>();

	private Map<String, List<IndustrialAttachment>> attachements = new HashMap<String, List<IndustrialAttachment>>();

	public MemoryPersistor() {

Defines if this repository can be intitialized. This means that the class defined in the org.eclipse.mylyn.sql.core.database.dbinitializer may be called to do initialization work. Whatever that may be is up to the implementor of that class.

	public boolean canInitialize(TaskRepository repository) throws SQLException, CoreException {
		return false;

Fetches additional Mylyn attributes from the repository. Until the Mylyn attribute is supported by its own method, it can be supplied by this method. We need this to supply the task reporter name.

	public Map<String, String> fetchAdditional(TaskRepository repository, String... key) throws SQLException,
			CoreException {

		Map<String, String> result = new HashMap<String, String>();
		result.put("", System.getProperty(""));
		return result;

Return the blob content of the attachment with the given key. The passed id of the attachment is read from the task so this method should not return null.

	public byte[] fetchAttachmentBlob(TaskRepository repository, String attachmentId) throws SQLException,
			CoreException {
		return blobs.get(attachmentId);

Given a repository and a task key, return all attachments belonging to the task with the given key.

	public List<IndustrialAttachment> fetchAttachments(TaskRepository repository, String... taskId)
			throws SQLException, CoreException {

		List<IndustrialAttachment> as = attachements.get(taskId[0]);
		return (as != null) ? as : new ArrayList<IndustrialAttachment>();


Given a repository and one or more task keys, return all comments belonging to the task with the given keys.

	public List<IndustrialComment> fetchComments(TaskRepository repository, String... taskId) throws SQLException,
			CoreException {
		List<IndustrialComment> cs = comments.get(taskId[0]);
		return (cs != null) ? cs : new ArrayList<IndustrialComment>();

Fetches a task from the repository

	public IndustrialTask fetchTask(TaskRepository repository, String... taskId) throws SQLException, CoreException {
		return tasks.get(taskId[0]);

Search for all tasks obeying the given criteria and return their keys. This just returns all tasks, no effort was made to match each task against the criteria

	public List<String> findTasks(TaskRepository repository, IndustrialQueryParams criteria) throws SQLException,
			CoreException {
		Set<String> keys = tasks.keySet();
		if (keys != null)
			return new ArrayList<String>(keys);
		return new ArrayList<String>();

This list of allowed statusses is also used to populate a Status task attribute and to query the repository.

	public List<String> getLegalIssueStatus(TaskRepository repository) throws SQLException, CoreException {
		return Arrays.asList(new String[] { "OPEN", "CLOSED" });

This list of owners is also used to populate the Owner task attribute and to query the repository.

	public List<String> getLegalOwners(TaskRepository repository) throws SQLException, CoreException {
		return Arrays.asList(new String[] { System.getProperty(""), "Some othe people" });

This list of priorities is also used to populate a Priority task attribute and to query the repository.

	public List<String> getLegalPriorities(TaskRepository repository) throws SQLException, CoreException {
		return Arrays.asList(new String[] { "High", "Medium", "Low" });

This list of products is also used to populate the Product task attribute and to query the repository.

	public List<String> getLegalProducts(TaskRepository repository) throws SQLException, CoreException {
		return Arrays.asList(new String[] { "ECLIPSE", ".NET", "NETBEANS" });

Initialize this repository configuration.

	public void initialize(TaskRepository repository) throws SQLException, CoreException {

Persists an attachement

	public void persistAttachment(TaskRepository repository, IndustrialAttachment attachment) throws SQLException,
			CoreException {
		List<IndustrialAttachment> list = attachements.get(attachment.getTaskId());
		if (list == null) {
			list = new ArrayList<IndustrialAttachment>();

		attachment.setId("" + (list.size() + 1));
		attachements.put(attachment.getTaskId(), list);


Persists a comment

	public void persistComment(TaskRepository repository, IndustrialComment comment) throws SQLException, CoreException {

		ArrayList<IndustrialComment> list = comments.get(comment.getTaskId());
		if (list == null) {
			list = new ArrayList<IndustrialComment>();
		comments.put(comment.getTaskId(), list);


Persists a task

	public String persistTask(TaskRepository repository, IndustrialTask toPersisTask) throws SQLException,
			CoreException {
		String id = "MemomryTask" + (tasks.size() + 1);
		tasks.put(id, toPersisTask);
		return id;

Updates a task

	public void updateTask(TaskRepository repository, IndustrialTask task) throws SQLException, CoreException {
		tasks.put(task.getTaskId(), task);

Validates the repository

	public boolean validate(TaskRepository repository) throws SQLException, CoreException {
		return true;


Back to the top