📄 processconfimpl.java
字号:
/* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you 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 org.apache.ode.store;import java.io.File;import java.io.FileInputStream;import java.io.FileNotFoundException;import java.io.IOException;import java.io.InputStream;import java.net.URI;import java.util.ArrayList;import java.util.Collections;import java.util.Date;import java.util.HashMap;import java.util.HashSet;import java.util.List;import java.util.Map;import java.util.Set;import java.util.concurrent.locks.ReadWriteLock;import java.util.concurrent.locks.ReentrantReadWriteLock;import javax.wsdl.Definition;import javax.xml.namespace.QName;import org.apache.commons.logging.Log;import org.apache.commons.logging.LogFactory;import org.apache.ode.bpel.dd.TDeployment;import org.apache.ode.bpel.dd.TInvoke;import org.apache.ode.bpel.dd.TMexInterceptor;import org.apache.ode.bpel.dd.TProcessEvents;import org.apache.ode.bpel.dd.TProvide;import org.apache.ode.bpel.dd.TScopeEvents;import org.apache.ode.bpel.dd.TService;import org.apache.ode.bpel.evt.BpelEvent;import org.apache.ode.bpel.iapi.ContextException;import org.apache.ode.bpel.iapi.Endpoint;import org.apache.ode.bpel.iapi.ProcessConf;import org.apache.ode.bpel.iapi.ProcessState;import org.apache.ode.bpel.iapi.EndpointReferenceContext;import org.apache.ode.bpel.iapi.EndpointReference;import org.apache.ode.store.DeploymentUnitDir.CBPInfo;import org.apache.ode.utils.DOMUtils;import org.apache.ode.utils.HierarchicalProperties;import org.apache.ode.utils.fs.FileWatchDog;import org.apache.ode.utils.msg.MessageBundle;import org.w3c.dom.Element;import org.w3c.dom.Node;/** * Implementation of the {@link org.apache.ode.bpel.iapi.ProcessConf} interface. * Provides configuration information for a process. Note that this class should * be immutable, that is the engine expects it to return consistent results! * * @author mriou <mriou at apache dot org> */public class ProcessConfImpl implements ProcessConf { private static final Log __log = LogFactory.getLog(ProcessConfImpl.class); private static final Messages __msgs = MessageBundle.getMessages(Messages.class); private final Date _deployDate; private final Map<QName, Node> _props; private final HashMap<String, Endpoint> _partnerRoleInitialValues = new HashMap<String, Endpoint>(); private final HashMap<String, Endpoint> _myRoleEndpoints = new HashMap<String, Endpoint>(); private final Map<String, Set<BpelEvent.TYPE>> _events = new HashMap<String, Set<BpelEvent.TYPE>>(); private final ArrayList<String> _mexi = new ArrayList<String>(); ProcessState _state; final TDeployment.Process _pinfo; final DeploymentUnitDir _du; private long _version = 0; private QName _pid; private QName _type; // cache the inMemory flag because XMLBeans objects are heavily synchronized (guarded by a coarse-grained lock) private volatile boolean _inMemory = false; // provide the IL properties private HierarchicalProperties ilProperties; // monitor the IL property file and reload it if necessary private ILWatchDog ilWatchDog; private final ReadWriteLock ilPropertiesLock = new ReentrantReadWriteLock(); private EndpointReferenceContext eprContext; ProcessConfImpl(QName pid, QName type, long version, DeploymentUnitDir du, TDeployment.Process pinfo, Date deployDate, Map<QName, Node> props, ProcessState pstate, EndpointReferenceContext eprContext) { _pid = pid; _version = version; _du = du; _pinfo = pinfo; _deployDate = deployDate; _props = Collections.unmodifiableMap(props); _state = pstate; _type = type; _inMemory = _pinfo.isSetInMemory() && _pinfo.getInMemory(); this.eprContext = eprContext; ilWatchDog = new ILWatchDog(); initLinks(); initMexInterceptors(); initEventList(); } private void initMexInterceptors() { if (_pinfo.getMexInterceptors() != null) { for (TMexInterceptor mexInterceptor : _pinfo.getMexInterceptors().getMexInterceptorList()) { _mexi.add(mexInterceptor.getClassName()); } } } private void initLinks() { if (_pinfo.getInvokeList() != null) { for (TInvoke invoke : _pinfo.getInvokeList()) { String plinkName = invoke.getPartnerLink(); TService service = invoke.getService(); // NOTE: service can be null for partner links if (service == null) continue; __log.debug("Processing <invoke> element for process " + _pinfo.getName() + ": partnerlink " + plinkName + " --> " + service); _partnerRoleInitialValues.put(plinkName, new Endpoint(service.getName(), service.getPort())); } } if (_pinfo.getProvideList() != null) { for (TProvide provide : _pinfo.getProvideList()) { String plinkName = provide.getPartnerLink(); TService service = provide.getService(); if (service == null) { String errmsg = "Error in <provide> element for process " + _pinfo.getName() + "; partnerlink " + plinkName + "did not identify an endpoint"; __log.error(errmsg); throw new ContextException(errmsg); } __log.debug("Processing <provide> element for process " + _pinfo.getName() + ": partnerlink " + plinkName + " --> " + service.getName() + " : " + service.getPort()); _myRoleEndpoints.put(plinkName, new Endpoint(service.getName(), service.getPort())); } } } public Date getDeployDate() { return _deployDate; } public String getDeployer() { return ""; } public List<File> getFiles() { return _du.allFiles(); } public QName getProcessId() { return _pid; } public QName getType() { return _pinfo.getType() == null ? _type : _pinfo.getType(); } public String getPackage() { return _du.getName(); } public Map<QName, Node> getProcessProperties() { return _props; } public long getVersion() { return _version; } public InputStream getCBPInputStream() { CBPInfo cbpInfo = _du.getCBPInfo(getType()); if (cbpInfo == null) throw new ContextException("CBP record not found for type " + getType()); try { return new FileInputStream(cbpInfo.cbp); } catch (FileNotFoundException e) { throw new ContextException("File Not Found: " + cbpInfo.cbp, e); } } public String getBpelDocument() { CBPInfo cbpInfo = _du.getCBPInfo(getType()); if (cbpInfo == null) throw new ContextException("CBP record not found for type " + getType()); try { String relative = getRelativePath(_du.getDeployDir(), cbpInfo.cbp).replaceAll("\\\\", "/"); if (!relative.endsWith(".cbp")) throw new ContextException("CBP file must end with .cbp suffix: " + cbpInfo.cbp); relative = relative.replace(".cbp", ".bpel"); File bpelFile = new File(_du.getDeployDir(), relative); if (!bpelFile.exists()) __log.warn("BPEL file does not exist: " + bpelFile); return relative; } catch (IOException e) { throw new ContextException("IOException in getBpelRelativePath: " + cbpInfo.cbp, e); } } public URI getBaseURI() { return _du.getDeployDir().toURI(); } public ProcessState getState() {
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -