Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Missing scopes #53

Merged
merged 16 commits into from
Sep 5, 2013
Merged
Show file tree
Hide file tree
Changes from 13 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,7 @@ InstanceCreator.class, getInstanceCreator(),
FlashScope.class, SessionFlashScope.class,
XStreamConverters.class, XStreamConverters.class,
MessageConverter.class, MessageConverter.class,
ParameterIncluderInterceptor.class, ParameterIncluderInterceptor.class
ParameterIncluderInterceptor.class, ParameterIncluderInterceptor.class
);

@SuppressWarnings({"unchecked", "rawtypes"})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,11 @@
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;

@javax.enterprise.inject.Stereotype
import javax.enterprise.context.RequestScoped;
import javax.enterprise.inject.Stereotype;

@RequestScoped
@Stereotype
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I figured that all Deserializer should be request scoped... am I right?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not really... There is no restriction for this...

If someone adds @RequestScope and another scope, what does it happen?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sorry, I've not explained right =) I was talking about default option, if client want
use session or any another scope, he just need annotate his class to override it.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok then ;)

@Documented
@Target(ElementType.TYPE)
@Retention(RetentionPolicy.RUNTIME)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import java.io.InputStream;
import java.lang.reflect.Method;

import javax.enterprise.context.RequestScoped;
import javax.inject.Inject;

