當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。