本文整理汇总了Java中org.apache.axis2.context.MessageContext.getServiceContext方法的典型用法代码示例。如果您正苦于以下问题:Java MessageContext.getServiceContext方法的具体用法?Java MessageContext.getServiceContext怎么用?Java MessageContext.getServiceContext使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.axis2.context.MessageContext
的用法示例。
在下文中一共展示了MessageContext.getServiceContext方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: invoke
import org.apache.axis2.context.MessageContext; //导入方法依赖的package包/类
public InvocationResponse invoke(MessageContext msgContext) throws AxisFault {
String title = "TempHandler[" + getHandlerID() + "]:invoke(): ";
// get the service context from the message context
ServiceContext serviceContext = msgContext.getServiceContext();
if (serviceContext == null) {
// get the service context from the operation context
OperationContext operationContext = msgContext.getOperationContext();
serviceContext = operationContext.getServiceContext();
}
if (serviceContext != null) {
for (int j = 0; j < numberProperties; j++) {
count++;
String key = new String(propertyKey + ".ID[" + getHandlerID() + "]." + count);
String value = new String(propertyValue + "[" + count + "]");
serviceContext.setProperty(key, value);
}
}
log.debug(title + "executedHandlers.add(" + handlerID + ")");
executedHandlers.add(handlerID);
return InvocationResponse.CONTINUE;
}
示例2: getServiceProperties
import org.apache.axis2.context.MessageContext; //导入方法依赖的package包/类
private Map getServiceProperties(MessageContext mc) {
Map properties = null;
// get the service context from the message context
ServiceContext serviceContext = mc.getServiceContext();
if (serviceContext == null) {
// get the service context from the operation context
OperationContext operationContext = mc.getOperationContext();
serviceContext = operationContext.getServiceContext();
}
if (serviceContext != null) {
properties = serviceContext.getProperties();
}
return properties;
}
示例3: addServiceProperties
import org.apache.axis2.context.MessageContext; //导入方法依赖的package包/类
private void addServiceProperties(MessageContext mc, String suffix) {
// get the service context from the message context
ServiceContext serviceContext = mc.getServiceContext();
if (serviceContext == null) {
// get the service context from the operation context
OperationContext operationContext = mc.getOperationContext();
serviceContext = operationContext.getServiceContext();
}
if (serviceContext != null) {
for (int k = 0; k < serviceKeys.length; k++) {
String key = serviceKeys[k];
String value = serviceValues[k] + suffix;
serviceContext.setProperty(key, value);
}
}
}
示例4: getRequestCount
import org.apache.axis2.context.MessageContext; //导入方法依赖的package包/类
public OMElement getRequestCount(OMElement oe) {
MessageContext msg = MessageContext.getCurrentMessageContext();
Integer requestCount = (Integer)msg.getProperty(REQUEST_COUNT);
if (requestCount == null) {
requestCount = new Integer(1);
} else {
requestCount = new Integer(requestCount.intValue() + 1);
}
ServiceContext sgc = msg.getServiceContext();
sgc.setProperty(REQUEST_COUNT, requestCount);
QName qn = new QName("http://ws.apache.org/axis2/namespaces/", "RequestCount","axis2");
OMElement response = OMAbstractFactory.getOMFactory().createOMElement(qn);
response.setText(requestCount.toString());
return response;
}
示例5: getTheImplementationObject
import org.apache.axis2.context.MessageContext; //导入方法依赖的package包/类
/**
* Retrieve the implementation object. This will either return a cached
* object if present in the ServiceContext, or create a new one via
* makeNewServiceObject() (and then cache that).
*
* @param msgContext the active MessageContext
* @return the appropriate back-end service object.
* @throws AxisFault if there's a problem
*/
protected Object getTheImplementationObject(MessageContext msgContext) throws AxisFault {
ServiceContext serviceContext = msgContext.getServiceContext();
Object serviceimpl = serviceContext.getProperty(ServiceContext.SERVICE_OBJECT);
if (serviceimpl != null) {
// since service impl is there in service context , take that from there
return serviceimpl;
} else {
// create a new service impl class for that service
serviceimpl = makeNewServiceObject(msgContext);
//Service initialization
DependencyManager.initServiceObject(serviceimpl, msgContext.getServiceContext());
serviceContext.setProperty(ServiceContext.SERVICE_OBJECT, serviceimpl);
return serviceimpl;
}
}
示例6: attachEnvelopeEvent
import org.apache.axis2.context.MessageContext; //导入方法依赖的package包/类
public void attachEnvelopeEvent(MessageContext mc) {
if(log.isDebugEnabled()){
log.debug("Start attachEnvelopeEvent");
}
if(mc.getServiceContext() !=null){
installParserInputStreamCustomBuilder(mc.getServiceContext(), mc);
if(log.isDebugEnabled()){
log.debug("Installed ParserInputStreamCustomBuilder");
}
}
if(log.isDebugEnabled()){
log.debug("Stop attachEnvelopeEvent");
}
}
示例7: replicate
import org.apache.axis2.context.MessageContext; //导入方法依赖的package包/类
/**
* Replicates all serializable properties in the ConfigurationContext, ServiceGroupContext &
* ServiceContext
*
* @param msgContext The MessageContext associated with the ServiceContext,
* ServiceGroupContext and ConfigurationContext to be replicated
* @throws ClusteringFault If replication fails
*/
public static void replicate(MessageContext msgContext) throws ClusteringFault {
if (!canReplicate(msgContext)) {
return;
}
log.debug("Going to replicate state stored in ConfigurationContext," +
" ServiceGroupContext, ServiceContext associated with " + msgContext + "...");
ConfigurationContext configurationContext = msgContext.getConfigurationContext();
StateManager stateManager = getStateManager(msgContext);
if (stateManager == null) {
return;
}
List<AbstractContext> contexts = new ArrayList<AbstractContext>();
// Do we need to replicate state stored in ConfigurationContext?
if (!configurationContext.getPropertyDifferences().isEmpty()) {
contexts.add(configurationContext);
}
// Do we need to replicate state stored in ServiceGroupContext?
ServiceGroupContext sgContext = msgContext.getServiceGroupContext();
if (sgContext != null && !sgContext.getPropertyDifferences().isEmpty()) {
contexts.add(sgContext);
}
// Do we need to replicate state stored in ServiceContext?
ServiceContext serviceContext = msgContext.getServiceContext();
if (serviceContext != null && !serviceContext.getPropertyDifferences().isEmpty()) {
contexts.add(serviceContext);
}
// Do the actual replication here
if (!contexts.isEmpty()) {
AbstractContext[] contextArray = contexts.toArray(new AbstractContext[contexts.size()]);
stateManager.updateContexts(contextArray);
}
}
示例8: setSessionObject
import org.apache.axis2.context.MessageContext; //导入方法依赖的package包/类
public static void setSessionObject(String name, Object obj) {
MessageContext messageContext = MessageContext.getCurrentMessageContext();
if (messageContext != null) {
ServiceContext serviceContext = messageContext.getServiceContext();
if (serviceContext != null) {
serviceContext.setProperty(name, obj);
}
}
}
示例9: getSessionObject
import org.apache.axis2.context.MessageContext; //导入方法依赖的package包/类
public static Object getSessionObject(String name) {
MessageContext messageContext = MessageContext.getCurrentMessageContext();
if (messageContext != null) {
ServiceContext serviceContext = messageContext.getServiceContext();
if (serviceContext != null) {
return serviceContext.getProperty(name);
}
}
return null;
}
示例10: getSessionObject
import org.apache.axis2.context.MessageContext; //导入方法依赖的package包/类
/**
* Returns an object stored in the session with the given name.
*/
private static Object getSessionObject(String name) {
MessageContext messageContext = MessageContext.getCurrentMessageContext();
if (messageContext != null) {
ServiceContext serviceContext = messageContext.getServiceContext();
if (serviceContext != null) {
return serviceContext.getProperty(name);
}
} else {
return threadLocalSession.get().get(name);
}
return null;
}
示例11: setSessionObject
import org.apache.axis2.context.MessageContext; //导入方法依赖的package包/类
/**
* Save the given object in the session with the given name.
*/
private static void setSessionObject(String name, Object obj) {
MessageContext messageContext = MessageContext.getCurrentMessageContext();
if (messageContext != null) {
ServiceContext serviceContext = messageContext.getServiceContext();
if (serviceContext != null) {
serviceContext.setProperty(name, obj);
}
} else {
threadLocalSession.get().put(name, obj);
}
}
示例12: initScript
import org.apache.axis2.context.MessageContext; //导入方法依赖的package包/类
/**
* Initializes the script service by finding the script source code,
* compiling it in a BSFEngine, and creating an OMElementConvertor
* for the script.
*/
protected BSFEngine initScript(MessageContext mc) throws AxisFault {
log.debug("initializing script service");
AxisService axisService = mc.getAxisService();
String scriptName = null;
String scriptSrc = null;
Parameter scriptFileParam = axisService.getParameter(SCRIPT_ATTR);
if (scriptFileParam != null) {
// the script is defined in a seperate file
scriptName = ((String) scriptFileParam.getValue()).trim();
Parameter scriptSrcParam = axisService.getParameter(SCRIPT_SRC_PROP);
if (scriptSrcParam != null) {
scriptSrc = (String) scriptSrcParam.getValue();
} else {
scriptSrc = readScript(axisService.getClassLoader(), scriptName);
}
} else {
// the script is defined inline within the services.xml
ArrayList parameters = axisService.getParameters();
for (int i=0; scriptFileParam == null && i<parameters.size(); i++) {
Parameter p = (Parameter) parameters.get(i);
if (p.getName().startsWith("script.")) {
scriptFileParam = p;
scriptName = p.getName();
scriptSrc = (String) p.getValue();
}
}
}
if (scriptName == null) {
throw new AxisFault("Missing script parameter");
}
try {
String scriptLanguage = BSFManager.getLangFromFilename(scriptName);
BSFManager bsfManager = new BSFManager();
bsfManager.setClassLoader(BSFManager.class.getClassLoader());
bsfManager.declareBean("_AxisService", axisService, AxisService.class);
BSFEngine bsfEngine = bsfManager.loadScriptingEngine(scriptLanguage);
bsfEngine.exec(scriptName, 0, 0, scriptSrc);
ServiceContext serviceContext = mc.getServiceContext();
serviceContext.setProperty(BSFENGINE_PROP, bsfEngine);
OMElementConvertor convertor = ConvertorFactory.createOMElementConvertor(axisService, scriptName);
serviceContext.setProperty(CONVERTOR_PROP, convertor);
return bsfEngine;
} catch (BSFException e) {
throw AxisFault.makeFault(e);
}
}
示例13: attachEnvelopeEvent
import org.apache.axis2.context.MessageContext; //导入方法依赖的package包/类
public void attachEnvelopeEvent(MessageContext mc) {
if (mc.getServiceContext() != null) {
installJAXBCustomBuilder(mc.getServiceContext(), mc);
}
}
示例14: getRuleSession
import org.apache.axis2.context.MessageContext; //导入方法依赖的package包/类
/**
* we handles the rule sessions with the axis2 sessions. Axis2 manages sessions using the service context. Therefore we can store the rule session
* on the service context as well.
* @param inMessageContext - in comming message context. From which we can obtain the service context object.
* @return - rule session to use
* @throws RuleRuntimeException - if there is a problem of getting the rule session.
*/
private RuleSession getRuleSession(MessageContext inMessageContext) throws RuleRuntimeException {
ServiceContext serviceContext = inMessageContext.getServiceContext();
RuleSession ruleSession =
(RuleSession) serviceContext.getProperty(Constants.RULE_SESSION_OBJECT);
if (ruleSession == null){
String serviceScope = inMessageContext.getAxisService().getScope();
if (serviceScope.equals(org.apache.axis2.Constants.SCOPE_TRANSPORT_SESSION) ||
serviceScope.equals(org.apache.axis2.Constants.SCOPE_SOAP_SESSION)) {
//Rule service is stateful service
//create new stateful session and set knowledge session in serviceContext
ruleSession = this.ruleEngine.createSession(Constants.RULE_STATEFUL_SESSION);
if (log.isDebugEnabled()) {
log.debug("New stateful knowledge session created");
}
// put a configuration to invalidate the session or keep the session continued
serviceContext.setProperty(Constants.RULE_SESSION_OBJECT, ruleSession);
//set rule session lifecycle to service context
if (serviceContext.getProperty(ServiceContext.SERVICE_OBJECT) == null) {
RuleSessionLifecycle ruleSessionLifecycle = new RuleSessionLifecycle();
serviceContext.setProperty(ServiceContext.SERVICE_OBJECT, ruleSessionLifecycle);
if (log.isDebugEnabled()) {
log.debug("Set RuleSessionLifecycle to ServiceContext.SERVICE_OBJECT property");
}
}
} else {
//Rule service is stateless service
ruleSession = this.ruleEngine.createSession(Constants.RULE_STATELESS_SESSION);
if (log.isDebugEnabled()) {
log.debug("New stateless knowledge session created");
}
}
}
return ruleSession;
}