├── README.md ├── .gitignore ├── etc ├── config │ ├── copyright-exclude │ └── copyright.txt └── bin │ └── fixEmptySpacesAtEOL.sh ├── CONTRIBUTING.md ├── jaxrs-api └── src │ ├── main │ └── java │ │ ├── javax │ │ └── ws │ │ │ └── rs │ │ │ ├── container │ │ │ ├── package-info.java │ │ │ ├── ConnectionCallback.java │ │ │ ├── PreMatching.java │ │ │ ├── ResourceInfo.java │ │ │ ├── ResourceContext.java │ │ │ └── CompletionCallback.java │ │ │ ├── ext │ │ │ ├── package-info.java │ │ │ ├── Provider.java │ │ │ ├── ExceptionMapper.java │ │ │ ├── ContextResolver.java │ │ │ ├── WriterInterceptor.java │ │ │ └── ParamConverterProvider.java │ │ │ ├── core │ │ │ ├── package-info.java │ │ │ ├── FeatureContext.java │ │ │ ├── Context.java │ │ │ ├── StreamingOutput.java │ │ │ └── PathSegment.java │ │ │ ├── sse │ │ │ └── package-info.java │ │ │ ├── RuntimeType.java │ │ │ ├── GET.java │ │ │ ├── PUT.java │ │ │ ├── HEAD.java │ │ │ ├── PATCH.java │ │ │ ├── POST.java │ │ │ ├── DELETE.java │ │ │ ├── OPTIONS.java │ │ │ ├── package-info.java │ │ │ ├── Encoded.java │ │ │ ├── client │ │ │ ├── ClientRequestFilter.java │ │ │ ├── ClientResponseFilter.java │ │ │ └── RxInvokerProvider.java │ │ │ ├── ApplicationPath.java │ │ │ ├── Consumes.java │ │ │ ├── DefaultValue.java │ │ │ └── Produces.java │ │ └── module-info.java │ └── test │ └── java │ └── javax │ └── ws │ └── rs │ └── core │ ├── AbstractMultivaluedMapTest.java │ ├── VariantTest.java │ ├── RuntimeDelegateStub.java │ ├── NewCookieTest.java │ ├── MediaTypeTest.java │ └── CookieTest.java └── examples └── src └── main └── java └── jaxrs └── examples ├── client ├── webdav │ ├── WebDavSyncInvoker.java │ └── WebDavAsyncInvoker.java ├── cache │ ├── CachingFeature.java │ ├── CacheExample.java │ ├── CacheEntry.java │ └── CacheEntryLocator.java ├── links │ └── LinkUsageExample.java ├── encoding │ └── GzipExample.java └── validator │ ├── NotNull.java │ └── Pattern.java ├── filter ├── logging │ ├── Logged.java │ ├── MyResourceClass.java │ ├── DynamicLoggingFilterFeature.java │ └── LoggingFilter.java ├── compression │ ├── Gzipped.java │ └── MyResourceClass.java ├── post │ └── PostMethodOverrideFilter.java └── caching │ └── ServerCachingFilter.java ├── rc ├── FooResource.java └── FruitsResource.java ├── async ├── LongRunningEjbResource.java └── SimpleAsyncEventResource.java └── link ├── clusterservice ├── Model.java ├── Cluster.java ├── ClientTest.java └── Machine.java └── LinkExamples.java /README.md: -------------------------------------------------------------------------------- 1 | # JAX-RS API 2 | 3 | This project has been moved to the Eclipse Foundation: https://github.com/eclipse-ee4j/jaxrs-api 4 | 5 | This repository is now read only and won't be updated. 6 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # maven noise 2 | target 3 | 4 | # osx noise 5 | .DS_Store 6 | profile 7 | 8 | #IntelliJ Idea noise 9 | .idea 10 | *.iws 11 | *.ipr 12 | *.iml 13 | 14 | # TeX build noise 15 | *.aux 16 | *.bbl 17 | *.blg 18 | *.log 19 | *.out 20 | *.tex~ 21 | *.thm 22 | *.toc 23 | -------------------------------------------------------------------------------- /etc/config/copyright-exclude: -------------------------------------------------------------------------------- 1 | .apt 2 | .args 3 | .bundle 4 | .class 5 | .exe 6 | .gif 7 | .gitignore 8 | .ico 9 | .iml 10 | .ipr 11 | .iws 12 | .jar 13 | .jks 14 | .jpg 15 | .js 16 | .json 17 | .mm 18 | .ods 19 | .png 20 | .project 21 | .sql 22 | .svg 23 | .war 24 | .zip 25 | .dat 26 | /MANIFEST.MF 27 | /META-INF/services/ 28 | /README 29 | /LICENSE.txt 30 | /CONTRIBUTING.md 31 | GenericEntity.java 32 | spec-license.html 33 | copyright-exclude 34 | copyright.txt 35 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | --- 2 | 3 | # Source Code Submissions 4 | We welcome your contributions and look forward to collaborating with you. We can only accept source code repository 5 | submissions from users who have signed and returned the Oracle 6 | Contributor Agreement. You will find details and the agreement to sign at this OTN web page: 7 | [Oracle Contributor Agreement](http://www.oracle.com/technetwork/community/oca-486395.html). 8 | 9 | # Other Contrbutions 10 | For all project Submissions other than source code repository contributions, the following also applies: Oracle does 11 | not claim ownership of Your Submissions. However, in order to fulfill 12 | the purposes of this project, You must give Oracle and all Users 13 | the right to post, access, discuss, use, publish, disseminate, and refine 14 | Your Submissions. 15 | 16 | In legalese: *You hereby grant to Oracle and all 17 | Users a royalty-free, perpetual, irrevocable, worldwide, non-exclusive, 18 | and fully sub-licensable right and license, under Your intellectual 19 | property rights, to reproduce, modify, adapt, publish, translate, create 20 | derivative works from, distribute, perform, display, and use Your 21 | Submissions (in whole or part) and to incorporate or implement them in 22 | other works in any form, media, or technology now known or later 23 | developed, all subject to the obligation to retain any copyright notices 24 | included in Your Submissions. All Users, Oracle, and their 25 | sublicensees are responsible for any modifications they make to the 26 | Submissions of others.* 27 | 28 | Copyright © 2017 Oracle and/or its affiliates. All rights reserved 29 | -------------------------------------------------------------------------------- /etc/config/copyright.txt: -------------------------------------------------------------------------------- 1 | /* 2 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. 3 | * 4 | * Copyright (c) YYYY Oracle and/or its affiliates. All rights reserved. 5 | * 6 | * The contents of this file are subject to the terms of either the GNU 7 | * General Public License Version 2 only ("GPL") or the Common Development 8 | * and Distribution License("CDDL") (collectively, the "License"). You 9 | * may not use this file except in compliance with the License. You can 10 | * obtain a copy of the License at 11 | * http://glassfish.java.net/public/CDDL+GPL_1_1.html 12 | * or packager/legal/LICENSE.txt. See the License for the specific 13 | * language governing permissions and limitations under the License. 14 | * 15 | * When distributing the software, include this License Header Notice in each 16 | * file and include the License file at packager/legal/LICENSE.txt. 17 | * 18 | * GPL Classpath Exception: 19 | * Oracle designates this particular file as subject to the "Classpath" 20 | * exception as provided by Oracle in the GPL Version 2 section of the License 21 | * file that accompanied this code. 22 | * 23 | * Modifications: 24 | * If applicable, add the following below the License Header, with the fields 25 | * enclosed by brackets [] replaced by your own identifying information: 26 | * "Portions Copyright [year] [name of copyright owner]" 27 | * 28 | * Contributor(s): 29 | * If you wish your version of this file to be governed by only the CDDL or 30 | * only the GPL Version 2, indicate your decision by adding "[Contributor] 31 | * elects to include this software in this distribution under the [CDDL or GPL 32 | * Version 2] license." If you don't indicate a single choice of license, a 33 | * recipient has the option to distribute your version of this file under 34 | * either the CDDL, the GPL Version 2 or to extend the choice of license to 35 | * its licensees as provided above. However, if you add GPL Version 2 code 36 | * and therefore, elected the GPL Version 2 license, then the option applies 37 | * only if the new code is made subject to such option by the copyright 38 | * holder. 39 | */ -------------------------------------------------------------------------------- /jaxrs-api/src/main/java/javax/ws/rs/container/package-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. 3 | * 4 | * Copyright (c) 2012-2015 Oracle and/or its affiliates. All rights reserved. 5 | * 6 | * The contents of this file are subject to the terms of either the GNU 7 | * General Public License Version 2 only ("GPL") or the Common Development 8 | * and Distribution License("CDDL") (collectively, the "License"). You 9 | * may not use this file except in compliance with the License. You can 10 | * obtain a copy of the License at 11 | * http://glassfish.java.net/public/CDDL+GPL_1_1.html 12 | * or packager/legal/LICENSE.txt. See the License for the specific 13 | * language governing permissions and limitations under the License. 14 | * 15 | * When distributing the software, include this License Header Notice in each 16 | * file and include the License file at packager/legal/LICENSE.txt. 17 | * 18 | * GPL Classpath Exception: 19 | * Oracle designates this particular file as subject to the "Classpath" 20 | * exception as provided by Oracle in the GPL Version 2 section of the License 21 | * file that accompanied this code. 22 | * 23 | * Modifications: 24 | * If applicable, add the following below the License Header, with the fields 25 | * enclosed by brackets [] replaced by your own identifying information: 26 | * "Portions Copyright [year] [name of copyright owner]" 27 | * 28 | * Contributor(s): 29 | * If you wish your version of this file to be governed by only the CDDL or 30 | * only the GPL Version 2, indicate your decision by adding "[Contributor] 31 | * elects to include this software in this distribution under the [CDDL or GPL 32 | * Version 2] license." If you don't indicate a single choice of license, a 33 | * recipient has the option to distribute your version of this file under 34 | * either the CDDL, the GPL Version 2 or to extend the choice of license to 35 | * its licensees as provided above. However, if you add GPL Version 2 code 36 | * and therefore, elected the GPL Version 2 license, then the option applies 37 | * only if the new code is made subject to such option by the copyright 38 | * holder. 39 | */ 40 | 41 | /** 42 | * Container-specific JAX-RS API. 43 | */ 44 | package javax.ws.rs.container; 45 | -------------------------------------------------------------------------------- /jaxrs-api/src/main/java/javax/ws/rs/ext/package-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. 3 | * 4 | * Copyright (c) 2010-2015 Oracle and/or its affiliates. All rights reserved. 5 | * 6 | * The contents of this file are subject to the terms of either the GNU 7 | * General Public License Version 2 only ("GPL") or the Common Development 8 | * and Distribution License("CDDL") (collectively, the "License"). You 9 | * may not use this file except in compliance with the License. You can 10 | * obtain a copy of the License at 11 | * http://glassfish.java.net/public/CDDL+GPL_1_1.html 12 | * or packager/legal/LICENSE.txt. See the License for the specific 13 | * language governing permissions and limitations under the License. 14 | * 15 | * When distributing the software, include this License Header Notice in each 16 | * file and include the License file at packager/legal/LICENSE.txt. 17 | * 18 | * GPL Classpath Exception: 19 | * Oracle designates this particular file as subject to the "Classpath" 20 | * exception as provided by Oracle in the GPL Version 2 section of the License 21 | * file that accompanied this code. 22 | * 23 | * Modifications: 24 | * If applicable, add the following below the License Header, with the fields 25 | * enclosed by brackets [] replaced by your own identifying information: 26 | * "Portions Copyright [year] [name of copyright owner]" 27 | * 28 | * Contributor(s): 29 | * If you wish your version of this file to be governed by only the CDDL or 30 | * only the GPL Version 2, indicate your decision by adding "[Contributor] 31 | * elects to include this software in this distribution under the [CDDL or GPL 32 | * Version 2] license." If you don't indicate a single choice of license, a 33 | * recipient has the option to distribute your version of this file under 34 | * either the CDDL, the GPL Version 2 or to extend the choice of license to 35 | * its licensees as provided above. However, if you add GPL Version 2 code 36 | * and therefore, elected the GPL Version 2 license, then the option applies 37 | * only if the new code is made subject to such option by the copyright 38 | * holder. 39 | */ 40 | 41 | /** 42 | * APIs that provide extensions to the types supported by the JAX-RS API. 43 | */ 44 | package javax.ws.rs.ext; 45 | -------------------------------------------------------------------------------- /jaxrs-api/src/main/java/javax/ws/rs/core/package-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. 3 | * 4 | * Copyright (c) 2010-2015 Oracle and/or its affiliates. All rights reserved. 5 | * 6 | * The contents of this file are subject to the terms of either the GNU 7 | * General Public License Version 2 only ("GPL") or the Common Development 8 | * and Distribution License("CDDL") (collectively, the "License"). You 9 | * may not use this file except in compliance with the License. You can 10 | * obtain a copy of the License at 11 | * http://glassfish.java.net/public/CDDL+GPL_1_1.html 12 | * or packager/legal/LICENSE.txt. See the License for the specific 13 | * language governing permissions and limitations under the License. 14 | * 15 | * When distributing the software, include this License Header Notice in each 16 | * file and include the License file at packager/legal/LICENSE.txt. 17 | * 18 | * GPL Classpath Exception: 19 | * Oracle designates this particular file as subject to the "Classpath" 20 | * exception as provided by Oracle in the GPL Version 2 section of the License 21 | * file that accompanied this code. 22 | * 23 | * Modifications: 24 | * If applicable, add the following below the License Header, with the fields 25 | * enclosed by brackets [] replaced by your own identifying information: 26 | * "Portions Copyright [year] [name of copyright owner]" 27 | * 28 | * Contributor(s): 29 | * If you wish your version of this file to be governed by only the CDDL or 30 | * only the GPL Version 2, indicate your decision by adding "[Contributor] 31 | * elects to include this software in this distribution under the [CDDL or GPL 32 | * Version 2] license." If you don't indicate a single choice of license, a 33 | * recipient has the option to distribute your version of this file under 34 | * either the CDDL, the GPL Version 2 or to extend the choice of license to 35 | * its licensees as provided above. However, if you add GPL Version 2 code 36 | * and therefore, elected the GPL Version 2 license, then the option applies 37 | * only if the new code is made subject to such option by the copyright 38 | * holder. 39 | */ 40 | 41 | /** 42 | * Low-level interfaces and annotations used to create RESTful service 43 | * resources. 44 | */ 45 | package javax.ws.rs.core; 46 | -------------------------------------------------------------------------------- /etc/bin/fixEmptySpacesAtEOL.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. 4 | # 5 | # Copyright (c) 2010-2017 Oracle and/or its affiliates. All rights reserved. 6 | # 7 | # The contents of this file are subject to the terms of either the GNU 8 | # General Public License Version 2 only ("GPL") or the Common Development 9 | # and Distribution License("CDDL") (collectively, the "License"). You 10 | # may not use this file except in compliance with the License. You can 11 | # obtain a copy of the License at 12 | # http://glassfish.java.net/public/CDDL+GPL_1_1.html 13 | # or packager/legal/LICENSE.txt. See the License for the specific 14 | # language governing permissions and limitations under the License. 15 | # 16 | # When distributing the software, include this License Header Notice in each 17 | # file and include the License file at packager/legal/LICENSE.txt. 18 | # 19 | # GPL Classpath Exception: 20 | # Oracle designates this particular file as subject to the "Classpath" 21 | # exception as provided by Oracle in the GPL Version 2 section of the License 22 | # file that accompanied this code. 23 | # 24 | # Modifications: 25 | # If applicable, add the following below the License Header, with the fields 26 | # enclosed by brackets [] replaced by your own identifying information: 27 | # "Portions Copyright [year] [name of copyright owner]" 28 | # 29 | # Contributor(s): 30 | # If you wish your version of this file to be governed by only the CDDL or 31 | # only the GPL Version 2, indicate your decision by adding "[Contributor] 32 | # elects to include this software in this distribution under the [CDDL or GPL 33 | # Version 2] license." If you don't indicate a single choice of license, a 34 | # recipient has the option to distribute your version of this file under 35 | # either the CDDL, the GPL Version 2 or to extend the choice of license to 36 | # its licensees as provided above. However, if you add GPL Version 2 code 37 | # and therefore, elected the GPL Version 2 license, then the option applies 38 | # only if the new code is made subject to such option by the copyright 39 | # holder. 40 | # 41 | 42 | fileNamePattern=$1 43 | 44 | for fileName in `find . -name $fileNamePattern` 45 | do 46 | echo 'Replacing in '$fileName 47 | perl -pi -e "s/\s+\n$/\n/" $fileName 48 | done 49 | 50 | -------------------------------------------------------------------------------- /jaxrs-api/src/main/java/javax/ws/rs/sse/package-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. 3 | * 4 | * Copyright (c) 2017 Oracle and/or its affiliates. All rights reserved. 5 | * 6 | * The contents of this file are subject to the terms of either the GNU 7 | * General Public License Version 2 only ("GPL") or the Common Development 8 | * and Distribution License("CDDL") (collectively, the "License"). You 9 | * may not use this file except in compliance with the License. You can 10 | * obtain a copy of the License at 11 | * http://glassfish.java.net/public/CDDL+GPL_1_1.html 12 | * or packager/legal/LICENSE.txt. See the License for the specific 13 | * language governing permissions and limitations under the License. 14 | * 15 | * When distributing the software, include this License Header Notice in each 16 | * file and include the License file at packager/legal/LICENSE.txt. 17 | * 18 | * GPL Classpath Exception: 19 | * Oracle designates this particular file as subject to the "Classpath" 20 | * exception as provided by Oracle in the GPL Version 2 section of the License 21 | * file that accompanied this code. 22 | * 23 | * Modifications: 24 | * If applicable, add the following below the License Header, with the fields 25 | * enclosed by brackets [] replaced by your own identifying information: 26 | * "Portions Copyright [year] [name of copyright owner]" 27 | * 28 | * Contributor(s): 29 | * If you wish your version of this file to be governed by only the CDDL or 30 | * only the GPL Version 2, indicate your decision by adding "[Contributor] 31 | * elects to include this software in this distribution under the [CDDL or GPL 32 | * Version 2] license." If you don't indicate a single choice of license, a 33 | * recipient has the option to distribute your version of this file under 34 | * either the CDDL, the GPL Version 2 or to extend the choice of license to 35 | * its licensees as provided above. However, if you add GPL Version 2 code 36 | * and therefore, elected the GPL Version 2 license, then the option applies 37 | * only if the new code is made subject to such option by the copyright 38 | * holder. 39 | */ 40 | 41 | /** 42 | * Server-Sent Events related API. 43 | * 44 | * This package provides support for providing event streams from the server 45 | * and also for processing then on the client side. 46 | */ 47 | package javax.ws.rs.sse; 48 | -------------------------------------------------------------------------------- /jaxrs-api/src/main/java/module-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. 3 | * 4 | * Copyright (c) 2017 Oracle and/or its affiliates. All rights reserved. 5 | * 6 | * The contents of this file are subject to the terms of either the GNU 7 | * General Public License Version 2 only ("GPL") or the Common Development 8 | * and Distribution License("CDDL") (collectively, the "License"). You 9 | * may not use this file except in compliance with the License. You can 10 | * obtain a copy of the License at 11 | * http://glassfish.java.net/public/CDDL+GPL_1_1.html 12 | * or packager/legal/LICENSE.txt. See the License for the specific 13 | * language governing permissions and limitations under the License. 14 | * 15 | * When distributing the software, include this License Header Notice in each 16 | * file and include the License file at packager/legal/LICENSE.txt. 17 | * 18 | * GPL Classpath Exception: 19 | * Oracle designates this particular file as subject to the "Classpath" 20 | * exception as provided by Oracle in the GPL Version 2 section of the License 21 | * file that accompanied this code. 22 | * 23 | * Modifications: 24 | * If applicable, add the following below the License Header, with the fields 25 | * enclosed by brackets [] replaced by your own identifying information: 26 | * "Portions Copyright [year] [name of copyright owner]" 27 | * 28 | * Contributor(s): 29 | * If you wish your version of this file to be governed by only the CDDL or 30 | * only the GPL Version 2, indicate your decision by adding "[Contributor] 31 | * elects to include this software in this distribution under the [CDDL or GPL 32 | * Version 2] license." If you don't indicate a single choice of license, a 33 | * recipient has the option to distribute your version of this file under 34 | * either the CDDL, the GPL Version 2 or to extend the choice of license to 35 | * its licensees as provided above. However, if you add GPL Version 2 code 36 | * and therefore, elected the GPL Version 2 license, then the option applies 37 | * only if the new code is made subject to such option by the copyright 38 | * holder. 39 | */ 40 | 41 | module java.ws.rs { 42 | 43 | requires transitive java.xml.bind; 44 | 45 | requires java.logging; 46 | 47 | exports javax.ws.rs; 48 | exports javax.ws.rs.client; 49 | exports javax.ws.rs.container; 50 | exports javax.ws.rs.core; 51 | exports javax.ws.rs.ext; 52 | exports javax.ws.rs.sse; 53 | 54 | } 55 | -------------------------------------------------------------------------------- /jaxrs-api/src/main/java/javax/ws/rs/RuntimeType.java: -------------------------------------------------------------------------------- 1 | /* 2 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. 3 | * 4 | * Copyright (c) 2012-2015 Oracle and/or its affiliates. All rights reserved. 5 | * 6 | * The contents of this file are subject to the terms of either the GNU 7 | * General Public License Version 2 only ("GPL") or the Common Development 8 | * and Distribution License("CDDL") (collectively, the "License"). You 9 | * may not use this file except in compliance with the License. You can 10 | * obtain a copy of the License at 11 | * http://glassfish.java.net/public/CDDL+GPL_1_1.html 12 | * or packager/legal/LICENSE.txt. See the License for the specific 13 | * language governing permissions and limitations under the License. 14 | * 15 | * When distributing the software, include this License Header Notice in each 16 | * file and include the License file at packager/legal/LICENSE.txt. 17 | * 18 | * GPL Classpath Exception: 19 | * Oracle designates this particular file as subject to the "Classpath" 20 | * exception as provided by Oracle in the GPL Version 2 section of the License 21 | * file that accompanied this code. 22 | * 23 | * Modifications: 24 | * If applicable, add the following below the License Header, with the fields 25 | * enclosed by brackets [] replaced by your own identifying information: 26 | * "Portions Copyright [year] [name of copyright owner]" 27 | * 28 | * Contributor(s): 29 | * If you wish your version of this file to be governed by only the CDDL or 30 | * only the GPL Version 2, indicate your decision by adding "[Contributor] 31 | * elects to include this software in this distribution under the [CDDL or GPL 32 | * Version 2] license." If you don't indicate a single choice of license, a 33 | * recipient has the option to distribute your version of this file under 34 | * either the CDDL, the GPL Version 2 or to extend the choice of license to 35 | * its licensees as provided above. However, if you add GPL Version 2 code 36 | * and therefore, elected the GPL Version 2 license, then the option applies 37 | * only if the new code is made subject to such option by the copyright 38 | * holder. 39 | */ 40 | 41 | package javax.ws.rs; 42 | 43 | /** 44 | * Enumeration of JAX-RS runtime types. 45 | * 46 | * @author Marek Potociar 47 | * @since 2.0 48 | */ 49 | public enum RuntimeType { 50 | /** 51 | * JAX-RS client run-time. 52 | */ 53 | CLIENT, 54 | /** 55 | * JAX-RS server run-time. 56 | */ 57 | SERVER 58 | } 59 | -------------------------------------------------------------------------------- /jaxrs-api/src/main/java/javax/ws/rs/core/FeatureContext.java: -------------------------------------------------------------------------------- 1 | /* 2 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. 3 | * 4 | * Copyright (c) 2012-2015 Oracle and/or its affiliates. All rights reserved. 5 | * 6 | * The contents of this file are subject to the terms of either the GNU 7 | * General Public License Version 2 only ("GPL") or the Common Development 8 | * and Distribution License("CDDL") (collectively, the "License"). You 9 | * may not use this file except in compliance with the License. You can 10 | * obtain a copy of the License at 11 | * http://glassfish.java.net/public/CDDL+GPL_1_1.html 12 | * or packager/legal/LICENSE.txt. See the License for the specific 13 | * language governing permissions and limitations under the License. 14 | * 15 | * When distributing the software, include this License Header Notice in each 16 | * file and include the License file at packager/legal/LICENSE.txt. 17 | * 18 | * GPL Classpath Exception: 19 | * Oracle designates this particular file as subject to the "Classpath" 20 | * exception as provided by Oracle in the GPL Version 2 section of the License 21 | * file that accompanied this code. 22 | * 23 | * Modifications: 24 | * If applicable, add the following below the License Header, with the fields 25 | * enclosed by brackets [] replaced by your own identifying information: 26 | * "Portions Copyright [year] [name of copyright owner]" 27 | * 28 | * Contributor(s): 29 | * If you wish your version of this file to be governed by only the CDDL or 30 | * only the GPL Version 2, indicate your decision by adding "[Contributor] 31 | * elects to include this software in this distribution under the [CDDL or GPL 32 | * Version 2] license." If you don't indicate a single choice of license, a 33 | * recipient has the option to distribute your version of this file under 34 | * either the CDDL, the GPL Version 2 or to extend the choice of license to 35 | * its licensees as provided above. However, if you add GPL Version 2 code 36 | * and therefore, elected the GPL Version 2 license, then the option applies 37 | * only if the new code is made subject to such option by the copyright 38 | * holder. 39 | */ 40 | 41 | package javax.ws.rs.core; 42 | 43 | /** 44 | * A configurable context passed to {@link Feature} and {@link javax.ws.rs.container.DynamicFeature} 45 | * instances by JAX-RS runtime during the phase of their configuration. 46 | * 47 | * @author Marek Potociar (marek.potociar at oracle.com) 48 | */ 49 | public interface FeatureContext extends Configurable { 50 | } 51 | -------------------------------------------------------------------------------- /examples/src/main/java/jaxrs/examples/client/webdav/WebDavSyncInvoker.java: -------------------------------------------------------------------------------- 1 | /* 2 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. 3 | * 4 | * Copyright (c) 2011-2015 Oracle and/or its affiliates. All rights reserved. 5 | * 6 | * The contents of this file are subject to the terms of either the GNU 7 | * General Public License Version 2 only ("GPL") or the Common Development 8 | * and Distribution License("CDDL") (collectively, the "License"). You 9 | * may not use this file except in compliance with the License. You can 10 | * obtain a copy of the License at 11 | * http://glassfish.java.net/public/CDDL+GPL_1_1.html 12 | * or packager/legal/LICENSE.txt. See the License for the specific 13 | * language governing permissions and limitations under the License. 14 | * 15 | * When distributing the software, include this License Header Notice in each 16 | * file and include the License file at packager/legal/LICENSE.txt. 17 | * 18 | * GPL Classpath Exception: 19 | * Oracle designates this particular file as subject to the "Classpath" 20 | * exception as provided by Oracle in the GPL Version 2 section of the License 21 | * file that accompanied this code. 22 | * 23 | * Modifications: 24 | * If applicable, add the following below the License Header, with the fields 25 | * enclosed by brackets [] replaced by your own identifying information: 26 | * "Portions Copyright [year] [name of copyright owner]" 27 | * 28 | * Contributor(s): 29 | * If you wish your version of this file to be governed by only the CDDL or 30 | * only the GPL Version 2, indicate your decision by adding "[Contributor] 31 | * elects to include this software in this distribution under the [CDDL or GPL 32 | * Version 2] license." If you don't indicate a single choice of license, a 33 | * recipient has the option to distribute your version of this file under 34 | * either the CDDL, the GPL Version 2 or to extend the choice of license to 35 | * its licensees as provided above. However, if you add GPL Version 2 code 36 | * and therefore, elected the GPL Version 2 license, then the option applies 37 | * only if the new code is made subject to such option by the copyright 38 | * holder. 39 | */ 40 | 41 | package jaxrs.examples.client.webdav; 42 | 43 | import javax.ws.rs.client.Entity; 44 | import javax.ws.rs.client.SyncInvoker; 45 | import javax.ws.rs.core.Response; 46 | 47 | /** 48 | * @author Marek Potociar 49 | */ 50 | public interface WebDavSyncInvoker extends SyncInvoker { 51 | 52 | public Response search(Entity entity); 53 | 54 | // other WebDAV method definitions go here 55 | } 56 | -------------------------------------------------------------------------------- /examples/src/main/java/jaxrs/examples/client/webdav/WebDavAsyncInvoker.java: -------------------------------------------------------------------------------- 1 | /* 2 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. 3 | * 4 | * Copyright (c) 2011-2015 Oracle and/or its affiliates. All rights reserved. 5 | * 6 | * The contents of this file are subject to the terms of either the GNU 7 | * General Public License Version 2 only ("GPL") or the Common Development 8 | * and Distribution License("CDDL") (collectively, the "License"). You 9 | * may not use this file except in compliance with the License. You can 10 | * obtain a copy of the License at 11 | * http://glassfish.java.net/public/CDDL+GPL_1_1.html 12 | * or packager/legal/LICENSE.txt. See the License for the specific 13 | * language governing permissions and limitations under the License. 14 | * 15 | * When distributing the software, include this License Header Notice in each 16 | * file and include the License file at packager/legal/LICENSE.txt. 17 | * 18 | * GPL Classpath Exception: 19 | * Oracle designates this particular file as subject to the "Classpath" 20 | * exception as provided by Oracle in the GPL Version 2 section of the License 21 | * file that accompanied this code. 22 | * 23 | * Modifications: 24 | * If applicable, add the following below the License Header, with the fields 25 | * enclosed by brackets [] replaced by your own identifying information: 26 | * "Portions Copyright [year] [name of copyright owner]" 27 | * 28 | * Contributor(s): 29 | * If you wish your version of this file to be governed by only the CDDL or 30 | * only the GPL Version 2, indicate your decision by adding "[Contributor] 31 | * elects to include this software in this distribution under the [CDDL or GPL 32 | * Version 2] license." If you don't indicate a single choice of license, a 33 | * recipient has the option to distribute your version of this file under 34 | * either the CDDL, the GPL Version 2 or to extend the choice of license to 35 | * its licensees as provided above. However, if you add GPL Version 2 code 36 | * and therefore, elected the GPL Version 2 license, then the option applies 37 | * only if the new code is made subject to such option by the copyright 38 | * holder. 39 | */ 40 | 41 | package jaxrs.examples.client.webdav; 42 | 43 | import java.util.concurrent.Future; 44 | 45 | import javax.ws.rs.client.AsyncInvoker; 46 | import javax.ws.rs.client.Entity; 47 | import javax.ws.rs.core.Response; 48 | 49 | /** 50 | * @author Marek Potociar 51 | */ 52 | public interface WebDavAsyncInvoker extends AsyncInvoker { 53 | 54 | public Future search(Entity entity); 55 | 56 | // other WebDAV method definitions go here 57 | } 58 | -------------------------------------------------------------------------------- /examples/src/main/java/jaxrs/examples/filter/logging/Logged.java: -------------------------------------------------------------------------------- 1 | /* 2 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. 3 | * 4 | * Copyright (c) 2011-2015 Oracle and/or its affiliates. All rights reserved. 5 | * 6 | * The contents of this file are subject to the terms of either the GNU 7 | * General Public License Version 2 only ("GPL") or the Common Development 8 | * and Distribution License("CDDL") (collectively, the "License"). You 9 | * may not use this file except in compliance with the License. You can 10 | * obtain a copy of the License at 11 | * http://glassfish.java.net/public/CDDL+GPL_1_1.html 12 | * or packager/legal/LICENSE.txt. See the License for the specific 13 | * language governing permissions and limitations under the License. 14 | * 15 | * When distributing the software, include this License Header Notice in each 16 | * file and include the License file at packager/legal/LICENSE.txt. 17 | * 18 | * GPL Classpath Exception: 19 | * Oracle designates this particular file as subject to the "Classpath" 20 | * exception as provided by Oracle in the GPL Version 2 section of the License 21 | * file that accompanied this code. 22 | * 23 | * Modifications: 24 | * If applicable, add the following below the License Header, with the fields 25 | * enclosed by brackets [] replaced by your own identifying information: 26 | * "Portions Copyright [year] [name of copyright owner]" 27 | * 28 | * Contributor(s): 29 | * If you wish your version of this file to be governed by only the CDDL or 30 | * only the GPL Version 2, indicate your decision by adding "[Contributor] 31 | * elects to include this software in this distribution under the [CDDL or GPL 32 | * Version 2] license." If you don't indicate a single choice of license, a 33 | * recipient has the option to distribute your version of this file under 34 | * either the CDDL, the GPL Version 2 or to extend the choice of license to 35 | * its licensees as provided above. However, if you add GPL Version 2 code 36 | * and therefore, elected the GPL Version 2 license, then the option applies 37 | * only if the new code is made subject to such option by the copyright 38 | * holder. 39 | */ 40 | 41 | package jaxrs.examples.filter.logging; 42 | 43 | import java.lang.annotation.ElementType; 44 | import java.lang.annotation.Retention; 45 | import java.lang.annotation.RetentionPolicy; 46 | import java.lang.annotation.Target; 47 | 48 | import javax.ws.rs.NameBinding; 49 | 50 | /** 51 | * @author Santiago Pericas-Geertsen 52 | */ 53 | @NameBinding 54 | @Target({ElementType.TYPE, ElementType.METHOD}) 55 | @Retention(value = RetentionPolicy.RUNTIME) 56 | public @interface Logged { 57 | } 58 | -------------------------------------------------------------------------------- /examples/src/main/java/jaxrs/examples/filter/compression/Gzipped.java: -------------------------------------------------------------------------------- 1 | /* 2 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. 3 | * 4 | * Copyright (c) 2011-2015 Oracle and/or its affiliates. All rights reserved. 5 | * 6 | * The contents of this file are subject to the terms of either the GNU 7 | * General Public License Version 2 only ("GPL") or the Common Development 8 | * and Distribution License("CDDL") (collectively, the "License"). You 9 | * may not use this file except in compliance with the License. You can 10 | * obtain a copy of the License at 11 | * http://glassfish.java.net/public/CDDL+GPL_1_1.html 12 | * or packager/legal/LICENSE.txt. See the License for the specific 13 | * language governing permissions and limitations under the License. 14 | * 15 | * When distributing the software, include this License Header Notice in each 16 | * file and include the License file at packager/legal/LICENSE.txt. 17 | * 18 | * GPL Classpath Exception: 19 | * Oracle designates this particular file as subject to the "Classpath" 20 | * exception as provided by Oracle in the GPL Version 2 section of the License 21 | * file that accompanied this code. 22 | * 23 | * Modifications: 24 | * If applicable, add the following below the License Header, with the fields 25 | * enclosed by brackets [] replaced by your own identifying information: 26 | * "Portions Copyright [year] [name of copyright owner]" 27 | * 28 | * Contributor(s): 29 | * If you wish your version of this file to be governed by only the CDDL or 30 | * only the GPL Version 2, indicate your decision by adding "[Contributor] 31 | * elects to include this software in this distribution under the [CDDL or GPL 32 | * Version 2] license." If you don't indicate a single choice of license, a 33 | * recipient has the option to distribute your version of this file under 34 | * either the CDDL, the GPL Version 2 or to extend the choice of license to 35 | * its licensees as provided above. However, if you add GPL Version 2 code 36 | * and therefore, elected the GPL Version 2 license, then the option applies 37 | * only if the new code is made subject to such option by the copyright 38 | * holder. 39 | */ 40 | 41 | package jaxrs.examples.filter.compression; 42 | 43 | import java.lang.annotation.ElementType; 44 | import java.lang.annotation.Retention; 45 | import java.lang.annotation.RetentionPolicy; 46 | import java.lang.annotation.Target; 47 | 48 | import javax.ws.rs.NameBinding; 49 | 50 | /** 51 | * @author Santiago Pericas-Geertsen 52 | */ 53 | @NameBinding 54 | @Target({ElementType.TYPE, ElementType.METHOD}) 55 | @Retention(value = RetentionPolicy.RUNTIME) 56 | public @interface Gzipped { 57 | } 58 | -------------------------------------------------------------------------------- /examples/src/main/java/jaxrs/examples/filter/logging/MyResourceClass.java: -------------------------------------------------------------------------------- 1 | /* 2 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. 3 | * 4 | * Copyright (c) 2011-2015 Oracle and/or its affiliates. All rights reserved. 5 | * 6 | * The contents of this file are subject to the terms of either the GNU 7 | * General Public License Version 2 only ("GPL") or the Common Development 8 | * and Distribution License("CDDL") (collectively, the "License"). You 9 | * may not use this file except in compliance with the License. You can 10 | * obtain a copy of the License at 11 | * http://glassfish.java.net/public/CDDL+GPL_1_1.html 12 | * or packager/legal/LICENSE.txt. See the License for the specific 13 | * language governing permissions and limitations under the License. 14 | * 15 | * When distributing the software, include this License Header Notice in each 16 | * file and include the License file at packager/legal/LICENSE.txt. 17 | * 18 | * GPL Classpath Exception: 19 | * Oracle designates this particular file as subject to the "Classpath" 20 | * exception as provided by Oracle in the GPL Version 2 section of the License 21 | * file that accompanied this code. 22 | * 23 | * Modifications: 24 | * If applicable, add the following below the License Header, with the fields 25 | * enclosed by brackets [] replaced by your own identifying information: 26 | * "Portions Copyright [year] [name of copyright owner]" 27 | * 28 | * Contributor(s): 29 | * If you wish your version of this file to be governed by only the CDDL or 30 | * only the GPL Version 2, indicate your decision by adding "[Contributor] 31 | * elects to include this software in this distribution under the [CDDL or GPL 32 | * Version 2] license." If you don't indicate a single choice of license, a 33 | * recipient has the option to distribute your version of this file under 34 | * either the CDDL, the GPL Version 2 or to extend the choice of license to 35 | * its licensees as provided above. However, if you add GPL Version 2 code 36 | * and therefore, elected the GPL Version 2 license, then the option applies 37 | * only if the new code is made subject to such option by the copyright 38 | * holder. 39 | */ 40 | 41 | package jaxrs.examples.filter.logging; 42 | 43 | import javax.ws.rs.GET; 44 | import javax.ws.rs.Path; 45 | import javax.ws.rs.PathParam; 46 | import javax.ws.rs.Produces; 47 | 48 | /** 49 | * @author Santiago Pericas-Geertsen 50 | */ 51 | @Path("/") 52 | public class MyResourceClass { 53 | 54 | @Logged 55 | @GET 56 | @Produces("text/plain") 57 | @Path("{name}") 58 | public String hello(@PathParam("name") String name) { 59 | return "Hello " + name; 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /examples/src/main/java/jaxrs/examples/filter/compression/MyResourceClass.java: -------------------------------------------------------------------------------- 1 | /* 2 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. 3 | * 4 | * Copyright (c) 2011-2015 Oracle and/or its affiliates. All rights reserved. 5 | * 6 | * The contents of this file are subject to the terms of either the GNU 7 | * General Public License Version 2 only ("GPL") or the Common Development 8 | * and Distribution License("CDDL") (collectively, the "License"). You 9 | * may not use this file except in compliance with the License. You can 10 | * obtain a copy of the License at 11 | * http://glassfish.java.net/public/CDDL+GPL_1_1.html 12 | * or packager/legal/LICENSE.txt. See the License for the specific 13 | * language governing permissions and limitations under the License. 14 | * 15 | * When distributing the software, include this License Header Notice in each 16 | * file and include the License file at packager/legal/LICENSE.txt. 17 | * 18 | * GPL Classpath Exception: 19 | * Oracle designates this particular file as subject to the "Classpath" 20 | * exception as provided by Oracle in the GPL Version 2 section of the License 21 | * file that accompanied this code. 22 | * 23 | * Modifications: 24 | * If applicable, add the following below the License Header, with the fields 25 | * enclosed by brackets [] replaced by your own identifying information: 26 | * "Portions Copyright [year] [name of copyright owner]" 27 | * 28 | * Contributor(s): 29 | * If you wish your version of this file to be governed by only the CDDL or 30 | * only the GPL Version 2, indicate your decision by adding "[Contributor] 31 | * elects to include this software in this distribution under the [CDDL or GPL 32 | * Version 2] license." If you don't indicate a single choice of license, a 33 | * recipient has the option to distribute your version of this file under 34 | * either the CDDL, the GPL Version 2 or to extend the choice of license to 35 | * its licensees as provided above. However, if you add GPL Version 2 code 36 | * and therefore, elected the GPL Version 2 license, then the option applies 37 | * only if the new code is made subject to such option by the copyright 38 | * holder. 39 | */ 40 | 41 | package jaxrs.examples.filter.compression; 42 | 43 | import javax.ws.rs.GET; 44 | import javax.ws.rs.Path; 45 | import javax.ws.rs.PathParam; 46 | import javax.ws.rs.Produces; 47 | 48 | /** 49 | * @author Santiago Pericas-Geertsen 50 | */ 51 | @Path("/") 52 | public class MyResourceClass { 53 | 54 | @Gzipped 55 | @GET 56 | @Produces("text/plain") 57 | @Path("{name}") 58 | public String hello(@PathParam("name") String name) { 59 | return "Hello " + name; 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /jaxrs-api/src/main/java/javax/ws/rs/GET.java: -------------------------------------------------------------------------------- 1 | /* 2 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. 3 | * 4 | * Copyright (c) 2010-2015 Oracle and/or its affiliates. All rights reserved. 5 | * 6 | * The contents of this file are subject to the terms of either the GNU 7 | * General Public License Version 2 only ("GPL") or the Common Development 8 | * and Distribution License("CDDL") (collectively, the "License"). You 9 | * may not use this file except in compliance with the License. You can 10 | * obtain a copy of the License at 11 | * http://glassfish.java.net/public/CDDL+GPL_1_1.html 12 | * or packager/legal/LICENSE.txt. See the License for the specific 13 | * language governing permissions and limitations under the License. 14 | * 15 | * When distributing the software, include this License Header Notice in each 16 | * file and include the License file at packager/legal/LICENSE.txt. 17 | * 18 | * GPL Classpath Exception: 19 | * Oracle designates this particular file as subject to the "Classpath" 20 | * exception as provided by Oracle in the GPL Version 2 section of the License 21 | * file that accompanied this code. 22 | * 23 | * Modifications: 24 | * If applicable, add the following below the License Header, with the fields 25 | * enclosed by brackets [] replaced by your own identifying information: 26 | * "Portions Copyright [year] [name of copyright owner]" 27 | * 28 | * Contributor(s): 29 | * If you wish your version of this file to be governed by only the CDDL or 30 | * only the GPL Version 2, indicate your decision by adding "[Contributor] 31 | * elects to include this software in this distribution under the [CDDL or GPL 32 | * Version 2] license." If you don't indicate a single choice of license, a 33 | * recipient has the option to distribute your version of this file under 34 | * either the CDDL, the GPL Version 2 or to extend the choice of license to 35 | * its licensees as provided above. However, if you add GPL Version 2 code 36 | * and therefore, elected the GPL Version 2 license, then the option applies 37 | * only if the new code is made subject to such option by the copyright 38 | * holder. 39 | */ 40 | 41 | package javax.ws.rs; 42 | 43 | import java.lang.annotation.Documented; 44 | import java.lang.annotation.ElementType; 45 | import java.lang.annotation.Retention; 46 | import java.lang.annotation.RetentionPolicy; 47 | import java.lang.annotation.Target; 48 | 49 | /** 50 | * Indicates that the annotated method responds to HTTP GET requests. 51 | * 52 | * @author Paul Sandoz 53 | * @author Marc Hadley 54 | * @see HttpMethod 55 | * @since 1.0 56 | */ 57 | @Target({ElementType.METHOD}) 58 | @Retention(RetentionPolicy.RUNTIME) 59 | @HttpMethod(HttpMethod.GET) 60 | @Documented 61 | public @interface GET { 62 | } 63 | -------------------------------------------------------------------------------- /jaxrs-api/src/main/java/javax/ws/rs/PUT.java: -------------------------------------------------------------------------------- 1 | /* 2 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. 3 | * 4 | * Copyright (c) 2010-2015 Oracle and/or its affiliates. All rights reserved. 5 | * 6 | * The contents of this file are subject to the terms of either the GNU 7 | * General Public License Version 2 only ("GPL") or the Common Development 8 | * and Distribution License("CDDL") (collectively, the "License"). You 9 | * may not use this file except in compliance with the License. You can 10 | * obtain a copy of the License at 11 | * http://glassfish.java.net/public/CDDL+GPL_1_1.html 12 | * or packager/legal/LICENSE.txt. See the License for the specific 13 | * language governing permissions and limitations under the License. 14 | * 15 | * When distributing the software, include this License Header Notice in each 16 | * file and include the License file at packager/legal/LICENSE.txt. 17 | * 18 | * GPL Classpath Exception: 19 | * Oracle designates this particular file as subject to the "Classpath" 20 | * exception as provided by Oracle in the GPL Version 2 section of the License 21 | * file that accompanied this code. 22 | * 23 | * Modifications: 24 | * If applicable, add the following below the License Header, with the fields 25 | * enclosed by brackets [] replaced by your own identifying information: 26 | * "Portions Copyright [year] [name of copyright owner]" 27 | * 28 | * Contributor(s): 29 | * If you wish your version of this file to be governed by only the CDDL or 30 | * only the GPL Version 2, indicate your decision by adding "[Contributor] 31 | * elects to include this software in this distribution under the [CDDL or GPL 32 | * Version 2] license." If you don't indicate a single choice of license, a 33 | * recipient has the option to distribute your version of this file under 34 | * either the CDDL, the GPL Version 2 or to extend the choice of license to 35 | * its licensees as provided above. However, if you add GPL Version 2 code 36 | * and therefore, elected the GPL Version 2 license, then the option applies 37 | * only if the new code is made subject to such option by the copyright 38 | * holder. 39 | */ 40 | 41 | package javax.ws.rs; 42 | 43 | import java.lang.annotation.Documented; 44 | import java.lang.annotation.ElementType; 45 | import java.lang.annotation.Retention; 46 | import java.lang.annotation.RetentionPolicy; 47 | import java.lang.annotation.Target; 48 | 49 | /** 50 | * Indicates that the annotated method responds to HTTP PUT requests. 51 | * 52 | * @author Paul Sandoz 53 | * @author Marc Hadley 54 | * @see HttpMethod 55 | * @since 1.0 56 | */ 57 | @Target({ElementType.METHOD}) 58 | @Retention(RetentionPolicy.RUNTIME) 59 | @HttpMethod(HttpMethod.PUT) 60 | @Documented 61 | public @interface PUT { 62 | } 63 | -------------------------------------------------------------------------------- /jaxrs-api/src/main/java/javax/ws/rs/HEAD.java: -------------------------------------------------------------------------------- 1 | /* 2 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. 3 | * 4 | * Copyright (c) 2010-2015 Oracle and/or its affiliates. All rights reserved. 5 | * 6 | * The contents of this file are subject to the terms of either the GNU 7 | * General Public License Version 2 only ("GPL") or the Common Development 8 | * and Distribution License("CDDL") (collectively, the "License"). You 9 | * may not use this file except in compliance with the License. You can 10 | * obtain a copy of the License at 11 | * http://glassfish.java.net/public/CDDL+GPL_1_1.html 12 | * or packager/legal/LICENSE.txt. See the License for the specific 13 | * language governing permissions and limitations under the License. 14 | * 15 | * When distributing the software, include this License Header Notice in each 16 | * file and include the License file at packager/legal/LICENSE.txt. 17 | * 18 | * GPL Classpath Exception: 19 | * Oracle designates this particular file as subject to the "Classpath" 20 | * exception as provided by Oracle in the GPL Version 2 section of the License 21 | * file that accompanied this code. 22 | * 23 | * Modifications: 24 | * If applicable, add the following below the License Header, with the fields 25 | * enclosed by brackets [] replaced by your own identifying information: 26 | * "Portions Copyright [year] [name of copyright owner]" 27 | * 28 | * Contributor(s): 29 | * If you wish your version of this file to be governed by only the CDDL or 30 | * only the GPL Version 2, indicate your decision by adding "[Contributor] 31 | * elects to include this software in this distribution under the [CDDL or GPL 32 | * Version 2] license." If you don't indicate a single choice of license, a 33 | * recipient has the option to distribute your version of this file under 34 | * either the CDDL, the GPL Version 2 or to extend the choice of license to 35 | * its licensees as provided above. However, if you add GPL Version 2 code 36 | * and therefore, elected the GPL Version 2 license, then the option applies 37 | * only if the new code is made subject to such option by the copyright 38 | * holder. 39 | */ 40 | 41 | package javax.ws.rs; 42 | 43 | import java.lang.annotation.Documented; 44 | import java.lang.annotation.ElementType; 45 | import java.lang.annotation.Retention; 46 | import java.lang.annotation.RetentionPolicy; 47 | import java.lang.annotation.Target; 48 | 49 | /** 50 | * Indicates that the annotated method responds to HTTP HEAD requests. 51 | * 52 | * @author Paul Sandoz 53 | * @author Marc Hadley 54 | * @see HttpMethod 55 | * @since 1.0 56 | */ 57 | @Target({ElementType.METHOD}) 58 | @Retention(RetentionPolicy.RUNTIME) 59 | @HttpMethod(HttpMethod.HEAD) 60 | @Documented 61 | public @interface HEAD { 62 | } 63 | -------------------------------------------------------------------------------- /jaxrs-api/src/main/java/javax/ws/rs/PATCH.java: -------------------------------------------------------------------------------- 1 | /* 2 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. 3 | * 4 | * Copyright (c) 2017 Oracle and/or its affiliates. All rights reserved. 5 | * 6 | * The contents of this file are subject to the terms of either the GNU 7 | * General Public License Version 2 only ("GPL") or the Common Development 8 | * and Distribution License("CDDL") (collectively, the "License"). You 9 | * may not use this file except in compliance with the License. You can 10 | * obtain a copy of the License at 11 | * http://glassfish.java.net/public/CDDL+GPL_1_1.html 12 | * or packager/legal/LICENSE.txt. See the License for the specific 13 | * language governing permissions and limitations under the License. 14 | * 15 | * When distributing the software, include this License Header Notice in each 16 | * file and include the License file at packager/legal/LICENSE.txt. 17 | * 18 | * GPL Classpath Exception: 19 | * Oracle designates this particular file as subject to the "Classpath" 20 | * exception as provided by Oracle in the GPL Version 2 section of the License 21 | * file that accompanied this code. 22 | * 23 | * Modifications: 24 | * If applicable, add the following below the License Header, with the fields 25 | * enclosed by brackets [] replaced by your own identifying information: 26 | * "Portions Copyright [year] [name of copyright owner]" 27 | * 28 | * Contributor(s): 29 | * If you wish your version of this file to be governed by only the CDDL or 30 | * only the GPL Version 2, indicate your decision by adding "[Contributor] 31 | * elects to include this software in this distribution under the [CDDL or GPL 32 | * Version 2] license." If you don't indicate a single choice of license, a 33 | * recipient has the option to distribute your version of this file under 34 | * either the CDDL, the GPL Version 2 or to extend the choice of license to 35 | * its licensees as provided above. However, if you add GPL Version 2 code 36 | * and therefore, elected the GPL Version 2 license, then the option applies 37 | * only if the new code is made subject to such option by the copyright 38 | * holder. 39 | */ 40 | 41 | package javax.ws.rs; 42 | 43 | import java.lang.annotation.Documented; 44 | import java.lang.annotation.ElementType; 45 | import java.lang.annotation.Retention; 46 | import java.lang.annotation.RetentionPolicy; 47 | import java.lang.annotation.Target; 48 | 49 | /** 50 | * Indicates that the annotated method responds to HTTP PATCH requests. 51 | * 52 | * @author Pavel Bucek (pavel.bucek at oracle.com) 53 | * @see HttpMethod 54 | * @since 2.1 55 | */ 56 | @Target({ElementType.METHOD}) 57 | @Retention(RetentionPolicy.RUNTIME) 58 | @HttpMethod(HttpMethod.PATCH) 59 | @Documented 60 | public @interface PATCH { 61 | } 62 | -------------------------------------------------------------------------------- /jaxrs-api/src/main/java/javax/ws/rs/POST.java: -------------------------------------------------------------------------------- 1 | /* 2 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. 3 | * 4 | * Copyright (c) 2010-2015 Oracle and/or its affiliates. All rights reserved. 5 | * 6 | * The contents of this file are subject to the terms of either the GNU 7 | * General Public License Version 2 only ("GPL") or the Common Development 8 | * and Distribution License("CDDL") (collectively, the "License"). You 9 | * may not use this file except in compliance with the License. You can 10 | * obtain a copy of the License at 11 | * http://glassfish.java.net/public/CDDL+GPL_1_1.html 12 | * or packager/legal/LICENSE.txt. See the License for the specific 13 | * language governing permissions and limitations under the License. 14 | * 15 | * When distributing the software, include this License Header Notice in each 16 | * file and include the License file at packager/legal/LICENSE.txt. 17 | * 18 | * GPL Classpath Exception: 19 | * Oracle designates this particular file as subject to the "Classpath" 20 | * exception as provided by Oracle in the GPL Version 2 section of the License 21 | * file that accompanied this code. 22 | * 23 | * Modifications: 24 | * If applicable, add the following below the License Header, with the fields 25 | * enclosed by brackets [] replaced by your own identifying information: 26 | * "Portions Copyright [year] [name of copyright owner]" 27 | * 28 | * Contributor(s): 29 | * If you wish your version of this file to be governed by only the CDDL or 30 | * only the GPL Version 2, indicate your decision by adding "[Contributor] 31 | * elects to include this software in this distribution under the [CDDL or GPL 32 | * Version 2] license." If you don't indicate a single choice of license, a 33 | * recipient has the option to distribute your version of this file under 34 | * either the CDDL, the GPL Version 2 or to extend the choice of license to 35 | * its licensees as provided above. However, if you add GPL Version 2 code 36 | * and therefore, elected the GPL Version 2 license, then the option applies 37 | * only if the new code is made subject to such option by the copyright 38 | * holder. 39 | */ 40 | 41 | package javax.ws.rs; 42 | 43 | import java.lang.annotation.Documented; 44 | import java.lang.annotation.ElementType; 45 | import java.lang.annotation.Retention; 46 | import java.lang.annotation.RetentionPolicy; 47 | import java.lang.annotation.Target; 48 | 49 | /** 50 | * Indicates that the annotated method responds to HTTP POST requests. 51 | * 52 | * @author Paul Sandoz 53 | * @author Marc Hadley 54 | * @see HttpMethod 55 | * @since 1.0 56 | */ 57 | @Target({ElementType.METHOD}) 58 | @Retention(RetentionPolicy.RUNTIME) 59 | @HttpMethod(HttpMethod.POST) 60 | @Documented 61 | public @interface POST { 62 | } 63 | -------------------------------------------------------------------------------- /jaxrs-api/src/main/java/javax/ws/rs/DELETE.java: -------------------------------------------------------------------------------- 1 | /* 2 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. 3 | * 4 | * Copyright (c) 2010-2015 Oracle and/or its affiliates. All rights reserved. 5 | * 6 | * The contents of this file are subject to the terms of either the GNU 7 | * General Public License Version 2 only ("GPL") or the Common Development 8 | * and Distribution License("CDDL") (collectively, the "License"). You 9 | * may not use this file except in compliance with the License. You can 10 | * obtain a copy of the License at 11 | * http://glassfish.java.net/public/CDDL+GPL_1_1.html 12 | * or packager/legal/LICENSE.txt. See the License for the specific 13 | * language governing permissions and limitations under the License. 14 | * 15 | * When distributing the software, include this License Header Notice in each 16 | * file and include the License file at packager/legal/LICENSE.txt. 17 | * 18 | * GPL Classpath Exception: 19 | * Oracle designates this particular file as subject to the "Classpath" 20 | * exception as provided by Oracle in the GPL Version 2 section of the License 21 | * file that accompanied this code. 22 | * 23 | * Modifications: 24 | * If applicable, add the following below the License Header, with the fields 25 | * enclosed by brackets [] replaced by your own identifying information: 26 | * "Portions Copyright [year] [name of copyright owner]" 27 | * 28 | * Contributor(s): 29 | * If you wish your version of this file to be governed by only the CDDL or 30 | * only the GPL Version 2, indicate your decision by adding "[Contributor] 31 | * elects to include this software in this distribution under the [CDDL or GPL 32 | * Version 2] license." If you don't indicate a single choice of license, a 33 | * recipient has the option to distribute your version of this file under 34 | * either the CDDL, the GPL Version 2 or to extend the choice of license to 35 | * its licensees as provided above. However, if you add GPL Version 2 code 36 | * and therefore, elected the GPL Version 2 license, then the option applies 37 | * only if the new code is made subject to such option by the copyright 38 | * holder. 39 | */ 40 | 41 | package javax.ws.rs; 42 | 43 | import java.lang.annotation.Documented; 44 | import java.lang.annotation.ElementType; 45 | import java.lang.annotation.Retention; 46 | import java.lang.annotation.RetentionPolicy; 47 | import java.lang.annotation.Target; 48 | 49 | /** 50 | * Indicates that the annotated method responds to HTTP DELETE requests. 51 | * 52 | * @author Paul Sandoz 53 | * @author Marc Hadley 54 | * @see HttpMethod 55 | * @since 1.0 56 | */ 57 | @Target({ElementType.METHOD}) 58 | @Retention(RetentionPolicy.RUNTIME) 59 | @HttpMethod(HttpMethod.DELETE) 60 | @Documented 61 | public @interface DELETE { 62 | } 63 | -------------------------------------------------------------------------------- /jaxrs-api/src/main/java/javax/ws/rs/OPTIONS.java: -------------------------------------------------------------------------------- 1 | /* 2 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. 3 | * 4 | * Copyright (c) 2010-2015 Oracle and/or its affiliates. All rights reserved. 5 | * 6 | * The contents of this file are subject to the terms of either the GNU 7 | * General Public License Version 2 only ("GPL") or the Common Development 8 | * and Distribution License("CDDL") (collectively, the "License"). You 9 | * may not use this file except in compliance with the License. You can 10 | * obtain a copy of the License at 11 | * http://glassfish.java.net/public/CDDL+GPL_1_1.html 12 | * or packager/legal/LICENSE.txt. See the License for the specific 13 | * language governing permissions and limitations under the License. 14 | * 15 | * When distributing the software, include this License Header Notice in each 16 | * file and include the License file at packager/legal/LICENSE.txt. 17 | * 18 | * GPL Classpath Exception: 19 | * Oracle designates this particular file as subject to the "Classpath" 20 | * exception as provided by Oracle in the GPL Version 2 section of the License 21 | * file that accompanied this code. 22 | * 23 | * Modifications: 24 | * If applicable, add the following below the License Header, with the fields 25 | * enclosed by brackets [] replaced by your own identifying information: 26 | * "Portions Copyright [year] [name of copyright owner]" 27 | * 28 | * Contributor(s): 29 | * If you wish your version of this file to be governed by only the CDDL or 30 | * only the GPL Version 2, indicate your decision by adding "[Contributor] 31 | * elects to include this software in this distribution under the [CDDL or GPL 32 | * Version 2] license." If you don't indicate a single choice of license, a 33 | * recipient has the option to distribute your version of this file under 34 | * either the CDDL, the GPL Version 2 or to extend the choice of license to 35 | * its licensees as provided above. However, if you add GPL Version 2 code 36 | * and therefore, elected the GPL Version 2 license, then the option applies 37 | * only if the new code is made subject to such option by the copyright 38 | * holder. 39 | */ 40 | 41 | package javax.ws.rs; 42 | 43 | import java.lang.annotation.Documented; 44 | import java.lang.annotation.ElementType; 45 | import java.lang.annotation.Retention; 46 | import java.lang.annotation.RetentionPolicy; 47 | import java.lang.annotation.Target; 48 | 49 | /** 50 | * Indicates that the annotated method responds to HTTP OPTIONS requests. 51 | * 52 | * @author Paul Sandoz 53 | * @author Marc Hadley 54 | * @see HttpMethod 55 | * @since 1.1 56 | */ 57 | @Target({ElementType.METHOD}) 58 | @Retention(RetentionPolicy.RUNTIME) 59 | @HttpMethod(HttpMethod.OPTIONS) 60 | @Documented 61 | public @interface OPTIONS { 62 | } 63 | -------------------------------------------------------------------------------- /jaxrs-api/src/main/java/javax/ws/rs/ext/Provider.java: -------------------------------------------------------------------------------- 1 | /* 2 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. 3 | * 4 | * Copyright (c) 2010-2015 Oracle and/or its affiliates. All rights reserved. 5 | * 6 | * The contents of this file are subject to the terms of either the GNU 7 | * General Public License Version 2 only ("GPL") or the Common Development 8 | * and Distribution License("CDDL") (collectively, the "License"). You 9 | * may not use this file except in compliance with the License. You can 10 | * obtain a copy of the License at 11 | * http://glassfish.java.net/public/CDDL+GPL_1_1.html 12 | * or packager/legal/LICENSE.txt. See the License for the specific 13 | * language governing permissions and limitations under the License. 14 | * 15 | * When distributing the software, include this License Header Notice in each 16 | * file and include the License file at packager/legal/LICENSE.txt. 17 | * 18 | * GPL Classpath Exception: 19 | * Oracle designates this particular file as subject to the "Classpath" 20 | * exception as provided by Oracle in the GPL Version 2 section of the License 21 | * file that accompanied this code. 22 | * 23 | * Modifications: 24 | * If applicable, add the following below the License Header, with the fields 25 | * enclosed by brackets [] replaced by your own identifying information: 26 | * "Portions Copyright [year] [name of copyright owner]" 27 | * 28 | * Contributor(s): 29 | * If you wish your version of this file to be governed by only the CDDL or 30 | * only the GPL Version 2, indicate your decision by adding "[Contributor] 31 | * elects to include this software in this distribution under the [CDDL or GPL 32 | * Version 2] license." If you don't indicate a single choice of license, a 33 | * recipient has the option to distribute your version of this file under 34 | * either the CDDL, the GPL Version 2 or to extend the choice of license to 35 | * its licensees as provided above. However, if you add GPL Version 2 code 36 | * and therefore, elected the GPL Version 2 license, then the option applies 37 | * only if the new code is made subject to such option by the copyright 38 | * holder. 39 | */ 40 | 41 | package javax.ws.rs.ext; 42 | 43 | import java.lang.annotation.Documented; 44 | import java.lang.annotation.ElementType; 45 | import java.lang.annotation.Retention; 46 | import java.lang.annotation.RetentionPolicy; 47 | import java.lang.annotation.Target; 48 | 49 | /** 50 | * Marks an implementation of an extension interface that should be discoverable 51 | * by JAX-RS runtime during a provider scanning phase. 52 | * 53 | * @author Paul Sandoz 54 | * @author Marc Hadley 55 | * @since 1.0 56 | */ 57 | @Target({ElementType.TYPE}) 58 | @Retention(RetentionPolicy.RUNTIME) 59 | @Documented 60 | public @interface Provider { 61 | } 62 | -------------------------------------------------------------------------------- /examples/src/main/java/jaxrs/examples/client/cache/CachingFeature.java: -------------------------------------------------------------------------------- 1 | /* 2 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. 3 | * 4 | * Copyright (c) 2011-2015 Oracle and/or its affiliates. All rights reserved. 5 | * 6 | * The contents of this file are subject to the terms of either the GNU 7 | * General Public License Version 2 only ("GPL") or the Common Development 8 | * and Distribution License("CDDL") (collectively, the "License"). You 9 | * may not use this file except in compliance with the License. You can 10 | * obtain a copy of the License at 11 | * http://glassfish.java.net/public/CDDL+GPL_1_1.html 12 | * or packager/legal/LICENSE.txt. See the License for the specific 13 | * language governing permissions and limitations under the License. 14 | * 15 | * When distributing the software, include this License Header Notice in each 16 | * file and include the License file at packager/legal/LICENSE.txt. 17 | * 18 | * GPL Classpath Exception: 19 | * Oracle designates this particular file as subject to the "Classpath" 20 | * exception as provided by Oracle in the GPL Version 2 section of the License 21 | * file that accompanied this code. 22 | * 23 | * Modifications: 24 | * If applicable, add the following below the License Header, with the fields 25 | * enclosed by brackets [] replaced by your own identifying information: 26 | * "Portions Copyright [year] [name of copyright owner]" 27 | * 28 | * Contributor(s): 29 | * If you wish your version of this file to be governed by only the CDDL or 30 | * only the GPL Version 2, indicate your decision by adding "[Contributor] 31 | * elects to include this software in this distribution under the [CDDL or GPL 32 | * Version 2] license." If you don't indicate a single choice of license, a 33 | * recipient has the option to distribute your version of this file under 34 | * either the CDDL, the GPL Version 2 or to extend the choice of license to 35 | * its licensees as provided above. However, if you add GPL Version 2 code 36 | * and therefore, elected the GPL Version 2 license, then the option applies 37 | * only if the new code is made subject to such option by the copyright 38 | * holder. 39 | */ 40 | 41 | package jaxrs.examples.client.cache; 42 | 43 | import java.util.Map; 44 | import java.util.concurrent.ConcurrentHashMap; 45 | 46 | import javax.ws.rs.core.Feature; 47 | import javax.ws.rs.core.FeatureContext; 48 | 49 | /** 50 | * Example caching feature. 51 | * 52 | * @author Marek Potociar 53 | */ 54 | public class CachingFeature implements Feature { 55 | 56 | @Override 57 | public boolean configure(FeatureContext context) { 58 | final Map cacheStore = new ConcurrentHashMap(); 59 | context.register(new CacheEntryLocator(cacheStore)).register(new CacheResponseFilter(cacheStore)); 60 | 61 | return true; 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /examples/src/main/java/jaxrs/examples/client/links/LinkUsageExample.java: -------------------------------------------------------------------------------- 1 | /* 2 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. 3 | * 4 | * Copyright (c) 2011-2015 Oracle and/or its affiliates. All rights reserved. 5 | * 6 | * The contents of this file are subject to the terms of either the GNU 7 | * General Public License Version 2 only ("GPL") or the Common Development 8 | * and Distribution License("CDDL") (collectively, the "License"). You 9 | * may not use this file except in compliance with the License. You can 10 | * obtain a copy of the License at 11 | * http://glassfish.java.net/public/CDDL+GPL_1_1.html 12 | * or packager/legal/LICENSE.txt. See the License for the specific 13 | * language governing permissions and limitations under the License. 14 | * 15 | * When distributing the software, include this License Header Notice in each 16 | * file and include the License file at packager/legal/LICENSE.txt. 17 | * 18 | * GPL Classpath Exception: 19 | * Oracle designates this particular file as subject to the "Classpath" 20 | * exception as provided by Oracle in the GPL Version 2 section of the License 21 | * file that accompanied this code. 22 | * 23 | * Modifications: 24 | * If applicable, add the following below the License Header, with the fields 25 | * enclosed by brackets [] replaced by your own identifying information: 26 | * "Portions Copyright [year] [name of copyright owner]" 27 | * 28 | * Contributor(s): 29 | * If you wish your version of this file to be governed by only the CDDL or 30 | * only the GPL Version 2, indicate your decision by adding "[Contributor] 31 | * elects to include this software in this distribution under the [CDDL or GPL 32 | * Version 2] license." If you don't indicate a single choice of license, a 33 | * recipient has the option to distribute your version of this file under 34 | * either the CDDL, the GPL Version 2 or to extend the choice of license to 35 | * its licensees as provided above. However, if you add GPL Version 2 code 36 | * and therefore, elected the GPL Version 2 license, then the option applies 37 | * only if the new code is made subject to such option by the copyright 38 | * holder. 39 | */ 40 | 41 | package jaxrs.examples.client.links; 42 | 43 | import javax.ws.rs.client.Client; 44 | import javax.ws.rs.client.ClientBuilder; 45 | import javax.ws.rs.core.MediaType; 46 | import javax.ws.rs.core.Response; 47 | 48 | /** 49 | * @author Marek Potociar 50 | */ 51 | public class LinkUsageExample { 52 | 53 | public void testCLientSideLinks() { 54 | Client client = ClientBuilder.newClient(); 55 | 56 | Response current = client.target("http://examples.jax-rs-spec.com/current") 57 | .request(MediaType.APPLICATION_XML).get(); 58 | 59 | Response next = client.target(current.getLink("next")) 60 | .request(MediaType.APPLICATION_XML).get(); 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /jaxrs-api/src/test/java/javax/ws/rs/core/AbstractMultivaluedMapTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. 3 | * 4 | * Copyright (c) 2013-2015 Oracle and/or its affiliates. All rights reserved. 5 | * 6 | * The contents of this file are subject to the terms of either the GNU 7 | * General Public License Version 2 only ("GPL") or the Common Development 8 | * and Distribution License("CDDL") (collectively, the "License"). You 9 | * may not use this file except in compliance with the License. You can 10 | * obtain a copy of the License at 11 | * http://glassfish.java.net/public/CDDL+GPL_1_1.html 12 | * or packager/legal/LICENSE.txt. See the License for the specific 13 | * language governing permissions and limitations under the License. 14 | * 15 | * When distributing the software, include this License Header Notice in each 16 | * file and include the License file at packager/legal/LICENSE.txt. 17 | * 18 | * GPL Classpath Exception: 19 | * Oracle designates this particular file as subject to the "Classpath" 20 | * exception as provided by Oracle in the GPL Version 2 section of the License 21 | * file that accompanied this code. 22 | * 23 | * Modifications: 24 | * If applicable, add the following below the License Header, with the fields 25 | * enclosed by brackets [] replaced by your own identifying information: 26 | * "Portions Copyright [year] [name of copyright owner]" 27 | * 28 | * Contributor(s): 29 | * If you wish your version of this file to be governed by only the CDDL or 30 | * only the GPL Version 2, indicate your decision by adding "[Contributor] 31 | * elects to include this software in this distribution under the [CDDL or GPL 32 | * Version 2] license." If you don't indicate a single choice of license, a 33 | * recipient has the option to distribute your version of this file under 34 | * either the CDDL, the GPL Version 2 or to extend the choice of license to 35 | * its licensees as provided above. However, if you add GPL Version 2 code 36 | * and therefore, elected the GPL Version 2 license, then the option applies 37 | * only if the new code is made subject to such option by the copyright 38 | * holder. 39 | */ 40 | 41 | package javax.ws.rs.core; 42 | 43 | import org.junit.Test; 44 | 45 | import static junit.framework.Assert.fail; 46 | 47 | /** 48 | * AbstractMultivaluedMap unit tests. 49 | * 50 | * @author Marek Potociar (marek.potociar at oracle.com) 51 | */ 52 | public class AbstractMultivaluedMapTest { 53 | 54 | /** 55 | * A test to reproduce issue reported in JAX_RS_SPEC-384. 56 | */ 57 | @Test 58 | public void testNpeThrownFromMap() { 59 | try { 60 | new AbstractMultivaluedMap(null) { 61 | }; 62 | fail("NullPointerException expected."); 63 | } catch (NullPointerException npe) { 64 | // passed 65 | } 66 | } 67 | } 68 | -------------------------------------------------------------------------------- /jaxrs-api/src/main/java/javax/ws/rs/package-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. 3 | * 4 | * Copyright (c) 2010-2015 Oracle and/or its affiliates. All rights reserved. 5 | * 6 | * The contents of this file are subject to the terms of either the GNU 7 | * General Public License Version 2 only ("GPL") or the Common Development 8 | * and Distribution License("CDDL") (collectively, the "License"). You 9 | * may not use this file except in compliance with the License. You can 10 | * obtain a copy of the License at 11 | * http://glassfish.java.net/public/CDDL+GPL_1_1.html 12 | * or packager/legal/LICENSE.txt. See the License for the specific 13 | * language governing permissions and limitations under the License. 14 | * 15 | * When distributing the software, include this License Header Notice in each 16 | * file and include the License file at packager/legal/LICENSE.txt. 17 | * 18 | * GPL Classpath Exception: 19 | * Oracle designates this particular file as subject to the "Classpath" 20 | * exception as provided by Oracle in the GPL Version 2 section of the License 21 | * file that accompanied this code. 22 | * 23 | * Modifications: 24 | * If applicable, add the following below the License Header, with the fields 25 | * enclosed by brackets [] replaced by your own identifying information: 26 | * "Portions Copyright [year] [name of copyright owner]" 27 | * 28 | * Contributor(s): 29 | * If you wish your version of this file to be governed by only the CDDL or 30 | * only the GPL Version 2, indicate your decision by adding "[Contributor] 31 | * elects to include this software in this distribution under the [CDDL or GPL 32 | * Version 2] license." If you don't indicate a single choice of license, a 33 | * recipient has the option to distribute your version of this file under 34 | * either the CDDL, the GPL Version 2 or to extend the choice of license to 35 | * its licensees as provided above. However, if you add GPL Version 2 code 36 | * and therefore, elected the GPL Version 2 license, then the option applies 37 | * only if the new code is made subject to such option by the copyright 38 | * holder. 39 | */ 40 | 41 | /** 42 | * High-level interfaces and annotations used to create RESTful service 43 | * resources. For example: 44 | *
45 |  * @Path("widgets/{widgetid}")
46 |  * @Consumes("application/widgets+xml")
47 |  * @Produces("application/widgets+xml")
48 |  * public class WidgetResource {
49 |  *
50 |  *     @GET
51 |  *     public String getWidget(@PathParam("widgetid") String id) {
52 |  *         return getWidgetAsXml(id);
53 |  *     }
54 |  *
55 |  *     @PUT
56 |  *     public void updateWidget(@PathParam("widgetid") String id,
57 |  *                              Source update) {
58 |  *         updateWidgetFromXml(id, update);
59 |  *     }
60 |  *
61 |  *     ...
62 |  * }
63 |  * 
64 | */ 65 | package javax.ws.rs; 66 | -------------------------------------------------------------------------------- /examples/src/main/java/jaxrs/examples/client/cache/CacheExample.java: -------------------------------------------------------------------------------- 1 | /* 2 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. 3 | * 4 | * Copyright (c) 2011-2015 Oracle and/or its affiliates. All rights reserved. 5 | * 6 | * The contents of this file are subject to the terms of either the GNU 7 | * General Public License Version 2 only ("GPL") or the Common Development 8 | * and Distribution License("CDDL") (collectively, the "License"). You 9 | * may not use this file except in compliance with the License. You can 10 | * obtain a copy of the License at 11 | * http://glassfish.java.net/public/CDDL+GPL_1_1.html 12 | * or packager/legal/LICENSE.txt. See the License for the specific 13 | * language governing permissions and limitations under the License. 14 | * 15 | * When distributing the software, include this License Header Notice in each 16 | * file and include the License file at packager/legal/LICENSE.txt. 17 | * 18 | * GPL Classpath Exception: 19 | * Oracle designates this particular file as subject to the "Classpath" 20 | * exception as provided by Oracle in the GPL Version 2 section of the License 21 | * file that accompanied this code. 22 | * 23 | * Modifications: 24 | * If applicable, add the following below the License Header, with the fields 25 | * enclosed by brackets [] replaced by your own identifying information: 26 | * "Portions Copyright [year] [name of copyright owner]" 27 | * 28 | * Contributor(s): 29 | * If you wish your version of this file to be governed by only the CDDL or 30 | * only the GPL Version 2, indicate your decision by adding "[Contributor] 31 | * elects to include this software in this distribution under the [CDDL or GPL 32 | * Version 2] license." If you don't indicate a single choice of license, a 33 | * recipient has the option to distribute your version of this file under 34 | * either the CDDL, the GPL Version 2 or to extend the choice of license to 35 | * its licensees as provided above. However, if you add GPL Version 2 code 36 | * and therefore, elected the GPL Version 2 license, then the option applies 37 | * only if the new code is made subject to such option by the copyright 38 | * holder. 39 | */ 40 | 41 | package jaxrs.examples.client.cache; 42 | 43 | import javax.ws.rs.client.Client; 44 | import javax.ws.rs.client.ClientBuilder; 45 | import javax.ws.rs.client.WebTarget; 46 | 47 | /** 48 | * @author Bill Burke 49 | * @author Marek Potociar 50 | */ 51 | public class CacheExample { 52 | 53 | public void cacheExample() { 54 | Client client = ClientBuilder.newClient(); 55 | client.register(CachingFeature.class); 56 | 57 | WebTarget resource = client.target("http://example.com/foo/bar.txt"); 58 | 59 | String text = resource.request("text/plain").get(String.class); 60 | String second = resource.request("text/plain").get(String.class); 61 | 62 | System.out.println(text); 63 | System.out.println(second); 64 | } 65 | } 66 | -------------------------------------------------------------------------------- /jaxrs-api/src/main/java/javax/ws/rs/core/Context.java: -------------------------------------------------------------------------------- 1 | /* 2 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. 3 | * 4 | * Copyright (c) 2010-2015 Oracle and/or its affiliates. All rights reserved. 5 | * 6 | * The contents of this file are subject to the terms of either the GNU 7 | * General Public License Version 2 only ("GPL") or the Common Development 8 | * and Distribution License("CDDL") (collectively, the "License"). You 9 | * may not use this file except in compliance with the License. You can 10 | * obtain a copy of the License at 11 | * http://glassfish.java.net/public/CDDL+GPL_1_1.html 12 | * or packager/legal/LICENSE.txt. See the License for the specific 13 | * language governing permissions and limitations under the License. 14 | * 15 | * When distributing the software, include this License Header Notice in each 16 | * file and include the License file at packager/legal/LICENSE.txt. 17 | * 18 | * GPL Classpath Exception: 19 | * Oracle designates this particular file as subject to the "Classpath" 20 | * exception as provided by Oracle in the GPL Version 2 section of the License 21 | * file that accompanied this code. 22 | * 23 | * Modifications: 24 | * If applicable, add the following below the License Header, with the fields 25 | * enclosed by brackets [] replaced by your own identifying information: 26 | * "Portions Copyright [year] [name of copyright owner]" 27 | * 28 | * Contributor(s): 29 | * If you wish your version of this file to be governed by only the CDDL or 30 | * only the GPL Version 2, indicate your decision by adding "[Contributor] 31 | * elects to include this software in this distribution under the [CDDL or GPL 32 | * Version 2] license." If you don't indicate a single choice of license, a 33 | * recipient has the option to distribute your version of this file under 34 | * either the CDDL, the GPL Version 2 or to extend the choice of license to 35 | * its licensees as provided above. However, if you add GPL Version 2 code 36 | * and therefore, elected the GPL Version 2 license, then the option applies 37 | * only if the new code is made subject to such option by the copyright 38 | * holder. 39 | */ 40 | 41 | package javax.ws.rs.core; 42 | 43 | import java.lang.annotation.Documented; 44 | import java.lang.annotation.ElementType; 45 | import java.lang.annotation.Retention; 46 | import java.lang.annotation.RetentionPolicy; 47 | import java.lang.annotation.Target; 48 | 49 | /** 50 | * This annotation is used to inject information into a class 51 | * field, bean property or method parameter. 52 | * 53 | * @author Paul Sandoz 54 | * @author Marc Hadley 55 | * @see Application 56 | * @see UriInfo 57 | * @see Request 58 | * @see HttpHeaders 59 | * @see SecurityContext 60 | * @see javax.ws.rs.ext.Providers 61 | * @since 1.0 62 | */ 63 | @Target({ElementType.PARAMETER, ElementType.METHOD, ElementType.FIELD}) 64 | @Retention(RetentionPolicy.RUNTIME) 65 | @Documented 66 | public @interface Context { 67 | } 68 | -------------------------------------------------------------------------------- /jaxrs-api/src/test/java/javax/ws/rs/core/VariantTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. 3 | * 4 | * Copyright (c) 2012-2015 Oracle and/or its affiliates. All rights reserved. 5 | * 6 | * The contents of this file are subject to the terms of either the GNU 7 | * General Public License Version 2 only ("GPL") or the Common Development 8 | * and Distribution License("CDDL") (collectively, the "License"). You 9 | * may not use this file except in compliance with the License. You can 10 | * obtain a copy of the License at 11 | * http://glassfish.java.net/public/CDDL+GPL_1_1.html 12 | * or packager/legal/LICENSE.txt. See the License for the specific 13 | * language governing permissions and limitations under the License. 14 | * 15 | * When distributing the software, include this License Header Notice in each 16 | * file and include the License file at packager/legal/LICENSE.txt. 17 | * 18 | * GPL Classpath Exception: 19 | * Oracle designates this particular file as subject to the "Classpath" 20 | * exception as provided by Oracle in the GPL Version 2 section of the License 21 | * file that accompanied this code. 22 | * 23 | * Modifications: 24 | * If applicable, add the following below the License Header, with the fields 25 | * enclosed by brackets [] replaced by your own identifying information: 26 | * "Portions Copyright [year] [name of copyright owner]" 27 | * 28 | * Contributor(s): 29 | * If you wish your version of this file to be governed by only the CDDL or 30 | * only the GPL Version 2, indicate your decision by adding "[Contributor] 31 | * elects to include this software in this distribution under the [CDDL or GPL 32 | * Version 2] license." If you don't indicate a single choice of license, a 33 | * recipient has the option to distribute your version of this file under 34 | * either the CDDL, the GPL Version 2 or to extend the choice of license to 35 | * its licensees as provided above. However, if you add GPL Version 2 code 36 | * and therefore, elected the GPL Version 2 license, then the option applies 37 | * only if the new code is made subject to such option by the copyright 38 | * holder. 39 | */ 40 | 41 | package javax.ws.rs.core; 42 | 43 | import org.junit.Test; 44 | import static org.junit.Assert.assertNull; 45 | 46 | /** 47 | * Variant regression unit tests. 48 | * 49 | * @author Marek Potociar 50 | */ 51 | public class VariantTest { 52 | 53 | @Test 54 | public void npeInConstructor() { 55 | // Regression test for JAX_RS_SPEC-250 56 | new Variant(MediaType.TEXT_PLAIN_TYPE, (String) null, null); 57 | new Variant(MediaType.TEXT_PLAIN_TYPE, (String) null, "deflate"); 58 | } 59 | 60 | @Test 61 | public void npeInGetLanguageString() { 62 | // Regression test for JAX_RS_SPEC-251 63 | final Variant variant = new Variant(MediaType.TEXT_PLAIN_TYPE, (String) null, null); 64 | assertNull(variant.getLanguageString()); 65 | } 66 | } 67 | -------------------------------------------------------------------------------- /examples/src/main/java/jaxrs/examples/client/cache/CacheEntry.java: -------------------------------------------------------------------------------- 1 | /* 2 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. 3 | * 4 | * Copyright (c) 2011-2015 Oracle and/or its affiliates. All rights reserved. 5 | * 6 | * The contents of this file are subject to the terms of either the GNU 7 | * General Public License Version 2 only ("GPL") or the Common Development 8 | * and Distribution License("CDDL") (collectively, the "License"). You 9 | * may not use this file except in compliance with the License. You can 10 | * obtain a copy of the License at 11 | * http://glassfish.java.net/public/CDDL+GPL_1_1.html 12 | * or packager/legal/LICENSE.txt. See the License for the specific 13 | * language governing permissions and limitations under the License. 14 | * 15 | * When distributing the software, include this License Header Notice in each 16 | * file and include the License file at packager/legal/LICENSE.txt. 17 | * 18 | * GPL Classpath Exception: 19 | * Oracle designates this particular file as subject to the "Classpath" 20 | * exception as provided by Oracle in the GPL Version 2 section of the License 21 | * file that accompanied this code. 22 | * 23 | * Modifications: 24 | * If applicable, add the following below the License Header, with the fields 25 | * enclosed by brackets [] replaced by your own identifying information: 26 | * "Portions Copyright [year] [name of copyright owner]" 27 | * 28 | * Contributor(s): 29 | * If you wish your version of this file to be governed by only the CDDL or 30 | * only the GPL Version 2, indicate your decision by adding "[Contributor] 31 | * elects to include this software in this distribution under the [CDDL or GPL 32 | * Version 2] license." If you don't indicate a single choice of license, a 33 | * recipient has the option to distribute your version of this file under 34 | * either the CDDL, the GPL Version 2 or to extend the choice of license to 35 | * its licensees as provided above. However, if you add GPL Version 2 code 36 | * and therefore, elected the GPL Version 2 license, then the option applies 37 | * only if the new code is made subject to such option by the copyright 38 | * holder. 39 | */ 40 | 41 | package jaxrs.examples.client.cache; 42 | 43 | import javax.ws.rs.core.MultivaluedMap; 44 | 45 | /** 46 | * @author Bill Burke 47 | * @author Marek Potociar 48 | */ 49 | public class CacheEntry { 50 | 51 | private int status; 52 | private MultivaluedMap headers; 53 | private byte[] body; 54 | 55 | public CacheEntry(int status, MultivaluedMap headers, byte[] body) { 56 | this.status = status; 57 | this.headers = headers; 58 | this.body = body; 59 | } 60 | 61 | public int getStatus() { 62 | return status; 63 | } 64 | 65 | public MultivaluedMap getHeaders() { 66 | return headers; 67 | } 68 | 69 | public byte[] getBody() { 70 | return body; 71 | } 72 | } 73 | -------------------------------------------------------------------------------- /examples/src/main/java/jaxrs/examples/client/encoding/GzipExample.java: -------------------------------------------------------------------------------- 1 | /* 2 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. 3 | * 4 | * Copyright (c) 2011-2015 Oracle and/or its affiliates. All rights reserved. 5 | * 6 | * The contents of this file are subject to the terms of either the GNU 7 | * General Public License Version 2 only ("GPL") or the Common Development 8 | * and Distribution License("CDDL") (collectively, the "License"). You 9 | * may not use this file except in compliance with the License. You can 10 | * obtain a copy of the License at 11 | * http://glassfish.java.net/public/CDDL+GPL_1_1.html 12 | * or packager/legal/LICENSE.txt. See the License for the specific 13 | * language governing permissions and limitations under the License. 14 | * 15 | * When distributing the software, include this License Header Notice in each 16 | * file and include the License file at packager/legal/LICENSE.txt. 17 | * 18 | * GPL Classpath Exception: 19 | * Oracle designates this particular file as subject to the "Classpath" 20 | * exception as provided by Oracle in the GPL Version 2 section of the License 21 | * file that accompanied this code. 22 | * 23 | * Modifications: 24 | * If applicable, add the following below the License Header, with the fields 25 | * enclosed by brackets [] replaced by your own identifying information: 26 | * "Portions Copyright [year] [name of copyright owner]" 27 | * 28 | * Contributor(s): 29 | * If you wish your version of this file to be governed by only the CDDL or 30 | * only the GPL Version 2, indicate your decision by adding "[Contributor] 31 | * elects to include this software in this distribution under the [CDDL or GPL 32 | * Version 2] license." If you don't indicate a single choice of license, a 33 | * recipient has the option to distribute your version of this file under 34 | * either the CDDL, the GPL Version 2 or to extend the choice of license to 35 | * its licensees as provided above. However, if you add GPL Version 2 code 36 | * and therefore, elected the GPL Version 2 license, then the option applies 37 | * only if the new code is made subject to such option by the copyright 38 | * holder. 39 | */ 40 | 41 | package jaxrs.examples.client.encoding; 42 | 43 | import javax.ws.rs.client.ClientBuilder; 44 | import javax.ws.rs.client.WebTarget; 45 | import static javax.ws.rs.client.Entity.text; 46 | 47 | import jaxrs.examples.filter.compression.GzipEntityInterceptor; 48 | 49 | /** 50 | * @author Bill Burke 51 | * @author Marek Potociar 52 | */ 53 | public class GzipExample { 54 | 55 | public void gzipExample() { 56 | WebTarget target = ClientBuilder.newClient().target("http://example.com/foo/bar.txt"); 57 | target.register(GzipEntityInterceptor.class); 58 | 59 | // getting a gzip encoded body 60 | String body = target.request("text/plain").get(String.class); 61 | 62 | // send a gzip encoded body 63 | target.request().header("Content-Encoding", "gzip").post(text(body)); 64 | } 65 | } 66 | -------------------------------------------------------------------------------- /examples/src/main/java/jaxrs/examples/client/validator/NotNull.java: -------------------------------------------------------------------------------- 1 | /* 2 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. 3 | * 4 | * Copyright (c) 2011-2015 Oracle and/or its affiliates. All rights reserved. 5 | * 6 | * The contents of this file are subject to the terms of either the GNU 7 | * General Public License Version 2 only ("GPL") or the Common Development 8 | * and Distribution License("CDDL") (collectively, the "License"). You 9 | * may not use this file except in compliance with the License. You can 10 | * obtain a copy of the License at 11 | * http://glassfish.java.net/public/CDDL+GPL_1_1.html 12 | * or packager/legal/LICENSE.txt. See the License for the specific 13 | * language governing permissions and limitations under the License. 14 | * 15 | * When distributing the software, include this License Header Notice in each 16 | * file and include the License file at packager/legal/LICENSE.txt. 17 | * 18 | * GPL Classpath Exception: 19 | * Oracle designates this particular file as subject to the "Classpath" 20 | * exception as provided by Oracle in the GPL Version 2 section of the License 21 | * file that accompanied this code. 22 | * 23 | * Modifications: 24 | * If applicable, add the following below the License Header, with the fields 25 | * enclosed by brackets [] replaced by your own identifying information: 26 | * "Portions Copyright [year] [name of copyright owner]" 27 | * 28 | * Contributor(s): 29 | * If you wish your version of this file to be governed by only the CDDL or 30 | * only the GPL Version 2, indicate your decision by adding "[Contributor] 31 | * elects to include this software in this distribution under the [CDDL or GPL 32 | * Version 2] license." If you don't indicate a single choice of license, a 33 | * recipient has the option to distribute your version of this file under 34 | * either the CDDL, the GPL Version 2 or to extend the choice of license to 35 | * its licensees as provided above. However, if you add GPL Version 2 code 36 | * and therefore, elected the GPL Version 2 license, then the option applies 37 | * only if the new code is made subject to such option by the copyright 38 | * holder. 39 | */ 40 | 41 | package jaxrs.examples.client.validator; 42 | 43 | import javax.enterprise.util.AnnotationLiteral; 44 | import javax.validation.Payload; 45 | 46 | /** 47 | * @author Santiago Pericas-Geertsen 48 | */ 49 | public class NotNull extends AnnotationLiteral 50 | implements javax.validation.constraints.NotNull { 51 | 52 | private static final long serialVersionUID = -5352564534866654470L; 53 | 54 | @Override 55 | public String message() { 56 | return "{javax.validation.constraints.NotNull.message}"; 57 | } 58 | 59 | @Override 60 | public Class[] groups() { 61 | return new Class[0]; 62 | } 63 | 64 | @Override 65 | public Class[] payload() { 66 | return (Class[]) new Class[0]; 67 | } 68 | } 69 | -------------------------------------------------------------------------------- /examples/src/main/java/jaxrs/examples/rc/FooResource.java: -------------------------------------------------------------------------------- 1 | /* 2 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. 3 | * 4 | * Copyright (c) 2012-2015 Oracle and/or its affiliates. All rights reserved. 5 | * 6 | * The contents of this file are subject to the terms of either the GNU 7 | * General Public License Version 2 only ("GPL") or the Common Development 8 | * and Distribution License("CDDL") (collectively, the "License"). You 9 | * may not use this file except in compliance with the License. You can 10 | * obtain a copy of the License at 11 | * http://glassfish.java.net/public/CDDL+GPL_1_1.html 12 | * or packager/legal/LICENSE.txt. See the License for the specific 13 | * language governing permissions and limitations under the License. 14 | * 15 | * When distributing the software, include this License Header Notice in each 16 | * file and include the License file at packager/legal/LICENSE.txt. 17 | * 18 | * GPL Classpath Exception: 19 | * Oracle designates this particular file as subject to the "Classpath" 20 | * exception as provided by Oracle in the GPL Version 2 section of the License 21 | * file that accompanied this code. 22 | * 23 | * Modifications: 24 | * If applicable, add the following below the License Header, with the fields 25 | * enclosed by brackets [] replaced by your own identifying information: 26 | * "Portions Copyright [year] [name of copyright owner]" 27 | * 28 | * Contributor(s): 29 | * If you wish your version of this file to be governed by only the CDDL or 30 | * only the GPL Version 2, indicate your decision by adding "[Contributor] 31 | * elects to include this software in this distribution under the [CDDL or GPL 32 | * Version 2] license." If you don't indicate a single choice of license, a 33 | * recipient has the option to distribute your version of this file under 34 | * either the CDDL, the GPL Version 2 or to extend the choice of license to 35 | * its licensees as provided above. However, if you add GPL Version 2 code 36 | * and therefore, elected the GPL Version 2 license, then the option applies 37 | * only if the new code is made subject to such option by the copyright 38 | * holder. 39 | */ 40 | 41 | package jaxrs.examples.rc; 42 | 43 | import javax.ws.rs.GET; 44 | import javax.ws.rs.Path; 45 | import javax.ws.rs.PathParam; 46 | import javax.ws.rs.container.ResourceContext; 47 | import javax.ws.rs.core.Context; 48 | 49 | /** 50 | * Example of using resource context to get a resource instance for a class. 51 | * 52 | * @author Marek Potociar (marek.potociar at oracle.com) 53 | */ 54 | @Path("foo/{fooId}") 55 | public class FooResource { 56 | public static class BarResource { 57 | @PathParam("fooId") 58 | private String fooId; 59 | 60 | @GET 61 | public String getIt() { 62 | return String.format("Got it from %s!", fooId); 63 | } 64 | } 65 | 66 | @Path("bar") 67 | public BarResource getBar(@Context ResourceContext rc) { 68 | return rc.getResource(BarResource.class); 69 | } 70 | 71 | } 72 | -------------------------------------------------------------------------------- /jaxrs-api/src/main/java/javax/ws/rs/container/ConnectionCallback.java: -------------------------------------------------------------------------------- 1 | /* 2 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. 3 | * 4 | * Copyright (c) 2012-2015 Oracle and/or its affiliates. All rights reserved. 5 | * 6 | * The contents of this file are subject to the terms of either the GNU 7 | * General Public License Version 2 only ("GPL") or the Common Development 8 | * and Distribution License("CDDL") (collectively, the "License"). You 9 | * may not use this file except in compliance with the License. You can 10 | * obtain a copy of the License at 11 | * http://glassfish.java.net/public/CDDL+GPL_1_1.html 12 | * or packager/legal/LICENSE.txt. See the License for the specific 13 | * language governing permissions and limitations under the License. 14 | * 15 | * When distributing the software, include this License Header Notice in each 16 | * file and include the License file at packager/legal/LICENSE.txt. 17 | * 18 | * GPL Classpath Exception: 19 | * Oracle designates this particular file as subject to the "Classpath" 20 | * exception as provided by Oracle in the GPL Version 2 section of the License 21 | * file that accompanied this code. 22 | * 23 | * Modifications: 24 | * If applicable, add the following below the License Header, with the fields 25 | * enclosed by brackets [] replaced by your own identifying information: 26 | * "Portions Copyright [year] [name of copyright owner]" 27 | * 28 | * Contributor(s): 29 | * If you wish your version of this file to be governed by only the CDDL or 30 | * only the GPL Version 2, indicate your decision by adding "[Contributor] 31 | * elects to include this software in this distribution under the [CDDL or GPL 32 | * Version 2] license." If you don't indicate a single choice of license, a 33 | * recipient has the option to distribute your version of this file under 34 | * either the CDDL, the GPL Version 2 or to extend the choice of license to 35 | * its licensees as provided above. However, if you add GPL Version 2 code 36 | * and therefore, elected the GPL Version 2 license, then the option applies 37 | * only if the new code is made subject to such option by the copyright 38 | * holder. 39 | */ 40 | 41 | package javax.ws.rs.container; 42 | 43 | /** 44 | * Asynchronous request processing lifecycle callback that receives connection 45 | * related {@link AsyncResponse asynchronous response} lifecycle events. 46 | *

