Java tutorial
/** * Copyright 2007-2010 ? * All rights reserved. * * This library is free software; you can redistribute it and/or modify it under the * terms of the GNU Lesser General Public License v3 as published by the Free Software * Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License along * with this library; if not, see http://www.gnu.org/licenses/lgpl.html. * */ package org.fireflow.server; import java.util.List; import javax.xml.ws.Endpoint; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.fireflow.engine.context.RuntimeContext; import org.fireflow.engine.exception.WebservicePublishException; import org.fireflow.engine.modules.environment.Environment; import org.fireflow.engine.modules.processlanguage.ProcessLanguageManager; /** * * @author ? nychen2000@163.com * Fire Workflow www.firesoa.com www.fireflow.org * */ public class WorkflowServer { private static final Log log = LogFactory.getLog(WorkflowServer.class); /** * ??WorkflowEngineServiceWebservice??<br> * * WebService?org.fireflow.engine.modules.environment.Environment.getWebserviceContextPath() * */ private boolean engineServiceEnabled = false; private RuntimeContext runtimeContext = null; /** * @param ctx */ public void setRuntimeContext(RuntimeContext ctx) { runtimeContext = ctx; } /** * @return */ public RuntimeContext getRuntimeContext() { return runtimeContext; } public boolean isEngineServiceEnabled() { return engineServiceEnabled; } public void setEngineServiceEnabled(boolean b) { this.engineServiceEnabled = b; } /** * ?ServerWorkflow Engine?webservice? * ?call-back-service??webservice */ public void start() { try { //1??WorkflowEngineService if (engineServiceEnabled) { publishWorkflowEngineService(); } //2???ProcessService List<ProcessLanguageManager> processLanguageManagers = runtimeContext.getProcessLanguages(); for (ProcessLanguageManager manager : processLanguageManagers) { manager.publishAllProcessServices(); } } catch (WebservicePublishException e) { log.error(e.getMessage(), e); } } public void stop() { } public void publishWorkflowEngineService() throws WebservicePublishException { Environment evn = runtimeContext.getDefaultEngineModule(Environment.class); String contextPath = evn.getWebserviceContextPath(); if (!contextPath.startsWith("/")) { contextPath = "/" + contextPath; } String address = "http://" + evn.getWebserviceIP() + ":" + Integer.toString(evn.getWebservicePort()) + contextPath; WorkflowEngineService implementor = runtimeContext.getDefaultEngineModule(WorkflowEngineService.class); Endpoint.publish(address, implementor); } }