当前位置: 首页>>代码示例>>Java>>正文


Java ServiceContext.setProperty方法代码示例

本文整理汇总了Java中org.apache.axis2.context.ServiceContext.setProperty方法的典型用法代码示例。如果您正苦于以下问题:Java ServiceContext.setProperty方法的具体用法?Java ServiceContext.setProperty怎么用?Java ServiceContext.setProperty使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.axis2.context.ServiceContext的用法示例。


在下文中一共展示了ServiceContext.setProperty方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: greet

import org.apache.axis2.context.ServiceContext; //导入方法依赖的package包/类
public String greet(String name) {
    ServiceContext serviceContext =
            MessageContext.getCurrentMessageContext().getServiceContext();
    serviceContext.setProperty(HELLO_SERVICE_NAME, name);
    try {
        Replicator.replicate(serviceContext, new String[]{HELLO_SERVICE_NAME});
    } catch (ClusteringFault clusteringFault) {
        clusteringFault.printStackTrace();
    }

    if (name != null) {
        return "Hello World, " + name + " !!!";
    } else {
        return "Hello World !!!";
    }
}
 
开发者ID:wso2,项目名称:product-ei,代码行数:17,代码来源:HelloService.java

示例2: invoke

import org.apache.axis2.context.ServiceContext; //导入方法依赖的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;
}
 
开发者ID:wso2,项目名称:wso2-axis2,代码行数:27,代码来源:MessageContextSaveCTest.java

示例3: addServiceProperties

import org.apache.axis2.context.ServiceContext; //导入方法依赖的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);
        }
    }
}
 
开发者ID:wso2,项目名称:wso2-axis2,代码行数:20,代码来源:MessageContextSaveBTest.java

示例4: getRequestCount

import org.apache.axis2.context.ServiceContext; //导入方法依赖的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;
}
 
开发者ID:wso2,项目名称:wso2-axis2,代码行数:19,代码来源:RequestCounter.java

示例5: initService

import org.apache.axis2.context.ServiceContext; //导入方法依赖的package包/类
/**
 * To init all the services in application scope
 *
 * @param serviceGroupContext the ServiceGroupContext from which to extract all the services
 * @throws AxisFault if there's a problem initializing
 */
public static void initService(ServiceGroupContext serviceGroupContext) throws AxisFault {
    AxisServiceGroup serviceGroup = serviceGroupContext.getDescription();
    Iterator<AxisService> serviceItr = serviceGroup.getServices();
    while (serviceItr.hasNext()) {
        AxisService axisService = (AxisService) serviceItr.next();
        ServiceContext serviceContext = serviceGroupContext.getServiceContext(axisService);
        AxisService service = serviceContext.getAxisService();
        ClassLoader classLoader = service.getClassLoader();
        Parameter implInfoParam = service.getParameter(Constants.SERVICE_CLASS);
        if (implInfoParam != null) {
            try {
            	ThreadContextDescriptor tc = setThreadContext(axisService);
                Class implClass = Loader.loadClass(
                        classLoader,
                        ((String) implInfoParam.getValue()).trim());
                Object serviceImpl = makeNewServiceObject(service);
                serviceContext.setProperty(ServiceContext.SERVICE_OBJECT, serviceImpl);
                initServiceObject(serviceImpl, serviceContext);
                restoreThreadContext(tc);
            } catch (Exception e) {
                throw AxisFault.makeFault(e);
            }
        }
    }
}
 
开发者ID:wso2,项目名称:wso2-axis2,代码行数:32,代码来源:DependencyManager.java

示例6: getTheImplementationObject

import org.apache.axis2.context.ServiceContext; //导入方法依赖的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;
    }
}
 
开发者ID:wso2,项目名称:wso2-axis2,代码行数:25,代码来源:AbstractMessageReceiver.java

示例7: testSetPropertyInServiceContext

import org.apache.axis2.context.ServiceContext; //导入方法依赖的package包/类
public void testSetPropertyInServiceContext() throws Exception {
    if (!canRunTests) {
        return;
    }

    ServiceGroupContext serviceGroupContext1 =
            configurationContext1.createServiceGroupContext(serviceGroup1);
    serviceGroupContext1.setId(TEST_SERVICE_NAME);
    ServiceContext serviceContext1 = serviceGroupContext1.getServiceContext(service1);
    configurationContext1.addServiceGroupContextIntoApplicationScopeTable(serviceGroupContext1);
    assertNotNull(serviceGroupContext1);
    assertNotNull(serviceContext1);

    ServiceGroupContext serviceGroupContext2 =
            configurationContext2.createServiceGroupContext(serviceGroup2);
    serviceGroupContext2.setId(TEST_SERVICE_NAME);
    ServiceContext serviceContext2 = serviceGroupContext2.getServiceContext(service2);
    configurationContext2.addServiceGroupContextIntoApplicationScopeTable(serviceGroupContext2);
    assertNotNull(serviceGroupContext2);
    assertNotNull(serviceContext2);

    String key1 = "sgCtxKey";
    String val1 = "sgCtxVal1";
    serviceContext1.setProperty(key1, val1);
    ctxMan1.updateContext(serviceContext1);

    assertEquals(val1, serviceContext2.getProperty(key1));
}
 