import br.com.caelum.vraptor4.controller.ControllerMethod;
Expand All @@ -34,17 +35,21 @@
* @author Rafael Viana
* @since 3.0.2
*/
@RequestScoped
public class XStreamXMLDeserializer implements XMLDeserializer {

private final ParameterNameProvider provider;
private final XStreamBuilder builder;
private ParameterNameProvider provider;
private XStreamBuilder builder;

@Deprecated // CDI eyes only
public XStreamXMLDeserializer() {}

@Inject
public XStreamXMLDeserializer(ParameterNameProvider provider, XStreamBuilder builder) {
this.provider = provider;
this.builder = builder;
}

public Object[] deserialize(InputStream inputStream, ControllerMethod method) {
Method javaMethod = method.getMethod();
Class<?>[] types = javaMethod.getParameterTypes();
Expand All @@ -54,7 +59,7 @@ public Object[] deserialize(InputStream inputStream, ControllerMethod method) {
XStream xStream = getConfiguredXStream(javaMethod, types);

Object[] params = new Object[types.length];

chooseParam(types, params, xStream.fromXML(inputStream));

return params;
Expand All @@ -65,9 +70,9 @@ public Object[] deserialize(InputStream inputStream, ControllerMethod method) {
*/
public XStream getConfiguredXStream(Method javaMethod, Class<?>[] types) {
XStream xStream = getXStream();

xStream.processAnnotations(types);

aliasParams(javaMethod, types, xStream);
return xStream;
}
Expand Down Expand Up @@ -96,5 +101,5 @@ private void aliasParams(Method method, Class<?>[] types, XStream deserializer)
protected XStream getXStream() {
return builder.xmlInstance();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
*/
package br.com.caelum.vraptor4.http;

import javax.enterprise.context.RequestScoped;
import javax.inject.Inject;
import javax.servlet.http.HttpServletRequest;

Expand All @@ -28,17 +29,21 @@
* @author Jose Donizetti
* @since 3.0.3
*/
@RequestScoped
public class DefaultFormatResolver implements FormatResolver {

private final HttpServletRequest request;
private final AcceptHeaderToFormat acceptHeaderToFormat;
private HttpServletRequest request;
private AcceptHeaderToFormat acceptHeaderToFormat;

@Deprecated // CDI eyes only
public DefaultFormatResolver() {}

@Inject
public DefaultFormatResolver(HttpServletRequest request, AcceptHeaderToFormat acceptHeaderToFormat) {
this.request = request;
this.acceptHeaderToFormat = acceptHeaderToFormat;
}

public String getAcceptFormat() {
String format = request.getParameter("_format");
if (format != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import java.util.Arrays;
import java.util.List;

import javax.enterprise.context.RequestScoped;
import javax.inject.Inject;

import br.com.caelum.vraptor4.http.ParameterNameProvider;
Expand All @@ -32,8 +33,13 @@
* @since
*
*/
@RequestScoped
public class VRaptorParameterNamesProvider implements br.com.caelum.iogi.spi.ParameterNamesProvider {
private final ParameterNameProvider parameterNameProvider;

private ParameterNameProvider parameterNameProvider;

@Deprecated // CDI eyes only
public VRaptorParameterNamesProvider() {}

@Inject
public VRaptorParameterNamesProvider(ParameterNameProvider parameterNameProvider) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
*/
package br.com.caelum.vraptor4.interceptor;

import javax.enterprise.context.RequestScoped;
import javax.inject.Inject;

import org.slf4j.Logger;
Expand Down Expand Up @@ -46,6 +47,7 @@
* @since 3.2
*/
@Intercepts
@RequestScoped
public class ExceptionHandlerInterceptor
implements Interceptor {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
import java.io.InputStream;
import java.io.OutputStream;

import javax.enterprise.context.RequestScoped;
import javax.inject.Inject;
import javax.servlet.http.HttpServletResponse;

Expand All @@ -45,7 +44,6 @@
* @author filipesabella
*/
@Intercepts(after=ExecuteMethodInterceptor.class, before=ForwardToDefaultViewInterceptor.class)
@RequestScoped
public class DownloadInterceptor implements Interceptor {

private static final Logger logger = LoggerFactory.getLogger(DownloadInterceptor.class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@

package br.com.caelum.vraptor4.interceptor.multipart;

import javax.enterprise.context.RequestScoped;

import org.apache.commons.fileupload.FileItemFactory;
import org.apache.commons.fileupload.servlet.ServletFileUpload;

Expand All @@ -26,6 +28,7 @@
*
* @author Otávio Scherer Garcia
*/
@RequestScoped
public class DefaultServletFileUploadCreator
implements ServletFileUploadCreator {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
*/
package br.com.caelum.vraptor4.interceptor.multipart;

import javax.enterprise.context.RequestScoped;

import br.com.caelum.vraptor4.InterceptionException;
import br.com.caelum.vraptor4.controller.ControllerMethod;
import br.com.caelum.vraptor4.core.InterceptorStack;
Expand All @@ -27,6 +29,7 @@
* @since 3.1.3
* @see CommonsUploadMultipartInterceptor
*/
@RequestScoped
public class NullMultipartInterceptor implements MultipartInterceptor {

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

import java.util.Calendar;

import javax.enterprise.context.RequestScoped;
import javax.inject.Inject;
import javax.servlet.http.HttpServletResponse;

Expand All @@ -27,17 +28,21 @@
import br.com.caelum.vraptor4.restfulie.resource.Cacheable;
import br.com.caelum.vraptor4.restfulie.resource.RestfulEntity;

@RequestScoped
public class DefaultRestHeadersHandler implements RestHeadersHandler {

private final HttpServletResponse response;
private final RestDefaults defaults;
private HttpServletResponse response;
private RestDefaults defaults;

@Deprecated // CDI eyes only
public DefaultRestHeadersHandler() {}

@Inject
public DefaultRestHeadersHandler(HttpServletResponse response, RestDefaults defaults) {
this.defaults = defaults;
this.response = response;
}

public void handle(HypermediaResource resource) {
// TODO implement link headers
if(Cacheable.class.isAssignableFrom(resource.getClass())) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import java.util.Collections;
import java.util.List;

import javax.enterprise.context.RequestScoped;
import javax.inject.Inject;

import br.com.caelum.vraptor4.Result;
Expand All @@ -34,21 +35,25 @@
* @author Jose Donizetti
* @since 3.0.3
*/
@RequestScoped
public class DefaultRepresentationResult implements RepresentationResult {

private final FormatResolver formatResolver;
private final List<Serialization> serializations;
private final Result result;
private final RestHeadersHandler headersHandler;

private FormatResolver formatResolver;
private List<Serialization> serializations;
private Result result;
private RestHeadersHandler headersHandler;

@Deprecated // CDI eyes only
public DefaultRepresentationResult() {}

@Inject
public DefaultRepresentationResult(FormatResolver formatResolver, Result result, List<Serialization> serializations, RestHeadersHandler headersHandler) {
this.formatResolver = formatResolver;
this.result = result;
this.serializations = serializations;
this.headersHandler = headersHandler;
}
}

public <T> Serializer from(T object) {
return from(object, null);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
/***
* Copyright (c) 2009 Caelum - www.caelum.com.br/opensource All rights reserved.
*
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
*
* http://www.apache.org/licenses/LICENSE-2.0
*
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
Expand All @@ -17,6 +17,7 @@

import static br.com.caelum.vraptor4.view.Results.page;

import javax.enterprise.context.RequestScoped;
import javax.inject.Inject;

import br.com.caelum.vraptor4.Result;
Expand All @@ -27,6 +28,7 @@
* @author Lucas Cavalcanti
* @since 3.1.3
*/
@RequestScoped
public class HTMLSerialization implements Serialization {

private Result result;
Expand All @@ -36,13 +38,13 @@ public class HTMLSerialization implements Serialization {
@Deprecated
public HTMLSerialization() {
}

@Inject
public HTMLSerialization(Result result, TypeNameExtractor extractor) {
this.result = result;
this.extractor = extractor;
}

@Override
public boolean accepts(String format) {
return "html".equals(format);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@

package br.com.caelum.vraptor4.serialization;

import javax.enterprise.context.RequestScoped;

import br.com.caelum.vraptor4.View;
import br.com.caelum.vraptor4.core.Localization;
import br.com.caelum.vraptor4.ioc.Container;
Expand All @@ -28,12 +30,13 @@
* @author Leonardo Wolter
* @since 3.5
*/
@RequestScoped
public class I18nMessageSerialization implements View{

private Localization localization;
private Container container;
private I18nMessage i18nMessage;

//CDI eyes only
@Deprecated
public I18nMessageSerialization() {
Expand All @@ -50,7 +53,7 @@ public I18nMessageSerialization from(String category, String key, Object...param
this.i18nMessage = i18nMessage;
return this;
}

public void as(Class<? extends Serialization> method){
Serialization serialization = container.instanceFor(method);
serialization.from(i18nMessage, "message").serialize();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import java.util.Arrays;
import java.util.Collections;

import javax.enterprise.context.Dependent;
import javax.inject.Inject;

import br.com.caelum.vraptor4.interceptor.DefaultTypeNameExtractor;
Expand All @@ -38,6 +39,7 @@
* @author Rafael Viana
* @since 3.4.0
*/
@Dependent
@Deprecated
public class XStreamBuilderImpl implements XStreamBuilder {

Expand Down
Loading