Author: apetrelli
Date: Mon Sep 28 16:56:14 2009
New Revision: 819641
URL: http://svn.apache.org/viewvc?rev=819641&view=rev
Log:
TILES-469
Checking if a class of the porlet API is present. If not, this problem is
trapped and the PortletTilesRequestContextFactory ignored.
Added:
tiles/framework/trunk/tiles-core/src/main/java/org/apache/tiles/factory/NotAvailableFeatureException.java
(with props)
tiles/framework/trunk/tiles-portlet/src/main/java/org/apache/tiles/portlet/context/NotAPortletEnvironmentException.java
(with props)
Modified:
tiles/framework/trunk/tiles-core/src/main/java/org/apache/tiles/factory/BasicTilesContainerFactory.java
tiles/framework/trunk/tiles-portlet/src/main/java/org/apache/tiles/portlet/context/PortletTilesRequestContextFactory.java
Modified:
tiles/framework/trunk/tiles-core/src/main/java/org/apache/tiles/factory/BasicTilesContainerFactory.java
URL:
http://svn.apache.org/viewvc/tiles/framework/trunk/tiles-core/src/main/java/org/apache/tiles/factory/BasicTilesContainerFactory.java?rev=819641&r1=819640&r2=819641&view=diff
==============================================================================
---
tiles/framework/trunk/tiles-core/src/main/java/org/apache/tiles/factory/BasicTilesContainerFactory.java
(original)
+++
tiles/framework/trunk/tiles-core/src/main/java/org/apache/tiles/factory/BasicTilesContainerFactory.java
Mon Sep 28 16:56:14 2009
@@ -188,6 +188,11 @@
if (log.isDebugEnabled()) {
log.debug("Cannot find class '" + className + "', ignoring
problem", e);
}
+ } catch (NotAvailableFeatureException e) {
+ if (log.isDebugEnabled()) {
+ log.debug("Not available feature exception during
instantiation of class '"
+ + className + "', ignoring problem", e);
+ }
} catch (InstantiationException e) {
throw new TilesContainerFactoryException(
"Cannot instantiate '" + className + "'", e);
Added:
tiles/framework/trunk/tiles-core/src/main/java/org/apache/tiles/factory/NotAvailableFeatureException.java
URL:
http://svn.apache.org/viewvc/tiles/framework/trunk/tiles-core/src/main/java/org/apache/tiles/factory/NotAvailableFeatureException.java?rev=819641&view=auto
==============================================================================
---
tiles/framework/trunk/tiles-core/src/main/java/org/apache/tiles/factory/NotAvailableFeatureException.java
(added)
+++
tiles/framework/trunk/tiles-core/src/main/java/org/apache/tiles/factory/NotAvailableFeatureException.java
Mon Sep 28 16:56:14 2009
@@ -0,0 +1,73 @@
+/*
+ * $Id$
+ *
+ * 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.tiles.factory;
+
+import org.apache.tiles.TilesException;
+
+/**
+ * Exception that indicates that a feature could not be used since it is not
+ * available.
+ *
+ * @version $Rev$ $Date$
+ * @since 2.1.4
+ */
+public class NotAvailableFeatureException extends TilesException {
+
+ /**
+ * Constructor.
+ *
+ * @since 2.1.4
+ */
+ public NotAvailableFeatureException() {
+ }
+
+ /**
+ * Constructor.
+ *
+ * @param message The detail message.
+ * @since 2.1.4
+ */
+ public NotAvailableFeatureException(String message) {
+ super(message);
+ }
+
+ /**
+ * Constructor.
+ *
+ * @param e The cause to be wrapped.
+ * @since 2.1.4
+ */
+ public NotAvailableFeatureException(Throwable e) {
+ super(e);
+ }
+
+ /**
+ * Constructor.
+ *
+ * @param message The detail message.
+ * @param e The cause to be wrapped.
+ * @since 2.1.4
+ */
+ public NotAvailableFeatureException(String message, Throwable e) {
+ super(message, e);
+ }
+}
Propchange:
tiles/framework/trunk/tiles-core/src/main/java/org/apache/tiles/factory/NotAvailableFeatureException.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange:
tiles/framework/trunk/tiles-core/src/main/java/org/apache/tiles/factory/NotAvailableFeatureException.java
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Added:
tiles/framework/trunk/tiles-portlet/src/main/java/org/apache/tiles/portlet/context/NotAPortletEnvironmentException.java
URL:
http://svn.apache.org/viewvc/tiles/framework/trunk/tiles-portlet/src/main/java/org/apache/tiles/portlet/context/NotAPortletEnvironmentException.java?rev=819641&view=auto
==============================================================================
---
tiles/framework/trunk/tiles-portlet/src/main/java/org/apache/tiles/portlet/context/NotAPortletEnvironmentException.java
(added)
+++
tiles/framework/trunk/tiles-portlet/src/main/java/org/apache/tiles/portlet/context/NotAPortletEnvironmentException.java
Mon Sep 28 16:56:14 2009
@@ -0,0 +1,73 @@
+/*
+ * $Id$
+ *
+ * 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.tiles.portlet.context;
+
+import org.apache.tiles.factory.NotAvailableFeatureException;
+
+/**
+ * Exception that indicates that a resource could not be used because it is not
+ * in a portlet environment.
+ *
+ * @version $Rev$ $Date$
+ * @since 2.1.4
+ */
+public class NotAPortletEnvironmentException extends
NotAvailableFeatureException {
+
+ /**
+ * Constructor.
+ *
+ * @since 2.1.4
+ */
+ public NotAPortletEnvironmentException() {
+ }
+
+ /**
+ * Constructor.
+ *
+ * @param message The detail message.
+ * @since 2.1.4
+ */
+ public NotAPortletEnvironmentException(String message) {
+ super(message);
+ }
+
+ /**
+ * Constructor.
+ *
+ * @param e The cause to be wrapped.
+ * @since 2.1.4
+ */
+ public NotAPortletEnvironmentException(Throwable e) {
+ super(e);
+ }
+
+ /**
+ * Constructor.
+ *
+ * @param message The detail message.
+ * @param e The cause to be wrapped.
+ * @since 2.1.4
+ */
+ public NotAPortletEnvironmentException(String message, Throwable e) {
+ super(message, e);
+ }
+}
Propchange:
tiles/framework/trunk/tiles-portlet/src/main/java/org/apache/tiles/portlet/context/NotAPortletEnvironmentException.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange:
tiles/framework/trunk/tiles-portlet/src/main/java/org/apache/tiles/portlet/context/NotAPortletEnvironmentException.java
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Modified:
tiles/framework/trunk/tiles-portlet/src/main/java/org/apache/tiles/portlet/context/PortletTilesRequestContextFactory.java
URL:
http://svn.apache.org/viewvc/tiles/framework/trunk/tiles-portlet/src/main/java/org/apache/tiles/portlet/context/PortletTilesRequestContextFactory.java?rev=819641&r1=819640&r2=819641&view=diff
==============================================================================
---
tiles/framework/trunk/tiles-portlet/src/main/java/org/apache/tiles/portlet/context/PortletTilesRequestContextFactory.java
(original)
+++
tiles/framework/trunk/tiles-portlet/src/main/java/org/apache/tiles/portlet/context/PortletTilesRequestContextFactory.java
Mon Sep 28 16:56:14 2009
@@ -21,14 +21,17 @@
package org.apache.tiles.portlet.context;
-import org.apache.tiles.TilesApplicationContext;
-import org.apache.tiles.context.TilesRequestContext;
-import org.apache.tiles.context.TilesRequestContextFactory;
+import java.util.Map;
import javax.portlet.PortletContext;
import javax.portlet.PortletRequest;
import javax.portlet.PortletResponse;
-import java.util.Map;
+
+import org.apache.tiles.TilesApplicationContext;
+import org.apache.tiles.context.TilesRequestContext;
+import org.apache.tiles.context.TilesRequestContextFactory;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
/**
* Creates an instance of the appropriate {...@link TilesRequestContext}
@@ -41,6 +44,11 @@
TilesRequestContextFactory {
/**
+ * The logging object.
+ */
+ private Logger logger = LoggerFactory.getLogger(getClass());
+
+ /**
* The site of the request object array in case there is a request, a
* response and a portlet context.
*
@@ -48,6 +56,20 @@
*/
private static final int REQUEST_OBJECTS_LENGTH = 3;
+ /**
+ * Constructor. To see if a portlet context is available, simply accesses a
+ * portlet class.
+ */
+ public PortletTilesRequestContextFactory() {
+ try {
+ logger.debug("The portlet environment is available, "
+ + "since the class {} is present", PortletRequest.class);
+ } catch (NoClassDefFoundError e) {
+ throw new NotAPortletEnvironmentException(
+ "Cannot access portlet classes", e);
+ }
+ }
+
/** {...@inheritdoc} */
public void init(Map<String, String> configParameters) {
}