|
Apache CXF example source code file (BookStoreWithInterface2.java)
The Apache CXF BookStoreWithInterface2.java source code/** * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ /** * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ package org.apache.cxf.systest.jaxrs; import javax.servlet.ServletContext; import javax.ws.rs.core.Context; public class BookStoreWithInterface2 extends BookStoreStorage implements BookInterface { private ServletContext servletContext; public BookStoreWithInterface2() { Book book = new Book(); book.setId(bookId); book.setName("CXF in Action"); books.put(book.getId(), book); } public BookStoreWithInterface2(@Context ServletContext scontext) { this(); this.servletContext = scontext; } public Book getThatBook(Long id, String s) throws BookNotFoundFault { if (servletContext == null) { throw new RuntimeException(); } if (!id.toString().equals(s)) { throw new RuntimeException(); } return doGetBook(id); } public Book getThatBook(Long id) throws BookNotFoundFault { if (servletContext == null) { throw new RuntimeException(); } return doGetBook(id); } private Book doGetBook(Long id) throws BookNotFoundFault { System.out.println("----invoking getBook with id: " + id); Book book = books.get(id); if (book != null) { return book; } else { BookNotFoundDetails details = new BookNotFoundDetails(); details.setId(id); throw new BookNotFoundFault(details); } } public Book getThatBook() throws BookNotFoundFault { if (servletContext == null) { throw new RuntimeException(); } return books.get(123L); } } Other Apache CXF examples (source code examples)Here is a short list of links related to this Apache CXF BookStoreWithInterface2.java source code file: |
... this post is sponsored by my books ... | |
#1 New Release! |
FP Best Seller |
Copyright 1998-2021 Alvin Alexander, alvinalexander.com
All Rights Reserved.
A percentage of advertising revenue from
pages under the /java/jwarehouse
URI on this website is
paid back to open source projects.