开发者ID:wso2,项目名称:wso2-axis2,代码行数:29,代码来源:ContextReplicationTest.java

示例8: testSetPropertyInServiceContext2

import org.apache.axis2.context.ServiceContext; //导入方法依赖的package包/类
public void testSetPropertyInServiceContext2() throws Exception {
    if (!canRunTests) {
        return;
    }

    ServiceGroupContext serviceGroupContext1 =
            configurationContext1.createServiceGroupContext(serviceGroup1);
    serviceGroupContext1.setId(TEST_SERVICE_NAME);
    ServiceContext serviceContext1 = serviceGroupContext1.getServiceContext(service1);
    configurationContext1.addServiceGroupContextIntoSoapSessionTable(serviceGroupContext1);
    assertNotNull(serviceGroupContext1);
    assertNotNull(serviceContext1);

    ServiceGroupContext serviceGroupContext2 =
            configurationContext2.createServiceGroupContext(serviceGroup2);
    serviceGroupContext2.setId(TEST_SERVICE_NAME);
    ServiceContext serviceContext2 = serviceGroupContext2.getServiceContext(service2);
    configurationContext2.addServiceGroupContextIntoSoapSessionTable(serviceGroupContext2);
    assertNotNull(serviceGroupContext2);
    assertNotNull(serviceContext2);

    String key1 = "sgCtxKey";
    String val1 = "sgCtxVal1";
    serviceContext1.setProperty(key1, val1);
    ctxMan1.updateContext(serviceContext1);

    assertEquals(val1, serviceContext2.getProperty(key1));
}
 
开发者ID:wso2,项目名称:wso2-axis2,代码行数:29,代码来源:ContextReplicationTest.java

示例9: testRemovePropertyFromServiceContext

import org.apache.axis2.context.ServiceContext; //导入方法依赖的package包/类
public void testRemovePropertyFromServiceContext() throws Exception {
    if (!canRunTests) {
        return;
    }

    // Add the property
    ServiceGroupContext serviceGroupContext1 =
            configurationContext1.createServiceGroupContext(serviceGroup1);
    serviceGroupContext1.setId(TEST_SERVICE_NAME);
    ServiceContext serviceContext1 = serviceGroupContext1.getServiceContext(service1);
    configurationContext1.addServiceGroupContextIntoApplicationScopeTable(serviceGroupContext1);
    assertNotNull(serviceGroupContext1);
    assertNotNull(serviceContext1);

    ServiceGroupContext serviceGroupContext2 =
            configurationContext2.createServiceGroupContext(serviceGroup2);
    serviceGroupContext2.setId(TEST_SERVICE_NAME);
    ServiceContext serviceContext2 = serviceGroupContext2.getServiceContext(service2);
    configurationContext2.addServiceGroupContextIntoApplicationScopeTable(serviceGroupContext2);
    assertNotNull(serviceGroupContext2);
    assertNotNull(serviceContext2);

    String key1 = "sgCtxKey";
    String val1 = "sgCtxVal1";
    serviceContext1.setProperty(key1, val1);
    ctxMan1.updateContext(serviceContext1);

    assertEquals(val1, serviceContext2.getProperty(key1));

    // Remove the property
    serviceContext2.removeProperty(key1);
    assertNull(serviceContext2.getProperty(key1));
    ctxMan2.updateContext(serviceContext2);
    assertNull(serviceContext1.getProperty(key1));
}
 
开发者ID:wso2,项目名称:wso2-axis2,代码行数:36,代码来源:ContextReplicationTest.java

示例10: testRemovePropertyFromServiceContext2

import org.apache.axis2.context.ServiceContext; //导入方法依赖的package包/类
public void testRemovePropertyFromServiceContext2() throws Exception {
    if (!canRunTests) {
        return;
    }

    // Add the property
    ServiceGroupContext serviceGroupContext1 =
            configurationContext1.createServiceGroupContext(serviceGroup1);
    serviceGroupContext1.setId(TEST_SERVICE_NAME);
    ServiceContext serviceContext1 = serviceGroupContext1.getServiceContext(service1);
    configurationContext1.addServiceGroupContextIntoSoapSessionTable(serviceGroupContext1);
    assertNotNull(serviceGroupContext1);
    assertNotNull(serviceContext1);

    ServiceGroupContext serviceGroupContext2 =
            configurationContext2.createServiceGroupContext(serviceGroup2);
    serviceGroupContext2.setId(TEST_SERVICE_NAME);
    ServiceContext serviceContext2 = serviceGroupContext2.getServiceContext(service2);
    configurationContext2.addServiceGroupContextIntoSoapSessionTable(serviceGroupContext2);
    assertNotNull(serviceGroupContext2);
    assertNotNull(serviceContext2);

    String key1 = "sgCtxKey";
    String val1 = "sgCtxVal1";
    serviceContext1.setProperty(key1, val1);
    ctxMan1.updateContext(serviceContext1);

    assertEquals(val1, serviceContext2.getProperty(key1));

    // Remove the property
    serviceContext2.removeProperty(key1);
    assertNull(serviceContext2.getProperty(key1));
    ctxMan2.updateContext(serviceContext2);
    assertNull(serviceContext1.getProperty(key1));
}
 