47 | * Support for this type of callback by JAX-RS runtime is OPTIONAL. 48 | *

49 | * 50 | * @author Marek Potociar 51 | * @since 2.0 52 | */ 53 | public interface ConnectionCallback { 54 | /** 55 | * This callback notification method is invoked in case the container detects 56 | * that the remote client connection associated with the asynchronous response 57 | * has been disconnected. 58 | * 59 | * @param disconnected asynchronous response for which the remote client connection 60 | * has been lost. 61 | */ 62 | public void onDisconnect(AsyncResponse disconnected); 63 | } 64 | -------------------------------------------------------------------------------- /examples/src/main/java/jaxrs/examples/filter/post/PostMethodOverrideFilter.java: -------------------------------------------------------------------------------- 1 | /* 2 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. 3 | * 4 | * Copyright (c) 2011-2015 Oracle and/or its affiliates. All rights reserved. 5 | * 6 | * The contents of this file are subject to the terms of either the GNU 7 | * General Public License Version 2 only ("GPL") or the Common Development 8 | * and Distribution License("CDDL") (collectively, the "License"). You 9 | * may not use this file except in compliance with the License. You can 10 | * obtain a copy of the License at 11 | * http://glassfish.java.net/public/CDDL+GPL_1_1.html 12 | * or packager/legal/LICENSE.txt. See the License for the specific 13 | * language governing permissions and limitations under the License. 14 | * 15 | * When distributing the software, include this License Header Notice in each 16 | * file and include the License file at packager/legal/LICENSE.txt. 17 | * 18 | * GPL Classpath Exception: 19 | * Oracle designates this particular file as subject to the "Classpath" 20 | * exception as provided by Oracle in the GPL Version 2 section of the License 21 | * file that accompanied this code. 22 | * 23 | * Modifications: 24 | * If applicable, add the following below the License Header, with the fields 25 | * enclosed by brackets [] replaced by your own identifying information: 26 | * "Portions Copyright [year] [name of copyright owner]" 27 | * 28 | * Contributor(s): 29 | * If you wish your version of this file to be governed by only the CDDL or 30 | * only the GPL Version 2, indicate your decision by adding "[Contributor] 31 | * elects to include this software in this distribution under the [CDDL or GPL 32 | * Version 2] license." If you don't indicate a single choice of license, a 33 | * recipient has the option to distribute your version of this file under 34 | * either the CDDL, the GPL Version 2 or to extend the choice of license to 35 | * its licensees as provided above. However, if you add GPL Version 2 code 36 | * and therefore, elected the GPL Version 2 license, then the option applies 37 | * only if the new code is made subject to such option by the copyright 38 | * holder. 39 | */ 40 | 41 | package jaxrs.examples.filter.post; 42 | 43 | import java.io.IOException; 44 | 45 | import javax.ws.rs.container.ContainerRequestContext; 46 | import javax.ws.rs.container.ContainerRequestFilter; 47 | import javax.ws.rs.ext.Provider; 48 | 49 | /** 50 | * PostMethodOverrideFilter class. 51 | * 52 | * @author Santiago.Pericas-Geertsen at oracle.com 53 | */ 54 | @Provider 55 | public class PostMethodOverrideFilter implements ContainerRequestFilter { 56 | 57 | @Override 58 | public void filter(ContainerRequestContext requestContext) throws IOException { 59 | if (requestContext.getMethod().equalsIgnoreCase("POST")) { 60 | String override = requestContext.getHeaders().getFirst("X-HTTP-Method-Override"); 61 | if (override != null) { 62 | requestContext.setMethod(override); 63 | } 64 | } 65 | } 66 | } 67 | -------------------------------------------------------------------------------- /examples/src/main/java/jaxrs/examples/async/LongRunningEjbResource.java: -------------------------------------------------------------------------------- 1 | /* 2 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. 3 | * 4 | * Copyright (c) 2012-2015 Oracle and/or its affiliates. All rights reserved. 5 | * 6 | * The contents of this file are subject to the terms of either the GNU 7 | * General Public License Version 2 only ("GPL") or the Common Development 8 | * and Distribution License("CDDL") (collectively, the "License"). You 9 | * may not use this file except in compliance with the License. You can 10 | * obtain a copy of the License at 11 | * http://glassfish.java.net/public/CDDL+GPL_1_1.html 12 | * or packager/legal/LICENSE.txt. See the License for the specific 13 | * language governing permissions and limitations under the License. 14 | * 15 | * When distributing the software, include this License Header Notice in each 16 | * file and include the License file at packager/legal/LICENSE.txt. 17 | * 18 | * GPL Classpath Exception: 19 | * Oracle designates this particular file as subject to the "Classpath" 20 | * exception as provided by Oracle in the GPL Version 2 section of the License 21 | * file that accompanied this code. 22 | * 23 | * Modifications: 24 | * If applicable, add the following below the License Header, with the fields 25 | * enclosed by brackets [] replaced by your own identifying information: 26 | * "Portions Copyright [year] [name of copyright owner]" 27 | * 28 | * Contributor(s): 29 | * If you wish your version of this file to be governed by only the CDDL or 30 | * only the GPL Version 2, indicate your decision by adding "[Contributor] 31 | * elects to include this software in this distribution under the [CDDL or GPL 32 | * Version 2] license." If you don't indicate a single choice of license, a 33 | * recipient has the option to distribute your version of this file under 34 | * either the CDDL, the GPL Version 2 or to extend the choice of license to 35 | * its licensees as provided above. However, if you add GPL Version 2 code 36 | * and therefore, elected the GPL Version 2 license, then the option applies 37 | * only if the new code is made subject to such option by the copyright 38 | * holder. 39 | */ 40 | 41 | package jaxrs.examples.async; 42 | 43 | import javax.ws.rs.GET; 44 | import javax.ws.rs.Path; 45 | import javax.ws.rs.container.AsyncResponse; 46 | import javax.ws.rs.container.Suspended; 47 | 48 | import javax.ejb.Asynchronous; 49 | import javax.ejb.Stateless; 50 | 51 | /** 52 | * TODO: javadoc. 53 | * 54 | * @author Marek Potociar 55 | */ 56 | @Stateless 57 | @Path("/") 58 | public class LongRunningEjbResource { 59 | @GET 60 | @Asynchronous 61 | public void longRunningOperation(@Suspended AsyncResponse ar) { 62 | final String result = executeLongRunningOperation(); 63 | ar.resume(result); 64 | } 65 | 66 | private String executeLongRunningOperation() { 67 | try { 68 | Thread.sleep(10000); 69 | } catch (InterruptedException e) { 70 | e.printStackTrace(); 71 | } 72 | return "done"; 73 | } 74 | } 75 | -------------------------------------------------------------------------------- /jaxrs-api/src/main/java/javax/ws/rs/Encoded.java: -------------------------------------------------------------------------------- 1 | /* 2 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. 3 | * 4 | * Copyright (c) 2010-2015 Oracle and/or its affiliates. All rights reserved. 5 | * 6 | * The contents of this file are subject to the terms of either the GNU 7 | * General Public License Version 2 only ("GPL") or the Common Development 8 | * and Distribution License("CDDL") (collectively, the "License"). You 9 | * may not use this file except in compliance with the License. You can 10 | * obtain a copy of the License at 11 | * http://glassfish.java.net/public/CDDL+GPL_1_1.html 12 | * or packager/legal/LICENSE.txt. See the License for the specific 13 | * language governing permissions and limitations under the License. 14 | * 15 | * When distributing the software, include this License Header Notice in each 16 | * file and include the License file at packager/legal/LICENSE.txt. 17 | * 18 | * GPL Classpath Exception: 19 | * Oracle designates this particular file as subject to the "Classpath" 20 | * exception as provided by Oracle in the GPL Version 2 section of the License 21 | * file that accompanied this code. 22 | * 23 | * Modifications: 24 | * If applicable, add the following below the License Header, with the fields 25 | * enclosed by brackets [] replaced by your own identifying information: 26 | * "Portions Copyright [year] [name of copyright owner]" 27 | * 28 | * Contributor(s): 29 | * If you wish your version of this file to be governed by only the CDDL or 30 | * only the GPL Version 2, indicate your decision by adding "[Contributor] 31 | * elects to include this software in this distribution under the [CDDL or GPL 32 | * Version 2] license." If you don't indicate a single choice of license, a 33 | * recipient has the option to distribute your version of this file under 34 | * either the CDDL, the GPL Version 2 or to extend the choice of license to 35 | * its licensees as provided above. However, if you add GPL Version 2 code 36 | * and therefore, elected the GPL Version 2 license, then the option applies 37 | * only if the new code is made subject to such option by the copyright 38 | * holder. 39 | */ 40 | 41 | package javax.ws.rs; 42 | 43 | import java.lang.annotation.Documented; 44 | import java.lang.annotation.ElementType; 45 | import java.lang.annotation.Retention; 46 | import java.lang.annotation.RetentionPolicy; 47 | import java.lang.annotation.Target; 48 | 49 | /** 50 | * Disables automatic decoding of parameter values bound using {@link QueryParam}, 51 | * {@link PathParam}, {@link FormParam} or {@link MatrixParam}. 52 | * Using this annotation on a method will disable decoding for all parameters. 53 | * Using this annotation on a class will disable decoding for all parameters of 54 | * all methods. 55 | * 56 | * @author Paul Sandoz 57 | * @author Marc Hadley 58 | * @see QueryParam 59 | * @see MatrixParam 60 | * @see PathParam 61 | * @see FormParam 62 | * @since 1.0 63 | */ 64 | @Target({ElementType.PARAMETER, ElementType.METHOD, ElementType.FIELD, ElementType.CONSTRUCTOR, ElementType.TYPE}) 65 | @Retention(RetentionPolicy.RUNTIME) 66 | @Documented 67 | public @interface Encoded { 68 | } 69 | -------------------------------------------------------------------------------- /jaxrs-api/src/main/java/javax/ws/rs/client/ClientRequestFilter.java: -------------------------------------------------------------------------------- 1 | /* 2 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. 3 | * 4 | * Copyright (c) 2012-2015 Oracle and/or its affiliates. All rights reserved. 5 | * 6 | * The contents of this file are subject to the terms of either the GNU 7 | * General Public License Version 2 only ("GPL") or the Common Development 8 | * and Distribution License("CDDL") (collectively, the "License"). You 9 | * may not use this file except in compliance with the License. You can 10 | * obtain a copy of the License at 11 | * http://glassfish.java.net/public/CDDL+GPL_1_1.html 12 | * or packager/legal/LICENSE.txt. See the License for the specific 13 | * language governing permissions and limitations under the License. 14 | * 15 | * When distributing the software, include this License Header Notice in each 16 | * file and include the License file at packager/legal/LICENSE.txt. 17 | * 18 | * GPL Classpath Exception: 19 | * Oracle designates this particular file as subject to the "Classpath" 20 | * exception as provided by Oracle in the GPL Version 2 section of the License 21 | * file that accompanied this code. 22 | * 23 | * Modifications: 24 | * If applicable, add the following below the License Header, with the fields 25 | * enclosed by brackets [] replaced by your own identifying information: 26 | * "Portions Copyright [year] [name of copyright owner]" 27 | * 28 | * Contributor(s): 29 | * If you wish your version of this file to be governed by only the CDDL or 30 | * only the GPL Version 2, indicate your decision by adding "[Contributor] 31 | * elects to include this software in this distribution under the [CDDL or GPL 32 | * Version 2] license." If you don't indicate a single choice of license, a 33 | * recipient has the option to distribute your version of this file under 34 | * either the CDDL, the GPL Version 2 or to extend the choice of license to 35 | * its licensees as provided above. However, if you add GPL Version 2 code 36 | * and therefore, elected the GPL Version 2 license, then the option applies 37 | * only if the new code is made subject to such option by the copyright 38 | * holder. 39 | */ 40 | 41 | package javax.ws.rs.client; 42 | 43 | import java.io.IOException; 44 | 45 | /** 46 | * An extension interface implemented by client request filters. 47 | * 48 | * Filters implementing this interface MUST be annotated with 49 | * {@link javax.ws.rs.ext.Provider @Provider}. This type of filters is supported 50 | * only as part of the Client API. 51 | * 52 | * @author Marek Potociar 53 | * @author Santiago Pericas-Geertsen 54 | * @see javax.ws.rs.client.ClientResponseFilter 55 | * @since 2.0 56 | */ 57 | public interface ClientRequestFilter { 58 | 59 | /** 60 | * Filter method called before a request has been dispatched to a client 61 | * transport layer. 62 | * 63 | * Filters in the filter chain are ordered according to their {@code javax.annotation.Priority} 64 | * class-level annotation value. 65 | * 66 | * @param requestContext request context. 67 | * @throws IOException if an I/O exception occurs. 68 | */ 69 | public void filter(ClientRequestContext requestContext) throws IOException; 70 | } 71 | -------------------------------------------------------------------------------- /jaxrs-api/src/test/java/javax/ws/rs/core/RuntimeDelegateStub.java: -------------------------------------------------------------------------------- 1 | /* 2 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. 3 | * 4 | * Copyright (c) 2010-2015 Oracle and/or its affiliates. All rights reserved. 5 | * 6 | * The contents of this file are subject to the terms of either the GNU 7 | * General Public License Version 2 only ("GPL") or the Common Development 8 | * and Distribution License("CDDL") (collectively, the "License"). You 9 | * may not use this file except in compliance with the License. You can 10 | * obtain a copy of the License at 11 | * http://glassfish.java.net/public/CDDL+GPL_1_1.html 12 | * or packager/legal/LICENSE.txt. See the License for the specific 13 | * language governing permissions and limitations under the License. 14 | * 15 | * When distributing the software, include this License Header Notice in each 16 | * file and include the License file at packager/legal/LICENSE.txt. 17 | * 18 | * GPL Classpath Exception: 19 | * Oracle designates this particular file as subject to the "Classpath" 20 | * exception as provided by Oracle in the GPL Version 2 section of the License 21 | * file that accompanied this code. 22 | * 23 | * Modifications: 24 | * If applicable, add the following below the License Header, with the fields 25 | * enclosed by brackets [] replaced by your own identifying information: 26 | * "Portions Copyright [year] [name of copyright owner]" 27 | * 28 | * Contributor(s): 29 | * If you wish your version of this file to be governed by only the CDDL or 30 | * only the GPL Version 2, indicate your decision by adding "[Contributor] 31 | * elects to include this software in this distribution under the [CDDL or GPL 32 | * Version 2] license." If you don't indicate a single choice of license, a 33 | * recipient has the option to distribute your version of this file under 34 | * either the CDDL, the GPL Version 2 or to extend the choice of license to 35 | * its licensees as provided above. However, if you add GPL Version 2 code 36 | * and therefore, elected the GPL Version 2 license, then the option applies 37 | * only if the new code is made subject to such option by the copyright 38 | * holder. 39 | */ 40 | 41 | package javax.ws.rs.core; 42 | 43 | import javax.ws.rs.core.Link.Builder; 44 | import javax.ws.rs.core.Response.ResponseBuilder; 45 | import javax.ws.rs.core.Variant.VariantListBuilder; 46 | import javax.ws.rs.ext.RuntimeDelegate; 47 | 48 | public class RuntimeDelegateStub extends RuntimeDelegate { 49 | 50 | @Override 51 | public UriBuilder createUriBuilder() { 52 | return null; 53 | } 54 | 55 | @Override 56 | public ResponseBuilder createResponseBuilder() { 57 | return null; 58 | } 59 | 60 | @Override 61 | public VariantListBuilder createVariantListBuilder() { 62 | return null; 63 | } 64 | 65 | @Override 66 | public T createEndpoint(Application application, Class endpointType) throws IllegalArgumentException, UnsupportedOperationException { 67 | return null; 68 | } 69 | 70 | @Override 71 | public HeaderDelegate createHeaderDelegate(Class type) { 72 | return null; 73 | } 74 | 75 | @Override 76 | public Builder createLinkBuilder() { 77 | return null; 78 | } 79 | } 80 | -------------------------------------------------------------------------------- /jaxrs-api/src/main/java/javax/ws/rs/container/PreMatching.java: -------------------------------------------------------------------------------- 1 | /* 2 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. 3 | * 4 | * Copyright (c) 2012-2015 Oracle and/or its affiliates. All rights reserved. 5 | * 6 | * The contents of this file are subject to the terms of either the GNU 7 | * General Public License Version 2 only ("GPL") or the Common Development 8 | * and Distribution License("CDDL") (collectively, the "License"). You 9 | * may not use this file except in compliance with the License. You can 10 | * obtain a copy of the License at 11 | * http://glassfish.java.net/public/CDDL+GPL_1_1.html 12 | * or packager/legal/LICENSE.txt. See the License for the specific 13 | * language governing permissions and limitations under the License. 14 | * 15 | * When distributing the software, include this License Header Notice in each 16 | * file and include the License file at packager/legal/LICENSE.txt. 17 | * 18 | * GPL Classpath Exception: 19 | * Oracle designates this particular file as subject to the "Classpath" 20 | * exception as provided by Oracle in the GPL Version 2 section of the License 21 | * file that accompanied this code. 22 | * 23 | * Modifications: 24 | * If applicable, add the following below the License Header, with the fields 25 | * enclosed by brackets [] replaced by your own identifying information: 26 | * "Portions Copyright [year] [name of copyright owner]" 27 | * 28 | * Contributor(s): 29 | * If you wish your version of this file to be governed by only the CDDL or 30 | * only the GPL Version 2, indicate your decision by adding "[Contributor] 31 | * elects to include this software in this distribution under the [CDDL or GPL 32 | * Version 2] license." If you don't indicate a single choice of license, a 33 | * recipient has the option to distribute your version of this file under 34 | * either the CDDL, the GPL Version 2 or to extend the choice of license to 35 | * its licensees as provided above. However, if you add GPL Version 2 code 36 | * and therefore, elected the GPL Version 2 license, then the option applies 37 | * only if the new code is made subject to such option by the copyright 38 | * holder. 39 | */ 40 | 41 | package javax.ws.rs.container; 42 | 43 | import java.lang.annotation.Documented; 44 | import java.lang.annotation.ElementType; 45 | import java.lang.annotation.Retention; 46 | import java.lang.annotation.RetentionPolicy; 47 | import java.lang.annotation.Target; 48 | 49 | /** 50 | * Global binding annotation that can be applied to a {@link ContainerRequestFilter 51 | * container request filter} to indicate that such filter should be applied globally 52 | * on all resources in the application before the actual resource matching occurs. 53 | *

54 | * The JAX-RS runtime will apply the filters marked with the {@code @PreMatching} 55 | * annotation globally to all resources, before the incoming request has been matched 56 | * to a particular resource method. 57 | * Any {@link javax.ws.rs.NameBinding named binding annotations} will be ignored on 58 | * a component annotated with the {@code @PreMatching} annotation. 59 | *

60 | * 61 | * @author Marek Potociar 62 | */ 63 | @Target({ElementType.TYPE}) 64 | @Retention(RetentionPolicy.RUNTIME) 65 | @Documented 66 | public @interface PreMatching { 67 | } 68 | -------------------------------------------------------------------------------- /examples/src/main/java/jaxrs/examples/link/clusterservice/Model.java: -------------------------------------------------------------------------------- 1 | /* 2 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. 3 | * 4 | * Copyright (c) 2011-2015 Oracle and/or its affiliates. All rights reserved. 5 | * 6 | * The contents of this file are subject to the terms of either the GNU 7 | * General Public License Version 2 only ("GPL") or the Common Development 8 | * and Distribution License("CDDL") (collectively, the "License"). You 9 | * may not use this file except in compliance with the License. You can 10 | * obtain a copy of the License at 11 | * http://glassfish.java.net/public/CDDL+GPL_1_1.html 12 | * or packager/legal/LICENSE.txt. See the License for the specific 13 | * language governing permissions and limitations under the License. 14 | * 15 | * When distributing the software, include this License Header Notice in each 16 | * file and include the License file at packager/legal/LICENSE.txt. 17 | * 18 | * GPL Classpath Exception: 19 | * Oracle designates this particular file as subject to the "Classpath" 20 | * exception as provided by Oracle in the GPL Version 2 section of the License 21 | * file that accompanied this code. 22 | * 23 | * Modifications: 24 | * If applicable, add the following below the License Header, with the fields 25 | * enclosed by brackets [] replaced by your own identifying information: 26 | * "Portions Copyright [year] [name of copyright owner]" 27 | * 28 | * Contributor(s): 29 | * If you wish your version of this file to be governed by only the CDDL or 30 | * only the GPL Version 2, indicate your decision by adding "[Contributor] 31 | * elects to include this software in this distribution under the [CDDL or GPL 32 | * Version 2] license." If you don't indicate a single choice of license, a 33 | * recipient has the option to distribute your version of this file under 34 | * either the CDDL, the GPL Version 2 or to extend the choice of license to 35 | * its licensees as provided above. However, if you add GPL Version 2 code 36 | * and therefore, elected the GPL Version 2 license, then the option applies 37 | * only if the new code is made subject to such option by the copyright 38 | * holder. 39 | */ 40 | 41 | package jaxrs.examples.link.clusterservice; 42 | 43 | /** 44 | * Model class. 45 | * 46 | * @author Santiago.Pericas-Geertsen@oracle.com 47 | */ 48 | public class Model { 49 | 50 | static final Cluster cluster; 51 | 52 | static { 53 | cluster = new Cluster("cluster1"); 54 | Machine m = new Machine("alpha"); 55 | m.setLoad(1.4); 56 | m.setnOfCpus(2); 57 | cluster.getMachines().add(m); 58 | m = new Machine("beta"); 59 | m.setLoad(0.75); 60 | m.setnOfCpus(4); 61 | cluster.getMachines().add(m); 62 | m = new Machine("gamma"); 63 | m.setLoad(0.2); 64 | m.setnOfCpus(8); 65 | cluster.getMachines().add(m); 66 | } 67 | 68 | static Cluster getCluster() { 69 | return cluster; 70 | } 71 | 72 | static Machine getMachine(String name) { 73 | for (Machine m : cluster.getMachines()) { 74 | if (name.equals(m.getName())) { 75 | return m; 76 | } 77 | } 78 | return null; 79 | } 80 | 81 | private Model() { 82 | } 83 | } 84 | -------------------------------------------------------------------------------- /examples/src/main/java/jaxrs/examples/filter/logging/DynamicLoggingFilterFeature.java: -------------------------------------------------------------------------------- 1 | /* 2 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. 3 | * 4 | * Copyright (c) 2011-2015 Oracle and/or its affiliates. All rights reserved. 5 | * 6 | * The contents of this file are subject to the terms of either the GNU 7 | * General Public License Version 2 only ("GPL") or the Common Development 8 | * and Distribution License("CDDL") (collectively, the "License"). You 9 | * may not use this file except in compliance with the License. You can 10 | * obtain a copy of the License at 11 | * http://glassfish.java.net/public/CDDL+GPL_1_1.html 12 | * or packager/legal/LICENSE.txt. See the License for the specific 13 | * language governing permissions and limitations under the License. 14 | * 15 | * When distributing the software, include this License Header Notice in each 16 | * file and include the License file at packager/legal/LICENSE.txt. 17 | * 18 | * GPL Classpath Exception: 19 | * Oracle designates this particular file as subject to the "Classpath" 20 | * exception as provided by Oracle in the GPL Version 2 section of the License 21 | * file that accompanied this code. 22 | * 23 | * Modifications: 24 | * If applicable, add the following below the License Header, with the fields 25 | * enclosed by brackets [] replaced by your own identifying information: 26 | * "Portions Copyright [year] [name of copyright owner]" 27 | * 28 | * Contributor(s): 29 | * If you wish your version of this file to be governed by only the CDDL or 30 | * only the GPL Version 2, indicate your decision by adding "[Contributor] 31 | * elects to include this software in this distribution under the [CDDL or GPL 32 | * Version 2] license." If you don't indicate a single choice of license, a 33 | * recipient has the option to distribute your version of this file under 34 | * either the CDDL, the GPL Version 2 or to extend the choice of license to 35 | * its licensees as provided above. However, if you add GPL Version 2 code 36 | * and therefore, elected the GPL Version 2 license, then the option applies 37 | * only if the new code is made subject to such option by the copyright 38 | * holder. 39 | */ 40 | 41 | package jaxrs.examples.filter.logging; 42 | 43 | import javax.ws.rs.GET; 44 | import javax.ws.rs.container.DynamicFeature; 45 | import javax.ws.rs.container.ResourceInfo; 46 | import javax.ws.rs.core.FeatureContext; 47 | import javax.ws.rs.ext.Provider; 48 | 49 | /** 50 | * Dynamic feature for a enabling a logging request/response post-matching filter 51 | * that dynamically decides to bind the logging filter only to GET processing 52 | * resource methods on all subclasses of {@link MyResourceClass} and the 53 | * {@code MyResourceClass} itself. 54 | * 55 | * @author Santiago Pericas-Geertsen 56 | * @author Marek Potociar 57 | */ 58 | @Provider 59 | public final class DynamicLoggingFilterFeature implements DynamicFeature { 60 | 61 | @Override 62 | public void configure(ResourceInfo resourceInfo, FeatureContext context) { 63 | if (MyResourceClass.class.isAssignableFrom(resourceInfo.getResourceClass()) 64 | && resourceInfo.getResourceMethod().isAnnotationPresent(GET.class)) { 65 | context.register(new LoggingFilter()); 66 | } 67 | } 68 | } 69 | -------------------------------------------------------------------------------- /examples/src/main/java/jaxrs/examples/client/validator/Pattern.java: -------------------------------------------------------------------------------- 1 | /* 2 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. 3 | * 4 | * Copyright (c) 2011-2015 Oracle and/or its affiliates. All rights reserved. 5 | * 6 | * The contents of this file are subject to the terms of either the GNU 7 | * General Public License Version 2 only ("GPL") or the Common Development 8 | * and Distribution License("CDDL") (collectively, the "License"). You 9 | * may not use this file except in compliance with the License. You can 10 | * obtain a copy of the License at 11 | * http://glassfish.java.net/public/CDDL+GPL_1_1.html 12 | * or packager/legal/LICENSE.txt. See the License for the specific 13 | * language governing permissions and limitations under the License. 14 | * 15 | * When distributing the software, include this License Header Notice in each 16 | * file and include the License file at packager/legal/LICENSE.txt. 17 | * 18 | * GPL Classpath Exception: 19 | * Oracle designates this particular file as subject to the "Classpath" 20 | * exception as provided by Oracle in the GPL Version 2 section of the License 21 | * file that accompanied this code. 22 | * 23 | * Modifications: 24 | * If applicable, add the following below the License Header, with the fields 25 | * enclosed by brackets [] replaced by your own identifying information: 26 | * "Portions Copyright [year] [name of copyright owner]" 27 | * 28 | * Contributor(s): 29 | * If you wish your version of this file to be governed by only the CDDL or 30 | * only the GPL Version 2, indicate your decision by adding "[Contributor] 31 | * elects to include this software in this distribution under the [CDDL or GPL 32 | * Version 2] license." If you don't indicate a single choice of license, a 33 | * recipient has the option to distribute your version of this file under 34 | * either the CDDL, the GPL Version 2 or to extend the choice of license to 35 | * its licensees as provided above. However, if you add GPL Version 2 code 36 | * and therefore, elected the GPL Version 2 license, then the option applies 37 | * only if the new code is made subject to such option by the copyright 38 | * holder. 39 | */ 40 | 41 | package jaxrs.examples.client.validator; 42 | 43 | import javax.enterprise.util.AnnotationLiteral; 44 | import javax.validation.Payload; 45 | 46 | /** 47 | * @author sp106478 48 | */ 49 | public class Pattern extends AnnotationLiteral 50 | implements javax.validation.constraints.Pattern { 51 | private static final long serialVersionUID = 920895043686145958L; 52 | 53 | private String regexp; 54 | 55 | public Pattern(String regexp) { 56 | this.regexp = regexp; 57 | } 58 | 59 | @Override 60 | public String message() { 61 | return "{javax.validation.constraints.Pattern.message}"; 62 | } 63 | 64 | @Override 65 | public Class[] groups() { 66 | return new Class[0]; 67 | } 68 | 69 | @Override 70 | public Class[] payload() { 71 | return (Class[]) new Class[0]; 72 | } 73 | 74 | @Override 75 | public String regexp() { 76 | return regexp; 77 | } 78 | 79 | @Override 80 | public Flag[] flags() { 81 | return new Flag[0]; 82 | } 83 | } 84 | -------------------------------------------------------------------------------- /examples/src/main/java/jaxrs/examples/filter/caching/ServerCachingFilter.java: -------------------------------------------------------------------------------- 1 | /* 2 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. 3 | * 4 | * Copyright (c) 2011-2015 Oracle and/or its affiliates. All rights reserved. 5 | * 6 | * The contents of this file are subject to the terms of either the GNU 7 | * General Public License Version 2 only ("GPL") or the Common Development 8 | * and Distribution License("CDDL") (collectively, the "License"). You 9 | * may not use this file except in compliance with the License. You can 10 | * obtain a copy of the License at 11 | * http://glassfish.java.net/public/CDDL+GPL_1_1.html 12 | * or packager/legal/LICENSE.txt. See the License for the specific 13 | * language governing permissions and limitations under the License. 14 | * 15 | * When distributing the software, include this License Header Notice in each 16 | * file and include the License file at packager/legal/LICENSE.txt. 17 | * 18 | * GPL Classpath Exception: 19 | * Oracle designates this particular file as subject to the "Classpath" 20 | * exception as provided by Oracle in the GPL Version 2 section of the License 21 | * file that accompanied this code. 22 | * 23 | * Modifications: 24 | * If applicable, add the following below the License Header, with the fields 25 | * enclosed by brackets [] replaced by your own identifying information: 26 | * "Portions Copyright [year] [name of copyright owner]" 27 | * 28 | * Contributor(s): 29 | * If you wish your version of this file to be governed by only the CDDL or 30 | * only the GPL Version 2, indicate your decision by adding "[Contributor] 31 | * elects to include this software in this distribution under the [CDDL or GPL 32 | * Version 2] license." If you don't indicate a single choice of license, a 33 | * recipient has the option to distribute your version of this file under 34 | * either the CDDL, the GPL Version 2 or to extend the choice of license to 35 | * its licensees as provided above. However, if you add GPL Version 2 code 36 | * and therefore, elected the GPL Version 2 license, then the option applies 37 | * only if the new code is made subject to such option by the copyright 38 | * holder. 39 | */ 40 | 41 | package jaxrs.examples.filter.caching; 42 | 43 | import java.io.IOException; 44 | 45 | import javax.ws.rs.Priorities; 46 | import javax.ws.rs.WebApplicationException; 47 | import javax.ws.rs.container.ContainerRequestContext; 48 | import javax.ws.rs.container.ContainerRequestFilter; 49 | import javax.ws.rs.core.Response; 50 | import javax.ws.rs.ext.Provider; 51 | 52 | import javax.annotation.Priority; 53 | 54 | /** 55 | * ServerCachingFilter class. 56 | * 57 | * @author Santiago Pericas-Geertsen 58 | */ 59 | @Provider 60 | @Priority(Priorities.USER) 61 | public class ServerCachingFilter implements ContainerRequestFilter { 62 | 63 | @Override 64 | public void filter(ContainerRequestContext requestContext) throws IOException { 65 | Response.ResponseBuilder res = getCachedResponse(requestContext); 66 | if (res != null) { 67 | // stop the filter chain 68 | throw new WebApplicationException(res.build()); 69 | } 70 | } 71 | 72 | private Response.ResponseBuilder getCachedResponse(ContainerRequestContext requestContext) { 73 | // implemetation goes here 74 | return null; 75 | } 76 | } 77 | -------------------------------------------------------------------------------- /jaxrs-api/src/main/java/javax/ws/rs/container/ResourceInfo.java: -------------------------------------------------------------------------------- 1 | /* 2 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. 3 | * 4 | * Copyright (c) 2011-2015 Oracle and/or its affiliates. All rights reserved. 5 | * 6 | * The contents of this file are subject to the terms of either the GNU 7 | * General Public License Version 2 only ("GPL") or the Common Development 8 | * and Distribution License("CDDL") (collectively, the "License"). You 9 | * may not use this file except in compliance with the License. You can 10 | * obtain a copy of the License at 11 | * http://glassfish.java.net/public/CDDL+GPL_1_1.html 12 | * or packager/legal/LICENSE.txt. See the License for the specific 13 | * language governing permissions and limitations under the License. 14 | * 15 | * When distributing the software, include this License Header Notice in each 16 | * file and include the License file at packager/legal/LICENSE.txt. 17 | * 18 | * GPL Classpath Exception: 19 | * Oracle designates this particular file as subject to the "Classpath" 20 | * exception as provided by Oracle in the GPL Version 2 section of the License 21 | * file that accompanied this code. 22 | * 23 | * Modifications: 24 | * If applicable, add the following below the License Header, with the fields 25 | * enclosed by brackets [] replaced by your own identifying information: 26 | * "Portions Copyright [year] [name of copyright owner]" 27 | * 28 | * Contributor(s): 29 | * If you wish your version of this file to be governed by only the CDDL or 30 | * only the GPL Version 2, indicate your decision by adding "[Contributor] 31 | * elects to include this software in this distribution under the [CDDL or GPL 32 | * Version 2] license." If you don't indicate a single choice of license, a 33 | * recipient has the option to distribute your version of this file under 34 | * either the CDDL, the GPL Version 2 or to extend the choice of license to 35 | * its licensees as provided above. However, if you add GPL Version 2 code 36 | * and therefore, elected the GPL Version 2 license, then the option applies 37 | * only if the new code is made subject to such option by the copyright 38 | * holder. 39 | */ 40 | 41 | package javax.ws.rs.container; 42 | 43 | import java.lang.reflect.Method; 44 | 45 | /** 46 | * An injectable class to access the resource class and resource method 47 | * matched by the current request. Methods in this class MAY return 48 | * null if a resource class and method have not been matched, 49 | * e.g. in a standalone, pre-matching {@link ContainerRequestFilter} that was 50 | * not provided by a post-matching {@link PreMatching}. 51 | * 52 | * @author Santiago Pericas-Geertsen 53 | * @since 2.0 54 | */ 55 | public interface ResourceInfo { 56 | 57 | /** 58 | * Get the resource method that is the target of a request, 59 | * or null if this information is not available. 60 | * 61 | * @return resource method instance or null 62 | * @see #getResourceClass() 63 | */ 64 | Method getResourceMethod(); 65 | 66 | /** 67 | * Get the resource class that is the target of a request, 68 | * or null if this information is not available. 69 | * 70 | * @return resource class instance or null 71 | * @see #getResourceMethod() 72 | */ 73 | Class getResourceClass(); 74 | } 75 | -------------------------------------------------------------------------------- /examples/src/main/java/jaxrs/examples/async/SimpleAsyncEventResource.java: -------------------------------------------------------------------------------- 1 | /* 2 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. 3 | * 4 | * Copyright (c) 2011-2015 Oracle and/or its affiliates. All rights reserved. 5 | * 6 | * The contents of this file are subject to the terms of either the GNU 7 | * General Public License Version 2 only ("GPL") or the Common Development 8 | * and Distribution License("CDDL") (collectively, the "License"). You 9 | * may not use this file except in compliance with the License. You can 10 | * obtain a copy of the License at 11 | * http://glassfish.java.net/public/CDDL+GPL_1_1.html 12 | * or packager/legal/LICENSE.txt. See the License for the specific 13 | * language governing permissions and limitations under the License. 14 | * 15 | * When distributing the software, include this License Header Notice in each 16 | * file and include the License file at packager/legal/LICENSE.txt. 17 | * 18 | * GPL Classpath Exception: 19 | * Oracle designates this particular file as subject to the "Classpath" 20 | * exception as provided by Oracle in the GPL Version 2 section of the License 21 | * file that accompanied this code. 22 | * 23 | * Modifications: 24 | * If applicable, add the following below the License Header, with the fields 25 | * enclosed by brackets [] replaced by your own identifying information: 26 | * "Portions Copyright [year] [name of copyright owner]" 27 | * 28 | * Contributor(s): 29 | * If you wish your version of this file to be governed by only the CDDL or 30 | * only the GPL Version 2, indicate your decision by adding "[Contributor] 31 | * elects to include this software in this distribution under the [CDDL or GPL 32 | * Version 2] license." If you don't indicate a single choice of license, a 33 | * recipient has the option to distribute your version of this file under 34 | * either the CDDL, the GPL Version 2 or to extend the choice of license to 35 | * its licensees as provided above. However, if you add GPL Version 2 code 36 | * and therefore, elected the GPL Version 2 license, then the option applies 37 | * only if the new code is made subject to such option by the copyright 38 | * holder. 39 | */ 40 | 41 | package jaxrs.examples.async; 42 | 43 | import java.util.concurrent.ArrayBlockingQueue; 44 | import java.util.concurrent.BlockingQueue; 45 | 46 | import javax.ws.rs.Consumes; 47 | import javax.ws.rs.GET; 48 | import javax.ws.rs.POST; 49 | import javax.ws.rs.Path; 50 | import javax.ws.rs.Produces; 51 | import javax.ws.rs.container.AsyncResponse; 52 | import javax.ws.rs.container.Suspended; 53 | import javax.ws.rs.core.MediaType; 54 | 55 | /** 56 | * Simple asynchronous event-based request processing example. 57 | * 58 | * @author Marek Potociar 59 | */ 60 | @Path("/async/nextMessage") 61 | @Produces(MediaType.TEXT_PLAIN) 62 | @Consumes(MediaType.TEXT_PLAIN) 63 | public class SimpleAsyncEventResource { 64 | private static final BlockingQueue SUSPENDED = new ArrayBlockingQueue(5); 65 | 66 | @GET 67 | public void readMessage(@Suspended final AsyncResponse ar) throws InterruptedException { 68 | SUSPENDED.put(ar); 69 | } 70 | 71 | @POST 72 | public String postMessage(final String message) throws InterruptedException { 73 | SUSPENDED.take().resume(message); 74 | return "Message sent"; 75 | } 76 | } 77 | -------------------------------------------------------------------------------- /examples/src/main/java/jaxrs/examples/rc/FruitsResource.java: -------------------------------------------------------------------------------- 1 | /* 2 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. 3 | * 4 | * Copyright (c) 2012-2015 Oracle and/or its affiliates. All rights reserved. 5 | * 6 | * The contents of this file are subject to the terms of either the GNU 7 | * General Public License Version 2 only ("GPL") or the Common Development 8 | * and Distribution License("CDDL") (collectively, the "License"). You 9 | * may not use this file except in compliance with the License. You can 10 | * obtain a copy of the License at 11 | * http://glassfish.java.net/public/CDDL+GPL_1_1.html 12 | * or packager/legal/LICENSE.txt. See the License for the specific 13 | * language governing permissions and limitations under the License. 14 | * 15 | * When distributing the software, include this License Header Notice in each 16 | * file and include the License file at packager/legal/LICENSE.txt. 17 | * 18 | * GPL Classpath Exception: 19 | * Oracle designates this particular file as subject to the "Classpath" 20 | * exception as provided by Oracle in the GPL Version 2 section of the License 21 | * file that accompanied this code. 22 | * 23 | * Modifications: 24 | * If applicable, add the following below the License Header, with the fields 25 | * enclosed by brackets [] replaced by your own identifying information: 26 | * "Portions Copyright [year] [name of copyright owner]" 27 | * 28 | * Contributor(s): 29 | * If you wish your version of this file to be governed by only the CDDL or 30 | * only the GPL Version 2, indicate your decision by adding "[Contributor] 31 | * elects to include this software in this distribution under the [CDDL or GPL 32 | * Version 2] license." If you don't indicate a single choice of license, a 33 | * recipient has the option to distribute your version of this file under 34 | * either the CDDL, the GPL Version 2 or to extend the choice of license to 35 | * its licensees as provided above. However, if you add GPL Version 2 code 36 | * and therefore, elected the GPL Version 2 license, then the option applies 37 | * only if the new code is made subject to such option by the copyright 38 | * holder. 39 | */ 40 | 41 | package jaxrs.examples.rc; 42 | 43 | import javax.ws.rs.GET; 44 | import javax.ws.rs.Path; 45 | import javax.ws.rs.PathParam; 46 | import javax.ws.rs.container.ResourceContext; 47 | import javax.ws.rs.core.Context; 48 | 49 | /** 50 | * Example of using resource context to get a resource instance for a class. 51 | * 52 | * @author Marek Potociar (marek.potociar at oracle.com) 53 | */ 54 | @Path("fruits") 55 | public class FruitsResource { 56 | @Context 57 | private ResourceContext rc; 58 | 59 | @Path("good/{fruit}") 60 | public TasteResource tasteGood() { 61 | return rc.initResource(new TasteResource("good")); 62 | } 63 | 64 | @Path("bad/{fruit}") 65 | public TasteResource tasteBad() { 66 | return rc.initResource(new TasteResource("bad")); 67 | } 68 | 69 | public static class TasteResource { 70 | @PathParam("fruit") 71 | private String fruitName; 72 | private final String taste; 73 | 74 | public TasteResource( String taste) { 75 | this.taste = taste; 76 | } 77 | 78 | @GET 79 | public String getTaste() { 80 | return String.format("%s is %s", fruitName, taste); 81 | } 82 | } 83 | } 84 | -------------------------------------------------------------------------------- /examples/src/main/java/jaxrs/examples/link/clusterservice/Cluster.java: -------------------------------------------------------------------------------- 1 | /* 2 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. 3 | * 4 | * Copyright (c) 2011-2015 Oracle and/or its affiliates. All rights reserved. 5 | * 6 | * The contents of this file are subject to the terms of either the GNU 7 | * General Public License Version 2 only ("GPL") or the Common Development 8 | * and Distribution License("CDDL") (collectively, the "License"). You 9 | * may not use this file except in compliance with the License. You can 10 | * obtain a copy of the License at 11 | * http://glassfish.java.net/public/CDDL+GPL_1_1.html 12 | * or packager/legal/LICENSE.txt. See the License for the specific 13 | * language governing permissions and limitations under the License. 14 | * 15 | * When distributing the software, include this License Header Notice in each 16 | * file and include the License file at packager/legal/LICENSE.txt. 17 | * 18 | * GPL Classpath Exception: 19 | * Oracle designates this particular file as subject to the "Classpath" 20 | * exception as provided by Oracle in the GPL Version 2 section of the License 21 | * file that accompanied this code. 22 | * 23 | * Modifications: 24 | * If applicable, add the following below the License Header, with the fields 25 | * enclosed by brackets [] replaced by your own identifying information: 26 | * "Portions Copyright [year] [name of copyright owner]" 27 | * 28 | * Contributor(s): 29 | * If you wish your version of this file to be governed by only the CDDL or 30 | * only the GPL Version 2, indicate your decision by adding "[Contributor] 31 | * elects to include this software in this distribution under the [CDDL or GPL 32 | * Version 2] license." If you don't indicate a single choice of license, a 33 | * recipient has the option to distribute your version of this file under 34 | * either the CDDL, the GPL Version 2 or to extend the choice of license to 35 | * its licensees as provided above. However, if you add GPL Version 2 code 36 | * and therefore, elected the GPL Version 2 license, then the option applies 37 | * only if the new code is made subject to such option by the copyright 38 | * holder. 39 | */ 40 | 41 | package jaxrs.examples.link.clusterservice; 42 | 43 | import java.util.ArrayList; 44 | import java.util.List; 45 | 46 | import javax.xml.bind.annotation.XmlRootElement; 47 | 48 | /** 49 | * Cluster class. 50 | * 51 | * @author Santiago.Pericas-Geertsen@oracle.com 52 | */ 53 | @XmlRootElement 54 | public class Cluster { 55 | 56 | public enum Status {OFFLINE, ONLINE}; 57 | 58 | private String name; 59 | 60 | private Status status = Status.ONLINE; 61 | 62 | private List machines = new ArrayList(); 63 | 64 | public Cluster() { 65 | } 66 | 67 | public Cluster(String name) { 68 | this.name = name; 69 | } 70 | 71 | public List getMachines() { 72 | return machines; 73 | } 74 | 75 | public void setMachines(List machines) { 76 | this.machines = machines; 77 | } 78 | 79 | public String getName() { 80 | return name; 81 | } 82 | 83 | public void setName(String name) { 84 | this.name = name; 85 | } 86 | 87 | public Status getStatus() { 88 | return status; 89 | } 90 | 91 | public void setStatus(Status status) { 92 | this.status = status; 93 | } 94 | 95 | } 96 | -------------------------------------------------------------------------------- /jaxrs-api/src/main/java/javax/ws/rs/core/StreamingOutput.java: -------------------------------------------------------------------------------- 1 | /* 2 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. 3 | * 4 | * Copyright (c) 2010-2015 Oracle and/or its affiliates. All rights reserved. 5 | * 6 | * The contents of this file are subject to the terms of either the GNU 7 | * General Public License Version 2 only ("GPL") or the Common Development 8 | * and Distribution License("CDDL") (collectively, the "License"). You 9 | * may not use this file except in compliance with the License. You can 10 | * obtain a copy of the License at 11 | * http://glassfish.java.net/public/CDDL+GPL_1_1.html 12 | * or packager/legal/LICENSE.txt. See the License for the specific 13 | * language governing permissions and limitations under the License. 14 | * 15 | * When distributing the software, include this License Header Notice in each 16 | * file and include the License file at packager/legal/LICENSE.txt. 17 | * 18 | * GPL Classpath Exception: 19 | * Oracle designates this particular file as subject to the "Classpath" 20 | * exception as provided by Oracle in the GPL Version 2 section of the License 21 | * file that accompanied this code. 22 | * 23 | * Modifications: 24 | * If applicable, add the following below the License Header, with the fields 25 | * enclosed by brackets [] replaced by your own identifying information: 26 | * "Portions Copyright [year] [name of copyright owner]" 27 | * 28 | * Contributor(s): 29 | * If you wish your version of this file to be governed by only the CDDL or 30 | * only the GPL Version 2, indicate your decision by adding "[Contributor] 31 | * elects to include this software in this distribution under the [CDDL or GPL 32 | * Version 2] license." If you don't indicate a single choice of license, a 33 | * recipient has the option to distribute your version of this file under 34 | * either the CDDL, the GPL Version 2 or to extend the choice of license to 35 | * its licensees as provided above. However, if you add GPL Version 2 code 36 | * and therefore, elected the GPL Version 2 license, then the option applies 37 | * only if the new code is made subject to such option by the copyright 38 | * holder. 39 | */ 40 | 41 | package javax.ws.rs.core; 42 | 43 | import java.io.IOException; 44 | import java.io.OutputStream; 45 | 46 | import javax.ws.rs.WebApplicationException; 47 | 48 | /** 49 | * A type that may be used as a resource method return value or as the entity 50 | * in a {@link Response} when the application wishes to stream the output. 51 | * This is a lightweight alternative to a 52 | * {@link javax.ws.rs.ext.MessageBodyWriter}. 53 | * 54 | * @author Paul Sandoz 55 | * @author Marc Hadley 56 | * @see javax.ws.rs.ext.MessageBodyWriter 57 | * @see javax.ws.rs.core.Response 58 | * @since 1.0 59 | */ 60 | public interface StreamingOutput { 61 | 62 | /** 63 | * Called to write the message body. 64 | * 65 | * @param output the OutputStream to write to. 66 | * @throws java.io.IOException if an IO error is encountered 67 | * @throws javax.ws.rs.WebApplicationException 68 | * if a specific 69 | * HTTP error response needs to be produced. Only effective if thrown prior 70 | * to any bytes being written to output. 71 | */ 72 | void write(OutputStream output) throws IOException, WebApplicationException; 73 | } 74 | -------------------------------------------------------------------------------- /jaxrs-api/src/main/java/javax/ws/rs/core/PathSegment.java: -------------------------------------------------------------------------------- 1 | /* 2 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. 3 | * 4 | * Copyright (c) 2010-2015 Oracle and/or its affiliates. All rights reserved. 5 | * 6 | * The contents of this file are subject to the terms of either the GNU 7 | * General Public License Version 2 only ("GPL") or the Common Development 8 | * and Distribution License("CDDL") (collectively, the "License"). You 9 | * may not use this file except in compliance with the License. You can 10 | * obtain a copy of the License at 11 | * http://glassfish.java.net/public/CDDL+GPL_1_1.html 12 | * or packager/legal/LICENSE.txt. See the License for the specific 13 | * language governing permissions and limitations under the License. 14 | * 15 | * When distributing the software, include this License Header Notice in each 16 | * file and include the License file at packager/legal/LICENSE.txt. 17 | * 18 | * GPL Classpath Exception: 19 | * Oracle designates this particular file as subject to the "Classpath" 20 | * exception as provided by Oracle in the GPL Version 2 section of the License 21 | * file that accompanied this code. 22 | * 23 | * Modifications: 24 | * If applicable, add the following below the License Header, with the fields 25 | * enclosed by brackets [] replaced by your own identifying information: 26 | * "Portions Copyright [year] [name of copyright owner]" 27 | * 28 | * Contributor(s): 29 | * If you wish your version of this file to be governed by only the CDDL or 30 | * only the GPL Version 2, indicate your decision by adding "[Contributor] 31 | * elects to include this software in this distribution under the [CDDL or GPL 32 | * Version 2] license." If you don't indicate a single choice of license, a 33 | * recipient has the option to distribute your version of this file under 34 | * either the CDDL, the GPL Version 2 or to extend the choice of license to 35 | * its licensees as provided above. However, if you add GPL Version 2 code 36 | * and therefore, elected the GPL Version 2 license, then the option applies 37 | * only if the new code is made subject to such option by the copyright 38 | * holder. 39 | */ 40 | 41 | package javax.ws.rs.core; 42 | 43 | /** 44 | * Represents a URI path segment and any associated matrix parameters. When an 45 | * instance of this type is injected with {@link javax.ws.rs.PathParam}, the 46 | * value of the annotation identifies which path segment is selected and the 47 | * presence of an {@link javax.ws.rs.Encoded} annotation will result in an 48 | * instance that supplies the path and matrix parameter values in 49 | * URI encoded form. 50 | * 51 | * @author Paul Sandoz 52 | * @author Marc Hadley 53 | * @see UriInfo#getPathSegments 54 | * @see javax.ws.rs.PathParam 55 | * @since 1.0 56 | */ 57 | public interface PathSegment { 58 | 59 | /** 60 | * Get the path segment. 61 | *

62 | * 63 | * @return the path segment 64 | */ 65 | String getPath(); 66 | 67 | /** 68 | * Get a map of the matrix parameters associated with the path segment. 69 | * The map keys are the names of the matrix parameters with any 70 | * percent-escaped octets decoded. 71 | * 72 | * @return the map of matrix parameters 73 | * @see Matrix URIs 74 | */ 75 | MultivaluedMap getMatrixParameters(); 76 | } 77 | -------------------------------------------------------------------------------- /jaxrs-api/src/main/java/javax/ws/rs/client/ClientResponseFilter.java: -------------------------------------------------------------------------------- 1 | /* 2 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. 3 | * 4 | * Copyright (c) 2012-2015 Oracle and/or its affiliates. All rights reserved. 5 | * 6 | * The contents of this file are subject to the terms of either the GNU 7 | * General Public License Version 2 only ("GPL") or the Common Development 8 | * and Distribution License("CDDL") (collectively, the "License"). You 9 | * may not use this file except in compliance with the License. You can 10 | * obtain a copy of the License at 11 | * http://glassfish.java.net/public/CDDL+GPL_1_1.html 12 | * or packager/legal/LICENSE.txt. See the License for the specific 13 | * language governing permissions and limitations under the License. 14 | * 15 | * When distributing the software, include this License Header Notice in each 16 | * file and include the License file at packager/legal/LICENSE.txt. 17 | * 18 | * GPL Classpath Exception: 19 | * Oracle designates this particular file as subject to the "Classpath" 20 | * exception as provided by Oracle in the GPL Version 2 section of the License 21 | * file that accompanied this code. 22 | * 23 | * Modifications: 24 | * If applicable, add the following below the License Header, with the fields 25 | * enclosed by brackets [] replaced by your own identifying information: 26 | * "Portions Copyright [year] [name of copyright owner]" 27 | * 28 | * Contributor(s): 29 | * If you wish your version of this file to be governed by only the CDDL or 30 | * only the GPL Version 2, indicate your decision by adding "[Contributor] 31 | * elects to include this software in this distribution under the [CDDL or GPL 32 | * Version 2] license." If you don't indicate a single choice of license, a 33 | * recipient has the option to distribute your version of this file under 34 | * either the CDDL, the GPL Version 2 or to extend the choice of license to 35 | * its licensees as provided above. However, if you add GPL Version 2 code 36 | * and therefore, elected the GPL Version 2 license, then the option applies 37 | * only if the new code is made subject to such option by the copyright 38 | * holder. 39 | */ 40 | 41 | package javax.ws.rs.client; 42 | 43 | import java.io.IOException; 44 | 45 | /** 46 | * An extension interface implemented by client response filters. 47 | * 48 | * Filters implementing this interface MUST be annotated with 49 | * {@link javax.ws.rs.ext.Provider @Provider}. This type of filters is supported 50 | * only as part of the Client API. 51 | * 52 | * @author Marek Potociar 53 | * @author Santiago Pericas-Geertsen 54 | * @see javax.ws.rs.client.ClientRequestFilter 55 | * @since 2.0 56 | */ 57 | public interface ClientResponseFilter { 58 | 59 | /** 60 | * Filter method called after a response has been provided for a request 61 | * (either by a {@link ClientRequestFilter request filter} or when the 62 | * HTTP invocation returns. 63 | * 64 | * Filters in the filter chain are ordered according to their {@code javax.annotation.Priority} 65 | * class-level annotation value. 66 | * 67 | * @param requestContext request context. 68 | * @param responseContext response context. 69 | * @throws IOException if an I/O exception occurs. 70 | */ 71 | public void filter(ClientRequestContext requestContext, ClientResponseContext responseContext) 72 | throws IOException; 73 | } 74 | -------------------------------------------------------------------------------- /jaxrs-api/src/main/java/javax/ws/rs/ext/ExceptionMapper.java: -------------------------------------------------------------------------------- 1 | /* 2 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. 3 | * 4 | * Copyright (c) 2010-2017 Oracle and/or its affiliates. All rights reserved. 5 | * 6 | * The contents of this file are subject to the terms of either the GNU 7 | * General Public License Version 2 only ("GPL") or the Common Development 8 | * and Distribution License("CDDL") (collectively, the "License"). You 9 | * may not use this file except in compliance with the License. You can 10 | * obtain a copy of the License at 11 | * http://glassfish.java.net/public/CDDL+GPL_1_1.html 12 | * or packager/legal/LICENSE.txt. See the License for the specific 13 | * language governing permissions and limitations under the License. 14 | * 15 | * When distributing the software, include this License Header Notice in each 16 | * file and include the License file at packager/legal/LICENSE.txt. 17 | * 18 | * GPL Classpath Exception: 19 | * Oracle designates this particular file as subject to the "Classpath" 20 | * exception as provided by Oracle in the GPL Version 2 section of the License 21 | * file that accompanied this code. 22 | * 23 | * Modifications: 24 | * If applicable, add the following below the License Header, with the fields 25 | * enclosed by brackets [] replaced by your own identifying information: 26 | * "Portions Copyright [year] [name of copyright owner]" 27 | * 28 | * Contributor(s): 29 | * If you wish your version of this file to be governed by only the CDDL or 30 | * only the GPL Version 2, indicate your decision by adding "[Contributor] 31 | * elects to include this software in this distribution under the [CDDL or GPL 32 | * Version 2] license." If you don't indicate a single choice of license, a 33 | * recipient has the option to distribute your version of this file under 34 | * either the CDDL, the GPL Version 2 or to extend the choice of license to 35 | * its licensees as provided above. However, if you add GPL Version 2 code 36 | * and therefore, elected the GPL Version 2 license, then the option applies 37 | * only if the new code is made subject to such option by the copyright 38 | * holder. 39 | */ 40 | 41 | package javax.ws.rs.ext; 42 | 43 | import javax.ws.rs.core.Response; 44 | 45 | /** 46 | * Contract for a provider that maps Java exceptions to {@link javax.ws.rs.core.Response}. 47 | *

48 | * Providers implementing {@code ExceptionMapper} contract must be either programmatically 49 | * registered in a JAX-RS runtime or must be annotated with 50 | * {@link javax.ws.rs.ext.Provider @Provider} annotation to be automatically discovered 51 | * by the JAX-RS runtime during a provider scanning phase. 52 | * 53 | * @param exception type supported by the provider. 54 | * @author Paul Sandoz 55 | * @author Marc Hadley 56 | * @see Provider 57 | * @see javax.ws.rs.core.Response 58 | * @since 1.0 59 | */ 60 | public interface ExceptionMapper { 61 | 62 | /** 63 | * Map an exception to a {@link javax.ws.rs.core.Response}. Returning 64 | * {@code null} results in a {@link javax.ws.rs.core.Response.Status#NO_CONTENT} 65 | * response. Throwing a runtime exception results in a 66 | * {@link javax.ws.rs.core.Response.Status#INTERNAL_SERVER_ERROR} response. 67 | * 68 | * @param exception the exception to map to a response. 69 | * @return a response mapped from the supplied exception. 70 | */ 71 | Response toResponse(E exception); 72 | } 73 | -------------------------------------------------------------------------------- /jaxrs-api/src/test/java/javax/ws/rs/core/NewCookieTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. 3 | * 4 | * Copyright (c) 2010-2015 Oracle and/or its affiliates. All rights reserved. 5 | * 6 | * The contents of this file are subject to the terms of either the GNU 7 | * General Public License Version 2 only ("GPL") or the Common Development 8 | * and Distribution License("CDDL") (collectively, the "License"). You 9 | * may not use this file except in compliance with the License. You can 10 | * obtain a copy of the License at 11 | * http://glassfish.java.net/public/CDDL+GPL_1_1.html 12 | * or packager/legal/LICENSE.txt. See the License for the specific 13 | * language governing permissions and limitations under the License. 14 | * 15 | * When distributing the software, include this License Header Notice in each 16 | * file and include the License file at packager/legal/LICENSE.txt. 17 | * 18 | * GPL Classpath Exception: 19 | * Oracle designates this particular file as subject to the "Classpath" 20 | * exception as provided by Oracle in the GPL Version 2 section of the License 21 | * file that accompanied this code. 22 | * 23 | * Modifications: 24 | * If applicable, add the following below the License Header, with the fields 25 | * enclosed by brackets [] replaced by your own identifying information: 26 | * "Portions Copyright [year] [name of copyright owner]" 27 | * 28 | * Contributor(s): 29 | * If you wish your version of this file to be governed by only the CDDL or 30 | * only the GPL Version 2, indicate your decision by adding "[Contributor] 31 | * elects to include this software in this distribution under the [CDDL or GPL 32 | * Version 2] license." If you don't indicate a single choice of license, a 33 | * recipient has the option to distribute your version of this file under 34 | * either the CDDL, the GPL Version 2 or to extend the choice of license to 35 | * its licensees as provided above. However, if you add GPL Version 2 code 36 | * and therefore, elected the GPL Version 2 license, then the option applies 37 | * only if the new code is made subject to such option by the copyright 38 | * holder. 39 | */ 40 | 41 | package javax.ws.rs.core; 42 | 43 | import javax.ws.rs.ext.RuntimeDelegate; 44 | 45 | import org.junit.After; 46 | import org.junit.Before; 47 | import org.junit.Test; 48 | import static org.junit.Assert.assertEquals; 49 | import static org.junit.Assert.fail; 50 | 51 | public class NewCookieTest { 52 | 53 | @Before 54 | public void setUp() throws Exception { 55 | RuntimeDelegate.setInstance(new RuntimeDelegateStub()); 56 | } 57 | 58 | @After 59 | public void tearDown() throws Exception { 60 | RuntimeDelegate.setInstance(null); 61 | } 62 | 63 | /** 64 | * Test of valueOf method, of class NewCookie. 65 | */ 66 | @Test 67 | public void testCtor() { 68 | System.out.println("ctor"); 69 | Cookie c = new Cookie("name", "value"); 70 | NewCookie nc = new NewCookie(c); 71 | assertEquals(nc.getName(), c.getName()); 72 | try { 73 | nc = new NewCookie(null); 74 | fail("Expected IllegalArgumentException"); 75 | } catch (IllegalArgumentException e) { 76 | } 77 | try { 78 | nc = new NewCookie(null, "comment", 120, true); 79 | fail("Expected IllegalArgumentException"); 80 | } catch (IllegalArgumentException e) { 81 | } 82 | } 83 | } 84 | -------------------------------------------------------------------------------- /examples/src/main/java/jaxrs/examples/filter/logging/LoggingFilter.java: -------------------------------------------------------------------------------- 1 | /* 2 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. 3 | * 4 | * Copyright (c) 2011-2015 Oracle and/or its affiliates. All rights reserved. 5 | * 6 | * The contents of this file are subject to the terms of either the GNU 7 | * General Public License Version 2 only ("GPL") or the Common Development 8 | * and Distribution License("CDDL") (collectively, the "License"). You 9 | * may not use this file except in compliance with the License. You can 10 | * obtain a copy of the License at 11 | * http://glassfish.java.net/public/CDDL+GPL_1_1.html 12 | * or packager/legal/LICENSE.txt. See the License for the specific 13 | * language governing permissions and limitations under the License. 14 | * 15 | * When distributing the software, include this License Header Notice in each 16 | * file and include the License file at packager/legal/LICENSE.txt. 17 | * 18 | * GPL Classpath Exception: 19 | * Oracle designates this particular file as subject to the "Classpath" 20 | * exception as provided by Oracle in the GPL Version 2 section of the License 21 | * file that accompanied this code. 22 | * 23 | * Modifications: 24 | * If applicable, add the following below the License Header, with the fields 25 | * enclosed by brackets [] replaced by your own identifying information: 26 | * "Portions Copyright [year] [name of copyright owner]" 27 | * 28 | * Contributor(s): 29 | * If you wish your version of this file to be governed by only the CDDL or 30 | * only the GPL Version 2, indicate your decision by adding "[Contributor] 31 | * elects to include this software in this distribution under the [CDDL or GPL 32 | * Version 2] license." If you don't indicate a single choice of license, a 33 | * recipient has the option to distribute your version of this file under 34 | * either the CDDL, the GPL Version 2 or to extend the choice of license to 35 | * its licensees as provided above. However, if you add GPL Version 2 code 36 | * and therefore, elected the GPL Version 2 license, then the option applies 37 | * only if the new code is made subject to such option by the copyright 38 | * holder. 39 | */ 40 | 41 | package jaxrs.examples.filter.logging; 42 | 43 | import java.io.IOException; 44 | 45 | import javax.ws.rs.Priorities; 46 | import javax.ws.rs.container.ContainerRequestContext; 47 | import javax.ws.rs.container.ContainerRequestFilter; 48 | import javax.ws.rs.container.ContainerResponseContext; 49 | import javax.ws.rs.container.ContainerResponseFilter; 50 | import javax.ws.rs.ext.Provider; 51 | 52 | import javax.annotation.Priority; 53 | 54 | /** 55 | * Example of a logging resource filter (server-side). 56 | * 57 | * @author Santiago Pericas-Geertsen 58 | * @author Marek Potociar 59 | */ 60 | @Provider 61 | @Logged // name-bound => resource filter 62 | @Priority(Priorities.USER) 63 | public class LoggingFilter implements ContainerRequestFilter, ContainerResponseFilter { 64 | 65 | @Override 66 | public void filter(ContainerRequestContext requestContext) throws IOException { 67 | log(requestContext); 68 | } 69 | 70 | @Override 71 | public void filter(ContainerRequestContext requestContext, ContainerResponseContext responseContext) throws IOException { 72 | log(responseContext); 73 | } 74 | 75 | private static void log(ContainerRequestContext context) { 76 | // implementation goes here 77 | } 78 | 79 | private static void log(ContainerResponseContext context) { 80 | // implementation goes here 81 | } 82 | } 83 | -------------------------------------------------------------------------------- /jaxrs-api/src/main/java/javax/ws/rs/ext/ContextResolver.java: -------------------------------------------------------------------------------- 1 | /* 2 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. 3 | * 4 | * Copyright (c) 2010-2015 Oracle and/or its affiliates. All rights reserved. 5 | * 6 | * The contents of this file are subject to the terms of either the GNU 7 | * General Public License Version 2 only ("GPL") or the Common Development 8 | * and Distribution License("CDDL") (collectively, the "License"). You 9 | * may not use this file except in compliance with the License. You can 10 | * obtain a copy of the License at 11 | * http://glassfish.java.net/public/CDDL+GPL_1_1.html 12 | * or packager/legal/LICENSE.txt. See the License for the specific 13 | * language governing permissions and limitations under the License. 14 | * 15 | * When distributing the software, include this License Header Notice in each 16 | * file and include the License file at packager/legal/LICENSE.txt. 17 | * 18 | * GPL Classpath Exception: 19 | * Oracle designates this particular file as subject to the "Classpath" 20 | * exception as provided by Oracle in the GPL Version 2 section of the License 21 | * file that accompanied this code. 22 | * 23 | * Modifications: 24 | * If applicable, add the following below the License Header, with the fields 25 | * enclosed by brackets [] replaced by your own identifying information: 26 | * "Portions Copyright [year] [name of copyright owner]" 27 | * 28 | * Contributor(s): 29 | * If you wish your version of this file to be governed by only the CDDL or 30 | * only the GPL Version 2, indicate your decision by adding "[Contributor] 31 | * elects to include this software in this distribution under the [CDDL or GPL 32 | * Version 2] license." If you don't indicate a single choice of license, a 33 | * recipient has the option to distribute your version of this file under 34 | * either the CDDL, the GPL Version 2 or to extend the choice of license to 35 | * its licensees as provided above. However, if you add GPL Version 2 code 36 | * and therefore, elected the GPL Version 2 license, then the option applies 37 | * only if the new code is made subject to such option by the copyright 38 | * holder. 39 | */ 40 | 41 | package javax.ws.rs.ext; 42 | 43 | /** 44 | * Contract for a provider that supplies context information to resource 45 | * classes and other providers. 46 | * 47 | * A {@code ContextResolver} implementation may be annotated 48 | * with {@link javax.ws.rs.Produces} to restrict the media types for 49 | * which it will be considered suitable. 50 | *

51 | * Providers implementing {@code ContextResolver} contract must be either programmatically 52 | * registered in a JAX-RS runtime or must be annotated with 53 | * {@link javax.ws.rs.ext.Provider @Provider} annotation to be automatically discovered 54 | * by the JAX-RS runtime during a provider scanning phase. 55 | *

56 | * 57 | * @param type of the context 58 | * @author Paul Sandoz 59 | * @author Marc Hadley 60 | * @see javax.ws.rs.core.Context 61 | * @see Providers#getContextResolver(Class, javax.ws.rs.core.MediaType) 62 | * @see Provider 63 | * @see javax.ws.rs.Produces 64 | * @since 1.0 65 | */ 66 | public interface ContextResolver { 67 | 68 | /** 69 | * Get a context of type {@code T} that is applicable to the supplied 70 | * type. 71 | * 72 | * @param type the class of object for which a context is desired 73 | * @return a context for the supplied type or {@code null} if a 74 | * context for the supplied type is not available from this provider. 75 | */ 76 | T getContext(Class type); 77 | } 78 | -------------------------------------------------------------------------------- /examples/src/main/java/jaxrs/examples/link/clusterservice/ClientTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. 3 | * 4 | * Copyright (c) 2011-2015 Oracle and/or its affiliates. All rights reserved. 5 | * 6 | * The contents of this file are subject to the terms of either the GNU 7 | * General Public License Version 2 only ("GPL") or the Common Development 8 | * and Distribution License("CDDL") (collectively, the "License"). You 9 | * may not use this file except in compliance with the License. You can 10 | * obtain a copy of the License at 11 | * http://glassfish.java.net/public/CDDL+GPL_1_1.html 12 | * or packager/legal/LICENSE.txt. See the License for the specific 13 | * language governing permissions and limitations under the License. 14 | * 15 | * When distributing the software, include this License Header Notice in each 16 | * file and include the License file at packager/legal/LICENSE.txt. 17 | * 18 | * GPL Classpath Exception: 19 | * Oracle designates this particular file as subject to the "Classpath" 20 | * exception as provided by Oracle in the GPL Version 2 section of the License 21 | * file that accompanied this code. 22 | * 23 | * Modifications: 24 | * If applicable, add the following below the License Header, with the fields 25 | * enclosed by brackets [] replaced by your own identifying information: 26 | * "Portions Copyright [year] [name of copyright owner]" 27 | * 28 | * Contributor(s): 29 | * If you wish your version of this file to be governed by only the CDDL or 30 | * only the GPL Version 2, indicate your decision by adding "[Contributor] 31 | * elects to include this software in this distribution under the [CDDL or GPL 32 | * Version 2] license." If you don't indicate a single choice of license, a 33 | * recipient has the option to distribute your version of this file under 34 | * either the CDDL, the GPL Version 2 or to extend the choice of license to 35 | * its licensees as provided above. However, if you add GPL Version 2 code 36 | * and therefore, elected the GPL Version 2 license, then the option applies 37 | * only if the new code is made subject to such option by the copyright 38 | * holder. 39 | */ 40 | 41 | package jaxrs.examples.link.clusterservice; 42 | 43 | import javax.ws.rs.client.Client; 44 | import javax.ws.rs.client.ClientBuilder; 45 | import javax.ws.rs.core.Link; 46 | import javax.ws.rs.core.Response; 47 | 48 | /** 49 | * ClientTest class. 50 | * 51 | * @author Santiago.Pericas-Geertsen@oracle.com 52 | */ 53 | public class ClientTest { 54 | 55 | public void test() { 56 | Client client = ClientBuilder.newClient(); 57 | 58 | // Get cluster representation -- entry point 59 | Response rc = client.target("/cluster").request("application/json").get(); 60 | 61 | // Ensure cluster is online 62 | if (rc.hasLink("onliner")) { 63 | client.invocation(rc.getLink("onliner")).buildPost(null).invoke(); 64 | } 65 | 66 | // Start all machines in cluster 67 | Cluster c = rc.readEntity(Cluster.class); 68 | for (Machine m : c.getMachines()) { 69 | // Machine name is need for URI template in link 70 | Link l = rc.getLinkBuilder("item").build(m.getName()); 71 | 72 | // Create invocation from link and call invoke() 73 | Response rm = client.invocation(l).buildGet().invoke(); 74 | 75 | // Start machine if not started already 76 | if (rm.hasLink("starter")) { 77 | client.invocation(rm.getLink("starter")).buildPost(null).invoke(); 78 | } 79 | } 80 | } 81 | } 82 | -------------------------------------------------------------------------------- /jaxrs-api/src/test/java/javax/ws/rs/core/MediaTypeTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. 3 | * 4 | * Copyright (c) 2012-2015 Oracle and/or its affiliates. All rights reserved. 5 | * 6 | * The contents of this file are subject to the terms of either the GNU 7 | * General Public License Version 2 only ("GPL") or the Common Development 8 | * and Distribution License("CDDL") (collectively, the "License"). You 9 | * may not use this file except in compliance with the License. You can 10 | * obtain a copy of the License at 11 | * http://glassfish.java.net/public/CDDL+GPL_1_1.html 12 | * or packager/legal/LICENSE.txt. See the License for the specific 13 | * language governing permissions and limitations under the License. 14 | * 15 | * When distributing the software, include this License Header Notice in each 16 | * file and include the License file at packager/legal/LICENSE.txt. 17 | * 18 | * GPL Classpath Exception: 19 | * Oracle designates this particular file as subject to the "Classpath" 20 | * exception as provided by Oracle in the GPL Version 2 section of the License 21 | * file that accompanied this code. 22 | * 23 | * Modifications: 24 | * If applicable, add the following below the License Header, with the fields 25 | * enclosed by brackets [] replaced by your own identifying information: 26 | * "Portions Copyright [year] [name of copyright owner]" 27 | * 28 | * Contributor(s): 29 | * If you wish your version of this file to be governed by only the CDDL or 30 | * only the GPL Version 2, indicate your decision by adding "[Contributor] 31 | * elects to include this software in this distribution under the [CDDL or GPL 32 | * Version 2] license." If you don't indicate a single choice of license, a 33 | * recipient has the option to distribute your version of this file under 34 | * either the CDDL, the GPL Version 2 or to extend the choice of license to 35 | * its licensees as provided above. However, if you add GPL Version 2 code 36 | * and therefore, elected the GPL Version 2 license, then the option applies 37 | * only if the new code is made subject to such option by the copyright 38 | * holder. 39 | */ 40 | 41 | package javax.ws.rs.core; 42 | 43 | import java.util.Map; 44 | 45 | import org.junit.Test; 46 | import static org.junit.Assert.assertEquals; 47 | 48 | /** 49 | * {@link MediaType} unit test. 50 | * 51 | * @author Marek Potociar 52 | */ 53 | public class MediaTypeTest { 54 | 55 | /** 56 | * Test {@link MediaType#withCharset(String)} method. 57 | */ 58 | @Test 59 | public void testWithCharset() { 60 | assertEquals("Unexpected produced media type content.", 61 | "UTF-8", 62 | MediaType.APPLICATION_XML_TYPE.withCharset("UTF-8") 63 | .getParameters().get(MediaType.CHARSET_PARAMETER)); 64 | assertEquals("Unexpected produced media type content.", 65 | "ISO-8859-13", 66 | MediaType.APPLICATION_XML_TYPE.withCharset("UTF-8").withCharset("ISO-8859-13") 67 | .getParameters().get(MediaType.CHARSET_PARAMETER)); 68 | } 69 | 70 | /** 71 | * Test that passing {@code null} values to {@link MediaType} constructor does 72 | * not throw a {@link NullPointerException} and produces expected result. 73 | */ 74 | @Test 75 | public void testNullConstructorValues() { 76 | MediaType actual; 77 | 78 | actual = new MediaType(null, null, (Map) null); 79 | assertEquals(MediaType.WILDCARD_TYPE, actual); 80 | 81 | actual = new MediaType(null, null, (String) null); 82 | assertEquals(MediaType.WILDCARD_TYPE, actual); 83 | } 84 | } 85 | -------------------------------------------------------------------------------- /jaxrs-api/src/main/java/javax/ws/rs/ApplicationPath.java: -------------------------------------------------------------------------------- 1 | /* 2 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. 3 | * 4 | * Copyright (c) 2010-2015 Oracle and/or its affiliates. All rights reserved. 5 | * 6 | * The contents of this file are subject to the terms of either the GNU 7 | * General Public License Version 2 only ("GPL") or the Common Development 8 | * and Distribution License("CDDL") (collectively, the "License"). You 9 | * may not use this file except in compliance with the License. You can 10 | * obtain a copy of the License at 11 | * http://glassfish.java.net/public/CDDL+GPL_1_1.html 12 | * or packager/legal/LICENSE.txt. See the License for the specific 13 | * language governing permissions and limitations under the License. 14 | * 15 | * When distributing the software, include this License Header Notice in each 16 | * file and include the License file at packager/legal/LICENSE.txt. 17 | * 18 | * GPL Classpath Exception: 19 | * Oracle designates this particular file as subject to the "Classpath" 20 | * exception as provided by Oracle in the GPL Version 2 section of the License 21 | * file that accompanied this code. 22 | * 23 | * Modifications: 24 | * If applicable, add the following below the License Header, with the fields 25 | * enclosed by brackets [] replaced by your own identifying information: 26 | * "Portions Copyright [year] [name of copyright owner]" 27 | * 28 | * Contributor(s): 29 | * If you wish your version of this file to be governed by only the CDDL or 30 | * only the GPL Version 2, indicate your decision by adding "[Contributor] 31 | * elects to include this software in this distribution under the [CDDL or GPL 32 | * Version 2] license." If you don't indicate a single choice of license, a 33 | * recipient has the option to distribute your version of this file under 34 | * either the CDDL, the GPL Version 2 or to extend the choice of license to 35 | * its licensees as provided above. However, if you add GPL Version 2 code 36 | * and therefore, elected the GPL Version 2 license, then the option applies 37 | * only if the new code is made subject to such option by the copyright 38 | * holder. 39 | */ 40 | 41 | package javax.ws.rs; 42 | 43 | import java.lang.annotation.Documented; 44 | import java.lang.annotation.ElementType; 45 | import java.lang.annotation.Retention; 46 | import java.lang.annotation.RetentionPolicy; 47 | import java.lang.annotation.Target; 48 | 49 | /** 50 | * Identifies the application path that serves as the base URI 51 | * for all resource URIs provided by {@link javax.ws.rs.Path}. May only be 52 | * applied to a subclass of {@link javax.ws.rs.core.Application}. 53 | * 54 | *

When published in a Servlet container, the value of the application path 55 | * may be overridden using a servlet-mapping element in the web.xml.

56 | * 57 | * @author Paul Sandoz 58 | * @author Marc Hadley 59 | * @see javax.ws.rs.core.Application 60 | * @see Path 61 | * @since 1.1 62 | */ 63 | @Documented 64 | @Target({ElementType.TYPE}) 65 | @Retention(RetentionPolicy.RUNTIME) 66 | public @interface ApplicationPath { 67 | 68 | /** 69 | * Defines the base URI for all resource URIs. A trailing '/' character will 70 | * be automatically appended if one is not present. 71 | * 72 | *

The supplied value is automatically percent 73 | * encoded to conform to the {@code path} production of 74 | * {@link RFC 3986 section 3.3}. 75 | * Note that percent encoded values are allowed in the value, an 76 | * implementation will recognize such values and will not double 77 | * encode the '%' character.

78 | */ 79 | String value(); 80 | } 81 | -------------------------------------------------------------------------------- /jaxrs-api/src/test/java/javax/ws/rs/core/CookieTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. 3 | * 4 | * Copyright (c) 2010-2015 Oracle and/or its affiliates. All rights reserved. 5 | * 6 | * The contents of this file are subject to the terms of either the GNU 7 | * General Public License Version 2 only ("GPL") or the Common Development 8 | * and Distribution License("CDDL") (collectively, the "License"). You 9 | * may not use this file except in compliance with the License. You can 10 | * obtain a copy of the License at 11 | * http://glassfish.java.net/public/CDDL+GPL_1_1.html 12 | * or packager/legal/LICENSE.txt. See the License for the specific 13 | * language governing permissions and limitations under the License. 14 | * 15 | * When distributing the software, include this License Header Notice in each 16 | * file and include the License file at packager/legal/LICENSE.txt. 17 | * 18 | * GPL Classpath Exception: 19 | * Oracle designates this particular file as subject to the "Classpath" 20 | * exception as provided by Oracle in the GPL Version 2 section of the License 21 | * file that accompanied this code. 22 | * 23 | * Modifications: 24 | * If applicable, add the following below the License Header, with the fields 25 | * enclosed by brackets [] replaced by your own identifying information: 26 | * "Portions Copyright [year] [name of copyright owner]" 27 | * 28 | * Contributor(s): 29 | * If you wish your version of this file to be governed by only the CDDL or 30 | * only the GPL Version 2, indicate your decision by adding "[Contributor] 31 | * elects to include this software in this distribution under the [CDDL or GPL 32 | * Version 2] license." If you don't indicate a single choice of license, a 33 | * recipient has the option to distribute your version of this file under 34 | * either the CDDL, the GPL Version 2 or to extend the choice of license to 35 | * its licensees as provided above. However, if you add GPL Version 2 code 36 | * and therefore, elected the GPL Version 2 license, then the option applies 37 | * only if the new code is made subject to such option by the copyright 38 | * holder. 39 | */ 40 | 41 | package javax.ws.rs.core; 42 | 43 | import javax.ws.rs.ext.RuntimeDelegate; 44 | 45 | import org.junit.After; 46 | import org.junit.Before; 47 | import org.junit.Test; 48 | import static org.junit.Assert.assertFalse; 49 | import static org.junit.Assert.assertTrue; 50 | 51 | public class CookieTest { 52 | 53 | @Before 54 | public void setUp() throws Exception { 55 | RuntimeDelegate.setInstance(new RuntimeDelegateStub()); 56 | } 57 | 58 | @After 59 | public void tearDown() throws Exception { 60 | RuntimeDelegate.setInstance(null); 61 | } 62 | 63 | /** 64 | * Test of equals method, of class Cookie and NewCookie. 65 | */ 66 | @Test 67 | public void testEquals() { 68 | System.out.println("equals"); 69 | Object nullObj = null; 70 | Cookie cookie = new Cookie("name", "value"); 71 | Cookie cookie1 = new Cookie("name", "value"); 72 | Cookie cookie2 = new Cookie("name", "value2"); 73 | NewCookie newCookie = new NewCookie("name", "value"); 74 | NewCookie newCookie1 = new NewCookie("name", "value"); 75 | NewCookie newCookie2 = new NewCookie("name", "value2"); 76 | assertFalse(cookie.equals(nullObj)); 77 | assertFalse(cookie.equals(newCookie)); 78 | assertFalse(cookie.equals(cookie2)); 79 | assertTrue(cookie.equals(cookie1)); 80 | assertTrue(cookie.equals(newCookie.toCookie())); 81 | assertTrue(newCookie.equals(newCookie1)); 82 | assertFalse(newCookie.equals(newCookie2)); 83 | } 84 | } 85 | -------------------------------------------------------------------------------- /jaxrs-api/src/main/java/javax/ws/rs/Consumes.java: -------------------------------------------------------------------------------- 1 | /* 2 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. 3 | * 4 | * Copyright (c) 2010-2015 Oracle and/or its affiliates. All rights reserved. 5 | * 6 | * The contents of this file are subject to the terms of either the GNU 7 | * General Public License Version 2 only ("GPL") or the Common Development 8 | * and Distribution License("CDDL") (collectively, the "License"). You 9 | * may not use this file except in compliance with the License. You can 10 | * obtain a copy of the License at 11 | * http://glassfish.java.net/public/CDDL+GPL_1_1.html 12 | * or packager/legal/LICENSE.txt. See the License for the specific 13 | * language governing permissions and limitations under the License. 14 | * 15 | * When distributing the software, include this License Header Notice in each 16 | * file and include the License file at packager/legal/LICENSE.txt. 17 | * 18 | * GPL Classpath Exception: 19 | * Oracle designates this particular file as subject to the "Classpath" 20 | * exception as provided by Oracle in the GPL Version 2 section of the License 21 | * file that accompanied this code. 22 | * 23 | * Modifications: 24 | * If applicable, add the following below the License Header, with the fields 25 | * enclosed by brackets [] replaced by your own identifying information: 26 | * "Portions Copyright [year] [name of copyright owner]" 27 | * 28 | * Contributor(s): 29 | * If you wish your version of this file to be governed by only the CDDL or 30 | * only the GPL Version 2, indicate your decision by adding "[Contributor] 31 | * elects to include this software in this distribution under the [CDDL or GPL 32 | * Version 2] license." If you don't indicate a single choice of license, a 33 | * recipient has the option to distribute your version of this file under 34 | * either the CDDL, the GPL Version 2 or to extend the choice of license to 35 | * its licensees as provided above. However, if you add GPL Version 2 code 36 | * and therefore, elected the GPL Version 2 license, then the option applies 37 | * only if the new code is made subject to such option by the copyright 38 | * holder. 39 | */ 40 | 41 | package javax.ws.rs; 42 | 43 | import java.lang.annotation.Documented; 44 | import java.lang.annotation.ElementType; 45 | import java.lang.annotation.Inherited; 46 | import java.lang.annotation.Retention; 47 | import java.lang.annotation.RetentionPolicy; 48 | import java.lang.annotation.Target; 49 | 50 | /** 51 | * Defines the media types that the methods of a resource class or 52 | * {@link javax.ws.rs.ext.MessageBodyReader} can accept. If 53 | * not specified, a container will assume that any media type is acceptable. 54 | * Method level annotations override a class level annotation. A container 55 | * is responsible for ensuring that the method invoked is capable of consuming 56 | * the media type of the HTTP request entity body. If no such method is 57 | * available the container must respond with a HTTP "415 Unsupported Media Type" 58 | * as specified by RFC 2616. 59 | * 60 | * @author Paul Sandoz 61 | * @author Marc Hadley 62 | * @see javax.ws.rs.ext.MessageBodyReader 63 | * @since 1.0 64 | */ 65 | @Inherited 66 | @Target({ElementType.TYPE, ElementType.METHOD}) 67 | @Retention(RetentionPolicy.RUNTIME) 68 | @Documented 69 | public @interface Consumes { 70 | 71 | /** 72 | * A list of media types. Each entry may specify a single type or consist 73 | * of a comma separated list of types, with any leading or trailing white-spaces 74 | * in a single type entry being ignored. For example: 75 | *
76 |      *  {"image/jpeg, image/gif ", " image/png"}
77 |      * 
78 | * Use of the comma-separated form allows definition of a common string constant 79 | * for use on multiple targets. 80 | */ 81 | String[] value() default "*/*"; 82 | } 83 | -------------------------------------------------------------------------------- /examples/src/main/java/jaxrs/examples/link/clusterservice/Machine.java: -------------------------------------------------------------------------------- 1 | /* 2 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. 3 | * 4 | * Copyright (c) 2011-2015 Oracle and/or its affiliates. All rights reserved. 5 | * 6 | * The contents of this file are subject to the terms of either the GNU 7 | * General Public License Version 2 only ("GPL") or the Common Development 8 | * and Distribution License("CDDL") (collectively, the "License"). You 9 | * may not use this file except in compliance with the License. You can 10 | * obtain a copy of the License at 11 | * http://glassfish.java.net/public/CDDL+GPL_1_1.html 12 | * or packager/legal/LICENSE.txt. See the License for the specific 13 | * language governing permissions and limitations under the License. 14 | * 15 | * When distributing the software, include this License Header Notice in each 16 | * file and include the License file at packager/legal/LICENSE.txt. 17 | * 18 | * GPL Classpath Exception: 19 | * Oracle designates this particular file as subject to the "Classpath" 20 | * exception as provided by Oracle in the GPL Version 2 section of the License 21 | * file that accompanied this code. 22 | * 23 | * Modifications: 24 | * If applicable, add the following below the License Header, with the fields 25 | * enclosed by brackets [] replaced by your own identifying information: 26 | * "Portions Copyright [year] [name of copyright owner]" 27 | * 28 | * Contributor(s): 29 | * If you wish your version of this file to be governed by only the CDDL or 30 | * only the GPL Version 2, indicate your decision by adding "[Contributor] 31 | * elects to include this software in this distribution under the [CDDL or GPL 32 | * Version 2] license." If you don't indicate a single choice of license, a 33 | * recipient has the option to distribute your version of this file under 34 | * either the CDDL, the GPL Version 2 or to extend the choice of license to 35 | * its licensees as provided above. However, if you add GPL Version 2 code 36 | * and therefore, elected the GPL Version 2 license, then the option applies 37 | * only if the new code is made subject to such option by the copyright 38 | * holder. 39 | */ 40 | 41 | package jaxrs.examples.link.clusterservice; 42 | 43 | import javax.xml.bind.annotation.XmlRootElement; 44 | 45 | /** 46 | * Machine class. 47 | * 48 | * @author Santiago.Pericas-Geertsen@oracle.com 49 | */ 50 | @XmlRootElement 51 | public class Machine { 52 | 53 | public enum Status {STOPPED, STARTED, SUSPENDED} 54 | 55 | ; 56 | 57 | /** 58 | * Machine's unique name. 59 | */ 60 | private String name; 61 | 62 | /** 63 | * Number of CPUs. 64 | */ 65 | private int nOfCpus; 66 | 67 | /** 68 | * Load, single number for all CPUs. 69 | */ 70 | private double load; 71 | 72 | /** 73 | * Machine's internal status. 74 | */ 75 | private Status status = Status.STOPPED; 76 | 77 | public Machine() { 78 | } 79 | 80 | public Machine(String name) { 81 | this.name = name; 82 | } 83 | 84 | public double getLoad() { 85 | return load; 86 | } 87 | 88 | public void setLoad(double load) { 89 | this.load = load; 90 | } 91 | 92 | public int getnOfCpus() { 93 | return nOfCpus; 94 | } 95 | 96 | public void setnOfCpus(int nOfCpus) { 97 | this.nOfCpus = nOfCpus; 98 | } 99 | 100 | public String getName() { 101 | return name; 102 | } 103 | 104 | public void setName(String name) { 105 | this.name = name; 106 | } 107 | 108 | public Status getStatus() { 109 | return status; 110 | } 111 | 112 | public void setStatus(Status status) { 113 | this.status = status; 114 | } 115 | 116 | } 117 | -------------------------------------------------------------------------------- /examples/src/main/java/jaxrs/examples/client/cache/CacheEntryLocator.java: -------------------------------------------------------------------------------- 1 | /* 2 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. 3 | * 4 | * Copyright (c) 2011-2015 Oracle and/or its affiliates. All rights reserved. 5 | * 6 | * The contents of this file are subject to the terms of either the GNU 7 | * General Public License Version 2 only ("GPL") or the Common Development 8 | * and Distribution License("CDDL") (collectively, the "License"). You 9 | * may not use this file except in compliance with the License. You can 10 | * obtain a copy of the License at 11 | * http://glassfish.java.net/public/CDDL+GPL_1_1.html 12 | * or packager/legal/LICENSE.txt. See the License for the specific 13 | * language governing permissions and limitations under the License. 14 | * 15 | * When distributing the software, include this License Header Notice in each 16 | * file and include the License file at packager/legal/LICENSE.txt. 17 | * 18 | * GPL Classpath Exception: 19 | * Oracle designates this particular file as subject to the "Classpath" 20 | * exception as provided by Oracle in the GPL Version 2 section of the License 21 | * file that accompanied this code. 22 | * 23 | * Modifications: 24 | * If applicable, add the following below the License Header, with the fields 25 | * enclosed by brackets [] replaced by your own identifying information: 26 | * "Portions Copyright [year] [name of copyright owner]" 27 | * 28 | * Contributor(s): 29 | * If you wish your version of this file to be governed by only the CDDL or 30 | * only the GPL Version 2, indicate your decision by adding "[Contributor] 31 | * elects to include this software in this distribution under the [CDDL or GPL 32 | * Version 2] license." If you don't indicate a single choice of license, a 33 | * recipient has the option to distribute your version of this file under 34 | * either the CDDL, the GPL Version 2 or to extend the choice of license to 35 | * its licensees as provided above. However, if you add GPL Version 2 code 36 | * and therefore, elected the GPL Version 2 license, then the option applies 37 | * only if the new code is made subject to such option by the copyright 38 | * holder. 39 | */ 40 | 41 | package jaxrs.examples.client.cache; 42 | 43 | import java.io.ByteArrayInputStream; 44 | import java.io.IOException; 45 | import java.util.List; 46 | import java.util.Map; 47 | 48 | import javax.ws.rs.client.ClientRequestContext; 49 | import javax.ws.rs.client.ClientRequestFilter; 50 | import javax.ws.rs.core.Response; 51 | 52 | /** 53 | * @author Bill Burke 54 | * @author Marek Potociar 55 | * @author Santiago Pericas-Geertsen 56 | */ 57 | public class CacheEntryLocator implements ClientRequestFilter { 58 | 59 | private Map cache; 60 | 61 | public CacheEntryLocator(Map cache) { 62 | this.cache = cache; 63 | } 64 | 65 | @Override 66 | public void filter(ClientRequestContext request) throws IOException { 67 | load(request); 68 | } 69 | 70 | private void load(ClientRequestContext request) { 71 | if (request.getMethod().equalsIgnoreCase("GET")) { 72 | CacheEntry cacheEntry = cache.get(request.getUri().toString()); 73 | 74 | if (cacheEntry != null) { 75 | Response.ResponseBuilder responseBuilder = 76 | Response.status(cacheEntry.getStatus()).entity(new ByteArrayInputStream(cacheEntry.getBody())); 77 | 78 | for (Map.Entry> mapEntry : cacheEntry.getHeaders().entrySet()) { 79 | for (String value : mapEntry.getValue()) { 80 | responseBuilder.header(mapEntry.getKey(), value); 81 | } 82 | } 83 | 84 | // stops filter chain & returns response 85 | request.abortWith(responseBuilder.build()); 86 | } 87 | } 88 | } 89 | } 90 | -------------------------------------------------------------------------------- /jaxrs-api/src/main/java/javax/ws/rs/client/RxInvokerProvider.java: -------------------------------------------------------------------------------- 1 | /* 2 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. 3 | * 4 | * Copyright (c) 2017 Oracle and/or its affiliates. All rights reserved. 5 | * 6 | * The contents of this file are subject to the terms of either the GNU 7 | * General Public License Version 2 only ("GPL") or the Common Development 8 | * and Distribution License("CDDL") (collectively, the "License"). You 9 | * may not use this file except in compliance with the License. You can 10 | * obtain a copy of the License at 11 | * http://glassfish.java.net/public/CDDL+GPL_1_1.html 12 | * or packager/legal/LICENSE.txt. See the License for the specific 13 | * language governing permissions and limitations under the License. 14 | * 15 | * When distributing the software, include this License Header Notice in each 16 | * file and include the License file at packager/legal/LICENSE.txt. 17 | * 18 | * GPL Classpath Exception: 19 | * Oracle designates this particular file as subject to the "Classpath" 20 | * exception as provided by Oracle in the GPL Version 2 section of the License 21 | * file that accompanied this code. 22 | * 23 | * Modifications: 24 | * If applicable, add the following below the License Header, with the fields 25 | * enclosed by brackets [] replaced by your own identifying information: 26 | * "Portions Copyright [year] [name of copyright owner]" 27 | * 28 | * Contributor(s): 29 | * If you wish your version of this file to be governed by only the CDDL or 30 | * only the GPL Version 2, indicate your decision by adding "[Contributor] 31 | * elects to include this software in this distribution under the [CDDL or GPL 32 | * Version 2] license." If you don't indicate a single choice of license, a 33 | * recipient has the option to distribute your version of this file under 34 | * either the CDDL, the GPL Version 2 or to extend the choice of license to 35 | * its licensees as provided above. However, if you add GPL Version 2 code 36 | * and therefore, elected the GPL Version 2 license, then the option applies 37 | * only if the new code is made subject to such option by the copyright 38 | * holder. 39 | */ 40 | 41 | package javax.ws.rs.client; 42 | 43 | import java.util.concurrent.ExecutorService; 44 | 45 | /** 46 | * {@link RxInvoker} provider. 47 | *

48 | * {@code RxInvokerProvider} must be registered in the client runtime using {@link Client#register(Class)}. 49 | * It provides a way to plug-in support for other reactive implementations, 50 | * see {@link Invocation.Builder#rx(Class)}. 51 | * 52 | * @param {@code RxInvoker} subclass type. 53 | * @author Pavel Bucek 54 | * @author Santiago Pericas-Geertsen 55 | * @since 2.1 56 | */ 57 | public interface RxInvokerProvider { 58 | 59 | /** 60 | * Determine if this is a provider for the given {@link RxInvoker} subclass. 61 | * 62 | * @param clazz {@code RxInvoker} subclass. 63 | * @return {@code true} when this provider provides given {@code RxInvoker} subclass, {@code false} otherwise. 64 | */ 65 | public boolean isProviderFor(Class clazz); 66 | 67 | /** 68 | * Get {@link RxInvoker} implementation instance. 69 | *

70 | * The returned instance has to be thread safe. 71 | * 72 | * @param syncInvoker {@code SyncInvoker} used to execute current request. 73 | * @param executorService executor service, which should be used for executing reactive callbacks invocations. 74 | * It can be {@code null}; in that case it's up to the implementation to choose the best 75 | * {@code ExecutorService} in given environment. 76 | * @return instance of the {@code RxInvoker} subclass. 77 | * @see ClientBuilder#executorService(ExecutorService) 78 | */ 79 | public T getRxInvoker(SyncInvoker syncInvoker, ExecutorService executorService); 80 | 81 | } 82 | -------------------------------------------------------------------------------- /examples/src/main/java/jaxrs/examples/link/LinkExamples.java: -------------------------------------------------------------------------------- 1 | /* 2 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. 3 | * 4 | * Copyright (c) 2011-2015 Oracle and/or its affiliates. All rights reserved. 5 | * 6 | * The contents of this file are subject to the terms of either the GNU 7 | * General Public License Version 2 only ("GPL") or the Common Development 8 | * and Distribution License("CDDL") (collectively, the "License"). You 9 | * may not use this file except in compliance with the License. You can 10 | * obtain a copy of the License at 11 | * http://glassfish.java.net/public/CDDL+GPL_1_1.html 12 | * or packager/legal/LICENSE.txt. See the License for the specific 13 | * language governing permissions and limitations under the License. 14 | * 15 | * When distributing the software, include this License Header Notice in each 16 | * file and include the License file at packager/legal/LICENSE.txt. 17 | * 18 | * GPL Classpath Exception: 19 | * Oracle designates this particular file as subject to the "Classpath" 20 | * exception as provided by Oracle in the GPL Version 2 section of the License 21 | * file that accompanied this code. 22 | * 23 | * Modifications: 24 | * If applicable, add the following below the License Header, with the fields 25 | * enclosed by brackets [] replaced by your own identifying information: 26 | * "Portions Copyright [year] [name of copyright owner]" 27 | * 28 | * Contributor(s): 29 | * If you wish your version of this file to be governed by only the CDDL or 30 | * only the GPL Version 2, indicate your decision by adding "[Contributor] 31 | * elects to include this software in this distribution under the [CDDL or GPL 32 | * Version 2] license." If you don't indicate a single choice of license, a 33 | * recipient has the option to distribute your version of this file under 34 | * either the CDDL, the GPL Version 2 or to extend the choice of license to 35 | * its licensees as provided above. However, if you add GPL Version 2 code 36 | * and therefore, elected the GPL Version 2 license, then the option applies 37 | * only if the new code is made subject to such option by the copyright 38 | * holder. 39 | */ 40 | 41 | package jaxrs.examples.link; 42 | 43 | import java.net.URI; 44 | import java.net.URISyntaxException; 45 | 46 | import javax.ws.rs.core.Link; 47 | import javax.ws.rs.core.Response; 48 | import javax.ws.rs.core.UriBuilder; 49 | 50 | /** 51 | * LinkExamples class. 52 | * 53 | * @author Santiago Pericas-Geertsen (santiago.pericasgeertsen at oracle.com) 54 | */ 55 | public class LinkExamples { 56 | 57 | /** 58 | * 3-step process: Build URI, build Link and build Response. 59 | * 60 | * @return response. 61 | */ 62 | public Response example1() { 63 | URI uri = UriBuilder.fromUri("http://foo.bar/employee/john").build(); 64 | Link link = Link.fromUri(uri).rel("emp").title("employee").build(); 65 | return Response.ok().links(link).build(); 66 | } 67 | 68 | /** 69 | * 2-step process: Build Link from String and build Response. 70 | * 71 | * @return response. 72 | */ 73 | public Response example2() { 74 | Link link = Link.fromUri("http://foo.bar/employee/john").rel("manager").rel("friend") 75 | .title("employee").type("application/xml").build(); 76 | System.out.println("Link = " + link); 77 | return Response.ok().links(link).build(); 78 | } 79 | 80 | /** 81 | * 1-step process: Build Response and add a link directly to it 82 | * using either a String or a URI. 83 | * 84 | * @return response. 85 | * @throws URISyntaxException 86 | */ 87 | public Response example3() throws URISyntaxException { 88 | Response r; 89 | r = Response.ok().link("http://foo.bar/employee/john", "manager").build(); 90 | r = Response.ok().link(new URI("http://foo.bar/employee/john"),"manager").build(); 91 | return r; 92 | } 93 | } 94 | -------------------------------------------------------------------------------- /jaxrs-api/src/main/java/javax/ws/rs/DefaultValue.java: -------------------------------------------------------------------------------- 1 | /* 2 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. 3 | * 4 | * Copyright (c) 2010-2015 Oracle and/or its affiliates. All rights reserved. 5 | * 6 | * The contents of this file are subject to the terms of either the GNU 7 | * General Public License Version 2 only ("GPL") or the Common Development 8 | * and Distribution License("CDDL") (collectively, the "License"). You 9 | * may not use this file except in compliance with the License. You can 10 | * obtain a copy of the License at 11 | * http://glassfish.java.net/public/CDDL+GPL_1_1.html 12 | * or packager/legal/LICENSE.txt. See the License for the specific 13 | * language governing permissions and limitations under the License. 14 | * 15 | * When distributing the software, include this License Header Notice in each 16 | * file and include the License file at packager/legal/LICENSE.txt. 17 | * 18 | * GPL Classpath Exception: 19 | * Oracle designates this particular file as subject to the "Classpath" 20 | * exception as provided by Oracle in the GPL Version 2 section of the License 21 | * file that accompanied this code. 22 | * 23 | * Modifications: 24 | * If applicable, add the following below the License Header, with the fields 25 | * enclosed by brackets [] replaced by your own identifying information: 26 | * "Portions Copyright [year] [name of copyright owner]" 27 | * 28 | * Contributor(s): 29 | * If you wish your version of this file to be governed by only the CDDL or 30 | * only the GPL Version 2, indicate your decision by adding "[Contributor] 31 | * elects to include this software in this distribution under the [CDDL or GPL 32 | * Version 2] license." If you don't indicate a single choice of license, a 33 | * recipient has the option to distribute your version of this file under 34 | * either the CDDL, the GPL Version 2 or to extend the choice of license to 35 | * its licensees as provided above. However, if you add GPL Version 2 code 36 | * and therefore, elected the GPL Version 2 license, then the option applies 37 | * only if the new code is made subject to such option by the copyright 38 | * holder. 39 | */ 40 | 41 | package javax.ws.rs; 42 | 43 | import java.lang.annotation.Documented; 44 | import java.lang.annotation.ElementType; 45 | import java.lang.annotation.Retention; 46 | import java.lang.annotation.RetentionPolicy; 47 | import java.lang.annotation.Target; 48 | 49 | /** 50 | * Defines the default value of request meta-data that is bound using one of the 51 | * following annotations: 52 | * {@link javax.ws.rs.PathParam}, 53 | * {@link javax.ws.rs.QueryParam}, 54 | * {@link javax.ws.rs.MatrixParam}, 55 | * {@link javax.ws.rs.CookieParam}, 56 | * {@link javax.ws.rs.FormParam}, 57 | * or {@link javax.ws.rs.HeaderParam}. 58 | * The default value is used if the corresponding meta-data is not present in the 59 | * request. 60 | *

61 | * If the type of the annotated parameter is {@link java.util.List}, 62 | * {@link java.util.Set} or {@link java.util.SortedSet} then the resulting collection 63 | * will have a single entry mapped from the supplied default value. 64 | *

65 | *

66 | * If this annotation is not used and the corresponding meta-data is not 67 | * present in the request, the value will be an empty collection for 68 | * {@code List}, {@code Set} or {@code SortedSet}, {@code null} for 69 | * other object types, and the Java-defined default for primitive types. 70 | *

71 | * 72 | * @author Paul Sandoz 73 | * @author Marc Hadley 74 | * @see PathParam 75 | * @see QueryParam 76 | * @see FormParam 77 | * @see HeaderParam 78 | * @see MatrixParam 79 | * @see CookieParam 80 | * @since 1.0 81 | */ 82 | @Target({ElementType.PARAMETER, ElementType.METHOD, ElementType.FIELD}) 83 | @Retention(RetentionPolicy.RUNTIME) 84 | @Documented 85 | public @interface DefaultValue { 86 | 87 | /** 88 | * The specified default value. 89 | */ 90 | String value(); 91 | } 92 | -------------------------------------------------------------------------------- /jaxrs-api/src/main/java/javax/ws/rs/container/ResourceContext.java: -------------------------------------------------------------------------------- 1 | /* 2 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. 3 | * 4 | * Copyright (c) 2012-2015 Oracle and/or its affiliates. All rights reserved. 5 | * 6 | * The contents of this file are subject to the terms of either the GNU 7 | * General Public License Version 2 only ("GPL") or the Common Development 8 | * and Distribution License("CDDL") (collectively, the "License"). You 9 | * may not use this file except in compliance with the License. You can 10 | * obtain a copy of the License at 11 | * http://glassfish.java.net/public/CDDL+GPL_1_1.html 12 | * or packager/legal/LICENSE.txt. See the License for the specific 13 | * language governing permissions and limitations under the License. 14 | * 15 | * When distributing the software, include this License Header Notice in each 16 | * file and include the License file at packager/legal/LICENSE.txt. 17 | * 18 | * GPL Classpath Exception: 19 | * Oracle designates this particular file as subject to the "Classpath" 20 | * exception as provided by Oracle in the GPL Version 2 section of the License 21 | * file that accompanied this code. 22 | * 23 | * Modifications: 24 | * If applicable, add the following below the License Header, with the fields 25 | * enclosed by brackets [] replaced by your own identifying information: 26 | * "Portions Copyright [year] [name of copyright owner]" 27 | * 28 | * Contributor(s): 29 | * If you wish your version of this file to be governed by only the CDDL or 30 | * only the GPL Version 2, indicate your decision by adding "[Contributor] 31 | * elects to include this software in this distribution under the [CDDL or GPL 32 | * Version 2] license." If you don't indicate a single choice of license, a 33 | * recipient has the option to distribute your version of this file under 34 | * either the CDDL, the GPL Version 2 or to extend the choice of license to 35 | * its licensees as provided above. However, if you add GPL Version 2 code 36 | * and therefore, elected the GPL Version 2 license, then the option applies 37 | * only if the new code is made subject to such option by the copyright 38 | * holder. 39 | */ 40 | 41 | package javax.ws.rs.container; 42 | 43 | import javax.ws.rs.core.Context; 44 | 45 | /** 46 | * The resource context provides access to instances of resource classes. 47 | *

48 | * This interface can be injected using the {@link Context} annotation. 49 | *

50 | *

51 | * The resource context can be utilized when instances of managed resource 52 | * classes are to be returned by sub-resource locator methods. Such instances 53 | * will be injected and managed within the declared scope just like instances 54 | * of root resource classes. 55 | *

56 | * 57 | * @author Marek Potociar 58 | */ 59 | public interface ResourceContext { 60 | 61 | /** 62 | * Get a resolved instance of a resource or sub-resource class. 63 | *

64 | * The resolved resource instance is properly initialized in the context of the 65 | * current request processing scope. The scope of the resolved resource instance 66 | * depends on the managing container. For resources managed by JAX-RS container 67 | * the default scope is per-request. 68 | *

69 | * 70 | * @param the type of the resource class. 71 | * @param resourceClass the resource class. 72 | * @return an instance if it could be resolved, otherwise {@code null}. 73 | */ 74 | public T getResource(Class resourceClass); 75 | 76 | /** 77 | * Initialize the resource or sub-resource instance. 78 | * 79 | * All JAX-RS injectable fields in the resource instance will be properly initialized in 80 | * the context of the current request processing scope. 81 | * 82 | * @param resource instance type. 83 | * @param resource resource instance. 84 | * @return initialized (same) resource instance. 85 | */ 86 | public T initResource(T resource); 87 | } 88 | -------------------------------------------------------------------------------- /jaxrs-api/src/main/java/javax/ws/rs/ext/WriterInterceptor.java: -------------------------------------------------------------------------------- 1 | /* 2 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. 3 | * 4 | * Copyright (c) 2011-2015 Oracle and/or its affiliates. All rights reserved. 5 | * 6 | * The contents of this file are subject to the terms of either the GNU 7 | * General Public License Version 2 only ("GPL") or the Common Development 8 | * and Distribution License("CDDL") (collectively, the "License"). You 9 | * may not use this file except in compliance with the License. You can 10 | * obtain a copy of the License at 11 | * http://glassfish.java.net/public/CDDL+GPL_1_1.html 12 | * or packager/legal/LICENSE.txt. See the License for the specific 13 | * language governing permissions and limitations under the License. 14 | * 15 | * When distributing the software, include this License Header Notice in each 16 | * file and include the License file at packager/legal/LICENSE.txt. 17 | * 18 | * GPL Classpath Exception: 19 | * Oracle designates this particular file as subject to the "Classpath" 20 | * exception as provided by Oracle in the GPL Version 2 section of the License 21 | * file that accompanied this code. 22 | * 23 | * Modifications: 24 | * If applicable, add the following below the License Header, with the fields 25 | * enclosed by brackets [] replaced by your own identifying information: 26 | * "Portions Copyright [year] [name of copyright owner]" 27 | * 28 | * Contributor(s): 29 | * If you wish your version of this file to be governed by only the CDDL or 30 | * only the GPL Version 2, indicate your decision by adding "[Contributor] 31 | * elects to include this software in this distribution under the [CDDL or GPL 32 | * Version 2] license." If you don't indicate a single choice of license, a 33 | * recipient has the option to distribute your version of this file under 34 | * either the CDDL, the GPL Version 2 or to extend the choice of license to 35 | * its licensees as provided above. However, if you add GPL Version 2 code 36 | * and therefore, elected the GPL Version 2 license, then the option applies 37 | * only if the new code is made subject to such option by the copyright 38 | * holder. 39 | */ 40 | 41 | package javax.ws.rs.ext; 42 | 43 | /** 44 | * Interface for message body writer interceptors that wrap around calls 45 | * to {@link javax.ws.rs.ext.MessageBodyWriter#writeTo}. 46 | * 47 | *

48 | * Providers implementing {@code WriterInterceptor} contract must be either programmatically 49 | * registered in a JAX-RS runtime or must be annotated with 50 | * {@link javax.ws.rs.ext.Provider @Provider} annotation to be automatically discovered 51 | * by the JAX-RS runtime during a provider scanning phase. 52 | * Message body interceptor instances may also be discovered and 53 | * bound {@link javax.ws.rs.container.DynamicFeature dynamically} to particular resource methods. 54 | *

55 | * 56 | * @author Santiago Pericas-Geertsen 57 | * @author Bill Burke 58 | * @author Marek Potociar 59 | * @see MessageBodyWriter 60 | * @since 2.0 61 | */ 62 | public interface WriterInterceptor { 63 | 64 | /** 65 | * Interceptor method wrapping calls to {@link MessageBodyWriter#writeTo} method. 66 | * The parameters of the wrapped method called are available from {@code context}. 67 | * Implementations of this method SHOULD explicitly call 68 | * {@link WriterInterceptorContext#proceed} to invoke the next interceptor in the chain, 69 | * and ultimately the wrapped {@code MessageBodyWriter.writeTo} method. 70 | * 71 | * @param context invocation context. 72 | * @throws java.io.IOException if an IO error arises or is thrown by the wrapped 73 | * {@code MessageBodyWriter.writeTo} method. 74 | * @throws javax.ws.rs.WebApplicationException 75 | * thrown by the wrapped {@code MessageBodyWriter.writeTo} method. 76 | */ 77 | void aroundWriteTo(WriterInterceptorContext context) 78 | throws java.io.IOException, javax.ws.rs.WebApplicationException; 79 | } 80 | -------------------------------------------------------------------------------- /jaxrs-api/src/main/java/javax/ws/rs/Produces.java: -------------------------------------------------------------------------------- 1 | /* 2 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. 3 | * 4 | * Copyright (c) 2010-2015 Oracle and/or its affiliates. All rights reserved. 5 | * 6 | * The contents of this file are subject to the terms of either the GNU 7 | * General Public License Version 2 only ("GPL") or the Common Development 8 | * and Distribution License("CDDL") (collectively, the "License"). You 9 | * may not use this file except in compliance with the License. You can 10 | * obtain a copy of the License at 11 | * http://glassfish.java.net/public/CDDL+GPL_1_1.html 12 | * or packager/legal/LICENSE.txt. See the License for the specific 13 | * language governing permissions and limitations under the License. 14 | * 15 | * When distributing the software, include this License Header Notice in each 16 | * file and include the License file at packager/legal/LICENSE.txt. 17 | * 18 | * GPL Classpath Exception: 19 | * Oracle designates this particular file as subject to the "Classpath" 20 | * exception as provided by Oracle in the GPL Version 2 section of the License 21 | * file that accompanied this code. 22 | * 23 | * Modifications: 24 | * If applicable, add the following below the License Header, with the fields 25 | * enclosed by brackets [] replaced by your own identifying information: 26 | * "Portions Copyright [year] [name of copyright owner]" 27 | * 28 | * Contributor(s): 29 | * If you wish your version of this file to be governed by only the CDDL or 30 | * only the GPL Version 2, indicate your decision by adding "[Contributor] 31 | * elects to include this software in this distribution under the [CDDL or GPL 32 | * Version 2] license." If you don't indicate a single choice of license, a 33 | * recipient has the option to distribute your version of this file under 34 | * either the CDDL, the GPL Version 2 or to extend the choice of license to 35 | * its licensees as provided above. However, if you add GPL Version 2 code 36 | * and therefore, elected the GPL Version 2 license, then the option applies 37 | * only if the new code is made subject to such option by the copyright 38 | * holder. 39 | */ 40 | 41 | package javax.ws.rs; 42 | 43 | import java.lang.annotation.Documented; 44 | import java.lang.annotation.ElementType; 45 | import java.lang.annotation.Inherited; 46 | import java.lang.annotation.Retention; 47 | import java.lang.annotation.RetentionPolicy; 48 | import java.lang.annotation.Target; 49 | 50 | /** 51 | * Defines the media type(s) that the methods of a resource class or 52 | * {@link javax.ws.rs.ext.MessageBodyWriter} can produce. 53 | * If not specified then a container will assume that any type can be produced. 54 | * Method level annotations override a class level annotation. A container 55 | * is responsible for ensuring that the method invoked is capable of producing 56 | * one of the media types requested in the HTTP request. If no such method is 57 | * available the container must respond with a HTTP "406 Not Acceptable" as 58 | * specified by RFC 2616. 59 | * 60 | *

A method for which there is a single-valued {@code @Produces} 61 | * is not required to set the media type of representations that it produces: 62 | * the container will use the value of the {@code @Produces} when 63 | * sending a response.

64 | * 65 | * @author Paul Sandoz 66 | * @author Marc Hadley 67 | * @see javax.ws.rs.ext.MessageBodyWriter 68 | * @since 1.0 69 | */ 70 | @Inherited 71 | @Target({ElementType.TYPE, ElementType.METHOD}) 72 | @Retention(RetentionPolicy.RUNTIME) 73 | @Documented 74 | public @interface Produces { 75 | 76 | /** 77 | * A list of media types. Each entry may specify a single type or consist 78 | * of a comma separated list of types, with any leading or trailing white-spaces 79 | * in a single type entry being ignored. For example: 80 | *
81 |      *  {"image/jpeg, image/gif ", " image/png"}
82 |      * 
83 | * Use of the comma-separated form allows definition of a common string constant 84 | * for use on multiple targets. 85 | */ 86 | String[] value() default "*/*"; 87 | } 88 | -------------------------------------------------------------------------------- /jaxrs-api/src/main/java/javax/ws/rs/ext/ParamConverterProvider.java: -------------------------------------------------------------------------------- 1 | /* 2 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. 3 | * 4 | * Copyright (c) 2012-2015 Oracle and/or its affiliates. All rights reserved. 5 | * 6 | * The contents of this file are subject to the terms of either the GNU 7 | * General Public License Version 2 only ("GPL") or the Common Development 8 | * and Distribution License("CDDL") (collectively, the "License"). You 9 | * may not use this file except in compliance with the License. You can 10 | * obtain a copy of the License at 11 | * http://glassfish.java.net/public/CDDL+GPL_1_1.html 12 | * or packager/legal/LICENSE.txt. See the License for the specific 13 | * language governing permissions and limitations under the License. 14 | * 15 | * When distributing the software, include this License Header Notice in each 16 | * file and include the License file at packager/legal/LICENSE.txt. 17 | * 18 | * GPL Classpath Exception: 19 | * Oracle designates this particular file as subject to the "Classpath" 20 | * exception as provided by Oracle in the GPL Version 2 section of the License 21 | * file that accompanied this code. 22 | * 23 | * Modifications: 24 | * If applicable, add the following below the License Header, with the fields 25 | * enclosed by brackets [] replaced by your own identifying information: 26 | * "Portions Copyright [year] [name of copyright owner]" 27 | * 28 | * Contributor(s): 29 | * If you wish your version of this file to be governed by only the CDDL or 30 | * only the GPL Version 2, indicate your decision by adding "[Contributor] 31 | * elects to include this software in this distribution under the [CDDL or GPL 32 | * Version 2] license." If you don't indicate a single choice of license, a 33 | * recipient has the option to distribute your version of this file under 34 | * either the CDDL, the GPL Version 2 or to extend the choice of license to 35 | * its licensees as provided above. However, if you add GPL Version 2 code 36 | * and therefore, elected the GPL Version 2 license, then the option applies 37 | * only if the new code is made subject to such option by the copyright 38 | * holder. 39 | */ 40 | 41 | package javax.ws.rs.ext; 42 | 43 | import java.lang.annotation.Annotation; 44 | import java.lang.reflect.Type; 45 | 46 | /** 47 | * Contract for a provider of {@link ParamConverter} instances. 48 | *

49 | * Providers implementing {@code ParamConverterProvider} contract must be either programmatically 50 | * registered in a JAX-RS runtime or must be annotated with 51 | * {@link javax.ws.rs.ext.Provider @Provider} annotation to be automatically discovered 52 | * by the JAX-RS runtime during a provider scanning phase. 53 | *

54 | * 55 | * @author Marek Potociar 56 | * @since 2.0 57 | */ 58 | public interface ParamConverterProvider { 59 | 60 | /** 61 | * Obtain a {@link ParamConverter} that can provide from/to string conversion 62 | * for an instance of a particular Java type. 63 | * 64 | * @param the supported Java type convertible to/from a {@code String} format. 65 | * @param rawType the raw type of the object to be converted. 66 | * @param genericType the type of object to be converted. E.g. if an String value 67 | * representing the injected request parameter 68 | * is to be converted into a method parameter, this will be the 69 | * formal type of the method parameter as returned by {@code Class.getGenericParameterTypes}. 70 | * @param annotations an array of the annotations associated with the convertible 71 | * parameter instance. E.g. if a string value is to be converted into a method parameter, 72 | * this would be the annotations on that parameter as returned by 73 | * {@link java.lang.reflect.Method#getParameterAnnotations}. 74 | * @return the string converter, otherwise {@code null}. 75 | */ 76 | public ParamConverter getConverter(Class rawType, Type genericType, Annotation annotations[]); 77 | } 78 | -------------------------------------------------------------------------------- /jaxrs-api/src/main/java/javax/ws/rs/container/CompletionCallback.java: -------------------------------------------------------------------------------- 1 | /* 2 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. 3 | * 4 | * Copyright (c) 2012-2015 Oracle and/or its affiliates. All rights reserved. 5 | * 6 | * The contents of this file are subject to the terms of either the GNU 7 | * General Public License Version 2 only ("GPL") or the Common Development 8 | * and Distribution License("CDDL") (collectively, the "License"). You 9 | * may not use this file except in compliance with the License. You can 10 | * obtain a copy of the License at 11 | * http://glassfish.java.net/public/CDDL+GPL_1_1.html 12 | * or packager/legal/LICENSE.txt. See the License for the specific 13 | * language governing permissions and limitations under the License. 14 | * 15 | * When distributing the software, include this License Header Notice in each 16 | * file and include the License file at packager/legal/LICENSE.txt. 17 | * 18 | * GPL Classpath Exception: 19 | * Oracle designates this particular file as subject to the "Classpath" 20 | * exception as provided by Oracle in the GPL Version 2 section of the License 21 | * file that accompanied this code. 22 | * 23 | * Modifications: 24 | * If applicable, add the following below the License Header, with the fields 25 | * enclosed by brackets [] replaced by your own identifying information: 26 | * "Portions Copyright [year] [name of copyright owner]" 27 | * 28 | * Contributor(s): 29 | * If you wish your version of this file to be governed by only the CDDL or 30 | * only the GPL Version 2, indicate your decision by adding "[Contributor] 31 | * elects to include this software in this distribution under the [CDDL or GPL 32 | * Version 2] license." If you don't indicate a single choice of license, a 33 | * recipient has the option to distribute your version of this file under 34 | * either the CDDL, the GPL Version 2 or to extend the choice of license to 35 | * its licensees as provided above. However, if you add GPL Version 2 code 36 | * and therefore, elected the GPL Version 2 license, then the option applies 37 | * only if the new code is made subject to such option by the copyright 38 | * holder. 39 | */ 40 | 41 | package javax.ws.rs.container; 42 | 43 | /** 44 | * A request processing callback that receives request processing completion events. 45 | *

46 | * A completion callback is invoked when the whole request processing is over, i.e. 47 | * once a response for the request has been processed and sent back to the client 48 | * or in when an unmapped exception or error is being propagated to the container. 49 | *

50 | * 51 | * @author Marek Potociar 52 | * @since 2.0 53 | */ 54 | public interface CompletionCallback { 55 | /** 56 | * A completion callback notification method that will be invoked when the request 57 | * processing is finished, after a response is processed and is sent back to the 58 | * client or when an unmapped throwable has been propagated to the hosting I/O 59 | * container. 60 | *

61 | * An unmapped throwable is propagated to the hosting I/O container in case no 62 | * {@link javax.ws.rs.ext.ExceptionMapper exception mapper} has been found for 63 | * a throwable indicating a request processing failure. 64 | * In this case a non-{@code null} unmapped throwable instance is passed to the method. 65 | * Note that the throwable instance represents the actual unmapped exception thrown 66 | * during the request processing, before it has been wrapped into an I/O container-specific 67 | * exception that was used to propagate the throwable to the hosting I/O container. 68 | *

69 | * 70 | * @param throwable is {@code null}, if the request processing has completed with a response 71 | * that has been sent to the client. In case the request processing resulted 72 | * in an unmapped exception or error that has been propagated to the hosting 73 | * I/O container, this parameter contains the unmapped exception instance. 74 | */ 75 | public void onComplete(Throwable throwable); 76 | } 77 | --------------------------------------------------------------------------------