[webbeans-commits] Webbeans SVN: r2673 - extensions/trunk/servlet/int/src/main/resources/META-INF.
by webbeans-commits@lists.jboss.org
Author: dan.j.allen
Date: 2009-05-08 01:54:32 -0400 (Fri, 08 May 2009)
New Revision: 2673
Modified:
extensions/trunk/servlet/int/src/main/resources/META-INF/faces-config.xml
Log:
WBRI-257
WBRI-258
Modified: extensions/trunk/servlet/int/src/main/resources/META-INF/faces-config.xml
===================================================================
--- extensions/trunk/servlet/int/src/main/resources/META-INF/faces-config.xml 2009-05-08 05:54:08 UTC (rev 2672)
+++ extensions/trunk/servlet/int/src/main/resources/META-INF/faces-config.xml 2009-05-08 05:54:32 UTC (rev 2673)
@@ -6,6 +6,7 @@
<application>
<el-resolver>org.jboss.webbeans.el.WebBeansELResolver</el-resolver>
+ <view-handler>org.jboss.webbeans.jsf.ConversationAwareViewHandler</view-handler>
</application>
<lifecycle>
<phase-listener>org.jboss.webbeans.jsf.WebBeansPhaseListener</phase-listener>
15 years, 6 months
[webbeans-commits] Webbeans SVN: r2672 - in ri/trunk/impl/src/main/java/org/jboss/webbeans: servlet and 1 other directory.
by webbeans-commits@lists.jboss.org
Author: dan.j.allen
Date: 2009-05-08 01:54:08 -0400 (Fri, 08 May 2009)
New Revision: 2672
Added:
ri/trunk/impl/src/main/java/org/jboss/webbeans/jsf/ConversationAwareViewHandler.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/jsf/FacesUrlTransformer.java
Modified:
ri/trunk/impl/src/main/java/org/jboss/webbeans/jsf/JsfApiAbstraction.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/jsf/PhaseHelper.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/jsf/WebBeansPhaseListener.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/servlet/ConversationPropagationFilter.java
Log:
WBRI-257
WBRI-258
Added: ri/trunk/impl/src/main/java/org/jboss/webbeans/jsf/ConversationAwareViewHandler.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/jsf/ConversationAwareViewHandler.java (rev 0)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/jsf/ConversationAwareViewHandler.java 2009-05-08 05:54:08 UTC (rev 2672)
@@ -0,0 +1,73 @@
+package org.jboss.webbeans.jsf;
+
+import javax.context.Conversation;
+import javax.faces.application.ViewHandler;
+import javax.faces.application.ViewHandlerWrapper;
+import javax.faces.context.FacesContext;
+import javax.inject.manager.Manager;
+
+import org.jboss.webbeans.CurrentManager;
+
+/**
+ * <p>
+ * A forwarding JSF ViewHandler implementation that produces URLs containing the
+ * conversation id query string parameter. All methods except those which
+ * produce a URL that need to be enhanced are forwarded to the ViewHandler
+ * delegate.
+ * </p>
+ *
+ * <p>
+ * A request parameter was choosen to propagate the conversation because it's
+ * the most technology agnostic approach for passing data between requests and
+ * allows for the ensuing request to use whatever means necessary (a servlet
+ * filter, phase listener, etc) to capture the conversation id and restore the
+ * long-running conversation.
+ * </p>
+ * QUESTION should we do the same for getResourceURL?
+ * TODO we should enable a way to disable conversation propagation by URL
+ *
+ * @author Dan Allen
+ */
+public class ConversationAwareViewHandler extends ViewHandlerWrapper
+{
+ private ViewHandler delegate;
+
+ public ConversationAwareViewHandler(ViewHandler delegate)
+ {
+ this.delegate = delegate;
+ }
+
+ /**
+ * Allow the delegate to produce the action URL. If the conversation is
+ * long-running, append the conversation id request parameter to the query
+ * string part of the URL, but only if the request parameter is not already
+ * present.
+ *
+ * @see {@link ViewHandler#getActionURL(FacesContext, String)}
+ */
+ @Override
+ public String getActionURL(FacesContext context, String viewId)
+ {
+ String actionUrl = super.getActionURL(context, viewId);
+ Manager manager = CurrentManager.rootManager();
+ Conversation conversation = manager.getInstanceByType(Conversation.class);
+ if (conversation.isLongRunning())
+ {
+ return new FacesUrlTransformer(actionUrl).appendConversationIdIfNecessary(conversation.getId()).getUrl();
+ }
+ else
+ {
+ return actionUrl;
+ }
+ }
+
+ /**
+ * @see {@link ViewHandlerWrapper#getWrapped()}
+ */
+ @Override
+ public ViewHandler getWrapped()
+ {
+ return delegate;
+ }
+
+}
Added: ri/trunk/impl/src/main/java/org/jboss/webbeans/jsf/FacesUrlTransformer.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/jsf/FacesUrlTransformer.java (rev 0)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/jsf/FacesUrlTransformer.java 2009-05-08 05:54:08 UTC (rev 2672)
@@ -0,0 +1,95 @@
+package org.jboss.webbeans.jsf;
+
+import javax.faces.context.FacesContext;
+import javax.inject.AnnotationLiteral;
+
+import org.jboss.webbeans.CurrentManager;
+import org.jboss.webbeans.conversation.ConversationIdName;
+
+/**
+ * Helper class for preparing JSF URLs which include the conversation id.
+ *
+ * TODO This class has the potential to be better designed to make it fit more use cases.
+ *
+ * @author Nicklas Karlsson
+ * @author Dan Allen
+ */
+public class FacesUrlTransformer
+{
+ private static final String HTTP_PROTOCOL_URL_PREFIX = "http://";
+ private static final String HTTPS_PROTOCOL_URL_PREFIX = "https://";
+ private static final String QUERY_STRING_DELIMITER = "?";
+ private static final String PARAMETER_PAIR_DELIMITER = "&";
+ private static final String PARAMETER_ASSIGNMENT_OPERATOR = "=";
+
+ private String url;
+ private FacesContext context;
+
+ public FacesUrlTransformer(String url)
+ {
+ this.url = url;
+ }
+
+ public FacesUrlTransformer appendConversationIdIfNecessary(String cid)
+ {
+ String cidParamName = CurrentManager.rootManager().getInstanceByType(String.class, new AnnotationLiteral<ConversationIdName>(){});
+ int queryStringIndex = url.indexOf(QUERY_STRING_DELIMITER);
+ // if there is no query string or there is a query string but the cid param is absent, then append it
+ if (queryStringIndex < 0 || url.indexOf(cidParamName + PARAMETER_ASSIGNMENT_OPERATOR, queryStringIndex) < 0)
+ {
+ url = new StringBuilder(url).append(queryStringIndex < 0 ? QUERY_STRING_DELIMITER : PARAMETER_PAIR_DELIMITER)
+ .append(cidParamName).append(PARAMETER_ASSIGNMENT_OPERATOR).append(cid).toString();
+ }
+ return this;
+ }
+
+ public String getUrl()
+ {
+ return url;
+ }
+
+ public FacesUrlTransformer toRedirectViewId()
+ {
+ if (isUrlAbsolute())
+ {
+ String requestPath = context().getExternalContext().getRequestContextPath();
+ url = url.substring(url.indexOf(requestPath) + requestPath.length());
+ }
+ else
+ {
+ int lastSlash = url.lastIndexOf("/");
+ if (lastSlash > 0)
+ {
+ url = url.substring(lastSlash);
+ }
+ }
+ return this;
+ }
+
+ public FacesUrlTransformer toActionUrl()
+ {
+ url = context().getApplication().getViewHandler().getActionURL(context(), url);
+ return this;
+ }
+
+ public String encode()
+ {
+ return context().getExternalContext().encodeActionURL(url);
+ }
+
+ private FacesContext context()
+ {
+ if (context == null)
+ {
+ context = FacesContext.getCurrentInstance();
+ }
+
+ return context;
+ }
+
+ private boolean isUrlAbsolute()
+ {
+ // TODO: any API call to do this?
+ return url.startsWith(HTTP_PROTOCOL_URL_PREFIX) || url.startsWith(HTTPS_PROTOCOL_URL_PREFIX);
+ }
+}
\ No newline at end of file
Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/jsf/JsfApiAbstraction.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/jsf/JsfApiAbstraction.java 2009-05-08 05:51:32 UTC (rev 2671)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/jsf/JsfApiAbstraction.java 2009-05-08 05:54:08 UTC (rev 2672)
@@ -21,21 +21,42 @@
import org.jboss.webbeans.util.ApiAbstraction;
/**
- * Utility class for JSF related components, concepts etc.
+ * Utility class for JSF related components, concepts etc. It can also
+ * report on the compatibility of the current JSF implementation being used.
*
* @author Pete Muir
- *
+ * @author Dan Allen
*/
public class JsfApiAbstraction extends ApiAbstraction implements Service
{
-
// An UI component
public final Class<?> UICOMPONENT_CLASS;
+ // JSF FacesContext
+ public final Class<?> FACES_CONTEXT;
+
+ public final double MINIMUM_API_VERSION;
+
public JsfApiAbstraction(ResourceLoader resourceLoader)
{
super(resourceLoader);
this.UICOMPONENT_CLASS = classForName("javax.faces.component.UIComponent");
+ this.FACES_CONTEXT = classForName("javax.faces.context.FacesContext");
+ double version = 2.0;
+ try
+ {
+ this.FACES_CONTEXT.getMethod("isPostback", new Class[] {});
+ }
+ catch (NoSuchMethodException e)
+ {
+ version = 1.2;
+ }
+ MINIMUM_API_VERSION = version;
}
+
+ public boolean isApiVersionCompatibleWith(double version)
+ {
+ return MINIMUM_API_VERSION >= version;
+ }
}
Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/jsf/PhaseHelper.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/jsf/PhaseHelper.java 2009-05-08 05:51:32 UTC (rev 2671)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/jsf/PhaseHelper.java 2009-05-08 05:54:08 UTC (rev 2672)
@@ -24,19 +24,18 @@
import org.jboss.webbeans.conversation.ConversationIdName;
import org.jboss.webbeans.log.LogProvider;
import org.jboss.webbeans.log.Logging;
+import org.jboss.webbeans.util.Reflections;
/**
* Helper class for JSF related operations
*
* @author Nicklas Karlsson
- *
+ * @author Dan Allen
*/
public class PhaseHelper
{
private static LogProvider log = Logging.getLogProvider(PhaseHelper.class);
- private static final String CONVERSATION_PROPAGATION_KEY = "webbeans_conversation_propagation";
-
/**
* Gets a FacesContext instance
*
@@ -48,28 +47,27 @@
}
/**
- * Checks if current request is a JSF postback
+ * Checks if the current request is a JSF postback. The JsfApiAbstraction is
+ * consulted to determine if the JSF version is compatible with JSF 2.0. If
+ * so, the {@link FacesContext#isPostback()} convenience method is used
+ * (which is technically an optimized and safer implementation). Otherwise,
+ * the ResponseStateManager is consulted directly.
*
- * @return True if postback, false otherwise
+ * @return true if this request is a JSF postback, false otherwise
*/
public static boolean isPostback()
{
- return context().getRenderKit().getResponseStateManager().isPostback(context());
+ if (CurrentManager.rootManager().getServices().get(JsfApiAbstraction.class).isApiVersionCompatibleWith(2.0))
+ {
+ return (Boolean) Reflections.invokeAndWrap("isPostback", context());
+ }
+ else
+ {
+ return context().getRenderKit().getResponseStateManager().isPostback(context());
+ }
}
/**
- * Creates and/or updates the conversation propagation component in the UI
- * view root
- *
- * @param cid The conversation id to propagate
- */
- public static void propagateConversation(String cid)
- {
- context().getViewRoot().getAttributes().put(CONVERSATION_PROPAGATION_KEY, cid);
- log.debug("Updated propagation component with cid " + cid);
- }
-
- /**
* Gets the propagated conversation id parameter from the request
*
* @return The conversation id (or null if not found)
@@ -78,42 +76,22 @@
{
String cidName = CurrentManager.rootManager().getInstanceByType(String.class, new AnnotationLiteral<ConversationIdName>(){});
String cid = context().getExternalContext().getRequestParameterMap().get(cidName);
- log.trace("Got cid " + cid + " from request");
+ log.trace("Found conversation id " + cid + " in request parameter");
return cid;
}
/**
- * Gets the propagated conversation id from the view root attribute map
+ * Gets the propagated conversation id.
*
* @return The conversation id (or null if not found)
*/
- public static String getConversationIdFromViewRoot()
- {
- String cid = (String) context().getViewRoot().getAttributes().get(CONVERSATION_PROPAGATION_KEY);
- log.trace("Got cid " + cid + " from propagation component");
- return cid;
- }
-
- /**
- * Gets the propagated conversation id
- *
- * @return The conversation id (or null if not found)
- */
public static String getConversationId()
{
- String cid = null;
- if (isPostback())
- {
- cid = getConversationIdFromViewRoot();
- }
- else
- {
- cid = getConversationIdFromRequest();
- }
- log.debug("Resuming conversation " + cid);
+ String cid = getConversationIdFromRequest();
+ log.debug("Resuming conversation with id " + cid);
return cid;
}
-
+
/**
* Gets the HTTP session
*
@@ -124,12 +102,4 @@
return (HttpSession) context().getExternalContext().getSession(true);
}
- /**
- * Stops conversation propagation through the view root
- */
- public static void stopConversationPropagation()
- {
- context().getViewRoot().getAttributes().remove(CONVERSATION_PROPAGATION_KEY);
- }
-
}
Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/jsf/WebBeansPhaseListener.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/jsf/WebBeansPhaseListener.java 2009-05-08 05:51:32 UTC (rev 2671)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/jsf/WebBeansPhaseListener.java 2009-05-08 05:54:08 UTC (rev 2672)
@@ -37,84 +37,102 @@
import org.jboss.webbeans.servlet.HttpSessionManager;
/**
- * A phase listener for propagating conversation id over postbacks through a
- * hidden component
+ * <p>
+ * A JSF phase listener that initializes aspects of Web Beans in a more
+ * fine-grained, integrated manner than what is possible with a servlet filter.
+ * This phase listener works in conjunction with other hooks and callbacks
+ * registered with the JSF runtime to help manage the Web Beans lifecycle.
+ * </p>
*
+ * <p>
+ * It's expected that over time, this phase listener may take on more work, but
+ * for now the work is focused soley on conversation management. The phase
+ * listener restores the long-running conversation if the conversation id token
+ * is detected in the request, activates the conversation context in either case
+ * (long-running or transient), and finally passivates the conversation after
+ * the response has been committed.
+ * </p>
+ *
* @author Nicklas Karlsson
- *
+ * @author Dan Allen
*/
public class WebBeansPhaseListener implements PhaseListener
{
- // The logging provider
private static LogProvider log = Logging.getLogProvider(WebBeansPhaseListener.class);
/**
- * Run before a given phase
+ * Execute before every phase in the JSF life cycle. The order this
+ * phase listener executes in relation to other phase listeners is
+ * determined by the ordering of the faces-config.xml descriptors.
+ * This phase listener should take precedence over extensions.
*
* @param phaseEvent The phase event
*/
public void beforePhase(PhaseEvent phaseEvent)
{
- if (phaseEvent.getPhaseId().equals(PhaseId.RENDER_RESPONSE))
+ if (phaseEvent.getPhaseId().equals(PhaseId.RESTORE_VIEW))
{
- beforeRenderReponse();
+ beforeRestoreView();
}
}
/**
- * Run before the response is rendered
+ * Execute after every phase in the JSF life cycle. The order this
+ * phase listener executes in relation to other phase listeners is
+ * determined by the ordering of the faces-config.xml descriptors.
+ * This phase listener should take precedence over extensions.
+ *
+ * @param phaseEvent The phase event
*/
- private void beforeRenderReponse()
+ public void afterPhase(PhaseEvent phaseEvent)
{
- log.trace("In before render response phase");
- Conversation conversation = CurrentManager.rootManager().getInstanceByType(Conversation.class);
- if (conversation.isLongRunning())
+ if (phaseEvent.getPhaseId().equals(PhaseId.RENDER_RESPONSE))
{
- PhaseHelper.propagateConversation(conversation.getId());
+ afterRenderResponse();
}
- else
+ // be careful with this else as it assumes only one if condition right now
+ else if (phaseEvent.getFacesContext().getResponseComplete())
{
- PhaseHelper.stopConversationPropagation();
+ afterResponseComplete(phaseEvent.getPhaseId());
}
}
/**
- * Run after a given phase
- *
- * @param phaseEvent The phase event
+ * Execute before the Restore View phase.
*/
- public void afterPhase(PhaseEvent phaseEvent)
+ private void beforeRestoreView()
{
- if (phaseEvent.getPhaseId().equals(PhaseId.RESTORE_VIEW))
- {
- afterRestoreView();
- }
- else if (phaseEvent.getPhaseId().equals(PhaseId.RENDER_RESPONSE))
- {
- afterRenderResponse();
- }
-
- if(phaseEvent.getFacesContext().getResponseComplete())
- {
- afterResponseComplete();
- }
+ log.trace("Initiating the session and conversation before the Restore View phase");
+ initiateSessionAndConversation();
}
+
+ /**
+ * Execute after the Render Response phase.
+ */
+ private void afterRenderResponse()
+ {
+ log.trace("Cleaning up the conversation after the Render Response phase");
+ CurrentManager.rootManager().getInstanceByType(ConversationManager.class).cleanupConversation();
+ ConversationContext.instance().setActive(false);
+ }
/**
- * Run after the response is complete
+ * Execute after any phase that marks the response as complete.
*/
- private void afterResponseComplete()
+ private void afterResponseComplete(PhaseId phaseId)
{
- log.trace("Post-response complete");
+ log.trace("Cleaning up the conversation after the " + phaseId + " phase as the response has been marked complete");
CurrentManager.rootManager().getInstanceByType(ConversationManager.class).cleanupConversation();
}
/**
- * Run after the view is restored
+ * Retrieve the HTTP session from the FacesContext and assign it to the Web
+ * Beans HttpSessionManager. Restore the long-running conversation if the
+ * conversation id token is present in the request and, in either case,
+ * activate the conversation context (long-running or transient).
*/
- private void afterRestoreView()
+ private void initiateSessionAndConversation()
{
- log.trace("In after restore view phase");
HttpSession session = PhaseHelper.getHttpSession();
CurrentManager.rootManager().getInstanceByType(HttpSessionManager.class).setSession(session);
CurrentManager.rootManager().getInstanceByType(ConversationManager.class).beginOrRestoreConversation(PhaseHelper.getConversationId());
@@ -124,15 +142,9 @@
}
/**
- * Run after the response is rendered
+ * The phase id for which this phase listener is active. This phase listener
+ * observes all JSF life-cycle phases.
*/
- private void afterRenderResponse()
- {
- log.trace("In after render reponse phase");
- CurrentManager.rootManager().getInstanceByType(ConversationManager.class).cleanupConversation();
- ConversationContext.instance().setActive(false);
- }
-
public PhaseId getPhaseId()
{
return PhaseId.ANY_PHASE;
Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/servlet/ConversationPropagationFilter.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/servlet/ConversationPropagationFilter.java 2009-05-08 05:51:32 UTC (rev 2671)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/servlet/ConversationPropagationFilter.java 2009-05-08 05:54:08 UTC (rev 2672)
@@ -19,8 +19,6 @@
import java.io.IOException;
import javax.context.Conversation;
-import javax.faces.context.FacesContext;
-import javax.inject.AnnotationLiteral;
import javax.servlet.Filter;
import javax.servlet.FilterChain;
import javax.servlet.FilterConfig;
@@ -31,87 +29,34 @@
import javax.servlet.http.HttpServletResponseWrapper;
import org.jboss.webbeans.CurrentManager;
-import org.jboss.webbeans.conversation.ConversationIdName;
import org.jboss.webbeans.conversation.ConversationManager;
+import org.jboss.webbeans.jsf.FacesUrlTransformer;
/**
- * Filter for handling conversation propagation over redirects
+ * <p>A Filter for handling conversation propagation over redirects.</p>
*
- * @author Nicklas Karlsson
+ * <p>This fiter intercepts the call to {@link HttpServletResponse#sendRedirect(String)} and
+ * appends the conversation id request parameter to the URL if the conversation is long-running,
+ * but only if the request parameter is not already present.</p>
*
+ * FIXME This filter is specifically for JSF and should be repackaged or split up to support non-JSF environments.
+ *
+ * @author Nicklas Karlsson
*/
public class ConversationPropagationFilter implements Filter
{
-
- /**
- * Helper class for handling URLs
- *
- * @author Nicklas Karlsson
- */
- private class UrlTransformer
+ public void init(FilterConfig config) throws ServletException
{
- private String URL;
- private FacesContext context;
-
- private boolean isUrlAbsolute()
- {
- // TODO: any API call to do this?
- return URL.startsWith("http://") || URL.startsWith("https://");
- }
-
- public UrlTransformer(String URL)
- {
- this.URL = URL;
- context = FacesContext.getCurrentInstance();
- }
-
- public UrlTransformer appendConversation(String cid)
- {
- String cidName = CurrentManager.rootManager().getInstanceByType(String.class, new AnnotationLiteral<ConversationIdName>()
- {
- });
- URL = URL + (URL.indexOf("?") > 0 ? "&" : "?") + cidName + "=" + cid;
- return this;
- }
-
- public UrlTransformer getRedirectView()
- {
- if (isUrlAbsolute())
- {
- String requestPath = context.getExternalContext().getRequestContextPath();
- URL = URL.substring(URL.indexOf(requestPath) + requestPath.length());
- }
- else
- {
- int lastSlash = URL.lastIndexOf("/");
- if (lastSlash > 0)
- {
- URL = URL.substring(lastSlash);
- }
- }
- return this;
- }
-
- public UrlTransformer getActionUrl()
- {
- URL = context.getApplication().getViewHandler().getActionURL(context, URL);
- return this;
- }
-
- public String encode()
- {
- return context.getExternalContext().encodeActionURL(URL);
- }
}
- public void destroy()
- {
- }
-
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException
{
chain.doFilter(request, wrapResponse((HttpServletResponse) response));
}
+
+ public void destroy()
+ {
+ }
private ServletResponse wrapResponse(HttpServletResponse response)
{
@@ -123,7 +68,7 @@
Conversation conversation = CurrentManager.rootManager().getInstanceByType(Conversation.class);
if (conversation.isLongRunning())
{
- path = new UrlTransformer(path).getRedirectView().getActionUrl().appendConversation(conversation.getId()).encode();
+ path = new FacesUrlTransformer(path).toRedirectViewId().toActionUrl().appendConversationIdIfNecessary(conversation.getId()).encode();
CurrentManager.rootManager().getInstanceByType(ConversationManager.class).cleanupConversation();
}
super.sendRedirect(path);
@@ -131,8 +76,4 @@
};
}
- public void init(FilterConfig config) throws ServletException
- {
- }
-
}
15 years, 6 months
[webbeans-commits] Webbeans SVN: r2671 - extensions/trunk/servlet.
by webbeans-commits@lists.jboss.org
Author: dan.j.allen
Date: 2009-05-08 01:51:32 -0400 (Fri, 08 May 2009)
New Revision: 2671
Modified:
extensions/trunk/servlet/
Log:
ignore local.build.properties
Property changes on: extensions/trunk/servlet
___________________________________________________________________
Name: svn:ignore
-
target
+ target
local.build.properties
15 years, 6 months
[webbeans-commits] Webbeans SVN: r2670 - examples/trunk.
by webbeans-commits@lists.jboss.org
Author: dan.j.allen
Date: 2009-05-08 01:51:09 -0400 (Fri, 08 May 2009)
New Revision: 2670
Modified:
examples/trunk/
Log:
ignore local.build.properties
Property changes on: examples/trunk
___________________________________________________________________
Name: svn:ignore
- target
.project
.settings
.classpath
pom.xml.releaseBackup
release.properties
+ target
.project
.settings
.classpath
pom.xml.releaseBackup
release.properties
local.build.properties
15 years, 6 months
[webbeans-commits] Webbeans SVN: r2669 - examples/trunk.
by webbeans-commits@lists.jboss.org
Author: dan.j.allen
Date: 2009-05-08 01:49:27 -0400 (Fri, 08 May 2009)
New Revision: 2669
Modified:
examples/trunk/build.xml
Log:
consult local.build.properties
Modified: examples/trunk/build.xml
===================================================================
--- examples/trunk/build.xml 2009-05-08 04:37:05 UTC (rev 2668)
+++ examples/trunk/build.xml 2009-05-08 05:49:27 UTC (rev 2669)
@@ -5,6 +5,7 @@
<property name="maven.dir" location="${wbexamples.dir}/lib/maven" />
<property file="${wbexamples.dir}/../jboss-as/local.build.properties"/>
+ <property file="${wbexamples.dir}/local.build.properties"/>
<property file="${wbexamples.dir}/build.properties"/>
<property file="${wbexamples.dir}/../jboss-as/build.properties"/>
15 years, 6 months
[webbeans-commits] Webbeans SVN: r2668 - ri/trunk/version-matrix.
by webbeans-commits@lists.jboss.org
Author: dan.j.allen
Date: 2009-05-08 00:37:05 -0400 (Fri, 08 May 2009)
New Revision: 2668
Modified:
ri/trunk/version-matrix/pom.xml
Log:
update enforcer plugin to be compatible with m2eclipse
Modified: ri/trunk/version-matrix/pom.xml
===================================================================
--- ri/trunk/version-matrix/pom.xml 2009-05-07 21:13:27 UTC (rev 2667)
+++ ri/trunk/version-matrix/pom.xml 2009-05-08 04:37:05 UTC (rev 2668)
@@ -511,7 +511,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-enforcer-plugin</artifactId>
- <version>1.0-alpha-4</version>
+ <version>1.0-beta-1</version>
<executions>
<execution>
<id>enforce</id>
15 years, 6 months
[webbeans-commits] Webbeans SVN: r2667 - ri/trunk/osgi-bundle.
by webbeans-commits@lists.jboss.org
Author: dallen6
Date: 2009-05-07 17:13:27 -0400 (Thu, 07 May 2009)
New Revision: 2667
Added:
ri/trunk/osgi-bundle/.project
Modified:
ri/trunk/osgi-bundle/
Log:
Added osgi-bundle/target dir to svn:ignore prop
Property changes on: ri/trunk/osgi-bundle
___________________________________________________________________
Name: svn:ignore
+ target
Added: ri/trunk/osgi-bundle/.project
===================================================================
--- ri/trunk/osgi-bundle/.project (rev 0)
+++ ri/trunk/osgi-bundle/.project 2009-05-07 21:13:27 UTC (rev 2667)
@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>osgi</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.wst.common.project.facet.core.builder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.wst.common.project.facet.core.nature</nature>
+ </natures>
+</projectDescription>
Property changes on: ri/trunk/osgi-bundle/.project
___________________________________________________________________
Name: svn:mime-type
+ text/plain
15 years, 6 months
[webbeans-commits] Webbeans SVN: r2666 - in test-harness/trunk: jboss51 and 13 other directories.
by webbeans-commits@lists.jboss.org
Author: pete.muir(a)jboss.org
Date: 2009-05-07 12:16:42 -0400 (Thu, 07 May 2009)
New Revision: 2666
Added:
test-harness/trunk/jboss51/
test-harness/trunk/jboss51/pom.xml
test-harness/trunk/jboss51/src/
test-harness/trunk/jboss51/src/main/
test-harness/trunk/jboss51/src/main/java/
test-harness/trunk/jboss51/src/main/java/org/
test-harness/trunk/jboss51/src/main/java/org/jboss/
test-harness/trunk/jboss51/src/main/java/org/jboss/testharness/
test-harness/trunk/jboss51/src/main/java/org/jboss/testharness/integration/
test-harness/trunk/jboss51/src/main/java/org/jboss/testharness/integration/jbossas/
test-harness/trunk/jboss51/src/main/java/org/jboss/testharness/integration/jbossas/JBossASConnector.java
test-harness/trunk/jboss51/src/main/java/org/jboss/testharness/integration/jbossas/ProfileServiceConnector.java
test-harness/trunk/jboss51/src/main/resources/
test-harness/trunk/jboss51/src/main/resources/META-INF/
test-harness/trunk/jboss51/src/main/resources/META-INF/jboss-test-harness.properties
test-harness/trunk/jboss51/src/main/resources/log4j.xml
test-harness/trunk/jboss51/src/test/
test-harness/trunk/jboss51/src/test/debug-resources/
test-harness/trunk/jboss51/src/test/debug-resources/META-INF/
test-harness/trunk/jboss51/src/test/debug-resources/META-INF/web-beans-tck.properties
test-harness/trunk/jboss51/src/test/java/
test-harness/trunk/jboss51/src/test/resources/
Modified:
test-harness/trunk/pom.xml
Log:
add jboss 5.1 connector
Property changes on: test-harness/trunk/jboss51
___________________________________________________________________
Name: svn:ignore
+
.classpath
.project
target
.settings
Added: test-harness/trunk/jboss51/pom.xml
===================================================================
--- test-harness/trunk/jboss51/pom.xml (rev 0)
+++ test-harness/trunk/jboss51/pom.xml 2009-05-07 16:16:42 UTC (rev 2666)
@@ -0,0 +1,47 @@
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <parent>
+ <artifactId>jboss-test-harness-parent</artifactId>
+ <groupId>org.jboss.test-harness</groupId>
+ <version>1.0.0-SNAPSHOT</version>
+ </parent>
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>org.jboss.test-harness</groupId>
+ <artifactId>jboss-test-harness-jboss-as-51</artifactId>
+ <name>JBoss Test Harness deployment for JBoss AS 5.1.x</name>
+ <description>Implements the JBoss Test Harness deployment SPI for JBoss AS 5.1.x</description>
+
+ <dependencies>
+
+ <dependency>
+ <groupId>org.jboss.test-harness</groupId>
+ <artifactId>jboss-test-harness-api</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>org.jboss.integration</groupId>
+ <artifactId>jboss-profileservice-spi</artifactId>
+ <version>5.1.0.CR3</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.jboss.deployers</groupId>
+ <artifactId>jboss-deployers-client-spi</artifactId>
+ <version>2.0.6.GA</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.jboss.jbossas</groupId>
+ <artifactId>jboss-as-client</artifactId>
+ <type>pom</type>
+ <scope>runtime</scope>
+ <version>5.1.0.CR1</version>
+ </dependency>
+
+ <dependency>
+ <groupId>log4j</groupId>
+ <artifactId>log4j</artifactId>
+ </dependency>
+
+ </dependencies>
+
+</project>
Added: test-harness/trunk/jboss51/src/main/java/org/jboss/testharness/integration/jbossas/JBossASConnector.java
===================================================================
--- test-harness/trunk/jboss51/src/main/java/org/jboss/testharness/integration/jbossas/JBossASConnector.java (rev 0)
+++ test-harness/trunk/jboss51/src/main/java/org/jboss/testharness/integration/jbossas/JBossASConnector.java 2009-05-07 16:16:42 UTC (rev 2666)
@@ -0,0 +1,60 @@
+package org.jboss.testharness.integration.jbossas;
+
+
+import java.io.File;
+import java.io.IOException;
+
+import org.jboss.testharness.spi.Containers;
+import org.jboss.testharness.spi.helpers.AbstractContainerConnector;
+
+/**
+ *
+ * @author jeffgenender
+ * @author Pete Muir
+ *
+ */
+public abstract class JBossASConnector extends AbstractContainerConnector implements Containers
+{
+
+ private static final String SERVER_HOME_PROPERTY_NAME = "jboss.home";
+
+ private String jbossBinDirectory;
+
+ public JBossASConnector() throws IOException
+ {
+
+ }
+
+ @Override
+ protected String getServerHomePropertyName()
+ {
+ return SERVER_HOME_PROPERTY_NAME;
+ }
+
+ protected void shutdownServer() throws IOException
+ {
+ launch(getJBossBinDirectory(), "shutdown", "-S");
+ }
+
+ @Override
+ protected void startServer() throws IOException
+ {
+ launch(getJBossBinDirectory(), "run", "--host=" + getHost());
+ }
+
+ protected String getJBossBinDirectory()
+ {
+ if (jbossBinDirectory == null)
+ {
+ jbossBinDirectory = new File(getServerDirectory() + "/bin").getPath();
+ }
+ return jbossBinDirectory;
+ }
+
+ @Override
+ protected String getLogName()
+ {
+ return "jboss.log";
+ }
+
+}
\ No newline at end of file
Added: test-harness/trunk/jboss51/src/main/java/org/jboss/testharness/integration/jbossas/ProfileServiceConnector.java
===================================================================
--- test-harness/trunk/jboss51/src/main/java/org/jboss/testharness/integration/jbossas/ProfileServiceConnector.java (rev 0)
+++ test-harness/trunk/jboss51/src/main/java/org/jboss/testharness/integration/jbossas/ProfileServiceConnector.java 2009-05-07 16:16:42 UTC (rev 2666)
@@ -0,0 +1,252 @@
+package org.jboss.testharness.integration.jbossas;
+
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map.Entry;
+
+import javax.naming.InitialContext;
+
+import org.apache.log4j.Logger;
+import org.jboss.deployers.client.spi.IncompleteDeploymentException;
+import org.jboss.deployers.spi.management.deploy.DeploymentManager;
+import org.jboss.deployers.spi.management.deploy.DeploymentProgress;
+import org.jboss.deployers.spi.management.deploy.DeploymentStatus;
+import org.jboss.profileservice.spi.ProfileKey;
+import org.jboss.profileservice.spi.ProfileService;
+import org.jboss.testharness.api.DeploymentException;
+import org.jboss.virtual.VFS;
+
+public class ProfileServiceConnector extends JBossASConnector
+{
+
+ private final Logger log = Logger.getLogger(ProfileServiceConnector.class);
+
+ public static final String MAX_DEPLOYMENTS_PROPERTY_NAME = "max.deployments.restart";
+
+ private final List<String> failedUndeployments;
+
+ private DeploymentManager deploymentManager;
+ private final File tmpdir;
+ private int deploymentCounter = 0;
+ private Integer maxDeployments;
+
+ private Boolean forceRestart;
+
+
+ public ProfileServiceConnector() throws Exception
+ {
+ tmpdir = new File(System.getProperty("java.io.tmpdir"), "org.jboss.webbeans.tck.integration.jbossas");
+ tmpdir.mkdir();
+ tmpdir.deleteOnExit();
+ this.failedUndeployments = new ArrayList<String>();
+ }
+
+
+ @Override
+ public void setup() throws IOException
+ {
+ super.setup();
+ try
+ {
+ initDeploymentManager();
+ }
+ catch (Exception e)
+ {
+ IOException ioe = new IOException();
+ ioe.initCause(e);
+ throw ioe;
+ }
+ }
+
+ public void deploy(InputStream archiveStream, String name) throws DeploymentException, IOException
+ {
+ if (deploymentManager == null)
+ {
+ throw new IllegalStateException("setup() has not been called!");
+ }
+ Exception failure = null;
+ try
+ {
+ File archive = new File(tmpdir, name);
+ archive.deleteOnExit();
+ copy(archiveStream, archive);
+ DeploymentProgress distribute = deploymentManager.distribute(name, archive.toURI().toURL(), true);
+ distribute.run();
+ DeploymentProgress progress = deploymentManager.start(name);
+ progress.run();
+ DeploymentStatus status = progress.getDeploymentStatus();
+ if (status.isFailed())
+ {
+ failure = status.getFailure();
+ doUndeploy(name);
+ }
+ }
+ catch (Exception e)
+ {
+ IOException ioe = new IOException();
+ ioe.initCause(e);
+ throw ioe;
+ }
+ if (failure != null)
+ {
+ if (failure.getCause() instanceof IncompleteDeploymentException)
+ {
+ IncompleteDeploymentException incompleteDeploymentException = (IncompleteDeploymentException) failure.getCause();
+ for (Entry<String, Throwable> entry : incompleteDeploymentException.getIncompleteDeployments().getContextsInError().entrySet())
+ {
+ if (entry.getKey().endsWith(name + "/_WebBeansBootstrapBean"))
+ {
+ throw new DeploymentException(entry.getValue());
+ }
+ }
+ }
+ throw new DeploymentException(failure);
+ }
+ }
+
+ private void doUndeploy(String name) throws IOException
+ {
+ try
+ {
+ DeploymentProgress stopProgress = deploymentManager.stop(name);
+ stopProgress.run();
+
+ DeploymentProgress undeployProgress = deploymentManager.remove(name);
+ undeployProgress.run();
+ if (undeployProgress.getDeploymentStatus().isFailed())
+ {
+ failedUndeployments.add(name);
+ }
+ else
+ {
+ deploymentCounter++;
+ }
+ }
+ catch (Exception e)
+ {
+ IOException ioe = new IOException();
+ ioe.initCause(e);
+ throw ioe;
+ }
+ }
+
+ public void undeploy(String name) throws IOException
+ {
+ try
+ {
+ doUndeploy(name);
+ }
+ finally
+ {
+ if (deploymentCounter >= getMaxDeployments())
+ {
+ // Force into force-restart mode
+ forceRestart = true;
+ deploymentCounter = 0;
+ // Let everything stablise
+ removeFailedUnDeployments();
+ try
+ {
+ Thread.sleep(5000);
+ }
+ catch (InterruptedException e)
+ {
+ Thread.currentThread().interrupt();
+ }
+ restartServer();
+ try
+ {
+ initDeploymentManager();
+ }
+ catch (Exception e)
+ {
+ IOException ioe = new IOException();
+ ioe.initCause(e);
+ throw ioe;
+ }
+ }
+ }
+ }
+
+ /**
+ * Obtain the Deployment Manager
+ * @throws Exception
+ */
+ protected void initDeploymentManager() throws Exception
+ {
+ String profileName = "default";
+ InitialContext ctx = new InitialContext();
+ ProfileService ps = (ProfileService) ctx.lookup("ProfileService");
+ deploymentManager = ps.getDeploymentManager();
+ ProfileKey defaultKey = new ProfileKey(profileName);
+ deploymentManager.loadProfile(defaultKey);
+ // Init the VFS to setup the vfs* protocol handlers
+ VFS.init();
+ }
+
+ @Override
+ public void cleanup() throws IOException
+ {
+ removeFailedUnDeployments();
+ super.cleanup();
+ }
+
+ private void removeFailedUnDeployments() throws IOException
+ {
+ List<String> remainingDeployments = new ArrayList<String>();
+ for (String name : failedUndeployments)
+ {
+ try
+ {
+ DeploymentProgress undeployProgress = deploymentManager.remove(name);
+ undeployProgress.run();
+ if (undeployProgress.getDeploymentStatus().isFailed())
+ {
+ remainingDeployments.add(name);
+ }
+ }
+ catch (Exception e)
+ {
+ IOException ioe = new IOException();
+ ioe.initCause(e);
+ throw ioe;
+ }
+ }
+ if (remainingDeployments.size() > 0)
+ {
+ //log.error("Failed to undeploy these artifacts: " + remainingDeployments);
+ }
+ failedUndeployments.clear();
+ }
+
+ protected String getMaxDeploymentsPropertyName()
+ {
+ return MAX_DEPLOYMENTS_PROPERTY_NAME;
+ }
+
+ protected Integer getMaxDeployments()
+ {
+ if (maxDeployments == null)
+ {
+ this.maxDeployments = getProperties().getIntValue(getMaxDeploymentsPropertyName(), 25, false);
+ }
+ return maxDeployments;
+ }
+
+ @Override
+ protected Boolean getForceRestart()
+ {
+ if (forceRestart == null)
+ {
+ return super.getForceRestart();
+ }
+ else
+ {
+ return forceRestart;
+ }
+ }
+
+}
Added: test-harness/trunk/jboss51/src/main/resources/META-INF/jboss-test-harness.properties
===================================================================
--- test-harness/trunk/jboss51/src/main/resources/META-INF/jboss-test-harness.properties (rev 0)
+++ test-harness/trunk/jboss51/src/main/resources/META-INF/jboss-test-harness.properties 2009-05-07 16:16:42 UTC (rev 2666)
@@ -0,0 +1,3 @@
+org.jboss.testharness.spi.Containers=org.jboss.testharness.integration.jbossas.ProfileServiceConnector
+org.jboss.testharness.connectDelay=1500
+org.jboss.testharness.connectRetries=8
\ No newline at end of file
Added: test-harness/trunk/jboss51/src/main/resources/log4j.xml
===================================================================
--- test-harness/trunk/jboss51/src/main/resources/log4j.xml (rev 0)
+++ test-harness/trunk/jboss51/src/main/resources/log4j.xml 2009-05-07 16:16:42 UTC (rev 2666)
@@ -0,0 +1,58 @@
+<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
+
+<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/" debug="false">
+
+ <appender name="CONSOLE" class="org.apache.log4j.ConsoleAppender">
+ <param name="Target" value="System.out"/>
+ <layout class="org.apache.log4j.PatternLayout">
+ <!-- The default pattern: Date Priority [Category] Message\n -->
+ <param name="ConversionPattern" value="%d{ABSOLUTE} %-5p [%c{2}] %m%n"/>
+ </layout>
+ </appender>
+
+ <!-- ############### JBoss ################# -->
+ <category name="org.jboss">
+ <priority value="ERROR"/>
+ </category>
+
+ <category name="org.jboss.test">
+ <priority value="ERROR"/>
+ </category>
+
+ <category name="com.arjuna">
+ <priority value="ERROR"/>
+ </category>
+
+ <!-- ############### Hibernate logging ################# -->
+
+ <category name="org.hibernate">
+ <priority value="ERROR"/>
+ </category>
+
+ <!--
+ <category name="org.hibernate.SQL">
+ <priority value="TRACE"/>
+ </category>
+
+ <category name="org.hibernate.type">
+ <priority value="TRACE"/>
+ </category>
+
+ <category name="org.hibernate.loader">
+ <priority value="TRACE"/>
+ </category>
+ <category name="org.hibernate.cache">
+ <priority value="TRACE"/>
+ </category>
+ -->
+
+ <category name="org.jboss.testharness">
+ <priority value="INFO"/>
+ </category>
+
+ <root>
+ <priority value="INFO"/>
+ <appender-ref ref="CONSOLE"/>
+ </root>
+
+</log4j:configuration>
Added: test-harness/trunk/jboss51/src/test/debug-resources/META-INF/web-beans-tck.properties
===================================================================
--- test-harness/trunk/jboss51/src/test/debug-resources/META-INF/web-beans-tck.properties (rev 0)
+++ test-harness/trunk/jboss51/src/test/debug-resources/META-INF/web-beans-tck.properties 2009-05-07 16:16:42 UTC (rev 2666)
@@ -0,0 +1,7 @@
+# Configuration for running incontainer tests from your IDE
+# Alter the path webbeans accordingly (relative from the tck/impl dir)
+org.jboss.testharness.standalone=false
+jboss-as.dir=../../webbeans/jboss-as
+jboss.force.restart=false
+org.jboss.testharness.libraryDirectory=../../webbeans/jboss-tck-runner/target/dependency/lib
+org.jboss.testharness.runIntegrationTests=true
\ No newline at end of file
Modified: test-harness/trunk/pom.xml
===================================================================
--- test-harness/trunk/pom.xml 2009-05-07 15:36:15 UTC (rev 2665)
+++ test-harness/trunk/pom.xml 2009-05-07 16:16:42 UTC (rev 2666)
@@ -44,6 +44,7 @@
<module>impl</module>
<module>tests</module>
<module>jboss</module>
+ <module>jboss51</module>
<module>tomcat</module>
</modules>
15 years, 6 months
[webbeans-commits] Webbeans SVN: r2665 - in ri/trunk: impl/src/main/java/org/jboss/webbeans/xml/checker/beanchildren/ext and 3 other directories.
by webbeans-commits@lists.jboss.org
Author: vitold
Date: 2009-05-07 11:36:15 -0400 (Thu, 07 May 2009)
New Revision: 2665
Modified:
ri/trunk/impl/src/main/java/org/jboss/webbeans/xml/ParseXmlHelper.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/xml/XmlParser.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/xml/checker/beanchildren/ext/AbstractBeanChildrenChecker.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/xml/checker/beanchildren/ext/SimpleBeanChildrenChecker.java
ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/xml/parser/schema/foo/Order.java
ri/trunk/tests/src/test/resources/org/jboss/webbeans/test/unit/xml/parser/schema/beans.xml
ri/trunk/tests/src/test/resources/org/jboss/webbeans/test/unit/xml/parser/user-defined-beans.xml
Log:
implement <Array> for constructor parameters
Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/xml/ParseXmlHelper.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/xml/ParseXmlHelper.java 2009-05-07 11:02:50 UTC (rev 2664)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/xml/ParseXmlHelper.java 2009-05-07 15:36:15 UTC (rev 2665)
@@ -19,6 +19,7 @@
import java.io.IOException;
import java.io.InputStream;
import java.lang.annotation.Annotation;
+import java.lang.reflect.Array;
import java.net.URL;
import java.util.ArrayList;
import java.util.HashSet;
@@ -36,7 +37,12 @@
import org.dom4j.Namespace;
import org.dom4j.QName;
import org.dom4j.io.SAXReader;
+import org.jboss.webbeans.bootstrap.api.ServiceRegistry;
import org.jboss.webbeans.introspector.AnnotatedClass;
+import org.jboss.webbeans.introspector.AnnotatedItem;
+import org.jboss.webbeans.introspector.jlr.AnnotatedClassImpl;
+import org.jboss.webbeans.resources.ClassTransformer;
+import org.jboss.webbeans.resources.spi.ResourceLoader;
import org.jboss.webbeans.resources.spi.ResourceLoadingException;
import org.xml.sax.SAXException;
@@ -309,4 +315,38 @@
throw new DefinitionException("A certain annotation type is declared more than once as a binding type, " +
"interceptor binding type or stereotype using XML");
}
+
+ public static AnnotatedClass<?> obtainArray(Element arrayElement, XmlEnvironment environment, Map<String, Set<String>> packagesMap)
+ {
+ AnnotatedClass<?> arrayType = obtainArrayType(arrayElement, environment, packagesMap);
+ Object array = Array.newInstance(arrayType.getRawType(), 0);
+ AnnotatedClass<?> result = AnnotatedClassImpl.of(array.getClass(), new ClassTransformer());
+ return result;
+ }
+
+ public static AnnotatedClass<?> obtainArrayType(Element arrayElement, XmlEnvironment environment, Map<String, Set<String>> packagesMap)
+ {
+ AnnotatedClass<?> arrayType = null;
+
+ boolean haveNotAnnotation = false;
+ Iterator<?> arrayIterator = arrayElement.elementIterator();
+ while (arrayIterator.hasNext())
+ {
+ Element arrayChild = (Element) arrayIterator.next();
+ AnnotatedClass<?> arrayChildType = ParseXmlHelper.loadElementClass(arrayChild, Object.class, environment, packagesMap);
+ boolean isAnnotation = arrayChildType.getRawType().isAnnotation();
+ if (!isAnnotation)
+ {
+ if (haveNotAnnotation)
+ throw new DefinitionException("<Array> element have second child which is not annotation, it is '" +
+ arrayChild.getName() + "'");
+ haveNotAnnotation = true;
+ arrayType = arrayChildType;
+ }
+ }
+ if (!haveNotAnnotation)
+ throw new DefinitionException("<Array> element must have one child elemen which is not annotation");
+
+ return arrayType;
+ }
}
Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/xml/XmlParser.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/xml/XmlParser.java 2009-05-07 11:02:50 UTC (rev 2664)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/xml/XmlParser.java 2009-05-07 15:36:15 UTC (rev 2665)
@@ -98,25 +98,7 @@
Element child = (Element) childIterator.next();
if (XmlConstants.ARRAY.equalsIgnoreCase(child.getName()))
- {
- boolean haveNotAnnotation = false;
- Iterator<?> arrayIterator = child.elementIterator();
- while (arrayIterator.hasNext())
- {
- Element arrayChild = (Element) arrayIterator.next();
- AnnotatedClass<?> arrayChildType = ParseXmlHelper.loadElementClass(arrayChild, Object.class, environment, packagesMap);
- boolean isAnnotation = arrayChildType.getRawType().isAnnotation();
- if (!isAnnotation)
- {
- if (haveNotAnnotation)
- throw new DefinitionException("<Array> element have second child which is not annotation, it is '" +
- arrayChild.getName() + "'");
- haveNotAnnotation = true;
- }
- }
- if (!haveNotAnnotation)
- throw new DefinitionException("<Array> element must have one child elemen which is not annotation");
- }
+ ParseXmlHelper.obtainArrayType(child, environment, packagesMap);
else
checkChildrenForArray(child);
}
Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/xml/checker/beanchildren/ext/AbstractBeanChildrenChecker.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/xml/checker/beanchildren/ext/AbstractBeanChildrenChecker.java 2009-05-07 11:02:50 UTC (rev 2664)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/xml/checker/beanchildren/ext/AbstractBeanChildrenChecker.java 2009-05-07 15:36:15 UTC (rev 2665)
@@ -109,7 +109,12 @@
private void checkBeanChild(Element beanChildElement, AnnotatedClass<?> beanClass)
{
if (XmlConstants.ARRAY.equalsIgnoreCase(beanChildElement.getName()))
+ {
+ // bean child element declaring an array parameter of the bean constructor
+ AnnotatedClass<?> array = ParseXmlHelper.obtainArray(beanChildElement, environment, packagesMap);
+ constructorParameters.add(array);
return;
+ }
List<AnnotatedClass<?>> beanChildClassList = ParseXmlHelper.tryLoadElementClass(beanChildElement, Object.class, environment, packagesMap);
@@ -120,7 +125,7 @@
Namespace beanChildNamespace = beanChildElement.getNamespace();
if (beanChildNamespace.equals(beanNamespace))
{
- // bean child element declaring a method or field of the bean.
+ // bean child element declaring a method or field of the bean
checkFieldOrMethodChild(beanChildElement, beanClass);
return;
}
Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/xml/checker/beanchildren/ext/SimpleBeanChildrenChecker.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/xml/checker/beanchildren/ext/SimpleBeanChildrenChecker.java 2009-05-07 11:02:50 UTC (rev 2664)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/xml/checker/beanchildren/ext/SimpleBeanChildrenChecker.java 2009-05-07 15:36:15 UTC (rev 2665)
@@ -82,18 +82,18 @@
if (parameters.size() != constructorParameters.size())
continue;
- boolean isMacthable = true;
+ boolean isMatchable = true;
for (int i = 0; i < parameters.size(); i++)
{
if (!parameters.get(i).isAssignableFrom(constructorParameters.get(i)))
{
- isMacthable = false;
+ isMatchable = false;
break;
}
}
- if (isMacthable)
+ if (isMatchable)
matchableConstructors.add(constructor);
}
Modified: ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/xml/parser/schema/foo/Order.java
===================================================================
--- ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/xml/parser/schema/foo/Order.java 2009-05-07 11:02:50 UTC (rev 2664)
+++ ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/xml/parser/schema/foo/Order.java 2009-05-07 15:36:15 UTC (rev 2665)
@@ -14,9 +14,10 @@
this.val = 0;
}
- public Order(int val)
+ public Order(int val, String[] strArr)
{
this.val = val;
+ this.strArr = strArr;
}
public int getVal()
Modified: ri/trunk/tests/src/test/resources/org/jboss/webbeans/test/unit/xml/parser/schema/beans.xml
===================================================================
--- ri/trunk/tests/src/test/resources/org/jboss/webbeans/test/unit/xml/parser/schema/beans.xml 2009-05-07 11:02:50 UTC (rev 2664)
+++ ri/trunk/tests/src/test/resources/org/jboss/webbeans/test/unit/xml/parser/schema/beans.xml 2009-05-07 15:36:15 UTC (rev 2665)
@@ -3,11 +3,11 @@
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="urn:java:org.jboss.webbeans.test.unit.xml.parser.schema.valid http://mydomain.com/myapp/schema-1.2.xsd">
<myapp:Order>
+ <myapp:getVal />
+ <myapp:val />
+ <Integer />
<Array>
<String />
</Array>
- <myapp:getVal />
- <myapp:val />
- <Integer />
</myapp:Order>
</Beans>
\ No newline at end of file
Modified: ri/trunk/tests/src/test/resources/org/jboss/webbeans/test/unit/xml/parser/user-defined-beans.xml
===================================================================
--- ri/trunk/tests/src/test/resources/org/jboss/webbeans/test/unit/xml/parser/user-defined-beans.xml 2009-05-07 11:02:50 UTC (rev 2664)
+++ ri/trunk/tests/src/test/resources/org/jboss/webbeans/test/unit/xml/parser/user-defined-beans.xml 2009-05-07 15:36:15 UTC (rev 2665)
@@ -29,12 +29,12 @@
<myapp:TestInterceptorBindingType />
<myapp:TestStereotype />
<myapp:TestDeploymentType />
+ <myapp:getVal />
+ <myapp:val />
+ <Integer />
<Array>
<String />
</Array>
- <myapp:getVal />
- <myapp:val />
- <Integer />
</myapp:Order>
<!--
<myapp:PaymentService>
@@ -48,13 +48,13 @@
</Resource>
</myapp:PaymentService>
-->
-
+<!--
<Topic>
<Resource>
<name>java:app/service/PaymentService</name>
</Resource>
</Topic>
-
+-->
<Decorators>
<myapp:TestDecorator />
</Decorators>
15 years, 6 months
[webbeans-commits] Webbeans SVN: r2664 - ri/trunk/tests/src/test/resources/org/jboss/webbeans/test/unit/xml/javaeepkg.
by webbeans-commits@lists.jboss.org
Author: vitold
Date: 2009-05-07 07:02:50 -0400 (Thu, 07 May 2009)
New Revision: 2664
Modified:
ri/trunk/tests/src/test/resources/org/jboss/webbeans/test/unit/xml/javaeepkg/beans.xml
Log:
minor
Modified: ri/trunk/tests/src/test/resources/org/jboss/webbeans/test/unit/xml/javaeepkg/beans.xml
===================================================================
--- ri/trunk/tests/src/test/resources/org/jboss/webbeans/test/unit/xml/javaeepkg/beans.xml 2009-05-07 10:56:51 UTC (rev 2663)
+++ ri/trunk/tests/src/test/resources/org/jboss/webbeans/test/unit/xml/javaeepkg/beans.xml 2009-05-07 11:02:50 UTC (rev 2664)
@@ -5,7 +5,7 @@
<RequestScoped />
<Integer />
<Date />
- <CommonDataSource />
+ <DataSource />
<InvocationContext />
<Event />
<ScheduleExpression />
@@ -31,7 +31,7 @@
javax.context.RequestScoped;
java.lang.Integer;
java.util.Date;
- javax.sql.CommonDataSource;
+ javax.sql.DataSource;
javax.interceptor.InvocationContext;
javax.event.Event;
javax.ejb.ScheduleExpression;
15 years, 6 months