开发者ID:wso2,项目名称:wso2-axis2,代码行数:36,代码来源:ContextReplicationTest.java

示例11: fillContextsFromSessionContext

import org.apache.axis2.context.ServiceContext; //导入方法依赖的package包/类
private void fillContextsFromSessionContext(MessageContext msgContext) throws AxisFault {
    AxisService service = msgContext.getAxisService();
    if (service == null) {
        throw new AxisFault(Messages.getMessage("unabletofindservice"));
    }
    SessionContext sessionContext = msgContext.getSessionContext();
    if (sessionContext == null) {
        TransportListener listener = msgContext.getTransportIn().getReceiver();
        sessionContext = listener.getSessionContext(msgContext);
        if (sessionContext == null) {
            createAndFillContexts(service, msgContext, sessionContext);
            return;
        }
    }
    String serviceGroupName = msgContext.getAxisServiceGroup().getServiceGroupName();
    ServiceGroupContext serviceGroupContext =
            sessionContext.getServiceGroupContext(serviceGroupName);
    if (serviceGroupContext != null) {
        //setting service group context
        msgContext.setServiceGroupContext(serviceGroupContext);
        // setting Service context
        msgContext.setServiceContext(serviceGroupContext.getServiceContext(service));
    } else {
        createAndFillContexts(service, msgContext, sessionContext);
    }
    ServiceContext serviceContext = sessionContext.getServiceContext(service);
    //found the serviceContext from session context , so adding that into msgContext
    if (serviceContext != null) {
        msgContext.setServiceContext(serviceContext);
        serviceContext.setProperty(HTTPConstants.COOKIE_STRING, sessionContext.getCookieID());
    }
}
 
开发者ID:wso2,项目名称:wso2-axis2,代码行数:33,代码来源:DispatchPhase.java

示例12: testMessageContextListener

import org.apache.axis2.context.ServiceContext; //导入方法依赖的package包/类
/**
 * Simple test to make verify that the MessageContext listener
 * is invoked when a ServiceContext is attached to the MessageContext
 * @throws Exception
 */
public void testMessageContextListener() throws Exception {
    
    AxisConfiguration ac = new AxisConfiguration();
    ConfigurationContext cc = new ConfigurationContext(ac);
    
    // Create a dummy AxisService
    AxisService service = new AxisService();
    service.setName("dummy");
    
    AxisServiceGroup asg = new AxisServiceGroup();
    asg.addService(service);
    
    // Attach a ServiceContextListener
    // The ServiceContextListener will copy sample information from 
    // the ServiceContext onto the MessageContext
    service.addMessageContextListener(new MyMessageContextListener());
    
    // Create a Dummy ServiceContext
    ServiceGroupContext sgc = new ServiceGroupContext(cc, asg);
    ServiceContext sc = sgc.getServiceContext(service);
    sc.setProperty("SERVICE_PROPERTY", "SUCCESSFUL");
    
    // Create a MessageContext
    MessageContext mc = new MessageContext();
    
    // Attach the ServiceContext and MessageContext.
    // This will trigger the MyServiceContextListener.attachEvent
    mc.setServiceContext(sc);
    
    // Verify success
    assertTrue("SUCCESSFUL".equals(mc.getProperty("MESSAGE_PROPERTY")));
}
 
开发者ID:wso2,项目名称:wso2-axis2,代码行数:38,代码来源:AxisServiceTest.java

示例13: setSessionObject

import org.apache.axis2.context.ServiceContext; //导入方法依赖的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);
        }
    }
}
 
开发者ID:wso2,项目名称:carbon-commons,代码行数:10,代码来源:LoggingSessionManager.java

示例14: setSessionObject

import org.apache.axis2.context.ServiceContext; //导入方法依赖的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);
	}
}
 
开发者ID:wso2,项目名称:carbon-data,代码行数:15,代码来源:DSSessionManager.java

示例15: init

import org.apache.axis2.context.ServiceContext; //导入方法依赖的package包/类
public void init(ServiceContext serviceContext) {
    System.out.println("Initializing the service context for service "
            + serviceContext.getAxisService().getName());
    // initialize the count to zero
    if (serviceContext.getProperty(COUNT) == null){
        serviceContext.setProperty(COUNT, new TestPOJO());
    }
    
}
 
开发者ID:syodage,项目名称:Axis2-Samples,代码行数:10,代码来源:SessionService.java


注:本文中的org.apache.axis2.context.ServiceContext.setProperty方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。