You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@openwebbeans.apache.org by ge...@apache.org on 2009/01/08 20:41:33 UTC
svn commit: r732803 [10/17] - in
/incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans:
./ annotation/ component/ component/ejb/ component/jms/ component/xml/
config/ container/ context/ context/type/ decorator/ decorator/xml/ d...
Modified: incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/jsf/ConversationImpl.java
URL: http://svn.apache.org/viewvc/incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/jsf/ConversationImpl.java?rev=732803&r1=732802&r2=732803&view=diff
==============================================================================
--- incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/jsf/ConversationImpl.java (original)
+++ incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/jsf/ConversationImpl.java Thu Jan 8 11:41:30 2009
@@ -1,22 +1,18 @@
/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You 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 License for the specific language governing permissions and
- * limitations under the License.
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with this
+ * work for additional information regarding copyright ownership. The ASF
+ * licenses this file to You 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 License for the specific language
+ * governing permissions and limitations under the License.
*/
package org.apache.webbeans.jsf;
-
import javax.webbeans.Conversation;
import javax.webbeans.ConversationScoped;
@@ -27,147 +23,148 @@
public class ConversationImpl implements Conversation
{
- private String id;
-
- private String viewId;
-
- private boolean longRunning = false;
-
- private long timeout;
-
- private String sessionId;
-
- private long activeTime = 0L;
-
- public ConversationImpl()
- {
-
- }
-
- public ConversationImpl(String sessionId)
- {
- Asserts.assertNotNull(sessionId);
- this.sessionId = sessionId;
-
- }
-
- public void begin()
- {
- this.longRunning = true;
- this.id = StringUtil.generateUUIDStringWithoutDash();
-
- ConversationManager.getInstance().addConversationContext(this,(ConversationContext) ManagerImpl.getManager().getContext(ConversationScoped.class));
- }
-
- public void begin(String id)
- {
- this.longRunning = true;
- this.id = id;
-
- ConversationManager.getInstance().addConversationContext(this,(ConversationContext) ManagerImpl.getManager().getContext(ConversationScoped.class));
- }
-
- public void end()
- {
- this.longRunning = false;
- }
-
- public String getId()
- {
- return this.id;
- }
-
- public long getTimeout()
- {
- return this.timeout;
- }
-
- public boolean isLongRunning()
- {
- return this.longRunning;
- }
-
- public void setTimeout(long milliseconds)
- {
- this.timeout = milliseconds;
- }
-
- public String getSessionId()
- {
- return this.sessionId;
- }
-
-
- /**
- * @return the creationTime
- */
- public long getActiveTime()
- {
- return activeTime;
- }
-
- /**
- * @return the viewId
- */
- public String getViewId()
- {
- return viewId;
- }
-
- public void updateTimeOut()
- {
- this.activeTime = System.currentTimeMillis();
- }
-
- /**
- * @param viewId the viewId to set
- */
- public void setViewId(String viewId)
- {
- this.viewId = viewId;
- }
-
- /* (non-Javadoc)
- * @see java.lang.Object#hashCode()
- */
- @Override
- public int hashCode()
- {
- final int prime = 31;
- int result = 1;
- result = prime * result + ((id == null) ? 0 : id.hashCode());
- result = prime * result + ((sessionId == null) ? 0 : sessionId.hashCode());
- return result;
- }
-
- /* (non-Javadoc)
- * @see java.lang.Object#equals(java.lang.Object)
- */
- @Override
- public boolean equals(Object obj)
- {
- if (this == obj)
- return true;
- if (obj == null)
- return false;
- if (getClass() != obj.getClass())
- return false;
- final ConversationImpl other = (ConversationImpl) obj;
- if (id == null)
- {
- if (other.id != null)
- return false;
- } else if (!id.equals(other.id))
- return false;
- if (sessionId == null)
- {
- if (other.sessionId != null)
- return false;
- } else if (!sessionId.equals(other.sessionId))
- return false;
- return true;
- }
-
-
-
-}
\ No newline at end of file
+ private String id;
+
+ private String viewId;
+
+ private boolean longRunning = false;
+
+ private long timeout;
+
+ private String sessionId;
+
+ private long activeTime = 0L;
+
+ public ConversationImpl()
+ {
+
+ }
+
+ public ConversationImpl(String sessionId)
+ {
+ Asserts.assertNotNull(sessionId);
+ this.sessionId = sessionId;
+
+ }
+
+ public void begin()
+ {
+ this.longRunning = true;
+ this.id = StringUtil.generateUUIDStringWithoutDash();
+
+ ConversationManager.getInstance().addConversationContext(this, (ConversationContext) ManagerImpl.getManager().getContext(ConversationScoped.class));
+ }
+
+ public void begin(String id)
+ {
+ this.longRunning = true;
+ this.id = id;
+
+ ConversationManager.getInstance().addConversationContext(this, (ConversationContext) ManagerImpl.getManager().getContext(ConversationScoped.class));
+ }
+
+ public void end()
+ {
+ this.longRunning = false;
+ }
+
+ public String getId()
+ {
+ return this.id;
+ }
+
+ public long getTimeout()
+ {
+ return this.timeout;
+ }
+
+ public boolean isLongRunning()
+ {
+ return this.longRunning;
+ }
+
+ public void setTimeout(long milliseconds)
+ {
+ this.timeout = milliseconds;
+ }
+
+ public String getSessionId()
+ {
+ return this.sessionId;
+ }
+
+ /**
+ * @return the creationTime
+ */
+ public long getActiveTime()
+ {
+ return activeTime;
+ }
+
+ /**
+ * @return the viewId
+ */
+ public String getViewId()
+ {
+ return viewId;
+ }
+
+ public void updateTimeOut()
+ {
+ this.activeTime = System.currentTimeMillis();
+ }
+
+ /**
+ * @param viewId the viewId to set
+ */
+ public void setViewId(String viewId)
+ {
+ this.viewId = viewId;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see java.lang.Object#hashCode()
+ */
+ @Override
+ public int hashCode()
+ {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + ((id == null) ? 0 : id.hashCode());
+ result = prime * result + ((sessionId == null) ? 0 : sessionId.hashCode());
+ return result;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see java.lang.Object#equals(java.lang.Object)
+ */
+ @Override
+ public boolean equals(Object obj)
+ {
+ if (this == obj)
+ return true;
+ if (obj == null)
+ return false;
+ if (getClass() != obj.getClass())
+ return false;
+ final ConversationImpl other = (ConversationImpl) obj;
+ if (id == null)
+ {
+ if (other.id != null)
+ return false;
+ } else if (!id.equals(other.id))
+ return false;
+ if (sessionId == null)
+ {
+ if (other.sessionId != null)
+ return false;
+ } else if (!sessionId.equals(other.sessionId))
+ return false;
+ return true;
+ }
+
+}
\ No newline at end of file
Modified: incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/jsf/ConversationManager.java
URL: http://svn.apache.org/viewvc/incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/jsf/ConversationManager.java?rev=732803&r1=732802&r2=732803&view=diff
==============================================================================
--- incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/jsf/ConversationManager.java (original)
+++ incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/jsf/ConversationManager.java Thu Jan 8 11:41:30 2009
@@ -1,18 +1,15 @@
/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You 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 License for the specific language governing permissions and
- * limitations under the License.
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with this
+ * work for additional information regarding copyright ownership. The ASF
+ * licenses this file to You 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 License for the specific language
+ * governing permissions and limitations under the License.
*/
package org.apache.webbeans.jsf;
@@ -32,132 +29,132 @@
public class ConversationManager
{
- private Map<Conversation, ConversationContext> conversations = null;
-
- public ConversationManager()
- {
-
- }
-
- public static ConversationManager getInstance()
- {
- ConversationManager manager = (ConversationManager)WebBeansFinder.getSingletonInstance(WebBeansFinder.SINGLETON_CONVERSATION_MANAGER);
- manager.conversations = new ConcurrentHashMap<Conversation, ConversationContext>();
-
- return manager;
- }
-
- public void addConversationContext(Conversation conversation, ConversationContext context)
- {
- conversations.put(conversation, context);
- }
-
- public ConversationContext removeConversation(Conversation conversation)
- {
- Asserts.assertNotNull(conversation,"conversation can not be null");
-
- return conversations.remove(conversation);
- }
-
- public ConversationContext getConversationContext(Conversation conversation)
- {
- Asserts.assertNotNull(conversation,"conversation can not be null");
-
- return conversations.get(conversation);
- }
-
-
- public Conversation getConversation(String conversationId)
- {
- Asserts.assertNotNull(conversationId,"conversationId parameter can not be null");
-
- ConversationImpl conv = null;
- Set<Conversation> set = conversations.keySet();
- Iterator<Conversation> it = set.iterator();
-
- while(it.hasNext())
- {
- conv = (ConversationImpl)it.next();
- if(conv.getId().equals(conversationId))
- {
- return conv;
- }
- }
-
- return null;
-
- }
-
- public void destroyConversationContextWithSessionId(String sessionId)
- {
- Asserts.assertNotNull(sessionId,"sessionId parameter can not be null");
-
- ConversationImpl conv = null;
- Set<Conversation> set = conversations.keySet();
- Iterator<Conversation> it = set.iterator();
-
- while(it.hasNext())
- {
- conv = (ConversationImpl)it.next();
- if(conv.getSessionId().equals(sessionId))
- {
- it.remove();
- }
- }
- }
-
- public Conversation createNewConversation(String viewId)
- {
- Asserts.assertNotNull(viewId,"viewId parameter can not be null");
-
- Conversation conversation = getCurrentConversation();
- ((ConversationImpl)conversation).setViewId(viewId);
-
- //Create conversation context
- //ContextFactory.initConversationContext();
-
- //addConversationContext(conversation,(ConversationContext) ManagerImpl.getManager().getContext(ConversationScoped.class));
-
- return conversation;
-
- }
-
- public Conversation getCurrentConversation()
- {
-
- Bean<Conversation> bean = ManagerImpl.getManager().resolveByType(Conversation.class, new CurrentLiteral()).iterator().next();
- Conversation conversation = ManagerImpl.getManager().getInstance(bean);
-
- return conversation;
- }
-
- public void destroyWithRespectToTimout()
- {
- ConversationImpl conv = null;
- Set<Conversation> set = conversations.keySet();
- Iterator<Conversation> it = set.iterator();
-
- while(it.hasNext())
- {
- conv = (ConversationImpl)it.next();
- long timeout = conv.getTimeout();
-
- if(timeout != 0L)
- {
- if((System.currentTimeMillis() - conv.getActiveTime()) > timeout)
- {
- it.remove();
- }
- }
- }
- }
-
- public void destroyAllConversations()
- {
- if(conversations != null)
- {
- conversations.clear();
- conversations = null;
- }
- }
+ private Map<Conversation, ConversationContext> conversations = null;
+
+ public ConversationManager()
+ {
+
+ }
+
+ public static ConversationManager getInstance()
+ {
+ ConversationManager manager = (ConversationManager) WebBeansFinder.getSingletonInstance(WebBeansFinder.SINGLETON_CONVERSATION_MANAGER);
+ manager.conversations = new ConcurrentHashMap<Conversation, ConversationContext>();
+
+ return manager;
+ }
+
+ public void addConversationContext(Conversation conversation, ConversationContext context)
+ {
+ conversations.put(conversation, context);
+ }
+
+ public ConversationContext removeConversation(Conversation conversation)
+ {
+ Asserts.assertNotNull(conversation, "conversation can not be null");
+
+ return conversations.remove(conversation);
+ }
+
+ public ConversationContext getConversationContext(Conversation conversation)
+ {
+ Asserts.assertNotNull(conversation, "conversation can not be null");
+
+ return conversations.get(conversation);
+ }
+
+ public Conversation getConversation(String conversationId)
+ {
+ Asserts.assertNotNull(conversationId, "conversationId parameter can not be null");
+
+ ConversationImpl conv = null;
+ Set<Conversation> set = conversations.keySet();
+ Iterator<Conversation> it = set.iterator();
+
+ while (it.hasNext())
+ {
+ conv = (ConversationImpl) it.next();
+ if (conv.getId().equals(conversationId))
+ {
+ return conv;
+ }
+ }
+
+ return null;
+
+ }
+
+ public void destroyConversationContextWithSessionId(String sessionId)
+ {
+ Asserts.assertNotNull(sessionId, "sessionId parameter can not be null");
+
+ ConversationImpl conv = null;
+ Set<Conversation> set = conversations.keySet();
+ Iterator<Conversation> it = set.iterator();
+
+ while (it.hasNext())
+ {
+ conv = (ConversationImpl) it.next();
+ if (conv.getSessionId().equals(sessionId))
+ {
+ it.remove();
+ }
+ }
+ }
+
+ public Conversation createNewConversation(String viewId)
+ {
+ Asserts.assertNotNull(viewId, "viewId parameter can not be null");
+
+ Conversation conversation = getCurrentConversation();
+ ((ConversationImpl) conversation).setViewId(viewId);
+
+ // Create conversation context
+ // ContextFactory.initConversationContext();
+
+ // addConversationContext(conversation,(ConversationContext)
+ // ManagerImpl.getManager().getContext(ConversationScoped.class));
+
+ return conversation;
+
+ }
+
+ public Conversation getCurrentConversation()
+ {
+
+ Bean<Conversation> bean = ManagerImpl.getManager().resolveByType(Conversation.class, new CurrentLiteral()).iterator().next();
+ Conversation conversation = ManagerImpl.getManager().getInstance(bean);
+
+ return conversation;
+ }
+
+ public void destroyWithRespectToTimout()
+ {
+ ConversationImpl conv = null;
+ Set<Conversation> set = conversations.keySet();
+ Iterator<Conversation> it = set.iterator();
+
+ while (it.hasNext())
+ {
+ conv = (ConversationImpl) it.next();
+ long timeout = conv.getTimeout();
+
+ if (timeout != 0L)
+ {
+ if ((System.currentTimeMillis() - conv.getActiveTime()) > timeout)
+ {
+ it.remove();
+ }
+ }
+ }
+ }
+
+ public void destroyAllConversations()
+ {
+ if (conversations != null)
+ {
+ conversations.clear();
+ conversations = null;
+ }
+ }
}
Modified: incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/jsf/WebBeansJSFFilter.java
URL: http://svn.apache.org/viewvc/incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/jsf/WebBeansJSFFilter.java?rev=732803&r1=732802&r2=732803&view=diff
==============================================================================
--- incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/jsf/WebBeansJSFFilter.java (original)
+++ incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/jsf/WebBeansJSFFilter.java Thu Jan 8 11:41:30 2009
@@ -1,18 +1,15 @@
/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You 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 License for the specific language governing permissions and
- * limitations under the License.
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with this
+ * work for additional information regarding copyright ownership. The ASF
+ * licenses this file to You 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 License for the specific language
+ * governing permissions and limitations under the License.
*/
package org.apache.webbeans.jsf;
@@ -36,52 +33,54 @@
public class WebBeansJSFFilter implements Filter
{
- public void destroy()
- {
-
- }
-
- public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException
- {
- HttpServletResponse servletResponse = (HttpServletResponse) response;
- HttpServletResponseWrapper responseWrapper = new HttpServletResponseWrapper(servletResponse){
-
- /* (non-Javadoc)
- * @see javax.servlet.http.HttpServletResponseWrapper#sendRedirect(java.lang.String)
- */
- @Override
- public void sendRedirect(String location) throws IOException
- {
- Bean<Conversation> bean = ManagerImpl.getManager().resolveByType(Conversation.class, new CurrentLiteral()).iterator().next();
- Conversation conversation = ManagerImpl.getManager().getInstance(bean);
-
- String path = location;
-
- if(conversation != null)
- {
-
- if(conversation.isLongRunning())
- {
- //Find JSFish view od of the redirection
- path = JSFUtil.getRedirectViewId(location);
- path = JSFUtil.getViewHandler().getActionURL(JSFUtil.getCurrentFacesContext(), path);
- path = JSFUtil.getExternalContext().encodeActionURL(path+"?cid="+conversation.getId());
- }
- }
-
- super.sendRedirect(path);
-
- }
-
-
- };
-
- chain.doFilter(request, responseWrapper);
- }
-
- public void init(FilterConfig config) throws ServletException
- {
-
- }
+ public void destroy()
+ {
+
+ }
+
+ public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException
+ {
+ HttpServletResponse servletResponse = (HttpServletResponse) response;
+ HttpServletResponseWrapper responseWrapper = new HttpServletResponseWrapper(servletResponse)
+ {
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see javax.servlet.http.HttpServletResponseWrapper#sendRedirect(java.lang.String)
+ */
+ @Override
+ public void sendRedirect(String location) throws IOException
+ {
+ Bean<Conversation> bean = ManagerImpl.getManager().resolveByType(Conversation.class, new CurrentLiteral()).iterator().next();
+ Conversation conversation = ManagerImpl.getManager().getInstance(bean);
+
+ String path = location;
+
+ if (conversation != null)
+ {
+
+ if (conversation.isLongRunning())
+ {
+ // Find JSFish view od of the redirection
+ path = JSFUtil.getRedirectViewId(location);
+ path = JSFUtil.getViewHandler().getActionURL(JSFUtil.getCurrentFacesContext(), path);
+ path = JSFUtil.getExternalContext().encodeActionURL(path + "?cid=" + conversation.getId());
+ }
+ }
+
+ super.sendRedirect(path);
+
+ }
+
+ };
+
+ chain.doFilter(request, responseWrapper);
+ }
+
+ public void init(FilterConfig config) throws ServletException
+ {
+
+ }
}
Modified: incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/jsf/WebBeansPhaseListener.java
URL: http://svn.apache.org/viewvc/incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/jsf/WebBeansPhaseListener.java?rev=732803&r1=732802&r2=732803&view=diff
==============================================================================
--- incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/jsf/WebBeansPhaseListener.java (original)
+++ incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/jsf/WebBeansPhaseListener.java Thu Jan 8 11:41:30 2009
@@ -1,18 +1,15 @@
/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You 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 License for the specific language governing permissions and
- * limitations under the License.
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with this
+ * work for additional information regarding copyright ownership. The ASF
+ * licenses this file to You 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 License for the specific language
+ * governing permissions and limitations under the License.
*/
package org.apache.webbeans.jsf;
@@ -31,150 +28,148 @@
public class WebBeansPhaseListener implements PhaseListener
{
- private static final long serialVersionUID = -8131516076829979596L;
+ private static final long serialVersionUID = -8131516076829979596L;
- private static WebBeansLogger logger = WebBeansLogger.getLogger(WebBeansPhaseListener.class);
+ private static WebBeansLogger logger = WebBeansLogger.getLogger(WebBeansPhaseListener.class);
- private static ConversationManager conversationManager = ConversationManager.getInstance();
+ private static ConversationManager conversationManager = ConversationManager.getInstance();
- private static ManagerImpl manager = ManagerImpl.getManager();
-
- private ConversationImpl conversation = null;
-
- public void afterPhase(PhaseEvent phaseEvent)
- {
- if (phaseEvent.getPhaseId().equals(PhaseId.RESTORE_VIEW))
- {
- if (!JSFUtil.isPostBack())
- {
- String cid = JSFUtil.getExternalContext().getRequestParameterMap().get("cid");
-
- //non-faces get request
- if (cid == null)
- {
- logger.info("Create new transitional conversation for non-faces request with view id : " + JSFUtil.getViewId());
- conversation = (ConversationImpl) conversationManager.createNewConversation(JSFUtil.getViewId());
-
- ContextFactory.initConversationContext(null);
-
- } else
- {
- logger.info("Propogation of the conversation with id : " + cid + " for view : " + JSFUtil.getViewId());
- conversation = (ConversationImpl) conversationManager.getConversation(cid);
-
- //can not restore conversation, create new transitional
- if (conversation == null)
- {
- logger.info("Propogated conversation can not be restored for view id : "+ JSFUtil.getViewId()+". Creates new transitional conversation");
- conversation = (ConversationImpl) conversationManager.createNewConversation(JSFUtil.getViewId());
-
- ContextFactory.initConversationContext(null);
- }
- else
- {
- ContextFactory.initConversationContext(conversationManager.getConversationContext(conversation));
- }
- }
- }
- else
- {
- logger.info("Postback JSF Request for view id : " + JSFUtil.getViewId());
-
- UIViewRoot viewRoot = JSFUtil.getViewRoot();
- HtmlInputHidden conversationId = (HtmlInputHidden) viewRoot.findComponent("javax_webbeans_ConversationId");
-
- if(conversationId != null)
- {
- //look long running conversation if exist
- conversation = (ConversationImpl) conversationManager.getConversation(conversationId.getValue().toString());
- ContextFactory.initConversationContext(conversationManager.getConversationContext(conversation));
-
- }
-
- //no long running conversation, create one transitional
- else
- {
- logger.info("Create new transient conversation for JSF postback view id : " + JSFUtil.getViewId());
- conversation = (ConversationImpl) conversationManager.createNewConversation(JSFUtil.getViewId());
-
- ContextFactory.initConversationContext(null);
- }
- }
- }
-
- else if (phaseEvent.getPhaseId().equals(PhaseId.RENDER_RESPONSE))
- {
- ConversationContext context = (ConversationContext)ManagerImpl.getManager().getContext(ConversationScoped.class);
-
- //if long running, saves it
- if (conversation.isLongRunning())
- {
- logger.info("Conversation with id : "+ conversation.getId() + " is marked as long running conversation");
- context.setActive(false);
- }
-
- //else destroy cınversation context
- else
- {
- logger.info("Destroying the conversation context for view id : " + JSFUtil.getViewId());
- context.destroy();
- }
-
- }
-
- }
-
- public void beforePhase(PhaseEvent phaseEvent)
- {
- if (phaseEvent.getPhaseId().equals(PhaseId.APPLY_REQUEST_VALUES))
- {
- ConversationContext context = (ConversationContext) manager.getContext(ConversationScoped.class);
-
- if (JSFUtil.isPostBack())
- {
- logger.info("Activating the conversation context for view id : " + JSFUtil.getViewId());
- context.setActive(true);
-
- conversation.updateTimeOut();
- }
- }
-
- else if (phaseEvent.getPhaseId().equals(PhaseId.RENDER_RESPONSE))
- {
- ConversationContext context = (ConversationContext) manager.getContext(ConversationScoped.class);
-
- if (!JSFUtil.isPostBack())
- {
- logger.info("Activating the conversation context for view id : " + JSFUtil.getViewId());
- context.setActive(true);
-
- conversation.updateTimeOut();
- }
-
- if(conversation.isLongRunning())
- {
- UIViewRoot viewRoot = JSFUtil.getViewRoot();
-
- HtmlInputHidden hidden = (HtmlInputHidden) viewRoot.findComponent("javax_webbeans_ConversationId");
-
- if(hidden != null)
- {
- viewRoot.getChildren().remove(hidden);
- }
-
- hidden = (HtmlInputHidden)JSFUtil.getApplication().createComponent(HtmlInputHidden.COMPONENT_TYPE);
- hidden.setValue(conversation.getId());
- hidden.setId("javax_webbeans_ConversationId");
-
- viewRoot.getChildren().add(hidden);
- }
- }
-
- }
-
- public PhaseId getPhaseId()
- {
- return PhaseId.ANY_PHASE;
- }
+ private static ManagerImpl manager = ManagerImpl.getManager();
+
+ private ConversationImpl conversation = null;
+
+ public void afterPhase(PhaseEvent phaseEvent)
+ {
+ if (phaseEvent.getPhaseId().equals(PhaseId.RESTORE_VIEW))
+ {
+ if (!JSFUtil.isPostBack())
+ {
+ String cid = JSFUtil.getExternalContext().getRequestParameterMap().get("cid");
+
+ // non-faces get request
+ if (cid == null)
+ {
+ logger.info("Create new transitional conversation for non-faces request with view id : " + JSFUtil.getViewId());
+ conversation = (ConversationImpl) conversationManager.createNewConversation(JSFUtil.getViewId());
+
+ ContextFactory.initConversationContext(null);
+
+ } else
+ {
+ logger.info("Propogation of the conversation with id : " + cid + " for view : " + JSFUtil.getViewId());
+ conversation = (ConversationImpl) conversationManager.getConversation(cid);
+
+ // can not restore conversation, create new transitional
+ if (conversation == null)
+ {
+ logger.info("Propogated conversation can not be restored for view id : " + JSFUtil.getViewId() + ". Creates new transitional conversation");
+ conversation = (ConversationImpl) conversationManager.createNewConversation(JSFUtil.getViewId());
+
+ ContextFactory.initConversationContext(null);
+ } else
+ {
+ ContextFactory.initConversationContext(conversationManager.getConversationContext(conversation));
+ }
+ }
+ } else
+ {
+ logger.info("Postback JSF Request for view id : " + JSFUtil.getViewId());
+
+ UIViewRoot viewRoot = JSFUtil.getViewRoot();
+ HtmlInputHidden conversationId = (HtmlInputHidden) viewRoot.findComponent("javax_webbeans_ConversationId");
+
+ if (conversationId != null)
+ {
+ // look long running conversation if exist
+ conversation = (ConversationImpl) conversationManager.getConversation(conversationId.getValue().toString());
+ ContextFactory.initConversationContext(conversationManager.getConversationContext(conversation));
+
+ }
+
+ // no long running conversation, create one transitional
+ else
+ {
+ logger.info("Create new transient conversation for JSF postback view id : " + JSFUtil.getViewId());
+ conversation = (ConversationImpl) conversationManager.createNewConversation(JSFUtil.getViewId());
+
+ ContextFactory.initConversationContext(null);
+ }
+ }
+ }
+
+ else if (phaseEvent.getPhaseId().equals(PhaseId.RENDER_RESPONSE))
+ {
+ ConversationContext context = (ConversationContext) ManagerImpl.getManager().getContext(ConversationScoped.class);
+
+ // if long running, saves it
+ if (conversation.isLongRunning())
+ {
+ logger.info("Conversation with id : " + conversation.getId() + " is marked as long running conversation");
+ context.setActive(false);
+ }
+
+ // else destroy cınversation context
+ else
+ {
+ logger.info("Destroying the conversation context for view id : " + JSFUtil.getViewId());
+ context.destroy();
+ }
+
+ }
+
+ }
+
+ public void beforePhase(PhaseEvent phaseEvent)
+ {
+ if (phaseEvent.getPhaseId().equals(PhaseId.APPLY_REQUEST_VALUES))
+ {
+ ConversationContext context = (ConversationContext) manager.getContext(ConversationScoped.class);
+
+ if (JSFUtil.isPostBack())
+ {
+ logger.info("Activating the conversation context for view id : " + JSFUtil.getViewId());
+ context.setActive(true);
+
+ conversation.updateTimeOut();
+ }
+ }
+
+ else if (phaseEvent.getPhaseId().equals(PhaseId.RENDER_RESPONSE))
+ {
+ ConversationContext context = (ConversationContext) manager.getContext(ConversationScoped.class);
+
+ if (!JSFUtil.isPostBack())
+ {
+ logger.info("Activating the conversation context for view id : " + JSFUtil.getViewId());
+ context.setActive(true);
+
+ conversation.updateTimeOut();
+ }
+
+ if (conversation.isLongRunning())
+ {
+ UIViewRoot viewRoot = JSFUtil.getViewRoot();
+
+ HtmlInputHidden hidden = (HtmlInputHidden) viewRoot.findComponent("javax_webbeans_ConversationId");
+
+ if (hidden != null)
+ {
+ viewRoot.getChildren().remove(hidden);
+ }
+
+ hidden = (HtmlInputHidden) JSFUtil.getApplication().createComponent(HtmlInputHidden.COMPONENT_TYPE);
+ hidden.setValue(conversation.getId());
+ hidden.setId("javax_webbeans_ConversationId");
+
+ viewRoot.getChildren().add(hidden);
+ }
+ }
+
+ }
+
+ public PhaseId getPhaseId()
+ {
+ return PhaseId.ANY_PHASE;
+ }
}
Modified: incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/lifecycle/WebBeansLifeCycle.java
URL: http://svn.apache.org/viewvc/incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/lifecycle/WebBeansLifeCycle.java?rev=732803&r1=732802&r2=732803&view=diff
==============================================================================
--- incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/lifecycle/WebBeansLifeCycle.java (original)
+++ incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/lifecycle/WebBeansLifeCycle.java Thu Jan 8 11:41:30 2009
@@ -1,18 +1,15 @@
/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You 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 License for the specific language governing permissions and
- * limitations under the License.
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with this
+ * work for additional information regarding copyright ownership. The ASF
+ * licenses this file to You 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 License for the specific language
+ * governing permissions and limitations under the License.
*/
package org.apache.webbeans.lifecycle;
@@ -43,123 +40,121 @@
public final class WebBeansLifeCycle
{
- private static WebBeansLogger logger = WebBeansLogger.getLogger(WebBeansLifeCycle.class);
-
- private ScheduledExecutorService service = null;
-
- private WebBeansScanner scanner = null;
-
- private WebBeansContainerDeployer deployer = null;
-
- private WebBeansXMLConfigurator xmlDeployer = null;
-
- public WebBeansLifeCycle()
- {
- this.scanner = new WebBeansScanner();
- this.xmlDeployer = new WebBeansXMLConfigurator();
- this.deployer = new WebBeansContainerDeployer(xmlDeployer);
- }
-
-
- public void requestStarted(ServletRequestEvent event)
- {
- logger.info("Initializing of the Request Context with Remote Address : " + event.getServletRequest().getRemoteAddr());
- ContextFactory.initRequestContext((HttpServletRequest)event.getServletRequest());
- }
-
- public void requestEnded(ServletRequestEvent event)
- {
- logger.info("Destroying of the Request Context with Remote Address : " + event.getServletRequest().getRemoteAddr());
- ContextFactory.destroyRequestContext((HttpServletRequest)event.getServletRequest());
- }
-
- public void sessionStarted(HttpSessionEvent event)
- {
- logger.info("Initializing of the Session Context with session id : " + event.getSession().getId());
- ContextFactory.initSessionContext(event.getSession());
- }
-
- public void sessionEnded(HttpSessionEvent event)
- {
- logger.info("Destroying of the Session Context with session id : " + event.getSession().getId());
- ContextFactory.destroySessionContext(event.getSession());
-
- ConversationManager conversationManager = ConversationManager.getInstance();
- conversationManager.destroyConversationContextWithSessionId(event.getSession().getId());
- }
-
- public void applicationStarted(ServletContextEvent event)
- {
- //I do not know this is the correct way, spec is not so explicit.
- service = Executors.newScheduledThreadPool(1);
- service.scheduleWithFixedDelay(new Runnable(){
-
- public void run()
- {
- ConversationManager.getInstance().destroyWithRespectToTimout();
-
- }
-
- }, 15000, 15000, TimeUnit.MILLISECONDS);
-
-
- logger.info("Starting the WebBeans Container Configuration");
- long begin = System.currentTimeMillis();
-
- logger.info("Scanning classpaths for WebBeans artifacts is started");
-
- scanner.scan(event.getServletContext());
-
- logger.info("Scanning is ended.");
-
- logger.info("Deploying the scanned WebBeans artifacts.");
-
- deployer.deploy(this.scanner);
-
- logger.info("Deploying is ended.");
-
- long end = System.currentTimeMillis();
- logger.info("WebBeans Container Configuration is ended, takes " + Long.toString(end - begin) + " ms.");
-
- //Initalize Application Context
- logger.info("Initializing of the Application Context with Context Path : " + event.getServletContext().getContextPath());
- ContextFactory.initApplicationContext(event.getServletContext());
-
- ServletContext context = event.getServletContext();
-
- try
- {
- //check this application is JSF application
- URL url = context.getResource("/WEB-INF/faces-config.xml");
- if(url == null)
- {
- JspApplicationContext applicationCtx = JspFactory.getDefaultFactory().getJspApplicationContext(context);
- applicationCtx.addELResolver(new WebBeansELResolver());
- }
-
- }catch(MalformedURLException e)
- {
- logger.error(e);
- throw new WebBeansException(e);
- }
-
-
- }
-
- public void applicationEnded(ServletContextEvent event)
- {
- service.shutdownNow();
-
- logger.info("Destroying of the Application Context with Context Path : " + event.getServletContext().getContextPath());
- ContextFactory.destroyApplicationContext(event.getServletContext());
-
- JNDIUtil.unbind(WebBeansConstants.WEB_BEANS_MANAGER_JNDI_NAME);
-
- this.deployer = null;
- this.scanner = null;
- this.service = null;
- this.xmlDeployer = null;
+ private static WebBeansLogger logger = WebBeansLogger.getLogger(WebBeansLifeCycle.class);
+
+ private ScheduledExecutorService service = null;
+
+ private WebBeansScanner scanner = null;
+
+ private WebBeansContainerDeployer deployer = null;
+
+ private WebBeansXMLConfigurator xmlDeployer = null;
+
+ public WebBeansLifeCycle()
+ {
+ this.scanner = new WebBeansScanner();
+ this.xmlDeployer = new WebBeansXMLConfigurator();
+ this.deployer = new WebBeansContainerDeployer(xmlDeployer);
+ }
+
+ public void requestStarted(ServletRequestEvent event)
+ {
+ logger.info("Initializing of the Request Context with Remote Address : " + event.getServletRequest().getRemoteAddr());
+ ContextFactory.initRequestContext((HttpServletRequest) event.getServletRequest());
+ }
+
+ public void requestEnded(ServletRequestEvent event)
+ {
+ logger.info("Destroying of the Request Context with Remote Address : " + event.getServletRequest().getRemoteAddr());
+ ContextFactory.destroyRequestContext((HttpServletRequest) event.getServletRequest());
+ }
+
+ public void sessionStarted(HttpSessionEvent event)
+ {
+ logger.info("Initializing of the Session Context with session id : " + event.getSession().getId());
+ ContextFactory.initSessionContext(event.getSession());
+ }
+
+ public void sessionEnded(HttpSessionEvent event)
+ {
+ logger.info("Destroying of the Session Context with session id : " + event.getSession().getId());
+ ContextFactory.destroySessionContext(event.getSession());
+
+ ConversationManager conversationManager = ConversationManager.getInstance();
+ conversationManager.destroyConversationContextWithSessionId(event.getSession().getId());
+ }
+
+ public void applicationStarted(ServletContextEvent event)
+ {
+ // I do not know this is the correct way, spec is not so explicit.
+ service = Executors.newScheduledThreadPool(1);
+ service.scheduleWithFixedDelay(new Runnable()
+ {
+
+ public void run()
+ {
+ ConversationManager.getInstance().destroyWithRespectToTimout();
+
+ }
+
+ }, 15000, 15000, TimeUnit.MILLISECONDS);
+
+ logger.info("Starting the WebBeans Container Configuration");
+ long begin = System.currentTimeMillis();
+
+ logger.info("Scanning classpaths for WebBeans artifacts is started");
+
+ scanner.scan(event.getServletContext());
+
+ logger.info("Scanning is ended.");
+
+ logger.info("Deploying the scanned WebBeans artifacts.");
+
+ deployer.deploy(this.scanner);
+
+ logger.info("Deploying is ended.");
+
+ long end = System.currentTimeMillis();
+ logger.info("WebBeans Container Configuration is ended, takes " + Long.toString(end - begin) + " ms.");
+
+ // Initalize Application Context
+ logger.info("Initializing of the Application Context with Context Path : " + event.getServletContext().getContextPath());
+ ContextFactory.initApplicationContext(event.getServletContext());
+
+ ServletContext context = event.getServletContext();
+
+ try
+ {
+ // check this application is JSF application
+ URL url = context.getResource("/WEB-INF/faces-config.xml");
+ if (url == null)
+ {
+ JspApplicationContext applicationCtx = JspFactory.getDefaultFactory().getJspApplicationContext(context);
+ applicationCtx.addELResolver(new WebBeansELResolver());
+ }
+
+ } catch (MalformedURLException e)
+ {
+ logger.error(e);
+ throw new WebBeansException(e);
+ }
+
+ }
+
+ public void applicationEnded(ServletContextEvent event)
+ {
+ service.shutdownNow();
+
+ logger.info("Destroying of the Application Context with Context Path : " + event.getServletContext().getContextPath());
+ ContextFactory.destroyApplicationContext(event.getServletContext());
+
+ JNDIUtil.unbind(WebBeansConstants.WEB_BEANS_MANAGER_JNDI_NAME);
+
+ this.deployer = null;
+ this.scanner = null;
+ this.service = null;
+ this.xmlDeployer = null;
+
+ }
- }
-
}
Modified: incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/logger/WebBeansLogger.java
URL: http://svn.apache.org/viewvc/incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/logger/WebBeansLogger.java?rev=732803&r1=732802&r2=732803&view=diff
==============================================================================
--- incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/logger/WebBeansLogger.java (original)
+++ incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/logger/WebBeansLogger.java Thu Jan 8 11:41:30 2009
@@ -1,27 +1,23 @@
/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You 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 License for the specific language governing permissions and
- * limitations under the License.
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with this
+ * work for additional information regarding copyright ownership. The ASF
+ * licenses this file to You 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 License for the specific language
+ * governing permissions and limitations under the License.
*/
package org.apache.webbeans.logger;
import org.apache.log4j.Logger;
/**
- * Wrapper class around the log4j logger class to include some checks
- * before the logs are actually written.
- *
+ * Wrapper class around the log4j logger class to include some checks before the
+ * logs are actually written.
* <p>
* Actually, it is a thin layer on the log4j {@link Logger} implementation.
* </p>
@@ -31,132 +27,132 @@
*/
public final class WebBeansLogger
{
- /**Inner logger object to log actual log messages*/
- private Logger logger = null;
+ /** Inner logger object to log actual log messages */
+ private Logger logger = null;
- /**Private constructor*/
- private WebBeansLogger()
- {
-
- }
-
-
- /**
- * Gets the new web beans logger instance.
- * @param clazz own the return logger
- * @return new logger
- */
- public static WebBeansLogger getLogger(Class<?> clazz)
- {
- WebBeansLogger wbLogger = new WebBeansLogger();
- Logger inLogger = Logger.getLogger(clazz);
-
- wbLogger.setLogger(inLogger);
-
- return wbLogger;
- }
-
- public void fatal(String message)
- {
- checkNullLogger();
- logger.fatal(message);
- }
-
- public void fatal(String message,Throwable e)
- {
- checkNullLogger();
- logger.fatal(message,e);
-
- }
-
- public void error(Throwable e)
- {
- checkNullLogger();
- logger.error(e);
- }
-
-
- public void error(String message)
- {
- checkNullLogger();
- logger.error(message);
- }
-
- public void error(String message,Throwable e)
- {
- checkNullLogger();
- logger.error(message,e);
-
- }
-
- public void warn(String message)
- {
- checkNullLogger();
- logger.warn(message);
- }
-
- public void warn(String message,Throwable e)
- {
- checkNullLogger();
- logger.warn(message,e);
- }
-
- public void info(String message)
- {
- checkNullLogger();
- if(logger.isInfoEnabled())
- logger.info(message);
- }
-
- public void info(String message,Throwable e)
- {
- checkNullLogger();
- if(logger.isInfoEnabled())
- logger.info(message,e);
- }
-
- public void debug(String message)
- {
- checkNullLogger();
- if(logger.isDebugEnabled())
- logger.debug(message);
- }
-
- public void debug(String message,Throwable e)
- {
- checkNullLogger();
- if(logger.isDebugEnabled())
- logger.debug(message,e);
- }
-
- public void trace(String message)
- {
- checkNullLogger();
- if(logger.isTraceEnabled())
- logger.trace(message);
- }
-
- public void trace(String message,Throwable e)
- {
- checkNullLogger();
- if(logger.isTraceEnabled())
- logger.trace(message,e);
- }
-
- /**
- * Sets the logger
- * @param logger new logger instance
- */
- public void setLogger(Logger logger)
- {
- this.logger = logger;
- }
-
- private void checkNullLogger()
- {
- if(this.logger == null)
- {
- throw new NullPointerException("Logger can not be null");
- }
- }
+ /** Private constructor */
+ private WebBeansLogger()
+ {
+
+ }
+
+ /**
+ * Gets the new web beans logger instance.
+ *
+ * @param clazz own the return logger
+ * @return new logger
+ */
+ public static WebBeansLogger getLogger(Class<?> clazz)
+ {
+ WebBeansLogger wbLogger = new WebBeansLogger();
+ Logger inLogger = Logger.getLogger(clazz);
+
+ wbLogger.setLogger(inLogger);
+
+ return wbLogger;
+ }
+
+ public void fatal(String message)
+ {
+ checkNullLogger();
+ logger.fatal(message);
+ }
+
+ public void fatal(String message, Throwable e)
+ {
+ checkNullLogger();
+ logger.fatal(message, e);
+
+ }
+
+ public void error(Throwable e)
+ {
+ checkNullLogger();
+ logger.error(e);
+ }
+
+ public void error(String message)
+ {
+ checkNullLogger();
+ logger.error(message);
+ }
+
+ public void error(String message, Throwable e)
+ {
+ checkNullLogger();
+ logger.error(message, e);
+
+ }
+
+ public void warn(String message)
+ {
+ checkNullLogger();
+ logger.warn(message);
+ }
+
+ public void warn(String message, Throwable e)
+ {
+ checkNullLogger();
+ logger.warn(message, e);
+ }
+
+ public void info(String message)
+ {
+ checkNullLogger();
+ if (logger.isInfoEnabled())
+ logger.info(message);
+ }
+
+ public void info(String message, Throwable e)
+ {
+ checkNullLogger();
+ if (logger.isInfoEnabled())
+ logger.info(message, e);
+ }
+
+ public void debug(String message)
+ {
+ checkNullLogger();
+ if (logger.isDebugEnabled())
+ logger.debug(message);
+ }
+
+ public void debug(String message, Throwable e)
+ {
+ checkNullLogger();
+ if (logger.isDebugEnabled())
+ logger.debug(message, e);
+ }
+
+ public void trace(String message)
+ {
+ checkNullLogger();
+ if (logger.isTraceEnabled())
+ logger.trace(message);
+ }
+
+ public void trace(String message, Throwable e)
+ {
+ checkNullLogger();
+ if (logger.isTraceEnabled())
+ logger.trace(message, e);
+ }
+
+ /**
+ * Sets the logger
+ *
+ * @param logger new logger instance
+ */
+ public void setLogger(Logger logger)
+ {
+ this.logger = logger;
+ }
+
+ private void checkNullLogger()
+ {
+ if (this.logger == null)
+ {
+ throw new NullPointerException("Logger can not be null");
+ }
+ }
}
Modified: incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/proxy/JavassistProxyFactory.java
URL: http://svn.apache.org/viewvc/incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/proxy/JavassistProxyFactory.java?rev=732803&r1=732802&r2=732803&view=diff
==============================================================================
--- incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/proxy/JavassistProxyFactory.java (original)
+++ incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/proxy/JavassistProxyFactory.java Thu Jan 8 11:41:30 2009
@@ -1,18 +1,15 @@
/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You 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 License for the specific language governing permissions and
- * limitations under the License.
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with this
+ * work for additional information regarding copyright ownership. The ASF
+ * licenses this file to You 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 License for the specific language
+ * governing permissions and limitations under the License.
*/
package org.apache.webbeans.proxy;
@@ -35,77 +32,74 @@
public final class JavassistProxyFactory
{
- private JavassistProxyFactory()
- {
-
- }
-
-
- public static <T> Object createNewProxyInstance(Bean<T> bean)
- {
- Object result = null;
- try
- {
- Set<Class<?>> types = bean.getTypes();
- List<Class<?>> interfaceList = new ArrayList<Class<?>>();
- Class<?> superClass = null;
- for(Class<?> type : types)
- {
- if(type.isInterface())
- {
- interfaceList.add(type);
- }
- else if ((superClass == null)
- || (superClass.isAssignableFrom(type) && type != Object.class ))
- {
- superClass = type;
- }
-
- }
-
- interfaceList.add(Serializable.class);
-
- Class<?>[] interfaceArray = new Class<?>[interfaceList.size()];
- interfaceArray = interfaceList.toArray(interfaceArray);
-
- ProxyFactory fact = new ProxyFactory();
- fact.setInterfaces(interfaceArray);
- fact.setSuperclass(superClass);
-
- if(!(bean instanceof WebBeansDecorator) && !(bean instanceof WebBeansInterceptor))
- {
- fact.setHandler(new InterceptorHandler((AbstractComponent<?>)bean));
- }
-
- result = fact.createClass().newInstance();
-
- }catch(Throwable e)
- {
- throw new WebBeansException(e);
- }
-
- return result;
- }
-
- public static WebBeansAnnotation createNewAnnotationProxy(Class<? extends Annotation> annotationType)
- {
- WebBeansAnnotation result = null;
-
- try
- {
- ProxyFactory pf = new ProxyFactory();
- pf.setInterfaces(new Class<?>[]{annotationType,Annotation.class});
- pf.setSuperclass(WebBeansAnnotation.class);
- pf.setHandler(new WebBeansAnnotation(annotationType));
-
- result = (WebBeansAnnotation)pf.create(new Class[]{Class.class}, new Object[]{annotationType});
-
- }catch(Exception e)
- {
- throw new WebBeansException(e);
- }
-
- return result;
- }
+ private JavassistProxyFactory()
+ {
+
+ }
+
+ public static <T> Object createNewProxyInstance(Bean<T> bean)
+ {
+ Object result = null;
+ try
+ {
+ Set<Class<?>> types = bean.getTypes();
+ List<Class<?>> interfaceList = new ArrayList<Class<?>>();
+ Class<?> superClass = null;
+ for (Class<?> type : types)
+ {
+ if (type.isInterface())
+ {
+ interfaceList.add(type);
+ } else if ((superClass == null) || (superClass.isAssignableFrom(type) && type != Object.class))
+ {
+ superClass = type;
+ }
+
+ }
+
+ interfaceList.add(Serializable.class);
+
+ Class<?>[] interfaceArray = new Class<?>[interfaceList.size()];
+ interfaceArray = interfaceList.toArray(interfaceArray);
+
+ ProxyFactory fact = new ProxyFactory();
+ fact.setInterfaces(interfaceArray);
+ fact.setSuperclass(superClass);
+
+ if (!(bean instanceof WebBeansDecorator) && !(bean instanceof WebBeansInterceptor))
+ {
+ fact.setHandler(new InterceptorHandler((AbstractComponent<?>) bean));
+ }
+
+ result = fact.createClass().newInstance();
+
+ } catch (Throwable e)
+ {
+ throw new WebBeansException(e);
+ }
+
+ return result;
+ }
+
+ public static WebBeansAnnotation createNewAnnotationProxy(Class<? extends Annotation> annotationType)
+ {
+ WebBeansAnnotation result = null;
+
+ try
+ {
+ ProxyFactory pf = new ProxyFactory();
+ pf.setInterfaces(new Class<?>[] { annotationType, Annotation.class });
+ pf.setSuperclass(WebBeansAnnotation.class);
+ pf.setHandler(new WebBeansAnnotation(annotationType));
+
+ result = (WebBeansAnnotation) pf.create(new Class[] { Class.class }, new Object[] { annotationType });
+
+ } catch (Exception e)
+ {
+ throw new WebBeansException(e);
+ }
+
+ return result;
+ }
}
Modified: incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/servlet/WebBeansConfigurationListener.java
URL: http://svn.apache.org/viewvc/incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/servlet/WebBeansConfigurationListener.java?rev=732803&r1=732802&r2=732803&view=diff
==============================================================================
--- incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/servlet/WebBeansConfigurationListener.java (original)
+++ incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/servlet/WebBeansConfigurationListener.java Thu Jan 8 11:41:30 2009
@@ -1,22 +1,18 @@
/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You 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 License for the specific language governing permissions and
- * limitations under the License.
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with this
+ * work for additional information regarding copyright ownership. The ASF
+ * licenses this file to You 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 License for the specific language
+ * governing permissions and limitations under the License.
*/
package org.apache.webbeans.servlet;
-
import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;
import javax.servlet.ServletRequestEvent;
@@ -29,60 +25,61 @@
/**
* Configures the all web beans components that are defined in the EAR or WAR
* file.
+ *
* @author <a href="mailto:gurkanerdogdu@yahoo.com">Gurkan Erdogdu</a>
* @since 1.0
*/
-public class WebBeansConfigurationListener implements ServletContextListener,ServletRequestListener,HttpSessionListener
+public class WebBeansConfigurationListener implements ServletContextListener, ServletRequestListener, HttpSessionListener
{
- private WebBeansLifeCycle lifeCycle = null;
+ private WebBeansLifeCycle lifeCycle = null;
+
+ /**
+ * Performed when the servlet context destroyed.
+ */
+ public void contextDestroyed(ServletContextEvent event)
+ {
+ this.lifeCycle.applicationEnded(event);
+ }
+
+ /**
+ * Performed when the servlet context started.
+ */
+ public void contextInitialized(ServletContextEvent event)
+ {
+ this.lifeCycle = new WebBeansLifeCycle();
+ this.lifeCycle.applicationStarted(event);
+ }
+
+ /**
+ * Destroy request context
+ */
+ public void requestDestroyed(ServletRequestEvent event)
+ {
+ this.lifeCycle.requestEnded(event);
+ }
+
+ /**
+ * Initializes the request context
+ */
+ public void requestInitialized(ServletRequestEvent event)
+ {
+ this.lifeCycle.requestStarted(event);
+ }
+
+ /**
+ * Initializes session context
+ */
+ public void sessionCreated(HttpSessionEvent event)
+ {
+ this.lifeCycle.sessionStarted(event);
+ }
+
+ /**
+ * Destroy session context
+ */
+ public void sessionDestroyed(HttpSessionEvent event)
+ {
+ this.lifeCycle.sessionEnded(event);
+ }
- /**
- * Performed when the servlet context destroyed.
- */
- public void contextDestroyed(ServletContextEvent event)
- {
- this.lifeCycle.applicationEnded(event);
- }
-
- /**
- * Performed when the servlet context started.
- */
- public void contextInitialized(ServletContextEvent event)
- {
- this.lifeCycle = new WebBeansLifeCycle();
- this.lifeCycle.applicationStarted(event);
- }
-
- /**
- * Destroy request context
- */
- public void requestDestroyed(ServletRequestEvent event)
- {
- this.lifeCycle.requestEnded(event);
- }
-
- /**
- * Initializes the request context
- */
- public void requestInitialized(ServletRequestEvent event)
- {
- this.lifeCycle.requestStarted(event);
- }
-
- /**
- * Initializes session context
- */
- public void sessionCreated(HttpSessionEvent event)
- {
- this.lifeCycle.sessionStarted(event);
- }
-
- /**
- * Destroy session context
- */
- public void sessionDestroyed(HttpSessionEvent event)
- {
- this.lifeCycle.sessionEnded(event);
- }
-
}
Modified: incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/transaction/TransactionUtil.java
URL: http://svn.apache.org/viewvc/incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/transaction/TransactionUtil.java?rev=732803&r1=732802&r2=732803&view=diff
==============================================================================
--- incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/transaction/TransactionUtil.java (original)
+++ incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/transaction/TransactionUtil.java Thu Jan 8 11:41:30 2009
@@ -1,18 +1,15 @@
/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You 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 License for the specific language governing permissions and
- * limitations under the License.
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with this
+ * work for additional information regarding copyright ownership. The ASF
+ * licenses this file to You 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 License for the specific language
+ * governing permissions and limitations under the License.
*/
package org.apache.webbeans.transaction;
@@ -25,31 +22,31 @@
public final class TransactionUtil
{
- private static WebBeansLogger logger = WebBeansLogger.getLogger(TransactionUtil.class);
-
- private static TransactionManager transactionManager = null;
-
- private TransactionUtil()
- {
-
- }
-
- public static TransactionManager getCurrentTransactionManager()
- {
- if(transactionManager == null)
- {
- try
- {
- transactionManager = (TransactionManager)JNDIUtil.getInitialContext().lookup("java:/TransactionManager");
-
- } catch (NamingException e)
- {
- logger.error("Unable to get TransactionManager",e);
- throw new WebBeansException(e);
- }
- }
-
- return transactionManager;
- }
-
+ private static WebBeansLogger logger = WebBeansLogger.getLogger(TransactionUtil.class);
+
+ private static TransactionManager transactionManager = null;
+
+ private TransactionUtil()
+ {
+
+ }
+
+ public static TransactionManager getCurrentTransactionManager()
+ {
+ if (transactionManager == null)
+ {
+ try
+ {
+ transactionManager = (TransactionManager) JNDIUtil.getInitialContext().lookup("java:/TransactionManager");
+
+ } catch (NamingException e)
+ {
+ logger.error("Unable to get TransactionManager", e);
+ throw new WebBeansException(e);
+ }
+ }
+
+ return transactionManager;
+ }
+
}