本文整理汇总了Java中org.springframework.stereotype.Controller.value方法的典型用法代码示例。如果您正苦于以下问题:Java Controller.value方法的具体用法?Java Controller.value怎么用?Java Controller.value使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.springframework.stereotype.Controller
的用法示例。
在下文中一共展示了Controller.value方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getBeanName
import org.springframework.stereotype.Controller; //导入方法依赖的package包/类
private String getBeanName(Class<?> clazz) {
Component component = clazz.getAnnotation(Component.class);
if (component != null)
return component.value();
Repository repository = clazz.getAnnotation(Repository.class);
if (repository != null)
return repository.value();
Service service = clazz.getAnnotation(Service.class);
if (service != null)
return service.value();
Controller controller = clazz.getAnnotation(Controller.class);
if (controller != null)
return controller.value();
return null;
}
示例2: getBeanName
import org.springframework.stereotype.Controller; //导入方法依赖的package包/类
private String getBeanName(final Class<?> clazz) {
final Component componentAnno = clazz.getAnnotation(Component.class);
if(componentAnno != null && !componentAnno.value().isEmpty()) {
return componentAnno.value();
}
final Service serviceAnno = clazz.getAnnotation(Service.class);
if(serviceAnno != null && !serviceAnno.value().isEmpty()) {
return serviceAnno.value();
}
final Repository repositoryAnno = clazz.getAnnotation(Repository.class);
if(repositoryAnno != null && !repositoryAnno.value().isEmpty()) {
return repositoryAnno.value();
}
final Controller controllerAnno = clazz.getAnnotation(Controller.class);
if(controllerAnno != null && !controllerAnno.value().isEmpty()) {
return controllerAnno.value();
}
// ステレオタイプのアノテーションでBean名の指定がない場合は、クラス名の先頭を小文字にした名称とする。
return uncapitalize(clazz.getSimpleName());
}
示例3: process
import org.springframework.stereotype.Controller; //导入方法依赖的package包/类
@Nullable
@Override
public <T> AnnotatedComponent<T> process(Scope scope, Class<T> clazz) {
Controller controller = clazz.getAnnotation(Controller.class);
if (controller != null) {
return new AnnotatedComponent(clazz, controller.value(), ComponentType.CONTROLLER);
}
Service service = clazz.getAnnotation(Service.class);
if (service != null) {
return new AnnotatedComponent(clazz, service.value(), ComponentType.CONTROLLER);
}
return null;
}
示例4: getActionName
import org.springframework.stereotype.Controller; //导入方法依赖的package包/类
protected String getActionName(){
String action=this.getClass().getSimpleName();
Controller ac=this.getClass().getAnnotation(Controller.class);
if(ac!=null){
action=ac.value();
if(action.lastIndexOf("Action")>0)action=action.substring(0,action.lastIndexOf("Action"));
}
return action;
}
示例5: updateContext
import org.springframework.stereotype.Controller; //导入方法依赖的package包/类
public void updateContext(Collection<Class> classes) {
if (beanFactory != null) {
boolean needToRefreshRemotingContext = false;
for (Class clazz : classes) {
Service serviceAnnotation = (Service) clazz.getAnnotation(Service.class);
ManagedBean managedBeanAnnotation = (ManagedBean) clazz.getAnnotation(ManagedBean.class);
Component componentAnnotation = (Component) clazz.getAnnotation(Component.class);
Controller controllerAnnotation = (Controller) clazz.getAnnotation(Controller.class);
String beanName = null;
if (serviceAnnotation != null) {
beanName = serviceAnnotation.value();
} else if (managedBeanAnnotation != null) {
beanName = managedBeanAnnotation.value();
} else if (componentAnnotation != null) {
beanName = componentAnnotation.value();
} else if (controllerAnnotation != null) {
beanName = controllerAnnotation.value();
}
if (StringUtils.isNotBlank(beanName)) {
GenericBeanDefinition beanDefinition = new GenericBeanDefinition();
beanDefinition.setBeanClass(clazz);
Scope scope = (Scope) clazz.getAnnotation(Scope.class);
if (scope != null) {
beanDefinition.setScope(scope.value());
}
beanFactory.registerBeanDefinition(beanName, beanDefinition);
}
if (StringUtils.isNotBlank(beanName)) {
needToRefreshRemotingContext = true;
}
}
if (needToRefreshRemotingContext) {
ApplicationContext remotingContext = RemotingContextHolder.getRemotingApplicationContext();
if (remotingContext != null && remotingContext instanceof ConfigurableApplicationContext) {
((ConfigurableApplicationContext) remotingContext).refresh();
}
}
}
}
示例6: getHttpMethodAndName
import org.springframework.stereotype.Controller; //导入方法依赖的package包/类
@Override
protected Map<RamlActionType, String> getHttpMethodAndName(Class<?> clazz, Method method) {
RequestMapping methodMapping = getRequestMapping(method);
RequestMapping classMapping = getAnnotation(clazz, RequestMapping.class, false);
RestController classRestController = getAnnotation(clazz, RestController.class, false);
Controller classController = getAnnotation(method.getDeclaringClass(), Controller.class, false);
RequestMethod[] verbs = methodMapping.method();
if (verbs == null || verbs.length == 0) {
verbs = RequestMethod.values();
}
String name = "";
if (classMapping != null && classMapping.value() != null && classMapping.value().length > 0) {
name += NamingHelper.resolveProperties(classMapping.value()[0]);
}
if (classRestController != null && classRestController.value() != null) {
name += NamingHelper.resolveProperties(classRestController.value());
}
if (classController != null && classController.value() != null) {
name += NamingHelper.resolveProperties(classController.value());
}
if (methodMapping.value() != null && methodMapping.value().length > 0) {
if (name.endsWith("/") && methodMapping.value()[0].startsWith("/")) {
name = name.substring(0, name.length() - 1);
} else if (name != "" && !name.endsWith("/") && !methodMapping.value()[0].startsWith("/")) {
name += "/";
}
name += NamingHelper.resolveProperties(methodMapping.value()[0]);
}
Map<RamlActionType, String> outMap = new HashMap<>();
for (RequestMethod rm : verbs) {
try {
RamlActionType apiAction = RamlActionType.valueOf(rm.name());
outMap.put(apiAction, name);
} catch (Exception ex) {
// skip verb not supported by RAML
logger.warn("Skipping unknown verb " + rm);
}
}
return outMap;// TODO sort value out
}