Repository: tapestry-5 Updated Branches: refs/heads/master 494b790c3 -> 325f5b6e7
http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/f963c7ab/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/util/ExceptionUtils.java ---------------------------------------------------------------------- diff --git a/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/util/ExceptionUtils.java b/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/util/ExceptionUtils.java deleted file mode 100644 index 2feaeca..0000000 --- a/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/util/ExceptionUtils.java +++ /dev/null @@ -1,115 +0,0 @@ -// Copyright 2008-2013 The Apache Software Foundation -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package org.apache.tapestry5.ioc.util; - -import org.apache.tapestry5.ioc.services.ClassPropertyAdapter; -import org.apache.tapestry5.ioc.services.PropertyAccess; - -/** - * Contains static methods useful for manipulating exceptions. - */ -public class ExceptionUtils -{ - /** - * Locates a particular type of exception, working its way via the cause property of each exception in the exception - * stack. - * - * @param t the outermost exception - * @param type the type of exception to search for - * @return the first exception of the given type, if found, or null - */ - public static <T extends Throwable> T findCause(Throwable t, Class<T> type) - { - Throwable current = t; - - while (current != null) - { - if (type.isInstance(current)) - { - return type.cast(current); - } - - // Not a match, work down. - - current = current.getCause(); - } - - return null; - } - - /** - * Locates a particular type of exception, working its way down via any property that returns some type of Exception. - * This is more expensive, but more accurate, than {@link #findCause(Throwable, Class)} as it works with older exceptions - * that do not properly implement the (relatively new) {@linkplain Throwable#getCause() cause property}. - * - * @param t the outermost exception - * @param type the type of exception to search for - * @param access used to access properties - * @return the first exception of the given type, if found, or null - */ - public static <T extends Throwable> T findCause(Throwable t, Class<T> type, PropertyAccess access) - { - Throwable current = t; - - while (current != null) - { - if (type.isInstance(current)) - { - return type.cast(current); - } - - Throwable next = null; - - ClassPropertyAdapter adapter = access.getAdapter(current); - - for (String name : adapter.getPropertyNames()) - { - - Object value = adapter.getPropertyAdapter(name).get(current); - - if (value != null && value != current && value instanceof Throwable) - { - next = (Throwable) value; - break; - } - } - - current = next; - } - - - return null; - } - - /** - * Extracts the message from an exception. If the exception's message is null, returns the exceptions class name. - * - * @param exception - * to extract message from - * @return message or class name - * @since 5.4 - */ - public static String toMessage(Throwable exception) - { - assert exception != null; - - String message = exception.getMessage(); - - if (message != null) - return message; - - return exception.getClass().getName(); - } -} http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/f963c7ab/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/util/UnknownValueException.java ---------------------------------------------------------------------- diff --git a/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/util/UnknownValueException.java b/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/util/UnknownValueException.java deleted file mode 100644 index 470b611..0000000 --- a/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/util/UnknownValueException.java +++ /dev/null @@ -1,47 +0,0 @@ -// Copyright 2010 The Apache Software Foundation -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package org.apache.tapestry5.ioc.util; - -import org.apache.tapestry5.ioc.internal.util.TapestryException; - -/** - * Special exception used when a value (typically from a map) is referenced that does not exist. Uses a - * {@link AvailableValues} object - * to track what the known values are. - * - * @since 5.2.0 - */ -public class UnknownValueException extends TapestryException -{ - private final AvailableValues availableValues; - - public UnknownValueException(String message, AvailableValues availableValues) - { - this(message, null, null, availableValues); - } - - public UnknownValueException(String message, Object location, Throwable cause, AvailableValues availableValues) - { - super(message, location, cause); - - this.availableValues = availableValues; - } - - public AvailableValues getAvailableValues() - { - return availableValues; - } - -} http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/f963c7ab/tapestry5-annotations/build.gradle ---------------------------------------------------------------------- diff --git a/tapestry5-annotations/build.gradle b/tapestry5-annotations/build.gradle index 7d7657c..4f411a1 100644 --- a/tapestry5-annotations/build.gradle +++ b/tapestry5-annotations/build.gradle @@ -1 +1 @@ -description = "Annotations used with Tapestry applications" \ No newline at end of file +description = "Annotations used with Tapestry, Tapestry-IoC and BeanModel applications" \ No newline at end of file http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/f963c7ab/tapestry5-annotations/src/main/java/org/apache/tapestry5/ioc/annotations/UsesConfiguration.java ---------------------------------------------------------------------- diff --git a/tapestry5-annotations/src/main/java/org/apache/tapestry5/ioc/annotations/UsesConfiguration.java b/tapestry5-annotations/src/main/java/org/apache/tapestry5/ioc/annotations/UsesConfiguration.java new file mode 100644 index 0000000..2e03557 --- /dev/null +++ b/tapestry5-annotations/src/main/java/org/apache/tapestry5/ioc/annotations/UsesConfiguration.java @@ -0,0 +1,34 @@ +// Copyright 2008, 2009 The Apache Software Foundation +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package org.apache.tapestry5.ioc.annotations; + +import java.lang.annotation.*; + + +/** + * A documentation-only interface placed on service interfaces for services which have an {@linkplain + * org.apache.tapestry5.ioc.Configuration unordered configuration}, to identify the type of contribution. + */ +@Target(ElementType.TYPE) +@Retention(RetentionPolicy.CLASS) +@Documented +@UseWith(AnnotationUseContext.SERVICE) +public @interface UsesConfiguration +{ + /** + * The type of object which may be contributed into the service's configuration. + */ + Class value(); +} http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/f963c7ab/tapestry5-annotations/src/main/java/org/apache/tapestry5/services/ComponentClasses.java ---------------------------------------------------------------------- diff --git a/tapestry5-annotations/src/main/java/org/apache/tapestry5/services/ComponentClasses.java b/tapestry5-annotations/src/main/java/org/apache/tapestry5/services/ComponentClasses.java new file mode 100644 index 0000000..c901d3a --- /dev/null +++ b/tapestry5-annotations/src/main/java/org/apache/tapestry5/services/ComponentClasses.java @@ -0,0 +1,35 @@ +// Copyright 2008, 2010 The Apache Software Foundation +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package org.apache.tapestry5.services; + +import java.lang.annotation.Documented; +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +/** + * Marker annotation used to inject the correct {@link org.apache.tapestry5.services.InvalidationEventHub} service + * responsible for invalidations when underlying component class files are changed. + * + * @since 5.1.0.0 + */ +@Target( +{ ElementType.PARAMETER, ElementType.FIELD, ElementType.METHOD }) +@Retention(RetentionPolicy.RUNTIME) +@Documented +public @interface ComponentClasses +{ +} http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/f963c7ab/tapestry5-annotations/src/main/java/org/apache/tapestry5/services/ComponentLayer.java ---------------------------------------------------------------------- diff --git a/tapestry5-annotations/src/main/java/org/apache/tapestry5/services/ComponentLayer.java b/tapestry5-annotations/src/main/java/org/apache/tapestry5/services/ComponentLayer.java new file mode 100644 index 0000000..e342c3f --- /dev/null +++ b/tapestry5-annotations/src/main/java/org/apache/tapestry5/services/ComponentLayer.java @@ -0,0 +1,37 @@ +// Copyright 2007 The Apache Software Foundation +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package org.apache.tapestry5.services; + +import java.lang.annotation.Documented; +import java.lang.annotation.Retention; +import java.lang.annotation.Target; + +import static java.lang.annotation.ElementType.FIELD; +import static java.lang.annotation.ElementType.PARAMETER; +import static java.lang.annotation.RetentionPolicy.RUNTIME; + +/** + * Marker annotation used to identify a service from the component layer that conflicts, in terms of service interface, + * with a service from elsewhere. In particular, this is used to disambiguate {@link org.apache.tapestry5.ioc.services.PlasticProxyFactory} which has one implementation (marked with {@link + * org.apache.tapestry5.ioc.services.Builtin} and another with this annotation. + */ +@Target( + {PARAMETER, FIELD}) +@Retention(RUNTIME) +@Documented +public @interface ComponentLayer +{ + +}