本文整理匯總了Java中org.springframework.context.support.MessageSourceAccessor類的典型用法代碼示例。如果您正苦於以下問題:Java MessageSourceAccessor類的具體用法?Java MessageSourceAccessor怎麽用?Java MessageSourceAccessor使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
MessageSourceAccessor類屬於org.springframework.context.support包,在下文中一共展示了MessageSourceAccessor類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: AuditOAuth2AccessDeniedHandler
import org.springframework.context.support.MessageSourceAccessor; //導入依賴的package包/類
@Autowired
public AuditOAuth2AccessDeniedHandler(
TokenStore tokenStore,
RequestAuditRecordDataService requestAuditRecordDataService,
SecurityEventsLogService securityEventsLogService,
UserContextFactory userContextFactory,
WebResponseExceptionTranslator exceptionTranslator,
AuditLogFactory auditLogFactory,
MessageSourceAccessor messageSourceAccessor
) {
this.userContextFactory = userContextFactory;
this.tokenStore = tokenStore;
this.requestAuditRecordDataService = requestAuditRecordDataService;
this.securityEventsLogService = securityEventsLogService;
this.exceptionTranslator = exceptionTranslator;
this.auditLogFactory = auditLogFactory;
this.messageSourceAccessor = messageSourceAccessor;
}
示例2: referenceData
import org.springframework.context.support.MessageSourceAccessor; //導入依賴的package包/類
@Override
protected Map<String, Object> referenceData(HttpServletRequest request) throws Exception {
Map<String, Object> map = new HashMap<String, Object>();
MessageSourceAccessor msa = getMessageSourceAccessor();
map.put("allowAdmin", ModuleUtil.allowAdmin().toString());
map.put("disallowUploads", msa.getMessage("Module.disallowUploads",
new String[] { ModuleConstants.RUNTIMEPROPERTY_ALLOW_ADMIN }));
map.put("openmrsVersion", OpenmrsConstants.OPENMRS_VERSION_SHORT);
map.put("moduleRepositoryURL", WebConstants.MODULE_REPOSITORY_URL);
map.put("loadedModules", ModuleFactory.getLoadedModules());
return map;
}
示例3: uncaughtException
import org.springframework.context.support.MessageSourceAccessor; //導入依賴的package包/類
public void uncaughtException(Thread thread, Throwable throwable) {
LogFactory.getLog(ApplicationLifecycleAdvisor.class).error(throwable.getMessage(), throwable);
String exceptionMessage;
if (throwable instanceof MessageSourceResolvable) {
exceptionMessage = ((MessageSourceAccessor) ApplicationServicesLocator.services()
.getService(MessageSourceAccessor.class))
.getMessage((MessageSourceResolvable) throwable);
} else {
exceptionMessage = throwable.getLocalizedMessage();
}
if (!StringUtils.hasText(exceptionMessage)) {
String defaultMessage = "An application exception occurred.\nPlease contact your administrator.";
exceptionMessage = ((MessageSourceAccessor) ApplicationServicesLocator.services()
.getService(MessageSourceAccessor.class))
.getMessage("applicationDialog.defaultException", defaultMessage);
}
Message message = new DefaultMessage(exceptionMessage, Severity.ERROR);
ApplicationWindow activeWindow = Application.instance().getActiveWindow();
JFrame parentFrame = (activeWindow == null) ? null : activeWindow.getControl();
JOptionPane.showMessageDialog(parentFrame, message.getMessage(), "Error", JOptionPane.ERROR_MESSAGE);
}
示例4: testGetErrorMessage
import org.springframework.context.support.MessageSourceAccessor; //導入依賴的package包/類
public void testGetErrorMessage() {
DefaultBindingErrorMessageProvider provider = new DefaultBindingErrorMessageProvider();
TestAbstractFormModel formModel = new TestAbstractFormModel(new Object()) {
public FieldFace getFieldFace(String field) {
return new DefaultFieldFace("Some Property", "", "", new LabelInfo("Some Property"), null);
}
};
formModel.add("someProperty", new ValueHolder("value"));
StaticMessageSource messageSource = new StaticMessageSource();
messageSource.addMessage("typeMismatch", Locale.getDefault(), "{0} has an invalid format \"{1}\"");
MessageSourceAccessor messageSourceAccessor = new MessageSourceAccessor(messageSource);
provider.setMessageSourceAccessor(messageSourceAccessor);
ValidationMessage message = provider.getErrorMessage(formModel, "someProperty", "new value",
new IllegalArgumentException());
assertNotNull(message);
assertEquals("someProperty", message.getProperty());
assertEquals("Some Property has an invalid format \"new value\"", message.getMessage());
}
示例5: shouldReturnTheFormattedLocalizedMessage
import org.springframework.context.support.MessageSourceAccessor; //導入依賴的package包/類
@Test
public void shouldReturnTheFormattedLocalizedMessage() {
CurrentLocale locale = new CurrentLocale();
ReloadableResourceBundleMessageSource source = new ReloadableResourceBundleMessageSource();
source.setBasename("test_message");
MessageSourceAccessor accessor = new MessageSourceAccessor(source);
Localizer localizer = new Localizer(accessor, locale);
assertThat(localizer.localize("hello_world"), is("Hello World"));
locale.setLocaleString(Localizer.LOCALE_ENGLISH_US);
assertThat(localizer.localize("MY_HOME", "San Francisco"), is("My home is San Francisco"));
locale.setLocaleString(Localizer.LOCALE_KANNADA);
assertThat(localizer.localize("MY_HOME", "ಬೆಂಗಳೂರು"), is("ನಮ್ಮ ಊರು ಬೆಂಗಳೂರು"));
locale.setLocaleString(Localizer.LOCALE_KANNADA);
assertThat(localizer.localize("MY_BIRTHDAY", new DateTime(1984, 12, 23, 14, 0, 0, 0, DateTimeZone.UTC).toDate()), is("ನನ್ನ ಹುಟ್ಟು ಹಬ್ಬ 12/23/84"));
locale.setLocaleString(Localizer.LOCALE_ENGLISH_US);
assertThat(localizer.localize("MY_BIRTHDAY", new DateTime(1984, 12, 23, 14, 0, 0, 0, DateTimeZone.UTC).toDate()), is("My birthday is 12/23/84"));
}
示例6: HalLinkListSerializer
import org.springframework.context.support.MessageSourceAccessor; //導入依賴的package包/類
public HalLinkListSerializer(BeanProperty property, CurieProvider curieProvider, EmbeddedMapper mapper,
MessageSourceAccessor messageSource) {
super(List.class, false);
this.property = property;
this.curieProvider = curieProvider;
this.mapper = mapper;
this.messageSource = messageSource;
}
示例7: HalHandlerInstantiator
import org.springframework.context.support.MessageSourceAccessor; //導入依賴的package包/類
public HalHandlerInstantiator(RelProvider resolver, CurieProvider curieProvider,
MessageSourceAccessor messageSource, boolean enforceEmbeddedCollections) {
EmbeddedMapper mapper = new EmbeddedMapper(resolver, curieProvider, enforceEmbeddedCollections);
Assert.notNull(resolver, "RelProvider must not be null!");
this.instanceMap.put(HalResourcesSerializer.class, new HalResourcesSerializer(mapper));
this.instanceMap.put(HalLinkListSerializer.class,
new HalLinkListSerializer(curieProvider, mapper, messageSource));
}
示例8: X509AuthenticationFailureHandler
import org.springframework.context.support.MessageSourceAccessor; //導入依賴的package包/類
@Autowired
X509AuthenticationFailureHandler(
MessageSourceAccessor messageSourceAccessor,
ObjectMapper objectMapper
) {
this.objectMapper = objectMapper;
this.messageSourceAccessor = messageSourceAccessor;
}
示例9: AuditOAuth2AuthenticationExceptionHandler
import org.springframework.context.support.MessageSourceAccessor; //導入依賴的package包/類
@Autowired
AuditOAuth2AuthenticationExceptionHandler(
CurrentTimeProvider currentTimeProvider,
AuthFailureAuditRecordDataService authFailureAuditRecordDataService,
MessageSourceAccessor messageSourceAccessor,
AuditLogFactory auditLogFactory
) {
this.currentTimeProvider = currentTimeProvider;
this.authFailureAuditRecordDataService = authFailureAuditRecordDataService;
this.auditLogFactory = auditLogFactory;
this.objectMapper = JsonParserFactory.create();
this.messageSourceAccessor = messageSourceAccessor;
}
開發者ID:cloudfoundry-incubator,項目名稱:credhub,代碼行數:14,代碼來源:AuditOAuth2AuthenticationExceptionHandler.java
示例10: OAuth2ExtraValidationFilter
import org.springframework.context.support.MessageSourceAccessor; //導入依賴的package包/類
@Autowired
OAuth2ExtraValidationFilter(
OAuth2IssuerService oAuth2IssuerService,
TokenStore tokenStore,
AuditOAuth2AuthenticationExceptionHandler oAuth2AuthenticationExceptionHandler,
MessageSourceAccessor messageSourceAccessor,
AuthenticationEventPublisher eventPublisher
) {
this.oAuth2IssuerService = oAuth2IssuerService;
this.tokenStore = tokenStore;
this.oAuth2AuthenticationExceptionHandler = oAuth2AuthenticationExceptionHandler;
this.eventPublisher = eventPublisher;
this.tokenExtractor = new BearerTokenExtractor();
this.messageSourceAccessor = messageSourceAccessor;
}
示例11: onSubmit
import org.springframework.context.support.MessageSourceAccessor; //導入依賴的package包/類
/**
* The onSubmit function receives the form/command object that was modified by the input form
* and saves it to the db
*
* @see org.springframework.web.servlet.mvc.SimpleFormController#onSubmit(javax.servlet.http.HttpServletRequest,
* javax.servlet.http.HttpServletResponse, java.lang.Object,
* org.springframework.validation.BindException)
*/
protected ModelAndView onSubmit(HttpServletRequest request, HttpServletResponse response, Object obj,
BindException errors) throws Exception {
HttpSession httpSession = request.getSession();
String view = getFormView();
if (Context.isAuthenticated()) {
String[] cdList = request.getParameterValues("conceptDatatypeId");
ConceptService cs = Context.getConceptService();
StringBuilder success = new StringBuilder("");
StringBuilder error = new StringBuilder();
MessageSourceAccessor msa = getMessageSourceAccessor();
String deleted = msa.getMessage("general.deleted");
String notDeleted = msa.getMessage("general.cannot.delete");
if (cdList.length != 0) {
log.warn("Deleting concept datatype is not supported");
if (!"".equals(error.toString())) {
error.append("<br/>");
}
error.append("ConceptDatatype").append(" ").append(notDeleted);
}
view = getSuccessView();
if (!"".equals(success.toString())) {
httpSession.setAttribute(WebConstants.OPENMRS_MSG_ATTR, success.toString());
}
if (!"".equals(error.toString())) {
httpSession.setAttribute(WebConstants.OPENMRS_ERROR_ATTR, error.toString());
}
}
return new ModelAndView(new RedirectView(view));
}
示例12: processFormSubmission
import org.springframework.context.support.MessageSourceAccessor; //導入依賴的package包/類
/**
* @see org.springframework.web.servlet.mvc.AbstractFormController#processFormSubmission(javax.servlet.http.HttpServletRequest,
* javax.servlet.http.HttpServletResponse, java.lang.Object,
* org.springframework.validation.BindException)
*/
protected ModelAndView processFormSubmission(HttpServletRequest request, HttpServletResponse response, Object obj,
BindException errors) throws Exception {
if (!Context.isAuthenticated()) {
errors.reject("auth.invalid");
}
if (errors.hasErrors()) {
return showForm(request, response, errors);
}
Person person = (Person) obj;
MessageSourceAccessor msa = getMessageSourceAccessor();
String action = request.getParameter("action");
if (action.equals(msa.getMessage("Person.save"))) {
updatePersonAddresses(request, person, errors);
updatePersonNames(request, person);
updatePersonAttributes(request, errors, person);
}
if (errors.hasErrors()) {
return showForm(request, response, errors);
}
return super.processFormSubmission(request, response, person, errors);
}
示例13: referenceData
import org.springframework.context.support.MessageSourceAccessor; //導入依賴的package包/類
@Override
protected Map<String, String> referenceData(HttpServletRequest request) throws Exception {
Map<String, String> map = new HashMap<String, String>();
MessageSourceAccessor msa = getMessageSourceAccessor();
map.put("allowUpload", ModuleUtil.allowAdmin().toString());
map.put("disallowUploads", msa.getMessage("Module.disallowUploads",
new String[] { ModuleConstants.RUNTIMEPROPERTY_ALLOW_UPLOAD }));
return map;
}
示例14: referenceData
import org.springframework.context.support.MessageSourceAccessor; //導入依賴的package包/類
@SuppressWarnings("unchecked")
@Override
protected Map referenceData(HttpServletRequest request, Object command, Errors errors) throws Exception {
Map<String, Object> map = new HashMap<String, Object>();
Collection<TaskDefinition> tasks = (Collection<TaskDefinition>) command;
Map<TaskDefinition, String> intervals = new HashMap<TaskDefinition, String>();
MessageSourceAccessor msa = getMessageSourceAccessor();
for (TaskDefinition task : tasks) {
Long interval = task.getRepeatInterval();
if (interval < 60) {
intervals.put(task, interval + " " + msa.getMessage("Scheduler.scheduleForm.repeatInterval.units.seconds"));
} else if (interval < 3600) {
intervals.put(task, interval / 60 + " "
+ msa.getMessage("Scheduler.scheduleForm.repeatInterval.units.minutes"));
} else if (interval < 86400) {
intervals.put(task, interval / 3600 + " "
+ msa.getMessage("Scheduler.scheduleForm.repeatInterval.units.hours"));
} else {
intervals.put(task, interval / 86400 + " "
+ msa.getMessage("Scheduler.scheduleForm.repeatInterval.units.days"));
}
}
map.put("intervals", intervals);
return map;
}
示例15: onSubmit
import org.springframework.context.support.MessageSourceAccessor; //導入依賴的package包/類
/**
* The onSubmit function receives the form/command object that was modified by the input form
* and saves it to the db
*
* @see org.springframework.web.servlet.mvc.SimpleFormController#onSubmit(javax.servlet.http.HttpServletRequest,
* javax.servlet.http.HttpServletResponse, java.lang.Object,
* org.springframework.validation.BindException)
*/
protected ModelAndView onSubmit(HttpServletRequest request, HttpServletResponse response, Object obj,
BindException errors) throws Exception {
HttpSession httpSession = request.getSession();
Locale locale = Context.getLocale();
if (Context.isAuthenticated()) {
AlertService as = Context.getAlertService();
MessageSourceAccessor msa = getMessageSourceAccessor();
String msg = "";
// expire the selected alerts
String[] alertIds = request.getParameterValues("alertId");
if (alertIds != null) {
for (String alertIdString : alertIds) {
Integer alertId = Integer.parseInt(alertIdString);
Alert a = as.getAlert(alertId);
a.setDateToExpire(new Date());
as.saveAlert(a);
}
msg = msa.getMessage("Alert.expired", new Object[] { alertIds.length }, locale);
} else {
msg = msa.getMessage("Alert.select");
}
httpSession.setAttribute(WebConstants.OPENMRS_MSG_ATTR, msg);
return new ModelAndView(new RedirectView(getSuccessView()));
}
// The user isn't authenticated or their session has expired
return showForm(request, response, errors);
}