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


Java Controller类代码示例

本文整理汇总了Java中org.springframework.stereotype.Controller的典型用法代码示例。如果您正苦于以下问题:Java Controller类的具体用法?Java Controller怎么用?Java Controller使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


Controller类属于org.springframework.stereotype包,在下文中一共展示了Controller类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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;
}
 
开发者ID:heisedebaise,项目名称:tephra,代码行数:20,代码来源:ClassReloaderImpl.java

示例2: start

import org.springframework.stereotype.Controller; //导入依赖的package包/类
public void start() {

		ResteasyDeployment dp = new ResteasyDeployment();

		Collection<Object> providers = ac.getBeansWithAnnotation(Provider.class).values();
		Collection<Object> controllers = ac.getBeansWithAnnotation(Controller.class).values();

		Assert.notEmpty(controllers);

		// extract providers
		if (providers != null) {
			dp.getProviders().addAll(providers);
		}
		// extract only controller annotated beans
		dp.getResources().addAll(controllers);
		
        netty = new NettyJaxrsServer();
		netty.setDeployment(dp);
        netty.setIoWorkerCount(ioWorkerCount);
        netty.setExecutorThreadCount(executorThreadCount);
		netty.setPort(port);
        netty.setRootResourcePath(rootResourcePath);
		netty.setSecurityDomain(null);
		netty.start();
        LOGGER.info("rest-netty-server started , port {}", port);
	}
 
开发者ID:netboynb,项目名称:coco,代码行数:27,代码来源:CocoRestServer.java

示例3: populateTriggerVOs

import org.springframework.stereotype.Controller; //导入依赖的package包/类
private void populateTriggerVOs() throws ClassNotFoundException {
    ClassPathScanningCandidateComponentProvider scanner = new ClassPathScanningCandidateComponentProvider(true);
    scanner.addIncludeFilter(new AnnotationTypeFilter(TriggerIndex.class));
    scanner.addExcludeFilter(new AnnotationTypeFilter(Controller.class));
    for (String pkg : getBasePkgNames()) {
        for (BeanDefinition bd : scanner.findCandidateComponents(pkg)) {
            Class<?> triggerVO = Class.forName(bd.getBeanClassName());
            if (!triggerVO.isAnnotationPresent(Entity.class)) {
                throw new IllegalArgumentException(String.format("Class[%s] is annotated by @TriggerIndex, but not annotated by @Entity",
                        triggerVO.getName()));
            }
            triggerVOs.add(triggerVO);
            popluateTriggerVONamesCascade(triggerVO);
        }
    }
}
 
开发者ID:zstackio,项目名称:zstack,代码行数:17,代码来源:InventoryIndexManagerImpl.java

示例4: generateApiMessageGroovyClass

import org.springframework.stereotype.Controller; //导入依赖的package包/类
private void generateApiMessageGroovyClass(StringBuilder sb, List<String> basePkgs) {
    ClassPathScanningCandidateComponentProvider scanner = new ClassPathScanningCandidateComponentProvider(true);
    scanner.addIncludeFilter(new AssignableTypeFilter(APIMessage.class));
    scanner.addIncludeFilter(new AssignableTypeFilter(APIReply.class));
    scanner.addIncludeFilter(new AssignableTypeFilter(APIEvent.class));
    scanner.addExcludeFilter(new AnnotationTypeFilter(Controller.class));
    scanner.addExcludeFilter(new AnnotationTypeFilter(Component.class));
    for (String pkg : basePkgs) {
        for (BeanDefinition bd : scanner.findCandidateComponents(pkg)) {
            try {
                Class<?> clazz = Class.forName(bd.getBeanClassName());
                //classToApiMessageGroovyClass(sb, clazz);
                classToApiMessageGroovyInformation(sb, clazz);
            } catch (ClassNotFoundException e) {
                logger.warn(String.format("Unable to generate groovy class for %s", bd.getBeanClassName()), e);
            }
        }
    }
}
 
开发者ID:zstackio,项目名称:zstack,代码行数:20,代码来源:ConfigurationManagerImpl.java

示例5: scanDeployer

