本文整理匯總了Java中javax.xml.ws.WebServiceContext類的典型用法代碼示例。如果您正苦於以下問題:Java WebServiceContext類的具體用法?Java WebServiceContext怎麽用?Java WebServiceContext使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
WebServiceContext類屬於javax.xml.ws包,在下文中一共展示了WebServiceContext類的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: createWebServiceContextMock
import javax.xml.ws.WebServiceContext; //導入依賴的package包/類
private WebServiceContext createWebServiceContextMock(String expectedIP,
String expectedUser) {
requestMock = mock(HttpServletRequest.class);
when(requestMock.getRemoteAddr()).thenReturn(expectedIP);
Principal principalMock = mock(Principal.class);
when(principalMock.getName()).thenReturn(expectedUser);
MessageContext msgContextMock = mock(MessageContext.class);
when(msgContextMock.get(anyString())).thenReturn(requestMock);
WebServiceContext wsContextMock = mock(WebServiceContext.class);
when(wsContextMock.getUserPrincipal()).thenReturn(principalMock);
when(wsContextMock.getMessageContext()).thenReturn(msgContextMock);
return wsContextMock;
}
示例2: identify
import javax.xml.ws.WebServiceContext; //導入依賴的package包/類
public UddiEntityPublisher identify(String authInfo, String authorizedName, WebServiceContext ctx) throws AuthenticationException {
EntityManager em = PersistenceManager.getEntityManager();
EntityTransaction tx = em.getTransaction();
try {
tx.begin();
Publisher publisher = em.find(Publisher.class, authorizedName);
if (publisher == null) {
throw new UnknownUserException(new ErrorMessage("errors.auth.NoPublisher", authorizedName));
}
return publisher;
} finally {
if (tx.isActive()) {
tx.rollback();
}
em.close();
}
}
示例3: identify
import javax.xml.ws.WebServiceContext; //導入依賴的package包/類
@Override
public UddiEntityPublisher identify(String authInfo, String authorizedName, WebServiceContext ctx) throws AuthenticationException {
EntityManager em = PersistenceManager.getEntityManager();
EntityTransaction tx = em.getTransaction();
try {
tx.begin();
Publisher publisher = em.find(Publisher.class, authorizedName);
if (publisher == null) {
throw new UnknownUserException(new ErrorMessage("errors.auth.NoPublisher", authorizedName));
}
return publisher;
} finally {
if (tx.isActive()) {
tx.rollback();
}
em.close();
}
}
示例4: identify
import javax.xml.ws.WebServiceContext; //導入依賴的package包/類
public UddiEntityPublisher identify(String authInfo, String authorizedName, WebServiceContext ctx) throws AuthenticationException, FatalErrorException {
EntityManager em = PersistenceManager.getEntityManager();
EntityTransaction tx = em.getTransaction();
try {
tx.begin();
Publisher publisher = em.find(Publisher.class, authorizedName);
if (publisher == null)
throw new UnknownUserException(new ErrorMessage("errors.auth.NoPublisher", authorizedName));
return publisher;
} finally {
if (tx.isActive()) {
tx.rollback();
}
em.close();
}
}
示例5: isWebServiceContextResource
import javax.xml.ws.WebServiceContext; //導入依賴的package包/類
private boolean isWebServiceContextResource(Resource atResource, Field field) {
Class type = atResource.type();
if (type == java.lang.Object.class) {
if (field != null && field.getType() == WebServiceContext.class) {
return true;
}
} else if (type == WebServiceContext.class) {
//TODO: Should I check if the field declared type is assignable from WebServiceContext. Spec is not clear about this.
return true;
}
if (log.isDebugEnabled()) {
log.debug(
"Invalid Field type or Resource Type found, cannot inject WebServiceContext on this field");
}
return false;
}
示例6: testInjectionOnField
import javax.xml.ws.WebServiceContext; //導入依賴的package包/類
public void testInjectionOnField(){
Object serviceInstance = new ResourceInjectionTestImpl1();
TestLogger.logger.debug("------------------------------");
TestLogger.logger.debug("Test : " + getName());
try{
ResourceInjector injector = ResourceInjectionFactory.createResourceInjector(WebServiceContext.class);
injector.inject(resource, serviceInstance);
ResourceInjectionTestImpl1 serviceImpl =(ResourceInjectionTestImpl1)serviceInstance;
assertNotNull(serviceImpl.ctx);
TestLogger.logger.debug("Resource Injected on Field");
TestLogger.logger.debug("------------------------------");
}catch(Exception e){
e.printStackTrace();
fail();
}
}
示例7: testInjectionOnMethod
import javax.xml.ws.WebServiceContext; //導入依賴的package包/類
public void testInjectionOnMethod(){
Object serviceInstance = new ResourceInjectionTestImpl2();
TestLogger.logger.debug("------------------------------");
TestLogger.logger.debug("Test : " + getName());
try{
ResourceInjector injector = ResourceInjectionFactory.createResourceInjector(WebServiceContext.class);
injector.inject(resource, serviceInstance);
ResourceInjectionTestImpl2 serviceImpl =(ResourceInjectionTestImpl2)serviceInstance;
assertNotNull(serviceImpl.ctx);
TestLogger.logger.debug("Resource Injected on Method");
TestLogger.logger.debug("------------------------------");
}catch(Exception e){
e.printStackTrace();
fail();
}
}