📄 servercontextfactorybean.java
字号:
package com.esri.solutions.jitk.common.agslocal;
import com.esri.adf.web.ags.data.AGSUser;
import org.apache.log4j.LogManager;
import org.apache.log4j.Logger;
import java.util.Properties;
/**
* Managed bean class that can be configured with the necessary information needed
* by a {@link IServerContextFactory} class for creating {@link IServerContext}
* objects.
*/
public class ServerContextFactoryBean {
/**
* {@link Logger} used to log messages for this class.
*/
private static Logger _logger = LogManager.getLogger(ServerContextFactoryBean.class);
/**
* {@link AGSUser} necessary for creating an {@link IServerContext} object.
*/
private AGSUser m_user = null;
/**
* Configured {@link IServerContextFactory} class.
*/
private String m_factoryClass = null;
/**
* Host name necessary for creating an {@link IServerContext} object.
*/
private String m_host = null;
/**
* Service name necessary for creating an {@link IServerContext} object.
*/
private String m_service = "";
/**
* Configuration property for the service type (optional).
*/
private String m_serviceType = "";
/**
* Reference to the {@link IServerContextFactory} object specified by the
* {@link #m_factoryClass}.
*/
private IServerContextFactory m_factory = null;
/**
* Gets the name of the host that will be used to create an
* {@link IServerContext} object.
*
* @return {@link String} name of the host.
*/
public String getHost() {
return m_host;
}
/**
* Sets the name of the host that will be used to create an
* {@link IServerContext} object.
*
* @param host {@link String} name of the host.
*/
public void setHost(String host) {
m_host = host;
}
/**
* Gets the {@link AGSUser} containing username and password information that is
* needed to create an {@link IServerContext} object.
*
* @return {@link AGSUser} to be used when creating an {@link IServerContext} object.
*/
public AGSUser getUser() {
return m_user;
}
/**
* Sets the {@link AGSUser} containing username and password information that is
* needed to create an {@link IServerContext} object.
*
* @param user {@link AGSUser} to be used when creating an {@link IServerContext} object.
*/
public void setUser(AGSUser user) {
m_user = user;
}
/**
* Gets the fully qualified classpath name of the {@link IServerContextFactory}
* implementation.
*
* @return {@link String} fully qualified classpath name of the {@link IServerContextFactoy}
* implementation.
*/
public String getFactoryClass() {
return m_factoryClass;
}
/**
* Sets the fully qualified classpath name of the {@link IServerContextFactory}
* implementation.
*
* @param clazz {@link String} fully qualified classpath name of the {@link IServerContextFactory}
* implementation.
*/
public void setFactoryClass(String clazz) {
m_factoryClass = clazz;
}
/**
* Gets the name of the service (optional) that can be used to create
* the {@link IServerContext} object.
*
* @return {@link String} name of the service (optional).
*/
public String getService() {
return m_service;
}
/**
* Sets the name of the service (optional) that can be used to
* create the {@link IServerContext} object.
*
* @param service {@ink String} name of the service.
*/
public void setService(String service) {
m_service = service;
}
/**
* Gets the type of the service (optional) used to create an {@link IServerContext}
* object.
*
* @return {@link String} service type.
*/
public String getServiceType() {
return m_serviceType;
}
/**
* Sets the type of the service (optional) used to create an {@link IServerContext}
* object.
*
* @param type {@link String} service type.
*/
public void setServiceType(String type) {
m_serviceType = type;
}
/**
* Gets the {@link IServerContextFactory} object used to create
* {@link IServerContext} object.
*
* <p>
* To get a create an {@link IServerContext} object use the method
* {@link IServerContextFactory#createServerContext()}.
* </p>
*
* @return {@link IServerContextFactory} object used to create the
* {@link IServerContext}.
*/
public IServerContextFactory getFactory() {
Properties props = null;
if (m_factory == null) {
try {
m_factory = (IServerContextFactory) Class.forName(m_factoryClass)
.newInstance();
} catch (ClassNotFoundException ex) {
_logger.warn("Unable to find concrete factory implementation class.",
ex);
} catch (IllegalAccessException ex) {
_logger.warn("Unable to create Server Context factory", ex);
} catch (InstantiationException ex) {
_logger.warn("Unable to create Server Context factory", ex);
}
}
props = new Properties();
props.setProperty("HOST", getHost());
props.setProperty("DOMAIN", getUser().getDomain());
props.setProperty("USERNAME", getUser().getUserName());
props.setProperty("PASSWORD", getUser().getPassword());
props.setProperty("PASSWORD_ENCRYPTED",
String.valueOf(getUser().isPasswordEncrypted()));
props.setProperty("SERVICE", getService());
props.setProperty("SERVICE_TYPE", getServiceType());
m_factory.setConnectionInfo(props);
return m_factory;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -