/**
 * Copyright 2010-2014 Ralph Schaer <ralphschaer@gmail.com>
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *   http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package ch.rasc.extdirectspring.demo.grid;

import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
import java.util.stream.Collectors;

import org.springframework.stereotype.Service;

import ch.ralscha.extdirectspring.annotation.ExtDirectMethod;
import ch.ralscha.extdirectspring.annotation.ExtDirectMethodType;
import ch.ralscha.extdirectspring.bean.ExtDirectStoreReadRequest;
import ch.rasc.extdirectspring.demo.util.PropertyComparatorFactory;

@Service
public class TurnoverService {

	private final List<Company> companies;

	public TurnoverService() {
		List<Company> builder = new ArrayList<>();

		builder.add(new Company("ABC Accounting", 50000));
		builder.add(new Company("Ezy Video Rental", 106300));
		builder.add(new Company("Greens Fruit Grocery", 120000));
		builder.add(new Company("Icecream Express", 73000));
		builder.add(new Company("Ripped Gym", 88400));
		builder.add(new Company("Smith Auto Mechanic", 222980));

		companies = Collections.unmodifiableList(builder);
	}

	@ExtDirectMethod(value = ExtDirectMethodType.STORE_READ, group = "turnover")
	public List<Company> getTurnovers(ExtDirectStoreReadRequest request) {

		Comparator<Company> comparator = PropertyComparatorFactory
				.createComparatorFromSorters(request.getSorters());
		if (comparator != null) {
			return companies.stream().sorted(comparator).collect(Collectors.toList());
		}

		return companies;
	}

}

@@ -808,16 +808,64 @@
 ctors;%0A%0A
+import javax.servlet.http.HttpServletResponse;%0A%0A
 import o
@@ -1826,16 +1826,46 @@
 rnovers(
+HttpServletResponse response, 
 ExtDirec
@@ -1893,16 +1893,76 @@
 uest) %7B%0A
+%09%09response.setHeader(%22Access-Control-Allow-Origin%22, %22*%22);%0A%09%09
 %0A%09%09Compa

Add cors header. Need this for a fiddle demo