本文整理汇总了Java中org.ofbiz.service.ServiceContainer类的典型用法代码示例。如果您正苦于以下问题:Java ServiceContainer类的具体用法?Java ServiceContainer怎么用?Java ServiceContainer使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ServiceContainer类属于org.ofbiz.service包,在下文中一共展示了ServiceContainer类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: makeWebappDispatcher
import org.ofbiz.service.ServiceContainer; //导入依赖的package包/类
/** This method only sets up a dispatcher for the current webapp and passed in delegator, it does not save it to the ServletContext or anywhere else, just returns it */
public static LocalDispatcher makeWebappDispatcher(ServletContext servletContext, Delegator delegator) {
if (delegator == null) {
Debug.logError("[ContextFilter.init] ERROR: delegator not defined.", module);
return null;
}
// get the unique name of this dispatcher
String dispatcherName = servletContext.getInitParameter("localDispatcherName");
if (dispatcherName == null) {
Debug.logError("No localDispatcherName specified in the web.xml file", module);
dispatcherName = delegator.getDelegatorName();
}
LocalDispatcher dispatcher = ServiceContainer.getLocalDispatcher(dispatcherName, delegator);
if (dispatcher == null) {
Debug.logError("[ContextFilter.init] ERROR: dispatcher could not be initialized.", module);
}
return dispatcher;
}
示例2: hasEntityPermission
import org.ofbiz.service.ServiceContainer; //导入依赖的package包/类
@Override
public Map<String, String> hasEntityPermission(String userLoginId, List<String> entities, List<String> actions) throws TException {
LocalDispatcher dispatcher = ServiceContainer.getLocalDispatcher(this.delegator.getDelegatorName(), delegator);
Security security = dispatcher.getSecurity();
GenericValue userLogin;
try {
userLogin = delegator.findOne("UserLogin", true, "userLoginId", userLoginId);
} catch (GenericEntityException e) {
e.printStackTrace();
throw new TException(e.getMessage());
}
Map<String, String> result = new HashMap();
for(int i=0, size=entities.size(); i<size; i++){
String entity = entities.get(i);
String action = actions.get(i);
result.put(entity+action, security.hasEntityPermission(entity, action, userLogin)?"true":"false");
}
return result;
}
示例3: callOfbizService
import org.ofbiz.service.ServiceContainer; //导入依赖的package包/类
@Override
public Map<String, String> callOfbizService(String userLoginId,
String serviceName, Map<String, String> context) throws TException {
GenericValue userLogin;
try {
userLogin = delegator.findOne("UserLogin", true, "userLoginId", userLoginId);
LocalDispatcher dispatcher = ServiceContainer.getLocalDispatcher(this.delegator.getDelegatorName(), delegator);
String tzId = (String)userLogin.getString("lastTimeZone");
TimeZone timeZone = UtilDateTime.toTimeZone(tzId);
Map<String,Object> serviceContext = ServiceUtil.setServiceFields(dispatcher, serviceName, (Map)context, userLogin, timeZone, Locale.getDefault());
serviceContext.put("userLogin", userLogin);
Map result = dispatcher.runSync(serviceName, serviceContext);
return result;
} catch (Exception e) {
e.printStackTrace();
throw new TException(e.getMessage());
}
}
示例4: getDispatcher
import org.ofbiz.service.ServiceContainer; //导入依赖的package包/类
public LocalDispatcher getDispatcher() {
LocalDispatcher dispatcher = this.dispatcher;
if (dispatcher == null) {
dispatcher = ServiceContainer.getLocalDispatcher(dispatcherName, this.getDelegator());
this.dispatcher = dispatcher;
}
return dispatcher;
}
示例5: ModelTestSuite
import org.ofbiz.service.ServiceContainer; //导入依赖的package包/类
public ModelTestSuite(Element mainElement, String testCase) {
this.suiteName = mainElement.getAttribute("suite-name");
this.originalDelegatorName = mainElement.getAttribute("delegator-name");
if (UtilValidate.isEmpty(this.originalDelegatorName)) this.originalDelegatorName = "test";
this.originalDispatcherName = mainElement.getAttribute("dispatcher-name");
if (UtilValidate.isEmpty(this.originalDispatcherName)) this.originalDispatcherName = "test-dispatcher";
String uniqueSuffix = "-" + RandomStringUtils.randomAlphanumeric(10);
this.delegator = DelegatorFactory.getDelegator(this.originalDelegatorName).makeTestDelegator(this.originalDelegatorName + uniqueSuffix);
this.dispatcher = ServiceContainer.getLocalDispatcher(originalDispatcherName + uniqueSuffix, delegator);
for (Element testCaseElement : UtilXml.childElementList(mainElement, UtilMisc.toSet("test-case", "test-group"))) {
String caseName = testCaseElement.getAttribute("case-name");
String nodeName = testCaseElement.getNodeName();
if (testCase == null || caseName.equals(testCase)) {
if (nodeName.equals("test-case")) {
parseTestElement(caseName, UtilXml.firstChildElement(testCaseElement));
} else if (nodeName.equals("test-group")) {
int i = 0;
for (Element childElement: UtilXml.childElementList(testCaseElement)) {
parseTestElement(caseName + '-' + i, childElement);
i++;
}
}
}
}
}
示例6: init
import org.ofbiz.service.ServiceContainer; //导入依赖的package包/类
@Override
public void init(ServletConfig config) throws ServletException{
try {
super.init(config);
ServletContext context = this.getServletContext();
String delegatorName = context.getInitParameter("entityDelegatorName");
this.delegator = DelegatorFactory.getDelegator(delegatorName);
String dispatcherName = context.getInitParameter("localDispatcherName");
this.dispatcher = ServiceContainer.getLocalDispatcher(dispatcherName, this.delegator);
this.security = SecurityFactory.getInstance(this.delegator);
String factoryClassName = context.getInitParameter("requestHandlerFactoryClass");
this.handlerFactory = (RequestHandlerFactory) Class.forName(factoryClassName).newInstance();
} catch (Exception e) {
Debug.logError(e, "Error while initializing WebDAV servlet: ", module);
throw new ServletException(e);
}
if (Debug.verboseOn()) {
StringBuilder buff = new StringBuilder("WebDAV servlet initialized: delegator = ");
buff.append(this.delegator.getDelegatorName());
buff.append(", dispatcher = ");
buff.append(this.dispatcher.getName());
buff.append(", security = ");
buff.append(this.security.getClass().getName());
buff.append(", handler factory = ");
buff.append(this.handlerFactory.getClass().getName());
Debug.logVerbose(buff.toString(), module);
}
}
示例7: init
import org.ofbiz.service.ServiceContainer; //导入依赖的package包/类
public void init(ServletContext context) throws EventHandlerException {
String delegatorName = context.getInitParameter("entityDelegatorName");
this.delegator = DelegatorFactory.getDelegator(delegatorName);
this.dispatcher = ServiceContainer.getLocalDispatcher(delegator.getDelegatorName(), delegator);
this.setHandlerMapping(new ServiceRpcHandler());
String extensionsEnabledString = context.getInitParameter("xmlrpc.enabledForExtensions");
if (UtilValidate.isNotEmpty(extensionsEnabledString)) {
enabledForExtensions = Boolean.valueOf(extensionsEnabledString);
}
String exceptionsEnabledString = context.getInitParameter("xmlrpc.enabledForExceptions");
if (UtilValidate.isNotEmpty(exceptionsEnabledString)) {
enabledForExceptions = Boolean.valueOf(exceptionsEnabledString);
}
}
示例8: start
import org.ofbiz.service.ServiceContainer; //导入依赖的package包/类
/**
* Start the container
*
* @return true if server started
* @throws org.ofbiz.base.container.ContainerException
*
*/
@Override
public boolean start() throws ContainerException {
ContainerConfig.Container cfg = ContainerConfig.getContainer(name, configFile);
String dispatcherName = ContainerConfig.getPropertyValue(cfg, "dispatcher-name", "JavaMailDispatcher");
String delegatorName = ContainerConfig.getPropertyValue(cfg, "delegator-name", "default");
this.deleteMail = "true".equals(ContainerConfig.getPropertyValue(cfg, "delete-mail", "false"));
this.delegator = DelegatorFactory.getDelegator(delegatorName);
this.dispatcher = ServiceContainer.getLocalDispatcher(dispatcherName, delegator);
this.timerDelay = ContainerConfig.getPropertyValue(cfg, "poll-delay", 300000);
this.maxSize = ContainerConfig.getPropertyValue(cfg, "maxSize", 1000000); // maximum size in bytes
// load the userLogin object
String runAsUser = ContainerConfig.getPropertyValue(cfg, "run-as-user", "system");
try {
this.userLogin = EntityQuery.use(delegator).from("UserLogin").where("userLoginId", runAsUser).queryOne();
} catch (GenericEntityException e) {
Debug.logError(e, "Unable to load run-as-user UserLogin; cannot start container", module);
return false;
}
// load the MCA configuration
ServiceMcaUtil.readConfig();
// load the listeners
List<ContainerConfig.Container.Property> configs = cfg.getPropertiesWithValue("store-listener");
for (ContainerConfig.Container.Property prop: configs) {
Session session = this.makeSession(prop);
Store store = this.getStore(session);
if (store != null) {
stores.put(store, session);
store.addStoreListener(new LoggingStoreListener());
}
}
// start the polling timer
if (UtilValidate.isNotEmpty(stores)) {
pollTimer.scheduleAtFixedRate(new PollerTask(dispatcher, userLogin), timerDelay, timerDelay, TimeUnit.MILLISECONDS);
} else {
Debug.logWarning("No JavaMail Store(s) configured; poller disabled.", module);
}
return true;
}
示例9: init
import org.ofbiz.service.ServiceContainer; //导入依赖的package包/类
@Override
public void init(ServletConfig config) throws ServletException{
try {
super.init(config);
ClassLoader loader = new CachedClassLoader(Thread.currentThread().getContextClassLoader(), null);
Thread.currentThread().setContextClassLoader(loader);
ServletContext context = this.getServletContext();
String delegatorName = context.getInitParameter("entityDelegatorName");
this.delegator = DelegatorFactory.getDelegator(delegatorName);
String dispatcherName = context.getInitParameter("localDispatcherName");
this.dispatcher = ServiceContainer.getLocalDispatcher(dispatcherName, this.delegator);
this.security = SecurityFactory.getInstance(this.delegator);
String factoryClassName = context.getInitParameter("requestHandlerFactoryClass");
this.handlerFactory = (RequestHandlerFactory) loader.loadClass(factoryClassName).newInstance();
} catch (Exception e) {
Debug.logError(e, "Error while initializing WebDAV servlet: ", module);
throw new ServletException(e);
}
if (Debug.verboseOn()) {
StringBuilder buff = new StringBuilder("WebDAV servlet initialized: delegator = ");
buff.append(this.delegator.getDelegatorName());
buff.append(", dispatcher = ");
buff.append(this.dispatcher.getName());
buff.append(", security = ");
buff.append(this.security.getClass().getName());
buff.append(", handler factory = ");
buff.append(this.handlerFactory.getClass().getName());
Debug.logVerbose(buff.toString(), module);
}
}
示例10: start
import org.ofbiz.service.ServiceContainer; //导入依赖的package包/类
/**
* Start the container
*
* @return true if server started
* @throws org.ofbiz.base.container.ContainerException
*
*/
public boolean start() throws ContainerException {
ContainerConfig.Container cfg = ContainerConfig.getContainer(name, configFile);
String dispatcherName = ContainerConfig.getPropertyValue(cfg, "dispatcher-name", "JavaMailDispatcher");
String delegatorName = ContainerConfig.getPropertyValue(cfg, "delegator-name", "default");
this.deleteMail = "true".equals(ContainerConfig.getPropertyValue(cfg, "delete-mail", "false"));
this.delegator = DelegatorFactory.getDelegator(delegatorName);
this.dispatcher = ServiceContainer.getLocalDispatcher(dispatcherName, delegator);
this.timerDelay = ContainerConfig.getPropertyValue(cfg, "poll-delay", 300000);
this.maxSize = ContainerConfig.getPropertyValue(cfg, "maxSize", 1000000); // maximum size in bytes
// load the userLogin object
String runAsUser = ContainerConfig.getPropertyValue(cfg, "run-as-user", "system");
try {
this.userLogin = delegator.findOne("UserLogin", false, "userLoginId", runAsUser);
} catch (GenericEntityException e) {
Debug.logError(e, "Unable to load run-as-user UserLogin; cannot start container", module);
return false;
}
// load the MCA configuration
ServiceMcaUtil.readConfig();
// load the listeners
List<ContainerConfig.Container.Property> configs = cfg.getPropertiesWithValue("store-listener");
for (ContainerConfig.Container.Property prop: configs) {
Session session = this.makeSession(prop);
Store store = this.getStore(session);
if (store != null) {
stores.put(store, session);
store.addStoreListener(new LoggingStoreListener());
}
}
// start the polling timer
if (UtilValidate.isNotEmpty(stores)) {
pollTimer.scheduleAtFixedRate(new PollerTask(dispatcher, userLogin), timerDelay, timerDelay, TimeUnit.MILLISECONDS);
} else {
Debug.logWarning("No JavaMail Store(s) configured; poller disabled.", module);
}
return true;
}
示例11: getMessageMap
import org.ofbiz.service.ServiceContainer; //导入依赖的package包/类
@Override
public Map<String, String> getMessageMap(String userLoginId, List<String> resourceNames) throws TException {
LocalDispatcher dispatcher = ServiceContainer.getLocalDispatcher(this.delegator.getDelegatorName(), delegator);
GenericValue userLogin;
try {
userLogin = delegator.findOne("UserLogin", true, "userLoginId", userLoginId);
} catch (GenericEntityException e) {
e.printStackTrace();
throw new TException(e.getMessage());
}
Locale locale = null;
String localeString = userLogin.getString("lastLocale");
if (UtilValidate.isNotEmpty(localeString)) {
locale = UtilMisc.parseLocale(localeString);
} else {
locale = Locale.getDefault();
}
Map<String, String> result = new HashMap();
for(String name : resourceNames){
String[] resourceName = name.split("#");
if (resourceName.length==1){
result.put(name, UtilProperties.getMessage("CommonUiLabels", resourceName[0], locale));
} else {
result.put(name, UtilProperties.getMessage(resourceName[0], resourceName[1], locale));
}
}
return result;
}
示例12: getDispatcher
import org.ofbiz.service.ServiceContainer; //导入依赖的package包/类
public LocalDispatcher getDispatcher() {
if (dispatcher == null) {
dispatcher = ServiceContainer.getLocalDispatcher(dispatcherName, this.getDelegator());
}
return dispatcher;
}
示例13: getDispatcher
import org.ofbiz.service.ServiceContainer; //导入依赖的package包/类
public LocalDispatcher getDispatcher() {
if (_dispatcher == null) {
_dispatcher = ServiceContainer.getLocalDispatcher(dispatcherName, this.getDelegator());
}
return _dispatcher;
}
示例14: init
import org.ofbiz.service.ServiceContainer; //导入依赖的package包/类
public void init(ServletContext context) throws EventHandlerException {
String delegatorName = context.getInitParameter("entityDelegatorName");
this.delegator = DelegatorFactory.getDelegator(delegatorName);
this.dispatcher = ServiceContainer.getLocalDispatcher(this.delegator.getDelegatorName(), delegator);
}
示例15: getDispatcher
import org.ofbiz.service.ServiceContainer; //导入依赖的package包/类
/** Returns the LocalDispatcher. */
public LocalDispatcher getDispatcher() {
LocalDispatcher thisDispatcher = ServiceContainer.getLocalDispatcher(delegator.getDelegatorName(), delegator);
return thisDispatcher;
}