jersey.repackaged.com.google.common.collect.Sets



API Populatity

1 Client projects

Project: jersey

Project jersey/jersey in file ...lassfish.jersey.process.internal.RequestScope.java (2014-03-07)
@@ -60,6 +60,7 @@ import org.glassfish.hk2.api.ServiceHandle;
 import org.glassfish.hk2.utilities.binding.AbstractBinder;
 
 import jersey.repackaged.com.google.common.base.Objects;
+import jersey.repackaged.com.google.common.collect.Sets;
 
 import static jersey.repackaged.com.google.common.base.Preconditions.checkState;
 
@@ -295,8 +296,8 @@ public class RequestScope implements Context<RequestScoped> {
             currentScopeInstance.set(scopeInstance.getReference());
             Errors.process(task);
         } finally {
-            currentScopeInstance.set(oldInstance);
             scopeInstance.release();
+            currentScopeInstance.set(oldInstance);
         }
     }
 
@@ -318,8 +319,8 @@ public class RequestScope implements Context<RequestScoped> {
             currentScopeInstance.set(instance);
             Errors.process(task);
         } finally {
-            currentScopeInstance.set(oldInstance);
             instance.release();
+            currentScopeInstance.set(oldInstance);
         }
     }
 
@@ -345,8 +346,8 @@ public class RequestScope implements Context<RequestScoped> {
             currentScopeInstance.set(scopeInstance.getReference());
             return Errors.process(task);
         } finally {
-            currentScopeInstance.set(oldInstance);
             scopeInstance.release();
+            currentScopeInstance.set(oldInstance);
         }
     }
 
@@ -371,8 +372,8 @@ public class RequestScope implements Context<RequestScoped> {
             currentScopeInstance.set(instance);
             return Errors.process(task);
         } finally {
-            currentScopeInstance.set(oldInstance);
             instance.release();
+            currentScopeInstance.set(oldInstance);
         }
     }
 
@@ -397,8 +398,8 @@ public class RequestScope implements Context<RequestScoped> {
             currentScopeInstance.set(scopeInstance.getReference());
             return Errors.process(task);
         } finally {
-            currentScopeInstance.set(oldInstance);
             scopeInstance.release();
+            currentScopeInstance.set(oldInstance);
         }
     }
 
@@ -422,8 +423,8 @@ public class RequestScope implements Context<RequestScoped> {
             currentScopeInstance.set(instance);
             return Errors.process(task);
         } finally {
-            currentScopeInstance.set(oldInstance);
             instance.release();
+            currentScopeInstance.set(oldInstance);
         }
     }
 
@@ -504,8 +505,11 @@ public class RequestScope implements Context<RequestScoped> {
          *
          * @param descriptor key for the value to be removed.
          */
-        void remove(ActiveDescriptor<?> descriptor) {
-            store.remove(descriptor);
+        <T> void remove(ActiveDescriptor<T> descriptor) {
+            final T removed = (T) store.remove(descriptor);
+            if (removed != null) {
+                descriptor.dispose(removed);
+            }
         }
 
         private <T> boolean contains(ActiveDescriptor<T> provider) {
@@ -520,7 +524,9 @@ public class RequestScope implements Context<RequestScoped> {
         public void release() {
             if (referenceCounter.decrementAndGet() < 1) {
                 try {
-                    store.clear();
+                    for (final ActiveDescriptor<?> descriptor : Sets.newHashSet(store.keySet())) {
+                        remove(descriptor);
+                    }
                 } finally {
                     logger.debugLog("Released scope instance {0}", this);
                 }
Project jersey/jersey in file ...ey.tests.integration.jersey1883.MyApplication.java (2015-02-11)
@@ -0,0 +1,60 @@
+/*
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
+ *
+ * Copyright (c) 2015 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 org.glassfish.jersey.tests.integration.jersey1883;
+
+import jersey.repackaged.com.google.common.collect.Sets;
+
+import javax.ws.rs.ApplicationPath;
+import javax.ws.rs.core.Application;
+import java.util.Set;
+
+/**
+ * Explicitly register {@code @Singleton} resource.
+ *
+ * @author Libor Kramolis (libor.kramolis at oracle.com)
+ */
+@ApplicationPath("/rest1")
+public class MyApplication extends Application {
+
+    @Override
+    public Set<Class<?>> getClasses() {
+        return Sets.<Class<?>>newHashSet(NoLife.class);
+    }
+}
Project jersey/jersey in file ...ests.e2e.entity.filtering.EntityFilteringTest.java (2014-07-21)
@@ -0,0 +1,71 @@
+/*
+ * 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 org.glassfish.jersey.tests.e2e.entity.filtering;
+
+import java.util.HashSet;
+
+import org.glassfish.jersey.test.JerseyTest;
+
+import static org.hamcrest.CoreMatchers.equalTo;
+import static org.hamcrest.MatcherAssert.assertThat;
+
+import jersey.repackaged.com.google.common.collect.Sets;
+
+/**
+ * Common parent class for Entity Filtering tests.
+ *
+ * @author Michal Gajdos (michal.gajdos at oracle.com)
+ */
+abstract class EntityFilteringTest extends JerseyTest {
+
+    /**
+     * Test that (filtered) fields of given strings are equal (fields are separated by commas).
+     *
+     * @param actual actual fields from response received from server.
+     * @param expected expected fields.
+     */
+    static void assertSameFields(final String actual, final String expected) {
+        final HashSet<String> actualSet = Sets.newHashSet(actual.split(","));
+        final HashSet<String> expectedSet = Sets.newHashSet(expected.split(","));
+
+        assertThat(actualSet, equalTo(expectedSet));
+    }
+}