📄 appdescriptor.java
字号:
/*
* JBoss, Home of Professional Open Source
* Copyright 2005, JBoss Inc., and individual contributors as indicated
* by the @authors tag.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the JBPM BPEL PUBLIC LICENSE AGREEMENT as
* published by JBoss Inc.; either version 1.0 of the License, or
* (at your option) any later version.
*
* This software 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.
*/
package org.jbpm.bpel.app;
import java.net.URL;
import org.xml.sax.InputSource;
import org.jbpm.JbpmConfiguration;
import org.jbpm.JbpmContext;
import org.jbpm.bpel.BpelException;
import org.jbpm.bpel.graph.def.BpelDefinition;
import org.jbpm.bpel.integration.catalog.ServiceCatalog;
import org.jbpm.bpel.xml.AppDescriptorReader;
import org.jbpm.bpel.xml.ProblemCollector;
import org.jbpm.db.GraphSession;
import org.jbpm.jpdl.xml.Problem;
/**
* Binding of <tt>bpelApplication</tt> element.
* @author Alejandro Gu韟ar
* @version $Revision: 1.3 $ $Date: 2007/01/22 00:24:55 $
*/
public class AppDescriptor extends AppScope {
private Integer version;
private ServiceCatalog serviceCatalog;
public static final String RESOURCE_APP_DESCRIPTOR = "resource.app.descriptor";
public static final String DEFAULT_APP_DESCRIPTOR = "/bpel-application.xml";
public Integer getVersion() {
return version;
}
public void setVersion(Integer version) {
this.version = version;
}
public ServiceCatalog getServiceCatalog() {
return serviceCatalog;
}
public void setServiceCatalog(ServiceCatalog serviceCatalog) {
this.serviceCatalog = serviceCatalog;
}
public BpelDefinition findProcessDefinition(JbpmContext jbpmContext) {
// this descriptor references a particular process definition
String name = getName();
Integer version = getVersion();
// use the given context to find the definition
BpelDefinition process;
GraphSession graphSession = jbpmContext.getGraphSession();
// check for a version indicator
if (version != null) {
// find a specific version of the process
process = (BpelDefinition) graphSession.findProcessDefinition(name,
version.intValue());
}
else {
// just retrieve the latest one
process = (BpelDefinition) graphSession.findLatestProcessDefinition(name);
}
// if no such process exist, halt
if (process == null) {
throw new BpelException("process not found: name="
+ name
+ ", version="
+ version);
}
return process;
}
public void accept(AppDescriptorVisitor visitor) {
visitor.visit(this);
}
public static AppDescriptor readAppDescriptor() {
String appDescriptorResource = DEFAULT_APP_DESCRIPTOR;
if (JbpmConfiguration.Configs.hasObject(RESOURCE_APP_DESCRIPTOR)) {
// use the configured resource instead
appDescriptorResource = JbpmConfiguration.Configs.getString(AppDescriptor.RESOURCE_APP_DESCRIPTOR);
}
// locate the app descriptor using the context class loader
URL appDescriptorURL = Thread.currentThread()
.getContextClassLoader()
.getResource(appDescriptorResource);
// could the app descriptor be found in the context resources?
if (appDescriptorURL == null) {
// fall back to the loader of this class
appDescriptorURL = AppDescriptor.class.getResource(appDescriptorResource);
// if the descriptor is really not there, halt
if (appDescriptorURL == null) {
throw new BpelException("could not find application descriptor: "
+ appDescriptorResource);
}
}
// get the shared reader
AppDescriptorReader appDescriptorReader = AppDescriptorReader.getInstance();
// prepare custom error handling
ProblemCollector problemHandler = new ProblemCollector(
appDescriptorResource);
appDescriptorReader.setProblemHandler(problemHandler);
// parse content
AppDescriptor appDescriptor = new AppDescriptor();
appDescriptorReader.read(appDescriptor, new InputSource(
appDescriptorURL.toExternalForm()));
// if the descriptor has errors, halt
if (Problem.containsProblemsOfLevel(problemHandler.getProblems(),
Problem.LEVEL_ERROR)) {
throw new BpelException("errors found in bpel application descriptor");
}
return appDescriptor;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -