Skip to content
This repository was archived by the owner on Jan 27, 2021. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion contribs/scala/jersey-lift/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@
</dependency>
<dependency>
<groupId>net.liftweb</groupId>
<artifactId>lift-webkit</artifactId>
<artifactId>lift-mapper_2.11</artifactId>
<version>${lift.version}</version>
</dependency>
</dependencies>
Expand Down
2 changes: 1 addition & 1 deletion contribs/scala/jersey-scala/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@
<plugin>
<groupId>org.scala-tools</groupId>
<artifactId>maven-scala-plugin</artifactId>
<version>2.10.1</version>
<version>2.15.2</version>
<executions>
<execution>
<goals>
Expand Down
7 changes: 3 additions & 4 deletions contribs/scala/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,8 @@

<properties>
<jetty.version>6.1.19</jetty.version>
<lift.version>1.1-M7</lift.version>
<scala.version>2.7.5</scala.version>
<lift.version>2.6</lift.version>
<scala.version>2.11.5</scala.version>
</properties>

<modules>
Expand All @@ -77,7 +77,7 @@
<plugin>
<groupId>org.scala-tools</groupId>
<artifactId>maven-scala-plugin</artifactId>
<version>2.10.1</version>
<version>2.15.2</version>
<executions>
<execution>
<goals>
Expand All @@ -93,7 +93,6 @@
<args>
<!-- arg>-unchecked</arg -->
<arg>-deprecation</arg>
<arg>-Xno-varargs-conversion</arg>
</args>
<scalaVersion>${scala.version}</scalaVersion>
</configuration>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ public interface DocProcessor {
void processClassDoc( ClassDoc classDoc, ClassDocType classDocType );

/**
* Process the provided methodDoc and add your custom information to the methodDocType.<br/>
* Process the provided methodDoc and add your custom information to the methodDocType.<br>
* Use e.g. {@link MethodDocType#getAny()} to store custom elements.
* @param methodDoc the {@link MethodDoc} representing the docs of your method.
* @param methodDocType the related {@link MethodDocType} that will later be processed by the {@link WadlGenerator}s.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
* Copyright (c) 2010-2011 Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2010-2014 Oracle and/or its affiliates. All rights reserved.
*
* The contents of this file are subject to the terms of either the GNU
* General Public License Version 2 only ("GPL") or the Common Development
Expand Down Expand Up @@ -58,7 +58,7 @@
* If the component is not supported then a null value may be returned and the
* runtime will manage the component.
* <p>
* Specializations of {@link IoCComponentProvider} must be returned by the
* Specializations of {@link IoCComponentProvider} must be returned by the
* <code>getComponentProvider</code> methods that declare the boundary of
* responsibility, between the runtime and the underlying IoC framework,
* for management of a component.
Expand All @@ -77,7 +77,7 @@
* component is fully managed by the runtime but when an instance is created
* the underlying IoC framework is deferred to for creating a proxy of the
* component instance.
*
*
* @author Paul.Sandoz@Sun.Com
*/
public interface IoCComponentProviderFactory extends ComponentProviderFactory<IoCComponentProvider> {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
* Copyright (c) 2010-2011 Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2010-2014 Oracle and/or its affiliates. All rights reserved.
*
* The contents of this file are subject to the terms of either the GNU
* General Public License Version 2 only ("GPL") or the Common Development
Expand Down Expand Up @@ -44,22 +44,42 @@
import com.sun.jersey.core.spi.component.ComponentProvider;
import com.sun.jersey.core.spi.component.ComponentScope;
import com.sun.jersey.core.spi.component.ProviderFactory;
import com.sun.jersey.core.util.PriorityUtil;
import com.sun.jersey.spi.inject.InjectableProviderContext;

import java.lang.reflect.InvocationTargetException;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.logging.Level;

/**
* An extension of {@link ProviderFactory} that defers to an
* {@link IoCComponentProviderFactory}.
*
* @author Paul.Sandoz@Sun.Com
*
* All registered provider factory implementations are being polled
* so that a single {@link IoCComponentProvider} instance could be selected
* for each component.
*
* @author Paul Sandoz (paul.sandoz at oracle.com)
*/
public class IoCProviderFactory extends ProviderFactory {

/*
The following would be added to the class javadoc if the priority annotation
was part of public API:

Polling order is specified by priority value
set on individual provider factories. The factory that has the highest
priority value is polled first. Priority value is set using
{@link Priority} annotation.
*/
private final List<IoCComponentProviderFactory> factories;

/**
* Create a new provider factory based
* on given context and factory.
*
* @param ipc the injectable provider context.
* @param icpf the IoC component provider factory.
Expand All @@ -71,6 +91,7 @@ public IoCProviderFactory(
}

/**
* Create a new provider factory based on given context and factories.
*
* @param ipc the injectable provider context.
* @param factories the list of IoC component provider factory.
Expand All @@ -79,7 +100,9 @@ public IoCProviderFactory(
InjectableProviderContext ipc,
List<IoCComponentProviderFactory> factories) {
super(ipc);
this.factories = factories;
List<IoCComponentProviderFactory> myFactories = new ArrayList<IoCComponentProviderFactory>(factories);
Collections.sort(myFactories, PriorityUtil.INSTANCE_COMPARATOR);
this.factories = Collections.unmodifiableList(myFactories);
}

@Override
Expand Down Expand Up @@ -123,15 +146,15 @@ private static class InstantiatedSingleton implements ComponentProvider, Destroy
private final Object o;

private final IoCDestroyable destroyable;

private final ComponentDestructor cd;

InstantiatedSingleton(InjectableProviderContext ipc,
IoCInstantiatedComponentProvider iicp,
Class c) {
this.destroyable = (iicp instanceof IoCDestroyable)
? (IoCDestroyable) iicp : null;

o = iicp.getInstance();

this.cd = (destroyable == null) ? new ComponentDestructor(c) : null;
Expand Down Expand Up @@ -210,7 +233,7 @@ private static class ProxiedSingletonWrapper implements ComponentProvider, Destr

this.destroyable = (cp instanceof Destroyable)
? (Destroyable) cp : null;

Object o = cp.getInstance();
this.proxy = ipcp.proxy(o);
if (!this.proxy.getClass().isAssignableFrom(o.getClass()))
Expand Down
68 changes: 68 additions & 0 deletions jersey-core/src/main/java/com/sun/jersey/core/util/Priority.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
* Copyright (c) 2014 Oracle and/or its affiliates. All rights reserved.
*
* The contents of this file are subject to the terms of either the GNU
* General Public License Version 2 only ("GPL") or the Common Development
* and Distribution License("CDDL") (collectively, the "License"). You
* may not use this file except in compliance with the License. You can
* obtain a copy of the License at
* http://glassfish.java.net/public/CDDL+GPL_1_1.html
* or packager/legal/LICENSE.txt. See the License for the specific
* language governing permissions and limitations under the License.
*
* When distributing the software, include this License Header Notice in each
* file and include the License file at packager/legal/LICENSE.txt.
*
* GPL Classpath Exception:
* Oracle designates this particular file as subject to the "Classpath"
* exception as provided by Oracle in the GPL Version 2 section of the License
* file that accompanied this code.
*
* Modifications:
* If applicable, add the following below the License Header, with the fields
* enclosed by brackets [] replaced by your own identifying information:
* "Portions Copyright [year] [name of copyright owner]"
*
* Contributor(s):
* If you wish your version of this file to be governed by only the CDDL or
* only the GPL Version 2, indicate your decision by adding "[Contributor]
* elects to include this software in this distribution under the [CDDL or GPL
* Version 2] license." If you don't indicate a single choice of license, a
* recipient has the option to distribute your version of this file under
* either the CDDL, the GPL Version 2 or to extend the choice of license to
* its licensees as provided above. However, if you add GPL Version 2 code
* and therefore, elected the GPL Version 2 license, then the option applies
* only if the new code is made subject to such option by the copyright
* holder.
*/
package com.sun.jersey.core.util;

import java.lang.annotation.Retention;
import java.lang.annotation.Target;

import static java.lang.annotation.RetentionPolicy.RUNTIME;
import static java.lang.annotation.ElementType.TYPE;


/**
* Priority annotation can be applied to provider classes
* to indicate in what order the providers should be polled.
* Concrete usage must be defined by individual provider specification.
*
* Introduced to help control component factory ordering.
*
* @author Jakub Podlesak (jakub.podlesak at oracle.com)
*/
@Target(value=TYPE)
@Retention(value=RUNTIME)
public @interface Priority {

/**
* The priority value.
*
* @return priority value to be used for annotated element.
*/
public int value();
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
* Copyright (c) 2014 Oracle and/or its affiliates. All rights reserved.
*
* The contents of this file are subject to the terms of either the GNU
* General Public License Version 2 only ("GPL") or the Common Development
* and Distribution License("CDDL") (collectively, the "License"). You
* may not use this file except in compliance with the License. You can
* obtain a copy of the License at
* http://glassfish.java.net/public/CDDL+GPL_1_1.html
* or packager/legal/LICENSE.txt. See the License for the specific
* language governing permissions and limitations under the License.
*
* When distributing the software, include this License Header Notice in each
* file and include the License file at packager/legal/LICENSE.txt.
*
* GPL Classpath Exception:
* Oracle designates this particular file as subject to the "Classpath"
* exception as provided by Oracle in the GPL Version 2 section of the License
* file that accompanied this code.
*
* Modifications:
* If applicable, add the following below the License Header, with the fields
* enclosed by brackets [] replaced by your own identifying information:
* "Portions Copyright [year] [name of copyright owner]"
*
* Contributor(s):
* If you wish your version of this file to be governed by only the CDDL or
* only the GPL Version 2, indicate your decision by adding "[Contributor]
* elects to include this software in this distribution under the [CDDL or GPL
* Version 2] license." If you don't indicate a single choice of license, a
* recipient has the option to distribute your version of this file under
* either the CDDL, the GPL Version 2 or to extend the choice of license to
* its licensees as provided above. However, if you add GPL Version 2 code
* and therefore, elected the GPL Version 2 license, then the option applies
* only if the new code is made subject to such option by the copyright
* holder.
*/

package com.sun.jersey.core.util;

import java.util.Comparator;

/**
* Utility code for work with {@link Priority} annotated types.
*
* @author Jakub Podlesak (jakub.podlesak at oracle.com)
*/
public class PriorityUtil {

/**
* Default priority value for factory types that do not have
* their priority set explicitly using {@link Priority} annotation.
*/
public static final int DEFAULT_PRIORITY = 100;

/**
* Convenience comparator instance.
*/
public static final InstanceComparator INSTANCE_COMPARATOR = new InstanceComparator();

/**
* Comparator for instances of types annotated with Priority
* annotation.
*/
public static final class InstanceComparator implements Comparator {

@Override
public int compare(Object o1, Object o2) {
return priorityOf(o2) - priorityOf(o1);
}

private int priorityOf(Object o) {
final Priority priorityAnnotation = o.getClass().getAnnotation(Priority.class);
return priorityAnnotation == null ? DEFAULT_PRIORITY : priorityAnnotation.value();
}
}

/**
* Comparator for types annotated with Priority
* annotation.
*/
public static class TypeComparator implements Comparator<Class<?>> {

@Override
public int compare(Class<?> o1, Class<?> o2) {
return priorityOf(o2) - priorityOf(o1);
}

private int priorityOf(Class<?> o) {
final Priority priorityAnnotation = o.getAnnotation(Priority.class);
return priorityAnnotation == null ? DEFAULT_PRIORITY : priorityAnnotation.value();
}
}
}
Loading