import org.springframework.stereotype.Controller; //导入依赖的package包/类
private void scanDeployer() {
    ClassPathScanningCandidateComponentProvider scanner = new ClassPathScanningCandidateComponentProvider(true);
    scanner.addIncludeFilter(new AssignableTypeFilter(AbstractDeployer.class));
    scanner.addExcludeFilter(new AnnotationTypeFilter(Controller.class));
    scanner.addExcludeFilter(new AnnotationTypeFilter(org.springframework.stereotype.Component.class));
    for (BeanDefinition bd : scanner.findCandidateComponents("org.zstack.test")) {
        try {
            Class<?> clazz = Class.forName(bd.getBeanClassName());
            AbstractDeployer d = (AbstractDeployer) clazz.newInstance();
            deployers.put(d.getSupportedDeployerClassType(), d);
            logger.debug(String.format("Scanned a deployer[%s] supporting %s", d.getClass().getName(), d.getSupportedDeployerClassType()));
        } catch (Exception e) {
            logger.warn(String.format("unable to create deployer[%s], it's probably there are some beans requried by deployer is not loaded, skip it. error message:\n%s", bd.getBeanClassName(), e.getMessage()));
        }

    }
}
 
开发者ID:zstackio,项目名称:zstack,代码行数:18,代码来源:Deployer.java

示例6: start

import org.springframework.stereotype.Controller; //导入依赖的package包/类
@Override
public boolean start() {
    try {
        ClassPathScanningCandidateComponentProvider scanner = new ClassPathScanningCandidateComponentProvider(true);
        scanner.addIncludeFilter(new AnnotationTypeFilter(Inventory.class));
        scanner.addExcludeFilter(new AnnotationTypeFilter(Controller.class));
        scanner.addExcludeFilter(new AnnotationTypeFilter(org.springframework.stereotype.Component.class));
        for (String pkg : getBasePkgNames()) {
            for (BeanDefinition bd : scanner.findCandidateComponents(pkg)) {
                Class<?> inventoryClass = Class.forName(bd.getBeanClassName());
                Inventory invat = inventoryClass.getAnnotation(Inventory.class);
                Info info = new Info();
                info.inventory = invat;
                info.inventoryClass = inventoryClass;
                inventoryMapping.put(invat.mappingVOClass(), info);
            }
        }
    } catch (Exception e) {
        throw new CloudRuntimeException(e);
    }
    return true;
}
 
开发者ID:zstackio,项目名称:zstack,代码行数:23,代码来源:InventoryFacadeImpl.java

示例7: Controller

import org.springframework.stereotype.Controller; //导入依赖的package包/类
@RequestMapping("/ConventerServlet")
@ResponseBody
String Controller(@RequestParam("jsonData") JSONObject data) {
    JSONObject sendObject = new JSONObject();
    String requestValue = "";


    try {
        requestValue = data.getString("operationCall");
    } catch (JSONException e) {
        e.printStackTrace();
    }

    sendObject = setNewRateToJsonObject(requestValue);


    return sendObject.toString();
}
 
开发者ID:Partizanin,项目名称:cashconverter,代码行数:19,代码来源:Main.java

示例8: execute

import org.springframework.stereotype.Controller; //导入依赖的package包/类
public void execute() throws MojoExecutionException, MojoFailureException {
    try {
        outputtFolder = new File(new File(sourceDocFolder), "restapi");
        outputtFolder.mkdirs();
        setupClasspath();
        setupHandlerbars();

        reflections = new Reflections(packageName);
        apiDescriptionsFinder = new ApiDescriptionFinder();
        Set<Class<?>> controllers = reflections.getTypesAnnotatedWith(Controller.class);
        for (Class<?> controller : controllers) {
            getLog().info("Found Controller: " + controller.getName());
            processRestApiController(controller);
        }

        fillModelFields();

        SortedSet<ApiObjectDoc> sortedObjects = new TreeSet<ApiObjectDoc>(modelObjects);
        generateFile(sortedObjects, "api_models", "models");
    }
    catch (Exception e) {
        throw new MojoExecutionException("Failed", e);
    }
}
 
开发者ID:mvb-online,项目名称:restapi-doc,代码行数:25,代码来源:RestApiDocGeneratorMojo.java

示例9: 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());
}
 
开发者ID:mygreen,项目名称:super-csv-annotation,代码行数:26,代码来源:SpringBeanFactory.java

示例10: process

import org.springframework.stereotype.Controller; //导入依赖的package包/类
@Override
public void process(RoundEnvironment roundEnv) {
    Set<TypeElement> annotatedTypes = ElementFilter.typesIn(roundEnv.getElementsAnnotatedWith(
            annotationType()));
    Iterable<TypeElement> controllerTypes = filterByAnnotation(
            annotatedTypes,
            Controller.class
    );

    for (TypeElement controller : controllerTypes) {
        Iterable<ExecutableElement> requestMethods = filterByAnnotation(
                ElementFilter.methodsIn(controller.getEnclosedElements()),
                RequestMapping.class
        );
        processTypeAndMethods(controller, requestMethods);
    }
}
 
