* Make the service locator API more flexible.
This commit is contained in:
parent
57c2bde1ad
commit
0f76a4264b
|
|
@ -18,9 +18,6 @@ package org.adempiere.base;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.compiere.model.Callout;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A service locator looks up services.
|
* A service locator looks up services.
|
||||||
* This is the central authority for adempiere service definition,
|
* This is the central authority for adempiere service definition,
|
||||||
|
|
@ -33,7 +30,11 @@ import org.compiere.model.Callout;
|
||||||
*/
|
*/
|
||||||
public interface IServiceLocator {
|
public interface IServiceLocator {
|
||||||
<T extends IService> T locate(Class<T> type);
|
<T extends IService> T locate(Class<T> type);
|
||||||
|
<T extends IService> T locate(Class<T> type, String id);
|
||||||
<T extends IService> T locate(Class<T> type, ServiceQuery query);
|
<T extends IService> T locate(Class<T> type, ServiceQuery query);
|
||||||
|
<T extends IService> T locate(Class<T> type, String id, ServiceQuery query);
|
||||||
<T extends IService> List<T> list(Class<T> type);
|
<T extends IService> List<T> list(Class<T> type);
|
||||||
|
<T extends IService> List<T> list(Class<T> type, String id);
|
||||||
<T extends IService> List<T> list(Class<T> type, ServiceQuery query);
|
<T extends IService> List<T> list(Class<T> type, ServiceQuery query);
|
||||||
|
<T extends IService> List<T> list(Class<T> type, String id, ServiceQuery query);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -58,18 +58,34 @@ public class Service {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static <T extends IService> T locate(Class<T> type) {
|
public static <T extends IService> T locate(Class<T> type) {
|
||||||
return locator().locate(type);
|
return locate(type, type.getName());
|
||||||
|
}
|
||||||
|
|
||||||
|
public static <T extends IService> T locate(Class<T> type, String id) {
|
||||||
|
return locator().locate(type, id);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static <T extends IService> T locate(Class<T> type, ServiceQuery query) {
|
public static <T extends IService> T locate(Class<T> type, ServiceQuery query) {
|
||||||
return locator().locate(type, query);
|
return locate(type, type.getName(), query);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static <T extends IService> T locate(Class<T> type, String id, ServiceQuery query) {
|
||||||
|
return locator().locate(type, id, query);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static <T extends IService> List<T> list(Class<T> type) {
|
public static <T extends IService> List<T> list(Class<T> type) {
|
||||||
return locator().list(type);
|
return list(type, type.getName());
|
||||||
|
}
|
||||||
|
|
||||||
|
public static <T extends IService> List<T> list(Class<T> type, String id) {
|
||||||
|
return locator().list(type, id);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static <T extends IService> List<T> list(Class<T> type, ServiceQuery query) {
|
public static <T extends IService> List<T> list(Class<T> type, ServiceQuery query) {
|
||||||
return locator().list(type, query);
|
return locator().list(type, type.getName(), query);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static <T extends IService> List<T> list(Class<T> type, String id, ServiceQuery query) {
|
||||||
|
return locator().list(type, id, query);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -34,23 +34,43 @@ import org.adempiere.base.ServiceQuery;
|
||||||
public class EquinoxServiceLocator implements IServiceLocator {
|
public class EquinoxServiceLocator implements IServiceLocator {
|
||||||
|
|
||||||
public <T extends IService> List<T> list(Class<T> type) {
|
public <T extends IService> List<T> list(Class<T> type) {
|
||||||
ExtensionList<T> list = new ExtensionList<T>(type, type.getName());
|
return list(type, type.getName());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public <T extends IService> List<T> list(Class<T> type, String id) {
|
||||||
|
ExtensionList<T> list = new ExtensionList<T>(type, id);
|
||||||
return list.asList();
|
return list.asList();
|
||||||
}
|
}
|
||||||
|
|
||||||
public <T extends IService> List<T> list(Class<T> type, ServiceQuery query) {
|
public <T extends IService> List<T> list(Class<T> type, ServiceQuery query) {
|
||||||
ExtensionList<T> list = new ExtensionList<T>(type, type.getName(), query);
|
return list(type, type.getName(), query);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public <T extends IService> List<T> list(Class<T> type, String id,
|
||||||
|
ServiceQuery query) {
|
||||||
|
ExtensionList<T> list = new ExtensionList<T>(type, id, query);
|
||||||
return list.asList();
|
return list.asList();
|
||||||
}
|
}
|
||||||
|
|
||||||
public <T extends IService> T locate(Class<T> type) {
|
public <T extends IService> T locate(Class<T> type) {
|
||||||
ExtensionList<T> list = new ExtensionList<T>(type, type.getName());
|
return locate(type, type.getName());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public <T extends IService> T locate(Class<T> type, String id) {
|
||||||
|
ExtensionList<T> list = new ExtensionList<T>(type, id);
|
||||||
return list.first();
|
return list.first();
|
||||||
}
|
}
|
||||||
|
|
||||||
public <T extends IService> T locate(Class<T> type, ServiceQuery query) {
|
public <T extends IService> T locate(Class<T> type, ServiceQuery query) {
|
||||||
|
return locate(type, type.getName(), query);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public <T extends IService> T locate(Class<T> type, String id, ServiceQuery query) {
|
||||||
ExtensionList<T> list = new ExtensionList<T>(type, type.getName(), query);
|
ExtensionList<T> list = new ExtensionList<T>(type, type.getName(), query);
|
||||||
return list.first();
|
return list.first();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -22,7 +22,6 @@ import java.util.Iterator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.adempiere.base.ServiceQuery;
|
import org.adempiere.base.ServiceQuery;
|
||||||
import org.compiere.model.Callout;
|
|
||||||
import org.eclipse.core.runtime.CoreException;
|
import org.eclipse.core.runtime.CoreException;
|
||||||
import org.eclipse.core.runtime.IConfigurationElement;
|
import org.eclipse.core.runtime.IConfigurationElement;
|
||||||
import org.eclipse.core.runtime.Platform;
|
import org.eclipse.core.runtime.Platform;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue