本文整理汇总了Java中javax.ejb.SessionContext类的典型用法代码示例。如果您正苦于以下问题:Java SessionContext类的具体用法?Java SessionContext怎么用?Java SessionContext使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
SessionContext类属于javax.ejb包,在下文中一共展示了SessionContext类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: SecurityInvocationHandler
import javax.ejb.SessionContext; //导入依赖的package包/类
SecurityInvocationHandler(SessionContext sessionContext, Method beanMethod) {
this.sessionContext = sessionContext;
RolesAllowed rolesAllowed = beanMethod.getAnnotation(RolesAllowed.class);
// a somewhat nasty scenario: a bean is spied using Mockito, so the
// roles allowed annotations have to be retrieved from the superclass...
Class<?> declaringClass = beanMethod.getDeclaringClass();
Class<?> superclass = declaringClass.getSuperclass();
if (declaringClass.getName().contains("Mockito")
&& !superclass.equals(Object.class)) {
try {
Method method = superclass.getMethod(beanMethod.getName(),
beanMethod.getParameterTypes());
rolesAllowed = method.getAnnotation(RolesAllowed.class);
} catch (Exception e) {
e.printStackTrace();
}
}
if (rolesAllowed == null) {
this.rolesAllowed = new String[0];
} else {
this.rolesAllowed = rolesAllowed.value();
}
}
示例2: setUp
import javax.ejb.SessionContext; //导入依赖的package包/类
@Before
public void setUp() throws Exception {
trackingCodeManagementServiceBean = spy(new TrackingCodeManagementServiceBean());
marketplace = new Marketplace();
marketplace.setMarketplaceId(MARKETPLACE_ID);
marketplace.setTrackingCode(TRACKING_CODE);
mpServiceLocal = mock(MarketplaceServiceLocal.class);
doReturn(marketplace).when(mpServiceLocal).getMarketplace(
eq(MARKETPLACE_ID));
doNothing().when(mpServiceLocal).updateMarketplaceTrackingCode(
anyString(), anyInt(), anyString());
response = new Response();
trackingCodeManagementServiceBean.mpServiceLocal = mpServiceLocal;
trackingCodeManagementServiceBean.sessionCtx = mock(SessionContext.class);
}
示例3: setup
import javax.ejb.SessionContext; //导入依赖的package包/类
@Before
public void setup() {
bean = new SubscriptionDetailsServiceBean();
bean.accountService = mock(AccountService.class);
bean.discountService = mock(DiscountService.class);
bean.ds = mock(DataService.class);
bean.identityService = mock(IdentityService.class);
bean.partnerService = mock(PartnerService.class);
bean.serviceProvisioningService = mock(ServiceProvisioningService.class);
bean.serviceProvisioningServiceInternal = mock(ServiceProvisioningServiceInternal.class);
bean.sessionCtx = mock(SessionContext.class);
bean.sessionService = mock(SessionService.class);
bean.subscriptionService = mock(SubscriptionService.class);
bean.subscriptionServiceInternal = mock(SubscriptionServiceInternal.class);
PlatformUser pu = new PlatformUser();
pu.setOrganization(new Organization());
pu.getOrganization().setKey(CURRENT_ORG_KEY);
when(bean.ds.getCurrentUser()).thenReturn(pu);
}
示例4: setup
import javax.ejb.SessionContext; //导入依赖的package包/类
@Before
public void setup() {
owner = new Organization();
owner.setOrganizationId("owner");
owner.setKey(1234);
notOwner = new Organization();
notOwner.setOrganizationId("notOwner");
notOwner.setKey(4321);
technicalProduct = new TechnicalProduct();
technicalProduct.setKey(9876);
technicalProduct.setTechnicalProductId("TP Id");
sessionMock = mock(SessionContext.class);
loggerMock = mock(Log4jLogger.class);
}
示例5: setup
import javax.ejb.SessionContext; //导入依赖的package包/类
@Before
public void setup() {
bean = new SubscriptionServiceBean();
bean.sessionCtx = mock(SessionContext.class);
sub = new Subscription();
sub.setSubscriptionId("subscriptionId");
Product prod = new Product();
prod.setParameterSet(new ParameterSet());
ParameterDefinition pd = new ParameterDefinition();
pd.setParameterId(PlatformParameterIdentifiers.NAMED_USER);
pd.setParameterType(ParameterType.PLATFORM_PARAMETER);
param = new Parameter();
param.setParameterDefinition(pd);
param.setParameterSet(prod.getParameterSet());
prod.getParameterSet().getParameters().add(param);
sub.setProduct(prod);
}
示例6: owns
import javax.ejb.SessionContext; //导入依赖的package包/类
/**
* Checks if the provided {@link Organization} is the owner of the provided
* {@link UdaDefinition} and throws an
* {@link OperationNotPermittedException} if this is not the case.
*
* @param def
* the {@link UdaDefinition} to check the ownership for
* @param org
* the {@link Organization} to check if it is the owner
* @param logger
* the optional logger - if not <code>null</code> it logs the
* created exception as warning to the system log
* @param context
* if not <code>null</code>,
* {@link SessionContext#setRollbackOnly()} will called.
* @throws OperationNotPermittedException
*/
public static void owns(UdaDefinition def, Organization org,
Log4jLogger logger, SessionContext context)
throws OperationNotPermittedException {
if (def.getOrganization() != org) {
String message = String
.format("Organization '%s' tried to access uda definition '%s' that is owned by a different organization",
org.getOrganizationId(), Long.valueOf(def.getKey()));
OperationNotPermittedException e = new OperationNotPermittedException(
message);
if (logger != null) {
logger.logWarn(
Log4jLogger.SYSTEM_LOG,
e,
LogMessageIdentifier.WARN_INSUFFICIENT_AUTH_BY_UDA_DEFINITION_ACCESS,
org.getOrganizationId(), String.valueOf(def.getKey()));
}
if (context != null) {
context.setRollbackOnly();
}
throw e;
}
}
示例7: supplierOfCustomer
import javax.ejb.SessionContext; //导入依赖的package包/类
/**
* Checks if the provided supplier {@link Organization} is supplier of the
* provided customer {@link Organization} and throws an
* {@link OperationNotPermittedException} if this is not the case.
*
* @param sup
* the {@link Organization} to check if it is supplier of the
* passed customer {@link Organization}
* @param cust
* the {@link Organization} to check if it is customer of the
* passed supplier {@link Organization}
* @param logger
* the optional logger - if not <code>null</code> it logs the
* created exception as warning to the system log
* @param context
* if not <code>null</code>,
* {@link SessionContext#setRollbackOnly()} will called.
* @throws OperationNotPermittedException
*/
public static void supplierOfCustomer(Organization sup, Organization cust,
Log4jLogger logger, SessionContext context)
throws OperationNotPermittedException {
List<Organization> customers = sup.getCustomersOfSupplier();
if (!customers.contains(cust)) {
String message = String.format(
"Organization '%s' is not supplier of customer '%s'",
sup.getOrganizationId(), cust.getOrganizationId());
OperationNotPermittedException e = new OperationNotPermittedException(
message);
if (logger != null) {
logger.logWarn(Log4jLogger.SYSTEM_LOG, e,
LogMessageIdentifier.WARN_NO_SUPPLIER_OF_CUSTOMER,
sup.getOrganizationId(), cust.getOrganizationId());
}
if (context != null) {
context.setRollbackOnly();
}
throw e;
}
}
示例8: brokerOfCustomer
import javax.ejb.SessionContext; //导入依赖的package包/类
/**
* Checks if the provided reseller {@link Organization} is a broker of the
* provided customer {@link Organization} and throws an
* {@link OperationNotPermittedException} if this is not the case.
*
* @param broker
* the {@link Organization} to check if it is a broker of the
* passed customer {@link Organization}
* @param cust
* the {@link Organization} to check if it is customer of the
* passed broker {@link Organization}
* @param logger
* the optional logger - if not <code>null</code> it logs the
* created exception as warning to the system log
* @param context
* if not <code>null</code>,
* {@link SessionContext#setRollbackOnly()} will called.
* @throws OperationNotPermittedException
*/
public static void brokerOfCustomer(Organization broker, Organization cust,
Log4jLogger logger, SessionContext context)
throws OperationNotPermittedException {
List<Organization> customers = broker.getCustomersOfBroker();
if (!customers.contains(cust)) {
String message = String.format(
"Organization '%s' is not broker of customer '%s'",
broker.getOrganizationId(), cust.getOrganizationId());
OperationNotPermittedException e = new OperationNotPermittedException(
message);
if (logger != null) {
logger.logWarn(Log4jLogger.SYSTEM_LOG, e,
LogMessageIdentifier.WARN_NO_BROKER_OF_CUSTOMER,
broker.getOrganizationId(), cust.getOrganizationId());
}
if (context != null) {
context.setRollbackOnly();
}
throw e;
}
}
示例9: resellerOfCustomer
import javax.ejb.SessionContext; //导入依赖的package包/类
/**
* Checks if the provided reseller {@link Organization} is reseller of the
* provided customer {@link Organization} and throws an
* {@link OperationNotPermittedException} if this is not the case.
*
* @param reseller
* the {@link Organization} to check if it is reseller of the
* passed customer {@link Organization}
* @param cust
* the {@link Organization} to check if it is customer of the
* passed reseller {@link Organization}
* @param logger
* the optional logger - if not <code>null</code> it logs the
* created exception as warning to the system log
* @param context
* if not <code>null</code>,
* {@link SessionContext#setRollbackOnly()} will called.
* @throws OperationNotPermittedException
*/
public static void resellerOfCustomer(Organization reseller,
Organization cust, Log4jLogger logger, SessionContext context)
throws OperationNotPermittedException {
List<Organization> customers = reseller.getCustomersOfReseller();
if (!customers.contains(cust)) {
String message = String.format(
"Organization '%s' is not reseller of customer '%s'",
reseller.getOrganizationId(), cust.getOrganizationId());
OperationNotPermittedException e = new OperationNotPermittedException(
message);
if (logger != null) {
logger.logWarn(Log4jLogger.SYSTEM_LOG, e,
LogMessageIdentifier.WARN_NO_RESELLER_OF_CUSTOMER,
reseller.getOrganizationId(), cust.getOrganizationId());
}
if (context != null) {
context.setRollbackOnly();
}
throw e;
}
}
示例10: same
import javax.ejb.SessionContext; //导入依赖的package包/类
public static void same(Organization org1, Organization org2,
Log4jLogger logger, SessionContext context)
throws OperationNotPermittedException {
if (org1 != org2) {
String message = String
.format("Organization '%s' tried to access organization '%s' but is not allowed to.",
org1.getOrganizationId(), org2.getOrganizationId());
OperationNotPermittedException e = new OperationNotPermittedException(
message);
if (logger != null) {
logger.logWarn(
Log4jLogger.SYSTEM_LOG,
e,
LogMessageIdentifier.WARN_INSUFFICIENT_AUTH_BY_ORGANIZATION_ACCESS,
org1.getOrganizationId(), org2.getOrganizationId());
}
if (context != null) {
context.setRollbackOnly();
}
throw e;
}
}
示例11: setup
import javax.ejb.SessionContext; //导入依赖的package包/类
@Before
public void setup() throws Exception {
opSrvBean = new OperatorServiceBean();
createdOrg = null;
currentUser = new PlatformUser();
currentUser.setLocale("en");
ds = mock(DataService.class);
doReturn(currentUser).when(ds).getCurrentUser();
opSrvBean.dm = ds;
as = mock(AccountServiceLocal.class);
opSrvBean.accMgmt = as;
sctx = mock(SessionContext.class);
opSrvBean.sessionCtx = sctx;
lsl = mock(LocalizerServiceLocal.class);
opSrvBean.localizer = lsl;
}
示例12: setUp
import javax.ejb.SessionContext; //导入依赖的package包/类
@Before
public void setUp() throws Exception {
operatorServiceLocalBean = spy(new OperatorServiceLocalBean());
sessionCtxMock = mock(SessionContext.class);
operatorServiceLocalBean.sessionCtx = sessionCtxMock;
ds = mock(DataService.class);
operatorServiceLocalBean.dm = ds;
getLanguages = mock(Query.class);
getDefaultLanguages = mock(Query.class);
getActiveLanguages = mock(Query.class);
getPlatformEvent = mock(Query.class);
getPlatformParameter = mock(Query.class);
getReportName = mock(Query.class);
getPaymentTypeName = mock(Query.class);
sl1 = getSupportedLanguage(1, "en", true, true);
sl2 = getSupportedLanguage(2, "de", true, false);
slNew = getSupportedLanguage(0, "te", false, false);
doReturn(sl1).when(ds).getReferenceByBusinessKey(sl1);
doReturn(sl2).when(ds).getReferenceByBusinessKey(sl2);
localizer = mock(LocalizerServiceLocal.class);
operatorServiceLocalBean.localizer = localizer;
defaultLanguageISOCodeList = new ArrayList<String>();
}
示例13: setUp
import javax.ejb.SessionContext; //导入依赖的package包/类
@Before
public void setUp() throws Exception {
MockitoAnnotations.initMocks(this);
operatorServiceBean = new OperatorServiceBean();
sessionCtxMock = mock(SessionContext.class);
operatorServiceBean.sessionCtx = sessionCtxMock;
accountServiceMock = mock(AccountServiceLocal.class);
operatorServiceBean.accMgmt = accountServiceMock;
dm = mock(DataService.class);
operatorServiceBean.dm = dm;
LocalizerServiceLocal localizer = mock(LocalizerServiceLocal.class);
operatorServiceBean.localizer = localizer;
marketplaceService = mock(MarketplaceServiceLocal.class);
operatorServiceBean.marketplaceService=marketplaceService;
createOrganization();
createUser();
}
示例14: BusinessObjectHelper
import javax.ejb.SessionContext; //导入依赖的package包/类
/** Creates a new instance of BusinessObjectHelper */
public BusinessObjectHelper(
SessionContext ctx,
UserService userService,
EJBContext context) {
this.ctx = ctx;
this.userService = userService;
this.context = context;
// 05.02..2013, krane, Client application crashes server, when selecting a large collection.
// So for entities in this List, the collections are not initialized to show in rich-client
// TODO: make this customizable or make a client application, which not automatically requests everything
collectionVetoList.add("nirwana");
collectionVetoList.add("shipped");
collectionVetoList.add("shipping");
collectionVetoList.add("versand");
collectionVetoList.add("papierkorb");
collectionVetoList.add("trash");
collectionVetoList.add("goods-in");
collectionVetoList.add("wareneingang");
collectionVetoList.add("goods-out");
collectionVetoList.add("warenausgang");
}
示例15: SecurityInvocationHandler
import javax.ejb.SessionContext; //导入依赖的package包/类
SecurityInvocationHandler(SessionContext sessionContext, Method beanMethod) {
this.sessionContext = sessionContext;
RolesAllowed rolesAllowed = beanMethod
.getAnnotation(RolesAllowed.class);
// a somewhat nasty scenario: a bean is spied using Mockito, so the
// roles allowed annotations have to be retrieved from the superclass...
Class<?> declaringClass = beanMethod.getDeclaringClass();
Class<?> superclass = declaringClass.getSuperclass();
if (declaringClass.getName().contains("Mockito")
&& !superclass.equals(Object.class)) {
try {
Method method = superclass.getMethod(beanMethod.getName(),
beanMethod.getParameterTypes());
rolesAllowed = method.getAnnotation(RolesAllowed.class);
} catch (Exception e) {
e.printStackTrace();
}
}
if (rolesAllowed == null) {
this.rolesAllowed = new String[0];
} else {
this.rolesAllowed = rolesAllowed.value();
}
}