开发者ID:atlasapi,项目名称:atlas-deer,代码行数:18,代码来源:ControllerAnnotationProcessor.java

示例11: getSpringClassAnnotation

import org.springframework.stereotype.Controller; //导入依赖的package包/类
private Annotation getSpringClassAnnotation(Class clazz) {
    Annotation classAnnotation = AnnotationUtils.findAnnotation(clazz, Component.class);

    if (classAnnotation == null) {
        classAnnotation = AnnotationUtils.findAnnotation(clazz, Controller.class);
    }
    if (classAnnotation == null) {
        classAnnotation = AnnotationUtils.findAnnotation(clazz, RestController.class);
    }
    if (classAnnotation == null) {
        classAnnotation = AnnotationUtils.findAnnotation(clazz, Service.class);
    }
    if (classAnnotation == null) {
        classAnnotation = AnnotationUtils.findAnnotation(clazz, Repository.class);
    }

    return classAnnotation;
}
 
开发者ID:exteso,项目名称:parkingfriends,代码行数:19,代码来源:SpringReloader.java

示例12: determineUrlsByAnnotations

import org.springframework.stereotype.Controller; //导入依赖的package包/类
protected String[] determineUrlsByAnnotations(Object handler) {
    Class<? extends Object> handlerType = handler.getClass();
    RequestMapping mapping = AnnotationUtils.findAnnotation(handlerType, RequestMapping.class);

    if (mapping != null) {
        // @RequestMapping found at type level
        this.cachedMappings.put(handlerType, mapping);
        Set<String> urls = new LinkedHashSet<String>();
        String[] paths = mapping.value();
        if (paths.length > 0) {
            // @RequestMapping specifies paths at type level
            for (String path : paths) {
                addUrlsForPath(urls, path);
            }
            return StringUtils.toStringArray(urls);
        } else {
            // actual paths specified by @RequestMapping at method level
            return determineUrlsForHandlerMethods(handlerType);
        }
    } else if (AnnotationUtils.findAnnotation(handlerType, Controller.class) != null) {
        // @RequestMapping to be introspected at method level
        return determineUrlsForHandlerMethods(handlerType);
    } else {
        return null;
    }
}
 
开发者ID:jirutka,项目名称:spring-modular,代码行数:27,代码来源:ContextParentAnnotationHandlerMapping.java

示例13: init

import org.springframework.stereotype.Controller; //导入依赖的package包/类
private void init(ApplicationContext context) {
	init();
	LOGGER.debug("Get All ExceptionHandlers");
	List<Object> exceptionsHandlers = ReflectionUtils
			.proxyToObject(context.getBeansWithAnnotation(ControllerAdvice.class).values());
	LOGGER.debug("Get All RestController");
	exceptionsHandlers.forEach(this::buildHttpCodes);
	controllers
			.addAll(ReflectionUtils.proxyToObject(context.getBeansWithAnnotation(RestController.class).values()));
	LOGGER.debug("Get All Controller");
	controllers.addAll(ReflectionUtils.proxyToObject(context.getBeansWithAnnotation(Controller.class).values()));
}
 
开发者ID:damianwajser,项目名称:spring-rest-commons-options,代码行数:13,代码来源:ResourcesBuilder.java

示例14: 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;
}
 
开发者ID:worldiety,项目名称:homunculus,代码行数:16,代码来源:SPRComponentController.java

示例15: isJson

import org.springframework.stereotype.Controller; //导入依赖的package包/类
/**
 * 判断整个类里的所有接口是否都返回json
 *
 * @param classz
 * @return
 */
protected boolean isJson(Class<?> classz) {
    Controller controllerAnno = classz.getAnnotation(Controller.class);
    RestController restControllerAnno = classz.getAnnotation(RestController.class);
    ResponseBody responseBody = classz.getAnnotation(ResponseBody.class);

    if (responseBody != null) {
        return true;
    } else if (controllerAnno != null) {
        return false;
    } else if (restControllerAnno != null) {
        return true;
    }
    return false;
}
 
开发者ID:treeleafj,项目名称:xDoc,代码行数:21,代码来源:SpringXDocOutputImpl.java


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