📄 agslocalcontextcreator.java
字号:
package com.esri.solutions.jitk.common.agslocal;
import com.esri.arcgis.server.IServerContext;
import org.apache.log4j.LogManager;
import org.apache.log4j.Logger;
/**
* Class that is responsible for creating and releasing an
* {@link IServerContext} object via {@link #createContext()} and
* {@link #releaseContext()}.
*/
public class AgsLocalContextCreator {
/**
* {@link Logger} used to log messages for this class.
*/
private static final Logger logger = LogManager.getLogger(AgsLocalContextCreator.class);
/**
* Reference to the {@link IServerContextFactory} that is used to create an
* {@link IServerContext} object.
*/
protected IServerContextFactory serverContextFactory;
/**
* Reference to the Java ADF {@link IServerContext} object created via the
* {@link #createContext()}.
*/
protected IServerContext serverContext;
/**
* Constructor that initializes the instance with the {@link IServerContextFactory} object
* that will be used to create an {@link IServerContext} object.
*
* @param svrCtxFact Reference to the {@link IServerContextFactory} object.
*/
public AgsLocalContextCreator(IServerContextFactory svrCtxFact) {
serverContextFactory = svrCtxFact;
}
/**
* Creates an {@link IServerContext} object using the
* {@link IServerContextFactory#createServerContext()}.
*
* @return Reference to the {@link IServerContext|.
* @throws FactoryException Thrown if there was an exception making the call
* {@link IServerContextFactory#createServerContext()}.
*/
public IServerContext createContext() throws FactoryException {
try {
serverContext = serverContextFactory.createServerContext();
} catch (FactoryException ex) {
logger.fatal("Can not create ArcGIS Server context");
releaseContext();
throw ex;
}
return serverContext;
}
/**
* Releases the {@link IServerContext} object via the
* {@link IServerContext#releaseContext()}.
*/
public void releaseContext() {
try {
if (serverContext != null) {
serverContext.releaseContext();
}
} catch (Exception ex) {
logger.warn("Can not release ArcGIS Server context");
} finally {
serverContext = null;
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -