001: /******************************************************************************
002: * JBoss, a division of Red Hat *
003: * Copyright 2006, Red Hat Middleware, LLC, and individual *
004: * contributors as indicated by the @authors tag. See the *
005: * copyright.txt in the distribution for a full listing of *
006: * individual contributors. *
007: * *
008: * This is free software; you can redistribute it and/or modify it *
009: * under the terms of the GNU Lesser General Public License as *
010: * published by the Free Software Foundation; either version 2.1 of *
011: * the License, or (at your option) any later version. *
012: * *
013: * This software is distributed in the hope that it will be useful, *
014: * but WITHOUT ANY WARRANTY; without even the implied warranty of *
015: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
016: * Lesser General Public License for more details. *
017: * *
018: * You should have received a copy of the GNU Lesser General Public *
019: * License along with this software; if not, write to the Free *
020: * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
021: * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
022: ******************************************************************************/package org.jboss.portal.workflow.service;
023:
024: import org.apache.log4j.Logger;
025: import org.jboss.portal.jems.as.JNDI;
026: import org.jboss.portal.jems.as.system.AbstractJBossService;
027: import org.jbpm.JbpmConfiguration;
028:
029: /** @author sohil.shah@jboss.com */
030: public class WorkflowServiceImpl extends AbstractJBossService implements
031: WorkflowService {
032: /** . */
033: private static Logger log = Logger
034: .getLogger(WorkflowServiceImpl.class);
035:
036: /** . */
037: private JbpmConfiguration jbpmConfiguration = null;
038:
039: /** . */
040: private String jbpmConfigurationXml = null;
041:
042: /** . */
043: private JNDI.Binding jndiBinding;
044:
045: /** . */
046: private String jndiName = null;
047:
048: /**
049: *
050: */
051: public WorkflowServiceImpl() {
052:
053: }
054:
055: /**
056: *
057: */
058: public void startService() throws Exception {
059: super .startService();
060: try {
061: log
062: .debug("---------------------------------------------------");
063: log.debug("Workflow Service successfully started ......");
064: log
065: .debug("---------------------------------------------------");
066:
067: //initialize the jbpm configuration
068: this .jbpmConfiguration = JbpmConfiguration
069: .parseXmlString(this .jbpmConfigurationXml);
070: } catch (Exception e) {
071: this .stopService();
072: throw new RuntimeException(e);
073: }
074:
075: if (this .jndiName != null) {
076: jndiBinding = new JNDI.Binding(jndiName, this );
077: jndiBinding.bind();
078: }
079: }
080:
081: /**
082: *
083: */
084: public void stopService() throws Exception {
085: super .stopService();
086:
087: if (jndiBinding != null) {
088: jndiBinding.unbind();
089: jndiBinding = null;
090: }
091: }
092:
093: public String getJNDIName() {
094: return this .jndiName;
095: }
096:
097: public void setJNDIName(String jndiName) {
098: this .jndiName = jndiName;
099: }
100:
101: /** @return */
102: public String getJbpmConfigurationXml() {
103: return this .jbpmConfigurationXml;
104: }
105:
106: /** @param jbpmConfigurationXml */
107: public void setJbpmConfigurationXml(String jbpmConfigurationXml) {
108: this .jbpmConfigurationXml = jbpmConfigurationXml;
109: }
110:
111: //---------------------------------------------------------------------------------------------------------------
112: /** @return */
113: public JbpmConfiguration getJbpmConfiguration() {
114: return this.jbpmConfiguration;
115: }
116: }
|