Method from org.apache.axis2.context.ConfigurationContext Detail: |
public void addContextListener(ContextListener contextListener) {
if (contextListeners == null) {
contextListeners = new ArrayList< ContextListener >();
}
contextListeners.add(contextListener);
}
|
public void addServiceGroupContextIntoApplicationScopeTable(ServiceGroupContext serviceGroupContext) {
if (applicationSessionServiceGroupContexts == null) {
applicationSessionServiceGroupContexts = new Hashtable< String, ServiceGroupContext >();
}
applicationSessionServiceGroupContexts.put(
serviceGroupContext.getDescription().getServiceGroupName(), serviceGroupContext);
}
Adds the given ServiceGroupContext into the Application Scope table |
public void addServiceGroupContextIntoSoapSessionTable(ServiceGroupContext serviceGroupContext) {
String id = serviceGroupContext.getId();
serviceGroupContextMap.put(id, serviceGroupContext);
serviceGroupContext.touch();
serviceGroupContext.setParent(this);
// this is the best time to clean up the SGCtxts since are not being used anymore
cleanupServiceGroupContexts();
}
Adds the given ServiceGroupContext into the SOAP session table |
public void cleanupContexts() {
if ((applicationSessionServiceGroupContexts != null) &&
(applicationSessionServiceGroupContexts.size() > 0)) {
for (Object o : applicationSessionServiceGroupContexts.values()) {
ServiceGroupContext serviceGroupContext =
(ServiceGroupContext)o;
cleanupServiceContexts(serviceGroupContext);
}
applicationSessionServiceGroupContexts.clear();
}
if ((serviceGroupContextMap != null) && (serviceGroupContextMap.size() > 0)) {
for (Object o : serviceGroupContextMap.values()) {
ServiceGroupContext serviceGroupContext =
(ServiceGroupContext)o;
cleanupServiceContexts(serviceGroupContext);
}
serviceGroupContextMap.clear();
}
}
Called during shutdown to clean up all Contexts |
void contextCreated(AbstractContext context) {
if (contextListeners == null) {
return;
}
for (Object contextListener : contextListeners) {
ContextListener listener = (ContextListener)contextListener;
listener.contextCreated(context);
}
}
Inform any listeners of a new context being created |
void contextRemoved(AbstractContext context) {
if (contextListeners == null) {
return;
}
for (Object contextListener : contextListeners) {
ContextListener listener = (ContextListener)contextListener;
listener.contextRemoved(context);
}
}
Inform any listeners of a context being removed |
public MessageContext createMessageContext() {
MessageContext msgCtx = new MessageContext(this);
contextCreated(msgCtx);
return msgCtx;
}
Create a MessageContext, and notify any registered ContextListener. |
public ServiceGroupContext createServiceGroupContext(AxisServiceGroup serviceGroup) {
ServiceGroupContext sgCtx = new ServiceGroupContext(this, serviceGroup);
contextCreated(sgCtx);
return sgCtx;
}
Create a ServiceGroupContext for the specified service group, and notify any registered
ContextListener. |
public void deployService(AxisService service) throws AxisFault {
axisConfiguration.addService(service);
if (Constants.SCOPE_APPLICATION.equals(service.getScope())) {
ServiceGroupContext sgc = createServiceGroupContext(service.getAxisServiceGroup());
DependencyManager.initService(sgc);
}
}
Deploy a service to the embedded AxisConfiguration, and initialize it. |
public void fillServiceContextAndServiceGroupContext(MessageContext messageContext) throws AxisFault {
// by this time service group context id must have a value. Either from transport or from addressing
ServiceGroupContext serviceGroupContext;
ServiceContext serviceContext = messageContext.getServiceContext();
AxisService axisService = messageContext.getAxisService();
if (serviceContext == null) {
String scope = axisService.getScope();
if (Constants.SCOPE_APPLICATION.equals(scope)) {
String serviceGroupName = axisService.getAxisServiceGroup().getServiceGroupName();
serviceGroupContext =
(ServiceGroupContext)applicationSessionServiceGroupContexts.get(
serviceGroupName);
if (serviceGroupContext == null) {
AxisServiceGroup axisServiceGroup = messageContext.getAxisServiceGroup();
if (axisServiceGroup == null) {
axisServiceGroup = axisService.getAxisServiceGroup();
messageContext.setAxisServiceGroup(axisServiceGroup);
}
ConfigurationContext cfgCtx = messageContext.getConfigurationContext();
serviceGroupContext = cfgCtx.createServiceGroupContext(axisServiceGroup);
applicationSessionServiceGroupContexts
.put(serviceGroupName, serviceGroupContext);
}
messageContext.setServiceGroupContext(serviceGroupContext);
messageContext
.setServiceContext(serviceGroupContext.getServiceContext(axisService));
} else if (Constants.SCOPE_SOAP_SESSION.equals(scope)) {
//cleaning the session
cleanupServiceGroupContexts();
String serviceGroupContextId = messageContext.getServiceGroupContextId();
if (serviceGroupContextId != null) {
serviceGroupContext =
getServiceGroupContextFromSoapSessionTable(serviceGroupContextId,
messageContext);
if (serviceGroupContext == null) {
// TODO: Adding this code so that requests to services deployed in soapsession scope will work
// TODO: However, soapsession functionality is still broken
serviceGroupContext =
new ServiceGroupContext(this,
axisService.getAxisServiceGroup());
serviceGroupContext.setId(serviceGroupContextId);
addServiceGroupContextIntoSoapSessionTable(serviceGroupContext);
// throw new AxisFault("Unable to find corresponding context" +
// " for the serviceGroupId: " + serviceGroupContextId);
}
} else {
AxisServiceGroup axisServiceGroup = axisService.getAxisServiceGroup();
serviceGroupContext = createServiceGroupContext(axisServiceGroup);
serviceContext = serviceGroupContext.getServiceContext(axisService);
// set the serviceGroupContextID
serviceGroupContextId = UUIDGenerator.getUUID();
serviceGroupContext.setId(serviceGroupContextId);
messageContext.setServiceGroupContextId(serviceGroupContextId);
addServiceGroupContextIntoSoapSessionTable(serviceGroupContext);
}
messageContext.setServiceGroupContext(serviceGroupContext);
messageContext
.setServiceContext(serviceGroupContext.getServiceContext(axisService));
} else if (Constants.SCOPE_REQUEST.equals(scope)) {
AxisServiceGroup axisServiceGroup = axisService.getAxisServiceGroup();
serviceGroupContext = createServiceGroupContext(axisServiceGroup);
messageContext.setServiceGroupContext(serviceGroupContext);
serviceContext = serviceGroupContext.getServiceContext(axisService);
messageContext.setServiceContext(serviceContext);
}
}
if (messageContext.getOperationContext() != null) {
messageContext.getOperationContext().setParent(serviceContext);
}
}
Searches for a ServiceGroupContext in the map with given id as the key.
If(key != null && found)
check for a service context for the intended service.
if (!found)
create one and hook up to ServiceGroupContext
else
create new ServiceGroupContext with the given key or if key is null with a new key
create a new service context for the service
|
public OperationContext findOperationContext(String operationName,
String serviceName,
String serviceGroupName) {
if (operationName == null) {
return null;
}
if (serviceName == null) {
return null;
}
// group name is not necessarily a prereq
// but if the group name is non-null, then it has to match
Iterator< OperationContext > it = operationContextMap.values().iterator();
while (it.hasNext()) {
OperationContext value = (OperationContext)it.next();
String valueOperationName;
String valueServiceName;
String valueServiceGroupName;
if (value != null) {
valueOperationName = value.getOperationName();
valueServiceName = value.getServiceName();
valueServiceGroupName = value.getServiceGroupName();
if ((valueOperationName != null) && (valueOperationName.equals(operationName))) {
if ((valueServiceName != null) && (valueServiceName.equals(serviceName))) {
if ((valueServiceGroupName != null) && (serviceGroupName != null)
&& (valueServiceGroupName.equals(serviceGroupName))) {
// match
return value;
}
// or, both need to be null
if ((valueServiceGroupName == null) && (serviceGroupName == null)) {
// match
return value;
}
}
}
}
}
// if we got here, we did not find an operation context
// that fits the criteria
return null;
}
Finds the OperationContext given the Operation name, Service Name, and ServiceGroupName |
public AxisConfiguration getAxisConfiguration() {
return axisConfiguration;
}
Returns the AxisConfiguration |
public String getContextRoot() {
return contextRoot;
}
Retrieves the ContextRoot |
public ListenerManager getListenerManager() {
return listenerManager;
}
Retrieve the ListenerManager |
public OperationContext getOperationContext(String messageID) {
return (OperationContext)this.operationContextMap.get(messageID);
}
Gets a OperationContext given a Message ID. |
public File getRealPath(String path) {
URL repository = axisConfiguration.getRepository();
if (repository != null) {
File repo = new File(repository.getFile());
return new File(repo, path);
}
return null;
}
Allows users to resolve the path relative to the root directory. |
public ConfigurationContext getRootContext() {
return this;
}
|
public String getServiceContextPath() {
if (cachedServicePath == null) {
cachedServicePath = internalGetServiceContextPath();
}
return cachedServicePath;
}
Retrieves the ServiceContext path |
public ServiceGroupContext getServiceGroupContext(String serviceGroupCtxId) {
if (serviceGroupCtxId == null) {
// Hashtables require non-null key-value pairs
return null;
}
ServiceGroupContext serviceGroupContext = null;
if (serviceGroupContextMap != null) {
serviceGroupContext =
(ServiceGroupContext)serviceGroupContextMap.get(serviceGroupCtxId);
if (serviceGroupContext != null) {
serviceGroupContext.touch();
} else {
serviceGroupContext =
(ServiceGroupContext)applicationSessionServiceGroupContexts
.get(serviceGroupCtxId);
if (serviceGroupContext != null) {
serviceGroupContext.touch();
}
}
}
return serviceGroupContext;
}
Returns a ServiceGroupContext object associated with the specified ID from the internal
table. |
public ServiceGroupContext getServiceGroupContextFromSoapSessionTable(String serviceGroupContextId,
MessageContext msgContext) throws AxisFault {
ServiceGroupContext serviceGroupContext =
(ServiceGroupContext)serviceGroupContextMap.get(serviceGroupContextId);
if (serviceGroupContext != null) {
serviceGroupContext.touch();
return serviceGroupContext;
} else {
throw new AxisFault("Unable to find corresponding context" +
" for the serviceGroupId: " + serviceGroupContextId);
}
}
Retrieve the ServiceGroupContext from the SOAP session table |
public String[] getServiceGroupContextIDs() {
String[] ids = new String[serviceGroupContextMap.size() +
applicationSessionServiceGroupContexts.size()];
int index = 0;
for (Object o : serviceGroupContextMap.keySet()) {
ids[index] = (String)o;
index++;
}
for (Object o : applicationSessionServiceGroupContexts.keySet()) {
ids[index] = (String)o;
index++;
}
return ids;
}
Gets all service groups in the system. |
public long getServiceGroupContextTimeoutInterval() {
Integer serviceGroupContextTimoutIntervalParam =
(Integer)getProperty(Constants.Configuration.CONFIG_CONTEXT_TIMEOUT_INTERVAL);
if (serviceGroupContextTimoutIntervalParam != null) {
// TODO: This seems wrong - setting a field inside a getter??
serviceGroupContextTimeoutInterval = serviceGroupContextTimoutIntervalParam;
}
return serviceGroupContextTimeoutInterval;
}
This will be used to fetch the serviceGroupContextTimoutInterval from any place available. |
public long getServiceGroupContextTimoutInterval() {
return getServiceGroupContextTimeoutInterval();
} Deprecated! MISSPELLING - - Please use getServiceGroupContextTimeoutInterval()
|
public Hashtable getServiceGroupContexts() {
return serviceGroupContextMap;
} Deprecated! Use - #getServiceGroupContextIDs & #getServiceGroupContext(String)
|
public String getServicePath() {
if (servicePath == null || servicePath.trim().length() == 0) {
throw new IllegalArgumentException("service path cannot be null or empty");
}
return servicePath.trim();
}
Retrieves the ServicePath |
public ThreadFactory getThreadPool() {
if (threadPool == null) {
threadPool = new ThreadPool();
}
return threadPool;
}
Returns the thread factory. |
public void initCluster() throws AxisFault {
ClusterManager clusterManager = axisConfiguration.getClusterManager();
if (clusterManager != null) {
ContextManager contextManager = clusterManager.getContextManager();
if (contextManager != null) {
contextManager.setConfigurationContext(this);
}
ConfigurationManager configManager = clusterManager.getConfigurationManager();
if (configManager != null) {
configManager.setConfigurationContext(this);
}
if (shouldClusterBeInitiated(clusterManager)) {
clusterManager.setConfigurationContext(this);
clusterManager.init();
}
}
}
Initializes the ClusterManager for this ConfigurationContext |
public boolean isAnyOperationContextRegistered() {
return !operationContextMap.isEmpty();
}
|
public boolean registerOperationContext(String messageID,
OperationContext operationContext) {
return registerOperationContext(messageID, operationContext, false);
}
Registers a OperationContext with a given message ID. If the given message id already has a
registered operation context, no change is made and the method returns false. |
public boolean registerOperationContext(String messageID,
OperationContext mepContext,
boolean override) {
if (messageID == null) {
if (log.isDebugEnabled()) {
log.debug("messageID is null. Returning false");
}
return false;
}
boolean alreadyInMap = false;
mepContext.setKey(messageID);
if (override) {
operationContextMap.put(messageID, mepContext);
} else {
Object previous = operationContextMap.putIfAbsent(messageID, mepContext);
alreadyInMap = (previous != null);
}
if (log.isDebugEnabled()) {
log.debug("registerOperationContext (" + override + "): " +
mepContext + " with key: " + messageID);
HashMap< String, MessageContext > msgContextMap = mepContext.getMessageContexts();
Iterator< MessageContext > msgContextIterator = msgContextMap.values().iterator();
while (msgContextIterator.hasNext()) {
MessageContext msgContext = (MessageContext)msgContextIterator.next();
log.debug("msgContext: " + msgContext + " action: " + msgContext.getWSAAction());
}
}
return (!alreadyInMap || override);
}
Registers a OperationContext with a given message ID. If the given message id already has a
registered operation context, no change is made unless the override flag is set. |
public void removeContextListener(ContextListener contextListener) {
if (contextListeners != null) {
contextListeners.remove(contextListener);
}
}
|
public void removeServiceGroupContext(String serviceGroupContextId) {
if (serviceGroupContextMap == null) {
return;
}
ServiceGroupContext serviceGroupContext =
(ServiceGroupContext)serviceGroupContextMap.get(serviceGroupContextId);
serviceGroupContextMap.remove(serviceGroupContextId);
cleanupServiceContexts(serviceGroupContext);
}
Remove a ServiceGroupContext |
public void removeServiceGroupContext(AxisServiceGroup serviceGroup) {
if (serviceGroup == null) return;
String groupName = serviceGroup.getServiceGroupName();
Object obj = applicationSessionServiceGroupContexts.get(groupName);
if (obj != null) {
applicationSessionServiceGroupContexts.remove(serviceGroup.getServiceGroupName());
return;
}
ArrayList< String > toBeRemovedList = new ArrayList< String >();
Iterator< ServiceGroupContext > serviceGroupContexts = serviceGroupContextMap.values().iterator();
while (serviceGroupContexts.hasNext()) {
ServiceGroupContext serviceGroupContext =
(ServiceGroupContext)serviceGroupContexts.next();
if (serviceGroupContext.getDescription().equals(serviceGroup)) {
toBeRemovedList.add(serviceGroupContext.getId());
}
}
for (Object aToBeRemovedList : toBeRemovedList) {
String s = (String)aToBeRemovedList;
serviceGroupContextMap.remove(s);
}
}
Removes the given ServiceGroup from the ServiceGroup context |
public void setAxisConfiguration(AxisConfiguration configuration) {
axisConfiguration = configuration;
}
Set the AxisConfiguration to the specified configuration |
public void setContextRoot(String contextRoot) {
if (contextRoot != null) {
this.contextRoot = contextRoot.trim(); // Trim before storing away for good hygiene
cachedServicePath = internalGetServiceContextPath();
}
}
Sets the context root to the given string |
public void setServicePath(String servicePath) {
this.servicePath = servicePath;
}
Sets the ServicePath to the given string |
public void setThreadPool(ThreadFactory pool) throws AxisFault {
if (threadPool == null) {
threadPool = pool;
} else {
throw new AxisFault(Messages.getMessage("threadpoolset"));
}
}
|
public void setTransportManager(ListenerManager listenerManager) {
this.listenerManager = listenerManager;
}
Set the TransportManager to the given ListenerManager |
public void terminate() throws AxisFault {
if (listenerManager != null) {
listenerManager.stop();
}
axisConfiguration.cleanup();
cleanupTemp();
}
Invoked during shutdown to stop the ListenerManager and perform configuration cleanup |
public void unregisterOperationContext(String messageID) {
if (messageID == null) {
if (log.isDebugEnabled()) {
log.debug("messageID is null.");
}
} else {
OperationContext opCtx = (OperationContext)operationContextMap.remove(messageID);
contextRemoved(opCtx);
}
}
Unregisters the operation context associated with the given messageID |