Skip to content
Permalink
Browse files
Updates for Juneau 8.2.0
  • Loading branch information
jamesbognar committed Oct 19, 2020
1 parent bac67b4 commit c03eb202329a1c67776473ed374a5032c9b8c371
Showing 20 changed files with 1,651 additions and 190 deletions.
@@ -1,3 +1,16 @@
# ***************************************************************************************************************************
# * 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. *
# ***************************************************************************************************************************

FROM maven:3.5-jdk-8 as build

COPY . .
@@ -12,7 +12,7 @@
// ***************************************************************************************************************************
package org.apache.juneau.petstore;

import static org.apache.juneau.http.HttpMethodName.*;
import static org.apache.juneau.http.HttpMethod.*;

import java.util.*;

@@ -71,7 +71,7 @@ public Pet apply(CreatePet x) {
this.name = x.getName();
this.price = x.getPrice();
this.species = x.getSpecies();
this.tags = x.getTags() == null ? null : Arrays.asList(x.getTags());
this.tags = new ArrayList<>(Arrays.asList(x.getTags()));
return this;
}

@@ -86,7 +86,7 @@ public Pet apply(UpdatePet x) {
this.name = x.getName();
this.price = x.getPrice();
this.species = x.getSpecies();
this.tags = x.getTags() == null ? null : Arrays.asList(x.getTags());
this.tags = x.getTags() == null ? null : new ArrayList<>(Arrays.asList(x.getTags()));
this.status = x.getStatus();
return this;
}
@@ -180,7 +180,7 @@ public Pet tags(List<String> value) {
* @return This object (for method chaining).
*/
public Pet tags(String...value) {
this.tags = Arrays.asList(value);
this.tags = new ArrayList<>(Arrays.asList(value));
return this;
}

@@ -17,16 +17,11 @@
import java.io.*;
import java.util.*;

import org.apache.http.auth.AuthScope;
import org.apache.http.auth.Credentials;
import org.apache.http.auth.UsernamePasswordCredentials;
import org.apache.http.client.CredentialsProvider;
import org.apache.http.impl.client.BasicCredentialsProvider;
import org.apache.juneau.json.*;
import org.apache.juneau.marshall.*;
import org.apache.juneau.parser.*;
import org.apache.juneau.petstore.dto.*;
import org.apache.juneau.rest.client.*;
import org.apache.juneau.rest.client2.*;

/**
* Example code showing how to connect to the PetStore application using a remote proxy.
@@ -39,36 +34,22 @@ public class Main {

private static final JsonParser JSON_PARSER = JsonParser.create().ignoreUnknownBeanProperties().build();

@SuppressWarnings("deprecation")
public static void main(String[] args) {
public static void main(String[] args) throws ParseException, IOException {

// TODO - This is broken until we can update to Juneau 8.1.3 which has a fix for handling how Spring Security
// processes Basic Auth requests.
RestClient restClient = RestClient.create().simpleJson().basicAuth("localhost", 5000, "admin", "password").build();

// Set up BASIC auth.
// User/passwords are hardcoded in SpringSecurityConfig.
Credentials up = new UsernamePasswordCredentials("admin", "password");
CredentialsProvider p = new BasicCredentialsProvider();
p.setCredentials(AuthScope.ANY, up);
// Instantiate our proxy.
PetStore petStore = restClient.getRemote(PetStore.class, "http://localhost:5000");

// Create a RestClient with JSON serialization support.
try (RestClient rc = RestClient.create(SimpleJsonSerializer.class, JsonParser.class).defaultCredentialsProvider(p).build()) {
// Print out the pets in the store.
Collection<Pet> pets = petStore.getPets();

// Instantiate our proxy.
PetStore petStore = rc.getRemote(PetStore.class, "http://localhost:5000");
// Pretty-print them to SYSOUT.
SimpleJson.DEFAULT_READABLE.println(pets);

// Print out the pets in the store.
Collection<Pet> pets = petStore.getPets();
// Initialize the application through REST calls.
init(new PrintWriter(System.out), petStore);

// Pretty-print them to SYSOUT.
SimpleJson.DEFAULT_READABLE.println(pets);

// Initialize the application through REST calls.
init(new PrintWriter(System.out), petStore);

} catch (Exception e) {
e.printStackTrace();
}
}

/**
@@ -41,7 +41,7 @@

<maven.javadoc.skip>true</maven.javadoc.skip>

<juneau.version>8.1.2</juneau.version>
<juneau.version>8.2.0</juneau.version>
<javax.inject.version>1</javax.inject.version>
<servlet.version>3.1.0</servlet.version>
<hibernate.version>5.0.9.Final</hibernate.version>
@@ -122,7 +122,7 @@
<dependency>
<groupId>org.apache.juneau</groupId>
<artifactId>juneau-rest-mock</artifactId>
<version>8.1.2</version>
<version>${juneau.version}</version>
<scope>test</scope>
</dependency>

@@ -12,10 +12,14 @@
// ***************************************************************************************************************************
package org.apache.juneau.petstore;

import java.io.*;

import org.apache.juneau.petstore.service.*;
import org.apache.juneau.rest.springboot.JuneauRestInitializer;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.cache.annotation.EnableCaching;
import org.springframework.context.*;
import org.springframework.data.jpa.repository.config.EnableJpaRepositories;

/**
@@ -28,12 +32,18 @@
public class App {

public static void main(String[] args) {
new App().start(args);
}
new App().start(args);
}

protected void start(String[] args) {
ConfigurableApplicationContext ctx = new SpringApplicationBuilder(App.class)
.initializers(new JuneauRestInitializer(App.class)) // Needed for Juneau resources as injectible Spring beans.
.run(args);

protected void start(String[] args) {
new SpringApplicationBuilder(App.class)
.initializers(new JuneauRestInitializer(App.class)) // Needed for Juneau resources as injectible Spring beans.
.run(args);
}
try {
ctx.getBean(PetStoreService.class).initDirect(new PrintWriter(System.out));
} catch (Exception e) {
e.printStackTrace();
}
}
}
@@ -13,7 +13,7 @@
package org.apache.juneau.petstore.rest;

import static org.apache.juneau.dto.swagger.ui.SwaggerUI.*;
import static org.apache.juneau.http.HttpMethodName.*;
import static org.apache.juneau.http.HttpMethod.*;
import static org.apache.juneau.http.response.Ok.*;

import java.util.*;
@@ -16,7 +16,6 @@
import org.apache.juneau.rest.*;
import org.apache.juneau.rest.annotation.*;
import org.apache.juneau.rest.widget.*;
import org.apache.juneau.serializer.annotation.*;

/**
* Sample REST resource showing how to implement a "router" resource page.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit c03eb20

Please sign in to comment.