[20/53] [partial] incubator-juneau git commit: Merge changes from GitHub repo.
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/1b4f98a0/org.apache.juneau.server/src/main/java/org/apache/juneau/server/vars/ServletInitParamVar.java -- diff --git a/org.apache.juneau.server/src/main/java/org/apache/juneau/server/vars/ServletInitParamVar.java b/org.apache.juneau.server/src/main/java/org/apache/juneau/server/vars/ServletInitParamVar.java new file mode 100644 index 000..3db7517 --- /dev/null +++ b/org.apache.juneau.server/src/main/java/org/apache/juneau/server/vars/ServletInitParamVar.java @@ -0,0 +1,48 @@ +/*** + * 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.juneau.server.vars; + +import org.apache.juneau.server.*; +import org.apache.juneau.svl.*; + +/** + * Servlet init parameter variable resolver. + * + * The format for this var is "$I{key}" or "$I{key,defaultValue}". + * + * This variable resolver requires that a {@link RestRequest} object be set as a context object on the resolver or a + * session object on the resolver session. + * + * Values are pulled from the {@link RestServlet#getInitParameter(String)} method. + * + * Since this is a {@link SimpleVar}, any variables contained in the result will be recursively resolved. + * Likewise, if the arguments contain any variables, those will be resolved before they are passed to this var. + * + * @see org.apache.juneau.svl + * @author James Bognar (james.bog...@salesforce.com) + */ +public class ServletInitParamVar extends DefaultingVar { + + /** +* Constructor. +*/ + public ServletInitParamVar() { + super("I"); + } + + @Override /* Var */ + public String resolve(VarResolverSession session, String key) { + return session.getSessionObject(RestRequest.class, RequestVar.SESSION_req).getServlet().getServletConfig().getInitParameter(key); + } +} http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/1b4f98a0/org.apache.juneau.server/src/main/java/org/apache/juneau/server/vars/UrlEncodeVar.java -- diff --git a/org.apache.juneau.server/src/main/java/org/apache/juneau/server/vars/UrlEncodeVar.java b/org.apache.juneau.server/src/main/java/org/apache/juneau/server/vars/UrlEncodeVar.java new file mode 100644 index 000..f3c9e72 --- /dev/null +++ b/org.apache.juneau.server/src/main/java/org/apache/juneau/server/vars/UrlEncodeVar.java @@ -0,0 +1,45 @@ +/*** + * 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.juneau.server.vars; + +import org.apache.juneau.server.*; +import org.apache.juneau.svl.*; + +/** + * URL-encoding variable resolver. + * + * The format for this var is "$UE{innerValue}". + * + * This variable takes the contents inside the variable and replaces it with a value returned by calling {@link RestUtils#encode(String)}). + * + * Since this is a {@link SimpleVar}, any variables
[11/53] [partial] incubator-juneau git commit: Merge changes from GitHub repo.
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/1b4f98a0/org.apache.juneau/src/main/java/org/apache/juneau/dto/atom/package.html -- diff --git a/org.apache.juneau/src/main/java/org/apache/juneau/dto/atom/package.html b/org.apache.juneau/src/main/java/org/apache/juneau/dto/atom/package.html new file mode 100644 index 000..3fbcf3b --- /dev/null +++ b/org.apache.juneau/src/main/java/org/apache/juneau/dto/atom/package.html @@ -0,0 +1,585 @@ + + + + + + + /* For viewing in Page Designer */ + @IMPORT url("../../../../../../../javadoc.css"); + + /* For viewing in REST interface */ + @IMPORT url("../htdocs/javadoc.css"); + body { + margin: 20px; + } + + + /* Replace all @code and @link tags. */ + window.onload = function() { + document.body.innerHTML = document.body.innerHTML.replace(/\{\@code ([^\}]+)\}/g, '$1
'); + document.body.innerHTML = document.body.innerHTML.replace(/\{\@link (([^\}]+)\.)?([^\.\}]+)\}/g, '$3
'); + } + + + +ATOM Data Transfer Objects + + function toggle(x) { + var div = x.nextSibling; + while (div != null && div.nodeType != 1) + div = div.nextSibling; + if (div != null) { + var d = div.style.display; + if (d == 'block' || d == '') { + div.style.display = 'none'; + x.className += " closed"; + } else { + div.style.display = 'block'; + x.className = x.className.replace(/(?:^|\s)closed(?!\S)/g , '' ); + } + } + } + +Table of Contents + + Overview + + Serializing ATOM feeds + + ATOM/JSON + ATOM/RDF/XML + ATOM/HTML + + Parsing ATOM feeds + + + + + + +1 - Overview + + + Juneau supports generation and consumption of ATOM feeds through the use of DTOs (Data Transfer Objects). + It uses existing support for serializing and parsing POJOs to and from XML to define these ATOM objects. + + + The examples shown here are pulled from the AtomFeedResource class in the org.apache.juneau.sample.war project. + + + + + + 1.1 - Serializing ATOM feeds + + + The Juneau ATOM feed DTOs are simply beans with fluent-style setters. + The following code shows a feed being created programmatically: + + + Feed feed = new Feed() + .setTitle(new Text("text", "Juneau ATOM specification")) + .setSubTitle(new Text("html", "A emlot/em of effort went into making this effortless")) + .setUpdated(parseDateTime("2013-05-08T12:29:29Z")) + .setId(new Id("tag:juneau.sample.com,2013:1")) + .addLinks( + new Link("alternate", "text/html", "http://www.sample.com/;).setHreflang("en"), + new Link("self", "application/atom+xml", "http://www.sample.com/feed.atom;) + ) + .setRights(new Text("Copyright (c) 2013, IBM")) + .setGenerator(new Generator("Juneau").setUri(new URI("http://juneau.ibm..com/;)).setVersion("1.0")) + .addEntries( + new Entry() + .setTitle(new Text("Juneau ATOM specification snapshot")) + .addLinks( + new Link("alternate", "text/html", "http://www.sample.com/2012/05/08/juneau.atom;), + new Link("enclosure", "audio/mpeg", ""http://www.sample.com/audio/juneau_podcast.mp3;).setLength(12345) + ) + .setId(new Id("tag:juneau.sample.com,2013:1.2345")) + .setUpdated(parseDateTime("2013-05-08T12:29:29Z")) + .setPublished(parseDateTime("2013-05-08T12:29:29Z")) + .addAuthors(new Person("James Bognar").setUri(new URI("http://www.sample.com/;)).setEmail("james.bog...@salesforce.com")) + .addContributors( + new Person("Barry M. Caceres") + ) + .setContent( + new Content() +
[46/53] [partial] incubator-juneau git commit: Merge changes from GitHub repo.
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/1b4f98a0/org.apache.juneau.microservice/.settings/org.eclipse.jdt.core.prefs -- diff --git a/org.apache.juneau.microservice/.settings/org.eclipse.jdt.core.prefs b/org.apache.juneau.microservice/.settings/org.eclipse.jdt.core.prefs new file mode 100755 index 000..54e4bf5 --- /dev/null +++ b/org.apache.juneau.microservice/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,306 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.6 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.doc.comment.support=enabled +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning +org.eclipse.jdt.core.compiler.problem.invalidJavadoc=warning +org.eclipse.jdt.core.compiler.problem.invalidJavadocTags=enabled +org.eclipse.jdt.core.compiler.problem.invalidJavadocTagsDeprecatedRef=disabled +org.eclipse.jdt.core.compiler.problem.invalidJavadocTagsNotVisibleRef=disabled +org.eclipse.jdt.core.compiler.problem.invalidJavadocTagsVisibility=protected +org.eclipse.jdt.core.compiler.problem.missingJavadocComments=warning +org.eclipse.jdt.core.compiler.problem.missingJavadocCommentsOverriding=disabled +org.eclipse.jdt.core.compiler.problem.missingJavadocCommentsVisibility=protected +org.eclipse.jdt.core.compiler.problem.missingJavadocTagDescription=return_tag +org.eclipse.jdt.core.compiler.problem.missingJavadocTags=warning +org.eclipse.jdt.core.compiler.problem.missingJavadocTagsMethodTypeParameters=disabled +org.eclipse.jdt.core.compiler.problem.missingJavadocTagsOverriding=disabled +org.eclipse.jdt.core.compiler.problem.missingJavadocTagsVisibility=protected +org.eclipse.jdt.core.compiler.source=1.6 +org.eclipse.jdt.core.formatter.align_type_members_on_columns=false +org.eclipse.jdt.core.formatter.alignment_for_arguments_in_allocation_expression=16 +org.eclipse.jdt.core.formatter.alignment_for_arguments_in_annotation=0 +org.eclipse.jdt.core.formatter.alignment_for_arguments_in_enum_constant=16 +org.eclipse.jdt.core.formatter.alignment_for_arguments_in_explicit_constructor_call=16 +org.eclipse.jdt.core.formatter.alignment_for_arguments_in_method_invocation=16 +org.eclipse.jdt.core.formatter.alignment_for_arguments_in_qualified_allocation_expression=16 +org.eclipse.jdt.core.formatter.alignment_for_assignment=0 +org.eclipse.jdt.core.formatter.alignment_for_binary_expression=16 +org.eclipse.jdt.core.formatter.alignment_for_compact_if=16 +org.eclipse.jdt.core.formatter.alignment_for_conditional_expression=80 +org.eclipse.jdt.core.formatter.alignment_for_enum_constants=0 +org.eclipse.jdt.core.formatter.alignment_for_expressions_in_array_initializer=16 +org.eclipse.jdt.core.formatter.alignment_for_method_declaration=0 +org.eclipse.jdt.core.formatter.alignment_for_multiple_fields=16 +org.eclipse.jdt.core.formatter.alignment_for_parameters_in_constructor_declaration=16 +org.eclipse.jdt.core.formatter.alignment_for_parameters_in_method_declaration=16 +org.eclipse.jdt.core.formatter.alignment_for_resources_in_try=80 +org.eclipse.jdt.core.formatter.alignment_for_selector_in_method_invocation=16 +org.eclipse.jdt.core.formatter.alignment_for_superclass_in_type_declaration=16 +org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_enum_declaration=16 +org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_type_declaration=16 +org.eclipse.jdt.core.formatter.alignment_for_throws_clause_in_constructor_declaration=16 +org.eclipse.jdt.core.formatter.alignment_for_throws_clause_in_method_declaration=16 +org.eclipse.jdt.core.formatter.alignment_for_union_type_in_multicatch=16 +org.eclipse.jdt.core.formatter.blank_lines_after_imports=1 +org.eclipse.jdt.core.formatter.blank_lines_after_package=1 +org.eclipse.jdt.core.formatter.blank_lines_before_field=0 +org.eclipse.jdt.core.formatter.blank_lines_before_first_class_body_declaration=0 +org.eclipse.jdt.core.formatter.blank_lines_before_imports=1 +org.eclipse.jdt.core.formatter.blank_lines_before_member_type=1 +org.eclipse.jdt.core.formatter.blank_lines_before_method=1 +org.eclipse.jdt.core.formatter.blank_lines_before_new_chunk=1 +org.eclipse.jdt.core.formatter.blank_lines_before_package=0 +org.eclipse.jdt.core.formatter.blank_lines_between_import_groups=1 +org.eclipse.jdt.core.formatter.blank_lines_between_type_declarations=1 +org.eclipse.jdt.core.formatter.brace_position_for_annotation_type_declaration=end_of_line
[25/53] [partial] incubator-juneau git commit: Merge changes from GitHub repo.
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/1b4f98a0/org.apache.juneau.server/src/main/java/org/apache/juneau/server/annotation/Response.java -- diff --git a/org.apache.juneau.server/src/main/java/org/apache/juneau/server/annotation/Response.java b/org.apache.juneau.server/src/main/java/org/apache/juneau/server/annotation/Response.java new file mode 100755 index 000..ee8d32c --- /dev/null +++ b/org.apache.juneau.server/src/main/java/org/apache/juneau/server/annotation/Response.java @@ -0,0 +1,68 @@ +/*** + * 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.juneau.server.annotation; + +import static java.lang.annotation.ElementType.*; +import static java.lang.annotation.RetentionPolicy.*; + +import java.lang.annotation.*; + +/** + * Annotation used in conjunction with {@link RestMethod#responses()} to identify possible responses by the method. + * + * Example + * + * @RestMethod( + * name="*", + * responses={ + * @Response(value=200,description="Everything was great."), + * @Response(value=404,description="File was not found.") + * @Response(500), + * } + * ) + * public void doAnything(RestRequest req, RestResponse res, @Method String method) { + * ... + * } + * + * + * @author James Bognar (james.bog...@salesforce.com) + */ +@Documented +@Target(PARAMETER) +@Retention(RUNTIME) +@Inherited +public @interface Response { + + /** +* HTTP response code. +*/ + int value(); + + /** +* Optional description. +* +* The default value pulls the description from the description entry in the servlet resource bundle. +* (e.g. "myMethod.res.[code] = foo" or "MyServlet.myMethod.res.[code] = foo"). +* +* This field can contain variables (e.g. "$L{my.localized.variable}"). +*/ + String description() default ""; + + /** +* Optional response variables. +* +* Response variables can also be defined in the servlet resource bundle. +* (e.g. "myMethod.res.[code].[category].[name] = foo" or "MyServlet.myMethod.res.[code].[category].[name] = foo"). +*/ + Var[] output() default {}; +} http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/1b4f98a0/org.apache.juneau.server/src/main/java/org/apache/juneau/server/annotation/RestMethod.java -- diff --git a/org.apache.juneau.server/src/main/java/org/apache/juneau/server/annotation/RestMethod.java b/org.apache.juneau.server/src/main/java/org/apache/juneau/server/annotation/RestMethod.java new file mode 100755 index 000..0df53ee --- /dev/null +++ b/org.apache.juneau.server/src/main/java/org/apache/juneau/server/annotation/RestMethod.java @@ -0,0 +1,438 @@ +/*** + * 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. +
[06/53] [partial] incubator-juneau git commit: Merge changes from GitHub repo.
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/1b4f98a0/org.apache.juneau/src/main/java/org/apache/juneau/html/dto/H2.java -- diff --git a/org.apache.juneau/src/main/java/org/apache/juneau/html/dto/H2.java b/org.apache.juneau/src/main/java/org/apache/juneau/html/dto/H2.java new file mode 100644 index 000..12e37fd --- /dev/null +++ b/org.apache.juneau/src/main/java/org/apache/juneau/html/dto/H2.java @@ -0,0 +1,26 @@ +/*** + * 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.juneau.html.dto; + +import org.apache.juneau.xml.annotation.*; + +/** + * TODO + * + * + * @author James Bognar (james.bog...@salesforce.com) + */ +@Xml(name="x") +public class H2 extends HtmlElement { +} http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/1b4f98a0/org.apache.juneau/src/main/java/org/apache/juneau/html/dto/H3.java -- diff --git a/org.apache.juneau/src/main/java/org/apache/juneau/html/dto/H3.java b/org.apache.juneau/src/main/java/org/apache/juneau/html/dto/H3.java new file mode 100644 index 000..469c858 --- /dev/null +++ b/org.apache.juneau/src/main/java/org/apache/juneau/html/dto/H3.java @@ -0,0 +1,26 @@ +/*** + * 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.juneau.html.dto; + +import org.apache.juneau.xml.annotation.*; + +/** + * TODO + * + * + * @author James Bognar (james.bog...@salesforce.com) + */ +@Xml(name="x") +public class H3 extends HtmlElement { +} http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/1b4f98a0/org.apache.juneau/src/main/java/org/apache/juneau/html/dto/H4.java -- diff --git a/org.apache.juneau/src/main/java/org/apache/juneau/html/dto/H4.java b/org.apache.juneau/src/main/java/org/apache/juneau/html/dto/H4.java new file mode 100644 index 000..8ec3bdd --- /dev/null +++ b/org.apache.juneau/src/main/java/org/apache/juneau/html/dto/H4.java @@ -0,0 +1,26 @@ +/*** + * 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
[13/53] [partial] incubator-juneau git commit: Merge changes from GitHub repo.
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/1b4f98a0/org.apache.juneau/src/main/java/org/apache/juneau/Visibility.java -- diff --git a/org.apache.juneau/src/main/java/org/apache/juneau/Visibility.java b/org.apache.juneau/src/main/java/org/apache/juneau/Visibility.java new file mode 100644 index 000..03a927f --- /dev/null +++ b/org.apache.juneau/src/main/java/org/apache/juneau/Visibility.java @@ -0,0 +1,199 @@ +/*** + * 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.juneau; + +import java.lang.reflect.*; + +/** + * Defines class/field/method visibilities. + * + * Used to specify minimum levels of visibility when detecting bean classes, methods, and fields. + * Used in conjunction with the following bean context properties: + * + * {@link BeanContext#BEAN_beanConstructorVisibility} + * {@link BeanContext#BEAN_beanClassVisibility} + * {@link BeanContext#BEAN_beanFieldVisibility} + * {@link BeanContext#BEAN_methodVisibility} + * + * + * @author James Bognar (james.bog...@salesforce.com) + */ +public enum Visibility { + + /** Ignore all */ + NONE, + + /** Include only public classes/fields/methods. */ + PUBLIC, + + /** Include only public or protected classes/fields/methods. */ + PROTECTED, + + /** Include all but private classes/fields/methods. */ + DEFAULT, + + /** Include all classes/fields/methods. */ + PRIVATE; + + /** +* Identifies if the specified mod matches this visibility. +* Example: +* +* PUBLIC.isVisible(MyPublicClass.class.getModifiers()); //true +* PUBLIC.isVisible(MyPrivateClass.class.getModifiers()); //false +* PRIVATE.isVisible(MyPrivateClass.class.getModifiers()); //true +* NONE.isVisible(MyPublicClass.class.getModifiers()); //false +* +* +* @param mod The modifier from the object being tested (e.g. results from {@link Class#getModifiers()}. +* @return true if this visibility matches the specified modifier attribute. +*/ + public boolean isVisible(int mod) { + switch(this) { + case NONE: return false; + case PRIVATE: return true; + case DEFAULT: return ! Modifier.isPrivate(mod); + case PROTECTED: return Modifier.isProtected(mod) || Modifier.isPublic(mod); + default: return Modifier.isPublic(mod); + } + } + + /** +* Shortcut for isVisible(x.getModifiers()); +* +* @param x The constructor to check. +* @return true if the constructor is at least as visible as this object. +*/ + public boolean isVisible(Constructor x) { + return isVisible(x.getModifiers()); + } + + /** +* Shortcut for isVisible(x.getModifiers()); +* +* @param x The method to check. +* @return true if the method is at least as visible as this object. +*/ + public boolean isVisible(Method x) { + return isVisible(x.getModifiers()); + } + + /** +* Shortcut for isVisible(x.getModifiers()); +* +* @param x The field to check. +* @return true if the field is at least as visible as this object. +*/ + public boolean isVisible(Field x) { + return isVisible(x.getModifiers()); + } + + /** +* Makes constructor accessible if it matches the visibility requirements, or returns null if it doesn't. +* Security exceptions thrown on the call to {@link Constructor#setAccessible(boolean)} are quietly ignored. +* +* @param x The constructor. +* @return The same constructor if visibility requirements met, or null if visibility requirement not +
[48/53] [partial] incubator-juneau git commit: Merge changes from GitHub repo.
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/1b4f98a0/org.apache.juneau.client/src/main/java/org/apache/juneau/client/RestClient.java -- diff --git a/org.apache.juneau.client/src/main/java/org/apache/juneau/client/RestClient.java b/org.apache.juneau.client/src/main/java/org/apache/juneau/client/RestClient.java new file mode 100755 index 000..ebd0b8a --- /dev/null +++ b/org.apache.juneau.client/src/main/java/org/apache/juneau/client/RestClient.java @@ -0,0 +1,1423 @@ +/*** + * 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.juneau.client; + +import static org.apache.juneau.internal.ThrowableUtils.*; + +import java.io.*; +import java.lang.reflect.*; +import java.lang.reflect.Proxy; +import java.net.*; +import java.security.*; +import java.util.*; +import java.util.concurrent.*; +import java.util.logging.*; +import java.util.regex.*; + +import javax.net.ssl.*; + +import org.apache.http.*; +import org.apache.http.auth.*; +import org.apache.http.client.*; +import org.apache.http.client.CookieStore; +import org.apache.http.client.config.*; +import org.apache.http.client.entity.*; +import org.apache.http.client.methods.*; +import org.apache.http.config.*; +import org.apache.http.conn.*; +import org.apache.http.conn.routing.*; +import org.apache.http.conn.socket.*; +import org.apache.http.conn.ssl.*; +import org.apache.http.conn.util.*; +import org.apache.http.cookie.*; +import org.apache.http.entity.*; +import org.apache.http.impl.client.*; +import org.apache.http.impl.conn.*; +import org.apache.http.protocol.*; +import org.apache.juneau.*; +import org.apache.juneau.internal.*; +import org.apache.juneau.json.*; +import org.apache.juneau.parser.*; +import org.apache.juneau.serializer.*; +import org.apache.juneau.urlencoding.*; + +/** + * Utility class for interfacing with remote REST interfaces. + * + * + * Features + * + * Convert POJOs directly to HTTP request message bodies using {@link Serializer} class. + * Convert HTTP response message bodies directly to POJOs using {@link Parser} class. + * Fluent interface. + * Thread safe. + * API for interacting with remoteable services. + * + * + * + * Additional Information + * + * org.apache.juneau.client REST client API for more information and code examples. + * + * + * @author James Bognar (james.bog...@salesforce.com) + */ +public class RestClient extends CoreApi { + + Mapheaders = new TreeMap (String.CASE_INSENSITIVE_ORDER); + volatile CloseableHttpClient httpClient; + HttpClientConnectionManager httpClientConnectionManager; + Serializer serializer; + UrlEncodingSerializer urlEncodingSerializer = new UrlEncodingSerializer(); // Used for form posts only. + Parser parser; + String accept, contentType; + List interceptors = new ArrayList(); + String remoteableServletUri; + private Map remoteableServiceUriMap = new ConcurrentHashMap (); + private String rootUrl; + private SSLOpts sslOpts; + private boolean pooled; + private volatile boolean isClosed = false; + private StackTraceElement[] creationStack; + + /** +* The {@link HttpClientBuilder} returned by {@link #createHttpClientBuilder()}. +*/ + protected HttpClientBuilder httpClientBuilder; + + /** +* Create a new client with no serializer, parser, or HTTP client. +* +* If you do not specify an {@link HttpClient} via the {@link #setHttpClient(CloseableHttpClient)}, one +* will be created using the {@link #createHttpClient()} method. +*/ + public RestClient() { + httpClientBuilder = createHttpClientBuilder(); + if (Boolean.getBoolean("org.apache.juneau.client.RestClient.trackCreation")) + creationStack =
[45/53] [partial] incubator-juneau git commit: Merge changes from GitHub repo.
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/1b4f98a0/org.apache.juneau.microservice/src/main/java/org/apache/juneau/microservice/RestMicroservice.java -- diff --git a/org.apache.juneau.microservice/src/main/java/org/apache/juneau/microservice/RestMicroservice.java b/org.apache.juneau.microservice/src/main/java/org/apache/juneau/microservice/RestMicroservice.java new file mode 100755 index 000..371a163 --- /dev/null +++ b/org.apache.juneau.microservice/src/main/java/org/apache/juneau/microservice/RestMicroservice.java @@ -0,0 +1,553 @@ +/*** + * 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.juneau.microservice; + +import java.io.*; +import java.util.*; +import java.util.logging.*; + +import javax.servlet.*; + +import org.apache.juneau.*; +import org.apache.juneau.ini.*; +import org.apache.juneau.internal.*; +import org.apache.juneau.json.*; +import org.apache.juneau.microservice.resources.*; +import org.apache.juneau.parser.*; +import org.apache.juneau.server.annotation.*; +import org.eclipse.jetty.security.*; +import org.eclipse.jetty.security.authentication.*; +import org.eclipse.jetty.server.*; +import org.eclipse.jetty.server.ssl.*; +import org.eclipse.jetty.servlet.*; +import org.eclipse.jetty.util.security.*; +import org.eclipse.jetty.util.ssl.*; + + +/** + * Entry point for Juneau microservice that implements a REST interface using Jetty on a single port. + * + * Jetty Server Details + * + * The Jetty server is created by the {@link #createServer()} method and started with the {@link #startServer()} method. + * These methods can be overridden to provided customized behavior. + * + * + * Defining REST Resources + * + * Top-level REST resources are defined by the {@link #getResourceMap()} method. + * This method can be overridden to provide a customized list of REST resources. + * + * + * Logging + * + * Logging is initialized by the {@link #initLogging()} method. + * This method can be overridden to provide customized logging behavior. + * + * Lifecycle Listener Methods + * Subclasses can optionally implement the following event listener methods: + * + * {@link #onStart()} - Gets executed before {@link #start()}. + * {@link #onStop()} - Gets executed before {@link #stop()}. + * {@link #onCreateServer()} - Gets executed before {@link #createServer()}. + * {@link #onStartServer()} - Gets executed before {@link #startServer()}. + * {@link #onPostStartServer()} - Gets executed after {@link #startServer()}. + * {@link #onStopServer()} - Gets executed before {@link #stop()}. + * {@link #onPostStopServer()} - Gets executed after {@link #stop()}. + * + * + * @author james.bog...@salesforce.com + */ +public class RestMicroservice extends Microservice { + + Server server; + int port; + Logger logger; + + /** +* Main method. +* Subclasses must also implement this method! +* +* @param args Command line arguments. +* @throws Exception +*/ + public static void main(String[] args) throws Exception { + new RestMicroservice(args).start(); + } + + /** +* Constructor. +* +* @param args The command line arguments. +* @throws Exception +*/ + public RestMicroservice(String[] args) throws Exception { + super(args); + } + + // + // Methods implemented on Microservice API + // + + @Override /* Microservice */ + protected void start() throws Exception { + super.start(); + initLogging(); + createServer(); + startServer(); + } + + @Override /* Microservice */ + public void
[02/53] [partial] incubator-juneau git commit: Merge changes from GitHub repo.
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/1b4f98a0/org.apache.juneau/src/main/java/org/apache/juneau/internal/ByteArrayCache.java -- diff --git a/org.apache.juneau/src/main/java/org/apache/juneau/internal/ByteArrayCache.java b/org.apache.juneau/src/main/java/org/apache/juneau/internal/ByteArrayCache.java new file mode 100644 index 000..9747902 --- /dev/null +++ b/org.apache.juneau/src/main/java/org/apache/juneau/internal/ByteArrayCache.java @@ -0,0 +1,106 @@ +/*** + * 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.juneau.internal; + +import java.io.*; +import java.util.*; +import java.util.concurrent.*; + +/** + * A utility class for caching byte arrays in memory so that duplicate arrays can be reused. + * + * + * @author James Bognar (james.bog...@salesforce.com) + */ +public class ByteArrayCache { + + /** +* Default global byte array cache. +* Note that this can't ever get garbage collected so don't add really large arrays! +*/ + public static final ByteArrayCache DEFAULT = new ByteArrayCache(); + + private final ConcurrentHashMapcache = new ConcurrentHashMap (); + + /** +* Add the specified byte array to this cache. +* +* @param contents The byte array to add to this cache. +* @return Either the same byte array or a previously cached byte array depending on whether the byte array +* already exists in the cache. +*/ + public byte[] cache(byte[] contents) { + if (contents == null) + return null; + ByteArray ba = new ByteArray(contents); + cache.putIfAbsent(ba, ba.contents); + return cache.get(ba); + } + + /** +* Add the specified input stream to this cache. +* +* @param contents The input stream whose contents are to be added to this cache. +* @return Either the same byte array or a previously cached byte array depending on whether the byte array +* already exists in the cache. +* @throws IOException +*/ + public byte[] cache(InputStream contents) throws IOException { + if (contents == null) + return null; + ByteArray ba = new ByteArray(IOUtils.readBytes(contents, 1024)); + cache.putIfAbsent(ba, ba.contents); + return cache.get(ba); + } + + /** +* Returns the number of byte arrays in this cache. +* +* @return The number of byte arrays in this cache. +*/ + public int size() { + return cache.size(); + } + + private static class ByteArray { + private int hashCode; + private byte[] contents; + + private ByteArray(byte[] contents) { + this.contents = contents; + int multiplier = 1; + for (int i = 0; i < contents.length; i++) { + hashCode += contents[i] * multiplier; + int shifted = multiplier << 5; + multiplier = shifted - multiplier; + } + } + + @Override /* Object */ + public int hashCode() { + if (hashCode == 0) { + } + return hashCode; + } + + @Override /* Object */ + public boolean equals(Object o) { + if (o instanceof ByteArray) { + ByteArray ba = (ByteArray)o; + if (ba.hashCode == hashCode) + return Arrays.equals(ba.contents, contents); + } +
[37/53] [partial] incubator-juneau git commit: Merge changes from GitHub repo.
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/1b4f98a0/org.apache.juneau.server.test/juneau-server-test.launch -- diff --git a/org.apache.juneau.server.test/juneau-server-test.launch b/org.apache.juneau.server.test/juneau-server-test.launch new file mode 100755 index 000..0d9fb35 --- /dev/null +++ b/org.apache.juneau.server.test/juneau-server-test.launch @@ -0,0 +1,56 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/1b4f98a0/org.apache.juneau.server.test/pom.xml -- diff --git a/org.apache.juneau.server.test/pom.xml b/org.apache.juneau.server.test/pom.xml new file mode 100644 index 000..8c6d675 --- /dev/null +++ b/org.apache.juneau.server.test/pom.xml @@ -0,0 +1,36 @@ +http://maven.apache.org/POM/4.0.0; xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance; xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd;> + 4.0.0 + org.apache.juneau + org.apache.juneau.server.test + 6.0.0-SNAPSHOT + org.apache.juneau.server.test + org.apache.juneau.server.test + + + +src/main/java + + **/*.java + + + + + +src/test/java + + **/*.java + + + + + +maven-compiler-plugin +3.3 + + 1.6 + 1.6 + + + + + \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/1b4f98a0/org.apache.juneau.server.test/src/main/java/org/apache/juneau/server/DTO2s.java -- diff --git a/org.apache.juneau.server.test/src/main/java/org/apache/juneau/server/DTO2s.java b/org.apache.juneau.server.test/src/main/java/org/apache/juneau/server/DTO2s.java new file mode 100755 index 000..4b9d40d --- /dev/null +++ b/org.apache.juneau.server.test/src/main/java/org/apache/juneau/server/DTO2s.java @@ -0,0 +1,136 @@ +/*** + * 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.juneau.server; + +import java.util.*; + +import org.apache.juneau.urlencoding.annotation.*; + +public class DTO2s { + + public static class A { + public String a; + public int b; + public boolean c; + + public static A create() { + A t = new A(); + t.a = "a"; + t.b = 1; + t.c = true; + return t; + } + + } + + @SuppressWarnings("serial") + public static class B { + public String[] f1; + public List f2; + public int[] f3; + public List f4; + public String[][] f5; + public Listf6; + public A[] f7; + public List f8; + public A[][] f9; + public List f10; + + private String[] f11; + private List f12; + private int[] f13; + private List f14; + private String[][] f15; + private List
f16; + private A[] f17; + private List f18; + private A[][] f19; + private List f20; + + public String[] getF11() { return f11; } + public List getF12() { return f12; } + public int[] getF13() { return f13; } + public List getF14() { return f14; } + public String[][] getF15() { return f15; } + public List
getF16() { return f16; } + public A[] getF17() { return f17; } + public List getF18()
[42/53] [partial] incubator-juneau git commit: Merge changes from GitHub repo.
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/1b4f98a0/org.apache.juneau.releng/javadoc.css -- diff --git a/org.apache.juneau.releng/javadoc.css b/org.apache.juneau.releng/javadoc.css new file mode 100755 index 000..1dbf706 --- /dev/null +++ b/org.apache.juneau.releng/javadoc.css @@ -0,0 +1,1145 @@ +/* Javadoc style sheet */ +/* +Overall document style +*/ +body { + background-image: linear-gradient(top, #cf 0, #eaeded 20px, #ff 70px); + background-image: -o-linear-gradient(top, #cf 0, #eaeded 20px, #ff 70px); + background-image: -moz-linear-gradient(top, #cf 0, #eaeded 20px, #ff 70px); + background-image: -webkit-linear-gradient(top, #cf 0, #eaeded 20px, #ff 70px); + background-image: -ms-linear-gradient(top, #cf 0, #eaeded 20px, #ff 70px); + background-image: -webkit-gradient(linear, left top, left bottom, color-stop(0, #cf), color-stop(20px, #eaeded), color-stop(70px, #ff) ); + background-repeat: no-repeat; + background-attachment: fixed; + color: #353833; + font-family: Arial, Helvetica, sans-serif; + font-size: 76%; + margin: 0; +} + +a:link,a:visited { + text-decoration: none; + color: #4c6b87; +} + +a:hover,a:focus { + text-decoration: none; + color: #bb7a2a; +} + +a:active { + text-decoration: none; + color: #4c6b87; +} + +a[name] { + color: #353833; +} + +a[name]:hover { + text-decoration: none; + color: #353833; +} + +h1 { + font-size: 1.5em; +} + +h2 { + font-size: 1.4em; +} + +h3 { + font-size: 1.3em; +} + +h4 { + font-size: 1.2em; +} + +h5 { + font-size: 1.1em; +} + +h6 { + font-size: 1.0em; +} + +ul { + list-style-type: disc; +} + +code, +tt, +pre, +dt code { + font-size: 9pt; +} + +table tr td dt code { + font-size: 9pt; + vertical-align: top; +} + +sup { + font-size: .6em; +} + +/* +Document title and Copyright styles +*/ +.clear { + clear: both; + height: 0px; + overflow: hidden; +} + +.aboutLanguage { + float: right; + padding: 0px 21px; + font-size: .8em; + z-index: 200; + margin-top: -7px; +} + +.legalCopy { + margin-left: .5em; +} + +.bar a, +.bar a:link, +.bar a:visited, +.bar a:active { + color: #ff; + text-decoration: none; +} + +.bar a:hover, +.bar a:focus { + color: #bb7a2a; +} + +.tab { + background-color: #0066ff; + background-image: url('data:image/gif;base64,R0lGODlhpAYoAOYAAPCgOe6fON+VNfChOu+gOeKXNvGiO+2fOtqOML58Kr17Kr18Krt6Kbp6KbZ2KLZ3KNuPMdqOMdqPMcyFLsyGLsiDLcOALMB+K799K79+K758K7t6Krh3Kbh4KbZ3KdKKMNKLMM+IL8yGL8mELsiDLsiELsaCLcWBLcWCLcJ/LMKALLl4Krh4KtKLMc+JMOWYNuOXNt+UNdyRNNmPM9WNMvCgOuqcOOibOOaYN+aZN+WYN+KWNt2SNdqQNNmQNNWOM/GhO/CgO+2eOuyeOuucOeudOeqcOeeaOPOiPN2VP92XQd+bSOezd+i1evnt4Pvy6v///wAAACH5BAEAAFIALACkBigAAAf/gAFRT00UCgoThhSKh4iKjIeJCouOk5ATlZSGkY+TlZmQlZKUoIilhqOonameo6Wsqpaep42wnLS3mriSn5SYtqzBnbHExa3DuaG2osjJx7Kyv8jC0dOM1LrLy7vGm6a+tNjdma/Wspvb2uPO67zq5ee1zZLp5rqf767gwKv98a7int2rF49ZwXDI9tkzxk/guHf3uOFCWNDdPIYXDzbUpfCfP1/24GXLGDFfM4oD0WUMKM1jtZcjHaK8dNKkxoWzLFbEWPDaR587bwYluGqmSKA8Y6YUupQoUprsbgX0thFqyZU1caqMFM3oVHJfISrDyrRo1aMCS3U9G/ap0a1X/4dmdblUARQmOoYo2cu3r9+/gAMLHky4sOHDiBMrXsy4sePHkCNLnky 5suXLmDNr3sy5s+fPoEOLHk26tOnTqFOrXs26tevXsGPLJu1kR4HbQhDg3p1bdwEhvBH4Bl5gePDiu3//Fp4c+HDjynvfhp47uW7qyJVnJ47dOPTuzZeHl64dePXtwcGXF89eCHf0yr9bD+99/nrs54mbZ77+PH7++sHn3nQCwifffbsdGOB/4wF4XIHSvafee9pNaCB9DTbIIIQOxpdhew8qmN6H/1kY3XMk8kagiSJ66CKFC34YIHkz+lYihv2tiCOMBCL4Yo8x9nejkECO6GONuG3Y4v9+Gu6oInIs2hekc1ImKKORSHJoIpMgnljkhVFW6OSSHDZJpJZOetkll2RWR6WYRz5Yo5JmmqdjnBfGSeaGc6Yo5Jbt0Qlnn3hySWiWQ04pp24SprmnlYNCmuWhIdY5X5g8/vhdo3g++mOBfGJZ6Z9pGorAEgMUIIABNxRgAKuv3sDqbbHW2qqrsBqAq6ywtqprrb3Smqusu+5qq7DGzgqsq8kSu+yzw/4Ka7LNSsurrL5Geyuw2OJa7bbRfltsrLwyy621r1J7rrHqhntuttfOKm667wobb7PlojsttPm6u2+u1c6rrb3H0juwq/kGzK/B99babsMD1yuwuApHrKz/xQ8fO7HE69Yb68a90ltxvyQ7bDLAHVscL7gre8uxvyuLnHLJ+jr7L802t/yyzjXLO3PBF/OccbA7nxzzryMzrPTN+iZN9MEe98yy0UDDC/TQ5sK8dNJD51y1xlFT/PPTVj/dtbJe9yxwyyCzbavMWjf989lrg41x0UyT3fbS3TrdLd5/S01w3oH7mvDYdFOtdtRu3w11tEgjvjDT1B4ed+J5+x203UIDLvjHChCRQAJFFDF66aiXPjrpqat+Ouqvt74667LHDjvrtt9Oeu62z9666bQDn3ruwrs+fPDG/0488Mgbv/zqyjdfPO/Q13789dYnr/3tvxdfu/SnP0/8//LMN9978OPTfn703YsP/u7vq189
[22/53] [partial] incubator-juneau git commit: Merge changes from GitHub repo.
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/1b4f98a0/org.apache.juneau.server/src/main/java/org/apache/juneau/server/package.html -- diff --git a/org.apache.juneau.server/src/main/java/org/apache/juneau/server/package.html b/org.apache.juneau.server/src/main/java/org/apache/juneau/server/package.html new file mode 100755 index 000..a498e78 --- /dev/null +++ b/org.apache.juneau.server/src/main/java/org/apache/juneau/server/package.html @@ -0,0 +1,3600 @@ + + + + + + + /* For viewing in Page Designer */ + @IMPORT url("../../../../../javadoc.css"); + + /* For viewing in REST interface */ + @IMPORT url("../htdocs/javadoc.css"); + body { + margin: 20px; + } + + + /* Replace all @code and @link tags. */ + window.onload = function() { + document.body.innerHTML = document.body.innerHTML.replace(/\{\@code ([^\}]+)\}/g, '$1
'); + document.body.innerHTML = document.body.innerHTML.replace(/\{\@link (([^\}]+)\.)?([^\.\}]+)\}/g, '$3
'); + } + + + +REST Servlet API + + + function toggle(x) { + var div = x.nextSibling; + while (div != null && div.nodeType != 1) + div = div.nextSibling; + if (div != null) { + var d = div.style.display; + if (d == 'block' || d == '') { + div.style.display = 'none'; + x.className += " closed"; + } else { + div.style.display = 'block'; + x.className = x.className.replace(/(?:^|\s)closed(?!\S)/g , '' ); + } + } + } + + + + Defines an API for defining REST resources as servlets. + + +Table of Contents + + Introduction + Hello World Example + Class Hierarchy + REST Servlets + + REST Java Method Signature + + Path + Matchers + + Request Content + + Form Posts + Multipart Form Posts + + Response Content + OPTIONS Pages + Serializers + Parsers + Properties + Transforms + Guards + Converters + Child Resources + Localized Messages + Encoders + SVL Vars + Static Files + Listener Methods + Stylesheet + Default Headers + Handling Errors / Logging + Configuration Files + Annotation Inheritence + HTTP Status Codes + Overloaded HTTP Methods + Built-In Parameters + Defining your own serializers/parsers + Response Handlers + Other Notes + + Using with OSGi + POJOs Convertable From Strings + Address Book Resource + + + + +1 - Introduction + + + The juneau-server.jar library allows you to quickly wrap POJOs and expose them as full-fledged REST resources served up in a servlet container using a bare-minimum amount of code. + The primary goal for Juneau was to make it as easy as possible to implement easy-to-read and self-documenting REST resources using very little code. + + + One of the biggest advantages of the Juneau REST framework over similar architectures is that it hides the serialization layer from the developer. + The developer can work entirely with POJOs and let the Juneau framework handle all the serialization and parsing work. + The developer need never know what the Accept or Content-Type or Accept-Encoding (etc...) header values are because those details are all handled by the framework. + + + The API builds upon the existing JEE Servlet API. + The root class, {@link org.apache.juneau.server.RestServlet} is nothing but a specialized {@link javax.servlet.http.HttpServlet}, and the + {@link org.apache.juneau.server.RestRequest} and {@link org.apache.juneau.server.RestResponse} classes are nothing more than specialized {@link javax.servlet.http.HttpServletRequest} and + {@link javax.servlet.http.HttpServletResponse} objects. + This allows maximum flexibility for the developer since you can let Juneau handle operations such as serialization, or you can
[43/53] [partial] incubator-juneau git commit: Merge changes from GitHub repo.
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/1b4f98a0/org.apache.juneau.releng/build.xml -- diff --git a/org.apache.juneau.releng/build.xml b/org.apache.juneau.releng/build.xml new file mode 100755 index 000..d6aa9ff --- /dev/null +++ b/org.apache.juneau.releng/build.xml @@ -0,0 +1,520 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
[09/53] [partial] incubator-juneau git commit: Merge changes from GitHub repo.
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/1b4f98a0/org.apache.juneau/src/main/java/org/apache/juneau/dto/jsonschema/package.html -- diff --git a/org.apache.juneau/src/main/java/org/apache/juneau/dto/jsonschema/package.html b/org.apache.juneau/src/main/java/org/apache/juneau/dto/jsonschema/package.html new file mode 100644 index 000..51977bf --- /dev/null +++ b/org.apache.juneau/src/main/java/org/apache/juneau/dto/jsonschema/package.html @@ -0,0 +1,518 @@ + + + + + + + /* For viewing in Page Designer */ + @IMPORT url("../../../../../../../javadoc.css"); + + /* For viewing in REST interface */ + @IMPORT url("../htdocs/javadoc.css"); + body { + margin: 20px; + } + + + /* Replace all @code and @link tags. */ + window.onload = function() { + document.body.innerHTML = document.body.innerHTML.replace(/\{\@code ([^\}]+)\}/g, '$1
'); + document.body.innerHTML = document.body.innerHTML.replace(/\{\@link (([^\}]+)\.)?([^\.\}]+)\}/g, '$3
'); + } + + + +JSON-Schema Data Transfer Objects + + function toggle(x) { + var div = x.nextSibling; + while (div != null && div.nodeType != 1) + div = div.nextSibling; + if (div != null) { + var d = div.style.display; + if (d == 'block' || d == '') { + div.style.display = 'none'; + x.className += " closed"; + } else { + div.style.display = 'block'; + x.className = x.className.replace(/(?:^|\s)closed(?!\S)/g , '' ); + } + } + } + +Table of Contents + + Overview + + JSON-Schema schema definition + Creating JSON-Schema documents + + Serializing to other data types + + Parsing JSON-Schema documents + + + + +1 - Overview + + + Juneau supports serializing and parsing of JSON-Schema documents through the use of beans defined in the org.apache.juneau.dto.jsonschema package. + These beans are used with the existing {@link org.apache.juneau.json.JsonSerializer} and {@link org.apache.juneau.json.JsonParser} classes to produce and consume JSON-Schema documents. + + + NOTE: JSON-Schema is currently in draft form. This API may change as the JSON-Schema specification changes. + + + + + 1.1 - JSON-Schema schema definition + + + The draft JSON-Schema specification that the JSON-Schema beans are modeled after is as follows: + + + { + "id": "http://json-schema.org/draft-04/schema#;, + "$schema": "http://json-schema.org/draft-04/schema#;, + "description": "Core schema meta-schema", + "definitions": { + "schemaArray": { + "type": "array", + "minItems": 1, + "items": { "$ref": "#" } + }, + "positiveInteger": { + "type": "integer", + "minimum": 0 + }, + "positiveIntegerDefault0": { + "allOf": [ { "$ref": "#/definitions/positiveInteger" }, { "default": 0 } ] + }, + "simpleTypes": { + "enum": [ "array", "boolean", "integer", "null", "number", "object", "string" ] + }, + "stringArray": { + "type": "array", + "items": { "type": "string" }, + "minItems": 1, + "uniqueItems": true + } + }, + "type": "object", + "properties": { + "id": { + "type": "string", + "format": "uri" + }, + "$schema": { + "type": "string", + "format": "uri" + }, + "title": { + "type": "string" + }, + "description": { + "type": "string" + }, + "default": {}, + "multipleOf": { + "type": "number", + "minimum": 0, + "exclusiveMinimum": true + }, + "maximum": { + "type": "number" + }, + "exclusiveMaximum": { +
[36/53] [partial] incubator-juneau git commit: Merge changes from GitHub repo.
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/1b4f98a0/org.apache.juneau.server.test/src/main/java/org/apache/juneau/server/TestMessages.properties -- diff --git a/org.apache.juneau.server.test/src/main/java/org/apache/juneau/server/TestMessages.properties b/org.apache.juneau.server.test/src/main/java/org/apache/juneau/server/TestMessages.properties new file mode 100755 index 000..d107ee8 --- /dev/null +++ b/org.apache.juneau.server.test/src/main/java/org/apache/juneau/server/TestMessages.properties @@ -0,0 +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. * +# * * +# *** + +key1 = value1a +key2 = value2a \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/1b4f98a0/org.apache.juneau.server.test/src/main/java/org/apache/juneau/server/TestMessages2.properties -- diff --git a/org.apache.juneau.server.test/src/main/java/org/apache/juneau/server/TestMessages2.properties b/org.apache.juneau.server.test/src/main/java/org/apache/juneau/server/TestMessages2.properties new file mode 100755 index 000..9a5fe73 --- /dev/null +++ b/org.apache.juneau.server.test/src/main/java/org/apache/juneau/server/TestMessages2.properties @@ -0,0 +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. * +# * * +# *** + +key2 = value2b +key3 = value3b \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/1b4f98a0/org.apache.juneau.server.test/src/main/java/org/apache/juneau/server/TestNls.java -- diff --git
[50/53] [partial] incubator-juneau git commit: Merge changes from GitHub repo.
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/1b4f98a0/org.apache.juneau.client/.settings/org.eclipse.jdt.core.prefs -- diff --git a/org.apache.juneau.client/.settings/org.eclipse.jdt.core.prefs b/org.apache.juneau.client/.settings/org.eclipse.jdt.core.prefs new file mode 100755 index 000..73f18fb --- /dev/null +++ b/org.apache.juneau.client/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,402 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.codeComplete.argumentPrefixes= +org.eclipse.jdt.core.codeComplete.argumentSuffixes= +org.eclipse.jdt.core.codeComplete.fieldPrefixes= +org.eclipse.jdt.core.codeComplete.fieldSuffixes= +org.eclipse.jdt.core.codeComplete.localPrefixes= +org.eclipse.jdt.core.codeComplete.localSuffixes= +org.eclipse.jdt.core.codeComplete.staticFieldPrefixes= +org.eclipse.jdt.core.codeComplete.staticFieldSuffixes= +org.eclipse.jdt.core.codeComplete.staticFinalFieldPrefixes= +org.eclipse.jdt.core.codeComplete.staticFinalFieldSuffixes= +org.eclipse.jdt.core.compiler.annotation.missingNonNullByDefaultAnnotation=ignore +org.eclipse.jdt.core.compiler.annotation.nonnull=org.eclipse.jdt.annotation.NonNull +org.eclipse.jdt.core.compiler.annotation.nonnullbydefault=org.eclipse.jdt.annotation.NonNullByDefault +org.eclipse.jdt.core.compiler.annotation.nullable=org.eclipse.jdt.annotation.Nullable +org.eclipse.jdt.core.compiler.annotation.nullanalysis=disabled +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.methodParameters=do not generate +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.6 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.doc.comment.support=enabled +org.eclipse.jdt.core.compiler.problem.annotationSuperInterface=warning +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.autoboxing=ignore +org.eclipse.jdt.core.compiler.problem.comparingIdentical=warning +org.eclipse.jdt.core.compiler.problem.deadCode=warning +org.eclipse.jdt.core.compiler.problem.deprecation=warning +org.eclipse.jdt.core.compiler.problem.deprecationInDeprecatedCode=disabled +org.eclipse.jdt.core.compiler.problem.deprecationWhenOverridingDeprecatedMethod=disabled +org.eclipse.jdt.core.compiler.problem.discouragedReference=warning +org.eclipse.jdt.core.compiler.problem.emptyStatement=warning +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.problem.explicitlyClosedAutoCloseable=ignore +org.eclipse.jdt.core.compiler.problem.fallthroughCase=warning +org.eclipse.jdt.core.compiler.problem.fatalOptionalError=enabled +org.eclipse.jdt.core.compiler.problem.fieldHiding=warning +org.eclipse.jdt.core.compiler.problem.finalParameterBound=warning +org.eclipse.jdt.core.compiler.problem.finallyBlockNotCompletingNormally=warning +org.eclipse.jdt.core.compiler.problem.forbiddenReference=error +org.eclipse.jdt.core.compiler.problem.hiddenCatchBlock=warning +org.eclipse.jdt.core.compiler.problem.includeNullInfoFromAsserts=disabled +org.eclipse.jdt.core.compiler.problem.incompatibleNonInheritedInterfaceMethod=warning +org.eclipse.jdt.core.compiler.problem.incompleteEnumSwitch=warning +org.eclipse.jdt.core.compiler.problem.indirectStaticAccess=warning +org.eclipse.jdt.core.compiler.problem.invalidJavadoc=warning +org.eclipse.jdt.core.compiler.problem.invalidJavadocTags=enabled +org.eclipse.jdt.core.compiler.problem.invalidJavadocTagsDeprecatedRef=enabled +org.eclipse.jdt.core.compiler.problem.invalidJavadocTagsNotVisibleRef=enabled +org.eclipse.jdt.core.compiler.problem.invalidJavadocTagsVisibility=protected +org.eclipse.jdt.core.compiler.problem.localVariableHiding=warning +org.eclipse.jdt.core.compiler.problem.methodWithConstructorName=warning +org.eclipse.jdt.core.compiler.problem.missingDefaultCase=ignore +org.eclipse.jdt.core.compiler.problem.missingDeprecatedAnnotation=warning +org.eclipse.jdt.core.compiler.problem.missingEnumCaseDespiteDefault=disabled +org.eclipse.jdt.core.compiler.problem.missingHashCodeMethod=warning +org.eclipse.jdt.core.compiler.problem.missingJavadocComments=warning +org.eclipse.jdt.core.compiler.problem.missingJavadocCommentsOverriding=disabled +org.eclipse.jdt.core.compiler.problem.missingJavadocCommentsVisibility=protected +org.eclipse.jdt.core.compiler.problem.missingJavadocTagDescription=return_tag +org.eclipse.jdt.core.compiler.problem.missingJavadocTags=warning +org.eclipse.jdt.core.compiler.problem.missingJavadocTagsMethodTypeParameters=disabled +org.eclipse.jdt.core.compiler.problem.missingJavadocTagsOverriding=disabled +org.eclipse.jdt.core.compiler.problem.missingJavadocTagsVisibility=protected
[23/53] [partial] incubator-juneau git commit: Merge changes from GitHub repo.
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/1b4f98a0/org.apache.juneau.server/src/main/java/org/apache/juneau/server/jena/RestServletJenaDefault.java -- diff --git a/org.apache.juneau.server/src/main/java/org/apache/juneau/server/jena/RestServletJenaDefault.java b/org.apache.juneau.server/src/main/java/org/apache/juneau/server/jena/RestServletJenaDefault.java new file mode 100755 index 000..00cb56a --- /dev/null +++ b/org.apache.juneau.server/src/main/java/org/apache/juneau/server/jena/RestServletJenaDefault.java @@ -0,0 +1,275 @@ +/*** + * 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.juneau.server.jena; + +import static org.apache.juneau.html.HtmlDocSerializerContext.*; +import static org.apache.juneau.server.RestServletContext.*; + +import org.apache.juneau.html.*; +import org.apache.juneau.jena.*; +import org.apache.juneau.jso.*; +import org.apache.juneau.json.*; +import org.apache.juneau.msgpack.*; +import org.apache.juneau.plaintext.*; +import org.apache.juneau.server.*; +import org.apache.juneau.server.annotation.*; +import org.apache.juneau.server.labels.*; +import org.apache.juneau.soap.*; +import org.apache.juneau.urlencoding.*; +import org.apache.juneau.xml.*; + +/** + * Subclass of {@link RestServlet} with default sets of serializers and parsers that include RDF support. + * + * Extends the {@link org.apache.juneau.server.RestServletDefault} class with additional RDF support. + * + * + * Supports the following request Accept header values with the resulting response Content-Type: + * + * + * + * Accept + * Content-Type + * Serializer + * + * + * application/jsontext/json + * application/json + * {@link JsonSerializer} + * + * + * application/json+simpletext/json+simple + * application/json + * {@link org.apache.juneau.json.JsonSerializer.Simple} + * + * application/json+schematext/json+schema + * application/json + * {@link JsonSchemaSerializer} + * + * + * text/xml + * text/xml + * {@link XmlDocSerializer} + * + * + * text/xml+schema + * text/xml + * {@link XmlSchemaDocSerializer} + * + * + * text/html + * text/html + * {@link HtmlDocSerializer} + * + * + * text/html+stripped + * text/html + * {@link HtmlStrippedDocSerializer} + * + * + * text/uon + * text/uon + * {@link UonSerializer} + * + * + * text/uon-simple + * text/uon + * {@link org.apache.juneau.urlencoding.UonSerializer.Simple} + * + * + * application/x-www-form-urlencoded + * application/x-www-form-urlencoded + * {@link UrlEncodingSerializer} + * + * + * application/x-www-form-urlencoded-simple + * application/x-www-form-urlencoded + * {@link org.apache.juneau.urlencoding.UrlEncodingSerializer.Simple} + * + * + * text/xml+soap + * text/xml + * {@link SoapXmlSerializer} + * + * + * text/plain + * text/plain + * {@link PlainTextSerializer} + * + * + * text/plain + * text/plain + * {@link PlainTextSerializer} + * + * + * application/x-java-serialized-object + * application/x-java-serialized-object + * {@link JavaSerializedObjectSerializer} + * + * + * text/xml+rdf + * text/xml+rdf + * {@link org.apache.juneau.jena.RdfSerializer.Xml} + * + * + *
[10/53] [partial] incubator-juneau git commit: Merge changes from GitHub repo.
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/1b4f98a0/org.apache.juneau/src/main/java/org/apache/juneau/dto/jsonschema/Schema.java -- diff --git a/org.apache.juneau/src/main/java/org/apache/juneau/dto/jsonschema/Schema.java b/org.apache.juneau/src/main/java/org/apache/juneau/dto/jsonschema/Schema.java new file mode 100644 index 000..d63a245 --- /dev/null +++ b/org.apache.juneau/src/main/java/org/apache/juneau/dto/jsonschema/Schema.java @@ -0,0 +1,1401 @@ +/*** + * 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.juneau.dto.jsonschema; + +import java.net.URI; +import java.util.*; + +import org.apache.juneau.*; +import org.apache.juneau.annotation.*; +import org.apache.juneau.parser.*; +import org.apache.juneau.serializer.*; +import org.apache.juneau.transform.*; +import org.apache.juneau.xml.annotation.*; + +/** + * Represents a top-level schema object bean in the JSON-Schema core specification. + * + * Refer to {@link org.apache.juneau.dto.jsonschema} for usage information. + * + * @author James Bognar (james.bog...@salesforce.com) + */ +@Xml(name="schema") +@SuppressWarnings("hiding") +@Bean(properties={"id","$schema","$ref", "title","description","type","definitions","properties", + "patternProperties","dependencies","items","multipleOf","maximum","exclusiveMaximum", + "minimum","exclusiveMinimum","maxLength","minLength","pattern","additionalItems", + "maxItems","minItems","uniqueItems","maxProperties","minProperties","required", + "additionalProperties","enum","allOf","anyOf","oneOf","not"}) +public class Schema { + private String name; // Property name. Not serialized. + private URI id; + private URI schemaVersion; + private String title; + private String description; + private JsonType typeJsonType; // JsonType representation of type + private JsonTypeArray typeJsonTypeArray; // JsonTypeArray representation of type + private Mapdefinitions; + private Map properties; + private Map patternProperties; + private Map dependencies; + private Schema itemsSchema;// Schema representation of items + private SchemaArray itemsSchemaArray; // SchemaArray representation of items + private Number multipleOf; + private Number maximum; + private Boolean exclusiveMaximum; + private Number minimum; + private Boolean exclusiveMinimum; + private Integer maxLength; + private Integer minLength; + private String pattern; + private Boolean additionalItemsBoolean;// Boolean representation of additionalItems + private SchemaArray additionalItemsSchemaArray;// SchemaArray representation of additionalItems + private Integer maxItems; + private Integer minItems; + private Boolean uniqueItems; + private Integer maxProperties; + private Integer minProperties; + private List required; + private Boolean additionalPropertiesBoolean; // Boolean representation of additionalProperties + private Schema additionalPropertiesSchema; // Schema representation of additionalProperties + private List _enum; + private List allOf; + private List anyOf; + private List oneOf; + private Schema not; + private URI ref; + private SchemaMap schemaMap; + private Schema master = this; + + /** +* Default constructor. +*/ + public Schema() {} + + // + // Bean properties + // + +
[28/53] [partial] incubator-juneau git commit: Merge changes from GitHub repo.
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/1b4f98a0/org.apache.juneau.server/src/main/java/org/apache/juneau/server/RestResponse.java -- diff --git a/org.apache.juneau.server/src/main/java/org/apache/juneau/server/RestResponse.java b/org.apache.juneau.server/src/main/java/org/apache/juneau/server/RestResponse.java new file mode 100755 index 000..8983868 --- /dev/null +++ b/org.apache.juneau.server/src/main/java/org/apache/juneau/server/RestResponse.java @@ -0,0 +1,431 @@ +/*** + * 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.juneau.server; + +import java.io.*; +import java.util.*; + +import javax.servlet.*; +import javax.servlet.http.*; + +import org.apache.juneau.*; +import org.apache.juneau.encoders.*; +import org.apache.juneau.jena.*; +import org.apache.juneau.json.*; +import org.apache.juneau.serializer.*; +import org.apache.juneau.urlencoding.*; +import org.apache.juneau.xml.*; + +/** + * Represents an HTTP response for a REST resource. + * + * Essentially an extended {@link HttpServletResponse} with some special convenience methods + * that allow you to easily output POJOs as responses. + * + * + * Since this class extends {@link HttpServletResponse}, developers are free to use these + * convenience methods, or revert to using lower level methods like any other servlet response. + * + * + * Examples + * + * @RestMethod(name="GET") + * public void doGet(RestRequest req, RestResponse res) { + * res.setProperty(HtmlSerializerContext.HTMLDOC_title, "My title") + * .setOutput("Simple string response"); + * } + * + * + * Refer to REST Servlet API for information about using this class. + * + * + * @author jbognar + */ +public final class RestResponse extends HttpServletResponseWrapper { + + private final RestRequest request; + private Object output; // The POJO being sent to the output. + private boolean isNullOutput;// The output is null (as opposed to not being set at all) + private ObjectMap properties;// Response properties + SerializerGroup serializerGroup; + UrlEncodingSerializer urlEncodingSerializer; // The serializer used to convert arguments passed into Redirect objects. + private EncoderGroup encoders; + private RestServlet servlet; + private ServletOutputStream os; + + /** +* Constructor. +*/ + RestResponse(RestServlet servlet, RestRequest req, HttpServletResponse res) { + super(res); + this.request = req; + this.servlet = servlet; + + for (Map.Entrye : servlet.getDefaultResponseHeaders().entrySet()) + setHeader(e.getKey(), e.getValue().toString()); + + try { + String passThroughHeaders = req.getHeader("x-response-headers"); + if (passThroughHeaders != null) { + ObjectMap m = servlet.getUrlEncodingParser().parseParameter(passThroughHeaders, ObjectMap.class); + for (Map.Entry e : m.entrySet()) + setHeader(e.getKey(), e.getValue().toString()); + } + } catch (Exception e1) { + throw new RestException(SC_BAD_REQUEST, "Invalid format for header 'x-response-headers'. Must be in URL-encoded format.").initCause(e1); + } + } + + /* +* Called from RestServlet after a match has been made but before the guard or method invocation. +*/ + @SuppressWarnings("hiding") + final void init(ObjectMap properties, String defaultCharset, SerializerGroup mSerializers, UrlEncodingSerializer mUrlEncodingSerializer,
[49/53] [partial] incubator-juneau git commit: Merge changes from GitHub repo.
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/1b4f98a0/org.apache.juneau.client/src/main/java/org/apache/juneau/client/RestCall.java -- diff --git a/org.apache.juneau.client/src/main/java/org/apache/juneau/client/RestCall.java b/org.apache.juneau.client/src/main/java/org/apache/juneau/client/RestCall.java new file mode 100755 index 000..8b79d13 --- /dev/null +++ b/org.apache.juneau.client/src/main/java/org/apache/juneau/client/RestCall.java @@ -0,0 +1,947 @@ +/*** + * 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.juneau.client; + +import java.io.*; +import java.net.*; +import java.util.*; +import java.util.logging.*; +import java.util.regex.*; + +import org.apache.http.*; +import org.apache.http.client.*; +import org.apache.http.client.config.*; +import org.apache.http.client.methods.*; +import org.apache.http.impl.client.*; +import org.apache.http.util.*; +import org.apache.juneau.*; +import org.apache.juneau.encoders.*; +import org.apache.juneau.internal.*; +import org.apache.juneau.parser.*; +import org.apache.juneau.parser.ParseException; +import org.apache.juneau.serializer.*; +import org.apache.juneau.utils.*; + +/** + * Represents a connection to a remote REST resource. + * + * Instances of this class are created by the various {@code doX()} methods on the {@link RestClient} class. + * + * This class uses only Java standard APIs. Requests can be built up using a fluent interface with method chaining, like so... + * + * + * RestClient client = new RestClient(); + * RestCall c = client.doPost(URL).setInput(o).setHeader(x,y); + * MyBean b = c.getResponse(MyBean.class); + * + * + * The actual connection and request/response transaction occurs when calling one of the getResponseXXX() methods. + * + * Additional Information + * + * org.apache.juneau.client REST client API for more information and code examples. + * + * + * @author James Bognar (james.bog...@salesforce.com) + */ +public final class RestCall { + + private final RestClient client; // The client that created this call. + private final HttpRequestBase request; // The request. + private HttpResponse response; // The response. + private List interceptors = new ArrayList(); // Used for intercepting and altering requests. + + private boolean isConnected = false; // connect() has been called. + private boolean allowRedirectsOnPosts; + private int retries = 1; + private int redirectOnPostsTries = 5; + private long retryInterval = -1; + private RetryOn retryOn = RetryOn.DEFAULT; + private boolean ignoreErrors; + private boolean byLines = false; + private TeeWriter writers = new TeeWriter(); + private StringWriter capturedResponseWriter; + private String capturedResponse; + private TeeOutputStream outputStreams = new TeeOutputStream(); + private boolean isClosed = false; + private boolean isFailed = false; + + /** +* Constructs a REST call with the specified method name. +* +* @param client The client that created this request. +* @param request The wrapped Apache HTTP client request object. +* @throws RestCallException If an exception or non-200 response code occurred during the connection attempt. +*/ + protected RestCall(RestClient client, HttpRequestBase request) throws RestCallException { + this.client = client; + this.request = request; + for (RestCallInterceptor i : this.client.interceptors) + addInterceptor(i); + } + + /** +* Sets the input for this REST call. +* +* @param input The input to be sent to the REST resource (only valid for PUT and POST)
[30/53] [partial] incubator-juneau git commit: Merge changes from GitHub repo.
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/1b4f98a0/org.apache.juneau.server.test/src/test/java/org/apache/juneau/server/TestUtils.java -- diff --git a/org.apache.juneau.server.test/src/test/java/org/apache/juneau/server/TestUtils.java b/org.apache.juneau.server.test/src/test/java/org/apache/juneau/server/TestUtils.java new file mode 100755 index 000..996a185 --- /dev/null +++ b/org.apache.juneau.server.test/src/test/java/org/apache/juneau/server/TestUtils.java @@ -0,0 +1,60 @@ +/*** + * 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.juneau.server; + +import java.text.*; + +import org.apache.juneau.client.*; +import org.apache.juneau.json.*; +import org.apache.juneau.serializer.*; +import org.apache.juneau.transforms.*; +import org.junit.Assert; + +import junit.framework.*; + +public class TestUtils { + + private static JsonSerializer js2 = new JsonSerializer.Simple() + .addTransforms(IteratorTransform.class, EnumerationTransform.class); + + /** +* Assert that the object equals the specified string after running it through JsonSerializer.DEFAULT_LAX.toString(). +*/ + public static void assertObjectEquals(String s, Object o) { + assertObjectEquals(s, o, js2); + } + + /** +* Assert that the object equals the specified string after running it through ws.toString(). +*/ + public static void assertObjectEquals(String s, Object o, WriterSerializer ws) { + Assert.assertEquals(s, ws.toString(o)); + } + + public static void checkErrorResponse(boolean debug, RestCallException e, int status, String...contains) throws AssertionFailedError { + String r = e.getResponseMessage(); + if (debug) { + System.err.println(r); + e.printStackTrace(); + } + if (status != e.getResponseCode()) + throw new AssertionFailedError(MessageFormat.format("Response status code was not correct. Expected: ''{0}''. Actual: ''{1}''", status, e.getResponseCode())); + for (String s : contains) { + if (r == null || ! r.contains(s)) { + if (! debug) + System.err.println(r); + throw new AssertionFailedError(MessageFormat.format("Response did not have the following expected text: ''{0}''", s)); + } + } + } +} http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/1b4f98a0/org.apache.juneau.server/.classpath -- diff --git a/org.apache.juneau.server/.classpath b/org.apache.juneau.server/.classpath new file mode 100755 index 000..a953066 --- /dev/null +++ b/org.apache.juneau.server/.classpath @@ -0,0 +1,24 @@ + + + + + + + + + + + + + + + + + + + + + + + + http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/1b4f98a0/org.apache.juneau.server/.gitignore -- diff --git a/org.apache.juneau.server/.gitignore b/org.apache.juneau.server/.gitignore new file mode 100644 index 000..30e1a65 --- /dev/null +++ b/org.apache.juneau.server/.gitignore @@ -0,0 +1,2 @@ +bin/ +/target/ http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/1b4f98a0/org.apache.juneau.server/.project -- diff --git a/org.apache.juneau.server/.project b/org.apache.juneau.server/.project new file
[03/53] [partial] incubator-juneau git commit: Merge changes from GitHub repo.
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/1b4f98a0/org.apache.juneau/src/main/java/org/apache/juneau/ini/ConfigMgr.java -- diff --git a/org.apache.juneau/src/main/java/org/apache/juneau/ini/ConfigMgr.java b/org.apache.juneau/src/main/java/org/apache/juneau/ini/ConfigMgr.java new file mode 100644 index 000..64c19b7 --- /dev/null +++ b/org.apache.juneau/src/main/java/org/apache/juneau/ini/ConfigMgr.java @@ -0,0 +1,314 @@ +/*** + * 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.juneau.ini; + +import static org.apache.juneau.ini.ConfigFileFormat.*; + +import java.io.*; +import java.nio.charset.*; +import java.util.*; +import java.util.concurrent.*; + +import org.apache.juneau.internal.*; +import org.apache.juneau.json.*; +import org.apache.juneau.parser.*; +import org.apache.juneau.serializer.*; +import org.apache.juneau.utils.*; + +/** + * Manager for retrieving shared instances of {@link ConfigFile ConfigFiles}. + * + * Example: + * + * ConfigFile cf = ConfigMgr.DEFAULT.get("MyConfig.cfg"); + * String setting = cf.get("MySection/mysetting"); + * + */ +public class ConfigMgr { + + /** +* Default reusable configuration manager. +* +* Read-only: false. +* Encoder: {@link XorEncoder}. +* Serializer: {@link JsonSerializer#DEFAULT}. +* Parser: {@link JsonParser#DEFAULT}. +* Charset: {@link Charset#defaultCharset()}. +* Search paths: ["."]. +* +*/ + public static final ConfigMgr DEFAULT = new ConfigMgr(false, new XorEncoder(), JsonSerializer.DEFAULT, JsonParser.DEFAULT, Charset.defaultCharset(), new String[]{"."}); + + private ConcurrentHashMapfiles = new ConcurrentHashMap (); + private ConcurrentHashMap configs = new ConcurrentHashMap (); + private final WriterSerializer serializer; + private final ReaderParser parser; + private final Encoder encoder; + private final boolean readOnly; + private final Charset charset; + private final List searchPaths = new LinkedList(); + + /** +* Create a custom configuration manager. +* +* @param readOnly Make {@link ConfigFile ConfigFiles} read-only. +* @param encoder Optional. Specify the encoder to use for encoded config file entries (e.g. "mySecret*={...}"). +* @param serializer Optional. Specify the serializer to use for serializing POJOs when using {@link ConfigFile#put(String, Object)}. +* @param parser Optional. Specify the parser to use for parsing POJOs when using {@link ConfigFile#getObject(Class,String)}. +* @param charset Optional. Specify the config file character encoding. If null, uses {@link Charset#defaultCharset()}. +* @param searchPaths Specify the search paths for config files. Can contain relative or absolute paths. +*/ + public ConfigMgr(boolean readOnly, Encoder encoder, WriterSerializer serializer, ReaderParser parser, Charset charset, String[] searchPaths) { + this.readOnly = readOnly; + this.encoder = encoder; + this.serializer = serializer; + this.parser = parser; + this.charset = charset; + if (searchPaths != null) + for (String p : searchPaths) + this.searchPaths.add(new File(p)); + } + + /** +* Returns the config file with the specified absolute or relative path. +* +* Multiple calls to the same path return the same ConfigFile instance. +* +* @param path The absolute or relative path of the config file. +* @return The config file. +* @throws IOException If config file could not be parsed. +* @throws
[12/53] [partial] incubator-juneau git commit: Merge changes from GitHub repo.
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/1b4f98a0/org.apache.juneau/src/main/java/org/apache/juneau/dto/atom/Category.java -- diff --git a/org.apache.juneau/src/main/java/org/apache/juneau/dto/atom/Category.java b/org.apache.juneau/src/main/java/org/apache/juneau/dto/atom/Category.java new file mode 100644 index 000..2dce6c6 --- /dev/null +++ b/org.apache.juneau/src/main/java/org/apache/juneau/dto/atom/Category.java @@ -0,0 +1,141 @@ +/*** + * 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.juneau.dto.atom; + +import static org.apache.juneau.xml.annotation.XmlFormat.*; + +import java.net.*; + +import org.apache.juneau.xml.annotation.*; + +/** + * Represents an atomCategory construct in the RFC4287 specification. + * + * Schema + * + * atomCategory = + * element atom:category { + * atomCommonAttributes, + * attribute term { text }, + * attribute scheme { atomUri }?, + * attribute label { text }?, + * undefinedContent + * } + * + * + * Refer to {@link org.apache.juneau.dto.atom} for further information about ATOM support. + * + * + * @author James Bognar (james.bog...@salesforce.com) + */ +@Xml(name="category") +public class Category extends Common { + + private String term; + private URI scheme; + private String label; + + /** +* Normal constructor. +* @param term The category term. +*/ + public Category(String term) { + this.term = term; + } + + /** Bean constructor. */ + public Category() {} + + + // + // Bean properties + // + + /** +* @return The category term. +*/ + @Xml(format=ATTR) + public String getTerm() { + return term; + } + + /** +* Sets the category term. +* +* @param term The category term. +* @return This object (for method chaining). +*/ + public Category setTerm(String term) { + this.term = term; + return this; + } + + /** +* Returns the category scheme. +* +* @return The category scheme. +*/ + @Xml(format=ATTR) + public URI getScheme() { + return scheme; + } + + /** +* Sets the category scheme. +* +* @param scheme The category scheme. +* @return This object (for method chaining). +*/ + public Category setScheme(URI scheme) { + this.scheme = scheme; + return this; + } + + /** +* Returns the category label. +* +* @return The category label. +*/ + @Xml(format=ATTR) + public String getLabel() { + return label; + } + + /** +* Sets the category label. +* +* @param label The category label. +* @return This object (for method chaining). +*/ + public Category setLabel(String label) { + this.label = label; + return this; + } + + + // + // Overridden setters (to simplify method chaining) + // + + @Override /* Common */ + public Category setBase(URI base) { + super.setBase(base); + return this; + } + + @Override /* Common */ + public Category setLang(String lang) { + super.setLang(lang); + return this; + }
[53/53] incubator-juneau git commit: Add missing copyrights.
Add missing copyrights. Project: http://git-wip-us.apache.org/repos/asf/incubator-juneau/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-juneau/commit/5f1a39d5 Tree: http://git-wip-us.apache.org/repos/asf/incubator-juneau/tree/5f1a39d5 Diff: http://git-wip-us.apache.org/repos/asf/incubator-juneau/diff/5f1a39d5 Branch: refs/heads/master Commit: 5f1a39d5ed173de0805283618d4c5761e5b84d64 Parents: 623f3ce Author: jamesbognarAuthored: Mon Aug 1 13:29:40 2016 -0400 Committer: jamesbognar Committed: Mon Aug 1 13:29:40 2016 -0400 -- org.apache.juneau.releng/Readme.txt | 33 .../juneau/samples/addressbook/package.html | 15 + .../server/samples/CodeFormatterResource.html | 15 + .../juneau/server/samples/SqlQueryResource.html | 15 + .../src/test/resources/log4j.properties | 16 +- 5 files changed, 60 insertions(+), 34 deletions(-) -- http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/5f1a39d5/org.apache.juneau.releng/Readme.txt -- diff --git a/org.apache.juneau.releng/Readme.txt b/org.apache.juneau.releng/Readme.txt deleted file mode 100755 index dce0414..000 --- a/org.apache.juneau.releng/Readme.txt +++ /dev/null @@ -1,33 +0,0 @@ -# -# Juneau Components List -# - -- -juneau-all.jar -Contains all binaries from the Core, Server, Client, and Microservice APIs -- - -- -bundles/* -Contents of juneau-all.jar as individual OSGi bundles. -- - -- -source/* -Same as the binaries, except includes all the source code as well. -- - -- -juneau-javadocs.war -The docs for everything. -- - -- -microservice-project.zip -The Eclipse project template for creating a microservice. -- - -- -microservice-samples-project.zip -The Eclipse project for running the samples. -- http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/5f1a39d5/org.apache.juneau.samples/src/main/java/org/apache/juneau/samples/addressbook/package.html -- diff --git a/org.apache.juneau.samples/src/main/java/org/apache/juneau/samples/addressbook/package.html b/org.apache.juneau.samples/src/main/java/org/apache/juneau/samples/addressbook/package.html index 5ac8abc..21caee9 100755 --- a/org.apache.juneau.samples/src/main/java/org/apache/juneau/samples/addressbook/package.html +++ b/org.apache.juneau.samples/src/main/java/org/apache/juneau/samples/addressbook/package.html @@ -1,3 +1,18 @@ +
[18/53] [partial] incubator-juneau git commit: Merge changes from GitHub repo.
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/1b4f98a0/org.apache.juneau/src/main/java/org/apache/juneau/BeanContext.java -- diff --git a/org.apache.juneau/src/main/java/org/apache/juneau/BeanContext.java b/org.apache.juneau/src/main/java/org/apache/juneau/BeanContext.java new file mode 100644 index 000..3b2f51c --- /dev/null +++ b/org.apache.juneau/src/main/java/org/apache/juneau/BeanContext.java @@ -0,0 +1,2069 @@ +/*** + * 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.juneau; + +import static org.apache.juneau.Visibility.*; +import static org.apache.juneau.internal.ClassUtils.*; +import static org.apache.juneau.internal.ThrowableUtils.*; + +import java.beans.*; +import java.io.*; +import java.lang.reflect.*; +import java.text.*; +import java.util.*; +import java.util.concurrent.*; +import java.util.concurrent.atomic.*; + +import org.apache.juneau.annotation.*; +import org.apache.juneau.internal.*; +import org.apache.juneau.json.*; +import org.apache.juneau.parser.*; +import org.apache.juneau.serializer.*; +import org.apache.juneau.transform.*; +import org.apache.juneau.transform.Transform; + +/** + * Core class of the Juneau architecture. + * + * This class servers multiple purposes: + * + * Provides the ability to wrap beans inside {@link Map} interfaces. + * Serves as a repository for metadata on POJOs, such as associated {@link Transform transforms}, {@link PropertyNamer property namers}, etc... + * which are used to tailor how POJOs are serialized and parsed. + * Serves as a common utility class for all {@link Serializer Serializers} and {@link Parser Parsers} + * for serializing and parsing Java beans. + * + * + * + * Bean Contexts + * + * Typically, it will be sufficient to use the existing {@link #DEFAULT} contexts for creating + * bean maps. However, if you want to tweak any of the settings on the context, you must + * either clone the default context or create a new one from scratch (whichever is simpler for you). + * You'll notice that this context class uses a fluent interface for defining settings. + * + * Bean contexts are created by {@link ContextFactory context factories}. + * The settings on a bean context are fixed at the point they are created by the factory. + * + * + * BeanContext settings + * BeanContexts have several settings that can be used to tweak behavior on how beans are handled. + * These are denoted as the static BEAN_* fields on this class. + * + * Some settings (e.g. {@link BeanContext#BEAN_beansRequireDefaultConstructor}) are used to differentiate between bean and non-bean classes. + * Attempting to create a bean map around one of these objects will throw a {@link BeanRuntimeException}. + * The purpose for this behavior is so that the serializers can identify these non-bean classes and convert them to plain strings using the {@link Object#toString()} method. + * + * Some settings (e.g. {@link BeanContext#BEAN_beanFieldVisibility}) are used to determine what kinds of properties are detected on beans. + * + * Some settings (e.g. {@link BeanContext#BEAN_beanMapPutReturnsOldValue}) change the runtime behavior of bean maps. + * + * Settings are specified using the {@link ContextFactory#setProperty(String, Object)} method and related convenience methods. + * + * Examples + * + * // Construct a context from scratch. + * BeanContext beanContext = ContextFactory.create() + * .setProperty(BeanContext.BEAN_beansRequireDefaultConstructor, true) + * .addNotBeanClasses(Foo.class) + * .getBeanContext(); + * + * // Clone an existing context factory. + * BeanContext beanContext = ContextFactory.create(otherConfig) + *
[07/53] [partial] incubator-juneau git commit: Merge changes from GitHub repo.
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/1b4f98a0/org.apache.juneau/src/main/java/org/apache/juneau/html/HtmlWriter.java -- diff --git a/org.apache.juneau/src/main/java/org/apache/juneau/html/HtmlWriter.java b/org.apache.juneau/src/main/java/org/apache/juneau/html/HtmlWriter.java new file mode 100644 index 000..ba115b0 --- /dev/null +++ b/org.apache.juneau/src/main/java/org/apache/juneau/html/HtmlWriter.java @@ -0,0 +1,333 @@ +/*** + * 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.juneau.html; + +import java.io.*; + +import org.apache.juneau.xml.*; + +/** + * Specialized writer for serializing HTML. + * + * @author James Bognar (james.bog...@salesforce.com) + */ +public class HtmlWriter extends XmlWriter { + + /** +* Constructor. +* +* @param out The writer being wrapped. +* @param useIndentation If true, tabs will be used in output. +* @param trimStrings If true, strings should be trimmed before they're serialized. +* @param quoteChar The quote character to use (i.e. '\'' or '"') +* @param uriContext The web application context path (e.g. "/contextRoot"). +* @param uriAuthority The web application URI authority (e.g. "http://hostname:9080;) +*/ + public HtmlWriter(Writer out, boolean useIndentation, boolean trimStrings, char quoteChar, String uriContext, String uriAuthority) { + super(out, useIndentation, trimStrings, quoteChar, uriContext, uriAuthority, false, null); + } + + /** +* Append an attribute with a URI value. +* +* @param name The attribute name. +* @param value The attribute value. Can be any object whose toString() method returns a URI. +* @return This object (for method chaining); +* @throws IOException If a problem occurred. +*/ + public HtmlWriter attrUri(String name, Object value) throws IOException { + super.attrUri((String)null, name, value); + return this; + } + + + // + // Overridden methods + // + + @Override /* XmlSerializerWriter */ + public HtmlWriter encodeText(Object o) throws IOException { + + String s = o.toString(); + for (int i = 0; i < s.length(); i++) { + char test = s.charAt(i); + if (test == '&') + append(""); + else if (test == '<') + append(""); + else if (test == '>') + append(""); + else if (test == '\n') + append(""); + else if (test == '\f') + append(""); + else if (test == '\b') + append(""); + else if (test == '\t') + append(""); + else if (Character.isISOControl(test)) + append("
[31/53] [partial] incubator-juneau git commit: Merge changes from GitHub repo.
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/1b4f98a0/org.apache.juneau.server.test/src/test/java/org/apache/juneau/server/CT_TestTransforms.java -- diff --git a/org.apache.juneau.server.test/src/test/java/org/apache/juneau/server/CT_TestTransforms.java b/org.apache.juneau.server.test/src/test/java/org/apache/juneau/server/CT_TestTransforms.java new file mode 100755 index 000..49a9030 --- /dev/null +++ b/org.apache.juneau.server.test/src/test/java/org/apache/juneau/server/CT_TestTransforms.java @@ -0,0 +1,68 @@ +/*** + * 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.juneau.server; + +import static org.junit.Assert.*; + +import org.apache.juneau.client.*; +import org.apache.juneau.json.*; +import org.junit.*; + +public class CT_TestTransforms { + + private static String URL = "/testTransforms"; + + // + // test1 - Test class transform overrides parent class transform + // Should return "A2-1". + // + @Test + public void testClassTransformOverridesParentClassTransform() throws Exception { + RestClient client = new TestRestClient(JsonSerializer.DEFAULT, JsonParser.DEFAULT); + String r; + String url = URL + "/testClassTransformOverridesParentClassTransform"; + + r = client.doGet(url).getResponse(String.class); + assertEquals("A2-0", r); + + r = client.doPut(url, "A2-1").getResponse(String.class); + assertEquals("A2-1", r); + + r = client.doPut(url + "/A2-2", "").getResponse(String.class); + assertEquals("A2-2", r); + + client.closeQuietly(); + } + + // + // Test method transform overrides class transform + // Should return "A3-1". + // + @Test + public void testMethodTransformOverridesClassTransform() throws Exception { + RestClient client = new TestRestClient(JsonSerializer.DEFAULT, JsonParser.DEFAULT); + String r; + String url = URL + "/testMethodTransformOverridesClassTransform"; + + r = client.doGet(url).getResponse(String.class); + assertEquals("A3-0", r); + + r = client.doPut(url, "A3-1").getResponse(String.class); + assertEquals("A3-1", r); + + r = client.doPut(url + "/A3-2", "").getResponse(String.class); + assertEquals("A3-2", r); + + client.closeQuietly(); + } +} http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/1b4f98a0/org.apache.juneau.server.test/src/test/java/org/apache/juneau/server/CT_TestUris.java -- diff --git a/org.apache.juneau.server.test/src/test/java/org/apache/juneau/server/CT_TestUris.java b/org.apache.juneau.server.test/src/test/java/org/apache/juneau/server/CT_TestUris.java new file mode 100755 index 000..d5b1f04 --- /dev/null +++ b/org.apache.juneau.server.test/src/test/java/org/apache/juneau/server/CT_TestUris.java @@ -0,0 +1,918 @@ +/*** + * 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
[27/53] [partial] incubator-juneau git commit: Merge changes from GitHub repo.
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/1b4f98a0/org.apache.juneau.server/src/main/java/org/apache/juneau/server/RestServlet.java -- diff --git a/org.apache.juneau.server/src/main/java/org/apache/juneau/server/RestServlet.java b/org.apache.juneau.server/src/main/java/org/apache/juneau/server/RestServlet.java new file mode 100755 index 000..9b5bbb8 --- /dev/null +++ b/org.apache.juneau.server/src/main/java/org/apache/juneau/server/RestServlet.java @@ -0,0 +1,2795 @@ +/*** + * 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.juneau.server; + +import static java.lang.String.*; +import static java.util.logging.Level.*; +import static javax.servlet.http.HttpServletResponse.*; +import static org.apache.juneau.internal.ArrayUtils.*; +import static org.apache.juneau.internal.ClassUtils.*; +import static org.apache.juneau.serializer.SerializerContext.*; +import static org.apache.juneau.server.RestServlet.ParamType.*; +import static org.apache.juneau.server.RestServletContext.*; +import static org.apache.juneau.server.annotation.Inherit.*; + +import java.io.*; +import java.lang.annotation.Annotation; +import java.lang.reflect.*; +import java.lang.reflect.Method; +import java.nio.charset.*; +import java.text.*; +import java.util.*; +import java.util.concurrent.*; +import java.util.logging.*; + +import javax.activation.*; +import javax.servlet.*; +import javax.servlet.http.*; + +import org.apache.juneau.*; +import org.apache.juneau.encoders.*; +import org.apache.juneau.encoders.Encoder; +import org.apache.juneau.ini.*; +import org.apache.juneau.internal.*; +import org.apache.juneau.json.*; +import org.apache.juneau.parser.*; +import org.apache.juneau.parser.ParseException; +import org.apache.juneau.serializer.*; +import org.apache.juneau.server.annotation.*; +import org.apache.juneau.server.annotation.Properties; +import org.apache.juneau.server.annotation.Var; +import org.apache.juneau.server.labels.*; +import org.apache.juneau.server.response.*; +import org.apache.juneau.server.vars.*; +import org.apache.juneau.svl.*; +import org.apache.juneau.svl.vars.*; +import org.apache.juneau.urlencoding.*; +import org.apache.juneau.utils.*; + +/** + * Servlet implementation of a REST resource. + * + * Refer to REST Servlet API for information about using this class. + * + * + * @author jbognar + */ +@SuppressWarnings({"rawtypes","hiding"}) +public abstract class RestServlet extends HttpServlet { + + private static final long serialVersionUID = 1L; + + static final SortedMapavailableCharsets = new TreeMap (String.CASE_INSENSITIVE_ORDER); + static { + availableCharsets.putAll(Charset.availableCharsets()); + } + // Map of HTTP method names (e.g. GET/PUT/...) to ResourceMethod implementations for it. Populated during resource initialization. + private final Map restMethods = new LinkedHashMap (); + + // The list of all @RestMethod annotated methods in the order they appear in the class. + private final Map javaRestMethods = new LinkedHashMap (); + + // Child resources of this resource defined through getX() methods on this class. + private final Map childResources = new LinkedHashMap (); + + private RestServlet parentResource; + + private ServletConfig servletConfig; + private volatile boolean isInitialized = false; + private Exception initException; // Exception thrown by init() method (cached so it can be thrown on all subsequent requests). + private JuneauLogger logger; + private MessageBundle msgs; // NLS messages. + + private Map stackTraceHashes = new HashMap (); +
[44/51] [partial] incubator-juneau git commit: Merge changes from GitHub repo.
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/244cc21a/org.apache.juneau.microservice/src/main/java/org/apache/juneau/microservice/resources/DirectoryResource.java -- diff --git a/org.apache.juneau.microservice/src/main/java/org/apache/juneau/microservice/resources/DirectoryResource.java b/org.apache.juneau.microservice/src/main/java/org/apache/juneau/microservice/resources/DirectoryResource.java new file mode 100755 index 000..53b79b9 --- /dev/null +++ b/org.apache.juneau.microservice/src/main/java/org/apache/juneau/microservice/resources/DirectoryResource.java @@ -0,0 +1,357 @@ +/*** + * 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.juneau.microservice.resources; + +import static java.util.logging.Level.*; +import static javax.servlet.http.HttpServletResponse.*; +import static org.apache.juneau.html.HtmlDocSerializerContext.*; +import static org.apache.juneau.server.RestServletContext.*; + +import java.io.*; +import java.net.*; +import java.util.*; +import java.util.logging.*; + +import javax.servlet.*; + +import org.apache.juneau.*; +import org.apache.juneau.annotation.*; +import org.apache.juneau.microservice.*; +import org.apache.juneau.server.*; +import org.apache.juneau.server.annotation.*; +import org.apache.juneau.server.converters.*; +import org.apache.juneau.transforms.*; +import org.apache.juneau.utils.*; + +/** + * REST resource that allows access to a file system directory. + * + * The root directory is specified in one of two ways: + * + * + * Specifying the location via a DirectoryResource.rootDir property. + * Overriding the {@link #getRootDir()} method. + * + * + * Read/write access control is handled through the following properties: + * + * + * DirectoryResource.allowViews - If true, allows view and download access to files. + * DirectoryResource.allowPuts - If true, allows files to be created or overwritten. + * DirectoryResource.allowDeletes - If true, allows files to be deleted. + * + * + * Access can also be controlled by overriding the {@link #checkAccess(RestRequest)} method. + * + */ +@RestResource( + label="File System Explorer", + description="Contents of $A{path}", + messages="nls/DirectoryResource", + properties={ + @Property(name=HTML_uriAnchorText, value=PROPERTY_NAME), + @Property(name=HTMLDOC_links, value="{up:'$R{requestParentURI}',options:'?method=OPTIONS',source:'$R{servletParentURI}/source?classes=(org.apache.juneau.server.samples.DirectoryResource)'}"), + @Property(name=REST_allowMethodParam, value="*"), + @Property(name="DirectoryResource.rootDir", value=""), + @Property(name="DirectoryResource.allowViews", value="false"), + @Property(name="DirectoryResource.allowDeletes", value="false"), + @Property(name="DirectoryResource.allowPuts", value="false") + } +) +public class DirectoryResource extends Resource { + private static final long serialVersionUID = 1L; + + private File rootDir; // The root directory + + // Settings enabled through servlet init parameters + private boolean allowDeletes, allowPuts, allowViews; + + private static Logger logger = Logger.getLogger(DirectoryResource.class.getName()); + + @Override /* Servlet */ + public void init() throws ServletException { + ObjectMap p = getProperties(); + rootDir = new File(p.getString("DirectoryResource.rootDir")); + allowViews = p.getBoolean("DirectoryResource.allowViews", false); + allowDeletes = p.getBoolean("DirectoryResource.allowDeletes", false); + allowPuts = p.getBoolean("DirectoryResource.allowPuts", false); + } + + /** +* Returns the root directory defined by the 'rootDir' init parameter. +*
[25/51] [partial] incubator-juneau git commit: Merge changes from GitHub repo.
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/244cc21a/org.apache.juneau.server/src/main/java/org/apache/juneau/server/annotation/Response.java -- diff --git a/org.apache.juneau.server/src/main/java/org/apache/juneau/server/annotation/Response.java b/org.apache.juneau.server/src/main/java/org/apache/juneau/server/annotation/Response.java new file mode 100755 index 000..ee8d32c --- /dev/null +++ b/org.apache.juneau.server/src/main/java/org/apache/juneau/server/annotation/Response.java @@ -0,0 +1,68 @@ +/*** + * 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.juneau.server.annotation; + +import static java.lang.annotation.ElementType.*; +import static java.lang.annotation.RetentionPolicy.*; + +import java.lang.annotation.*; + +/** + * Annotation used in conjunction with {@link RestMethod#responses()} to identify possible responses by the method. + * + * Example + * + * @RestMethod( + * name="*", + * responses={ + * @Response(value=200,description="Everything was great."), + * @Response(value=404,description="File was not found.") + * @Response(500), + * } + * ) + * public void doAnything(RestRequest req, RestResponse res, @Method String method) { + * ... + * } + * + * + * @author James Bognar (james.bog...@salesforce.com) + */ +@Documented +@Target(PARAMETER) +@Retention(RUNTIME) +@Inherited +public @interface Response { + + /** +* HTTP response code. +*/ + int value(); + + /** +* Optional description. +* +* The default value pulls the description from the description entry in the servlet resource bundle. +* (e.g. "myMethod.res.[code] = foo" or "MyServlet.myMethod.res.[code] = foo"). +* +* This field can contain variables (e.g. "$L{my.localized.variable}"). +*/ + String description() default ""; + + /** +* Optional response variables. +* +* Response variables can also be defined in the servlet resource bundle. +* (e.g. "myMethod.res.[code].[category].[name] = foo" or "MyServlet.myMethod.res.[code].[category].[name] = foo"). +*/ + Var[] output() default {}; +} http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/244cc21a/org.apache.juneau.server/src/main/java/org/apache/juneau/server/annotation/RestMethod.java -- diff --git a/org.apache.juneau.server/src/main/java/org/apache/juneau/server/annotation/RestMethod.java b/org.apache.juneau.server/src/main/java/org/apache/juneau/server/annotation/RestMethod.java new file mode 100755 index 000..0df53ee --- /dev/null +++ b/org.apache.juneau.server/src/main/java/org/apache/juneau/server/annotation/RestMethod.java @@ -0,0 +1,438 @@ +/*** + * 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. +
[27/51] [partial] incubator-juneau git commit: Merge changes from GitHub repo.
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/244cc21a/org.apache.juneau.server/src/main/java/org/apache/juneau/server/RestServlet.java -- diff --git a/org.apache.juneau.server/src/main/java/org/apache/juneau/server/RestServlet.java b/org.apache.juneau.server/src/main/java/org/apache/juneau/server/RestServlet.java new file mode 100755 index 000..9b5bbb8 --- /dev/null +++ b/org.apache.juneau.server/src/main/java/org/apache/juneau/server/RestServlet.java @@ -0,0 +1,2795 @@ +/*** + * 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.juneau.server; + +import static java.lang.String.*; +import static java.util.logging.Level.*; +import static javax.servlet.http.HttpServletResponse.*; +import static org.apache.juneau.internal.ArrayUtils.*; +import static org.apache.juneau.internal.ClassUtils.*; +import static org.apache.juneau.serializer.SerializerContext.*; +import static org.apache.juneau.server.RestServlet.ParamType.*; +import static org.apache.juneau.server.RestServletContext.*; +import static org.apache.juneau.server.annotation.Inherit.*; + +import java.io.*; +import java.lang.annotation.Annotation; +import java.lang.reflect.*; +import java.lang.reflect.Method; +import java.nio.charset.*; +import java.text.*; +import java.util.*; +import java.util.concurrent.*; +import java.util.logging.*; + +import javax.activation.*; +import javax.servlet.*; +import javax.servlet.http.*; + +import org.apache.juneau.*; +import org.apache.juneau.encoders.*; +import org.apache.juneau.encoders.Encoder; +import org.apache.juneau.ini.*; +import org.apache.juneau.internal.*; +import org.apache.juneau.json.*; +import org.apache.juneau.parser.*; +import org.apache.juneau.parser.ParseException; +import org.apache.juneau.serializer.*; +import org.apache.juneau.server.annotation.*; +import org.apache.juneau.server.annotation.Properties; +import org.apache.juneau.server.annotation.Var; +import org.apache.juneau.server.labels.*; +import org.apache.juneau.server.response.*; +import org.apache.juneau.server.vars.*; +import org.apache.juneau.svl.*; +import org.apache.juneau.svl.vars.*; +import org.apache.juneau.urlencoding.*; +import org.apache.juneau.utils.*; + +/** + * Servlet implementation of a REST resource. + * + * Refer to REST Servlet API for information about using this class. + * + * + * @author jbognar + */ +@SuppressWarnings({"rawtypes","hiding"}) +public abstract class RestServlet extends HttpServlet { + + private static final long serialVersionUID = 1L; + + static final SortedMapavailableCharsets = new TreeMap (String.CASE_INSENSITIVE_ORDER); + static { + availableCharsets.putAll(Charset.availableCharsets()); + } + // Map of HTTP method names (e.g. GET/PUT/...) to ResourceMethod implementations for it. Populated during resource initialization. + private final Map restMethods = new LinkedHashMap (); + + // The list of all @RestMethod annotated methods in the order they appear in the class. + private final Map javaRestMethods = new LinkedHashMap (); + + // Child resources of this resource defined through getX() methods on this class. + private final Map childResources = new LinkedHashMap (); + + private RestServlet parentResource; + + private ServletConfig servletConfig; + private volatile boolean isInitialized = false; + private Exception initException; // Exception thrown by init() method (cached so it can be thrown on all subsequent requests). + private JuneauLogger logger; + private MessageBundle msgs; // NLS messages. + + private Map stackTraceHashes = new HashMap (); +
[02/51] [partial] incubator-juneau git commit: Merge changes from GitHub repo.
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/244cc21a/org.apache.juneau/src/main/java/org/apache/juneau/internal/ByteArrayCache.java -- diff --git a/org.apache.juneau/src/main/java/org/apache/juneau/internal/ByteArrayCache.java b/org.apache.juneau/src/main/java/org/apache/juneau/internal/ByteArrayCache.java new file mode 100644 index 000..9747902 --- /dev/null +++ b/org.apache.juneau/src/main/java/org/apache/juneau/internal/ByteArrayCache.java @@ -0,0 +1,106 @@ +/*** + * 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.juneau.internal; + +import java.io.*; +import java.util.*; +import java.util.concurrent.*; + +/** + * A utility class for caching byte arrays in memory so that duplicate arrays can be reused. + * + * + * @author James Bognar (james.bog...@salesforce.com) + */ +public class ByteArrayCache { + + /** +* Default global byte array cache. +* Note that this can't ever get garbage collected so don't add really large arrays! +*/ + public static final ByteArrayCache DEFAULT = new ByteArrayCache(); + + private final ConcurrentHashMapcache = new ConcurrentHashMap (); + + /** +* Add the specified byte array to this cache. +* +* @param contents The byte array to add to this cache. +* @return Either the same byte array or a previously cached byte array depending on whether the byte array +* already exists in the cache. +*/ + public byte[] cache(byte[] contents) { + if (contents == null) + return null; + ByteArray ba = new ByteArray(contents); + cache.putIfAbsent(ba, ba.contents); + return cache.get(ba); + } + + /** +* Add the specified input stream to this cache. +* +* @param contents The input stream whose contents are to be added to this cache. +* @return Either the same byte array or a previously cached byte array depending on whether the byte array +* already exists in the cache. +* @throws IOException +*/ + public byte[] cache(InputStream contents) throws IOException { + if (contents == null) + return null; + ByteArray ba = new ByteArray(IOUtils.readBytes(contents, 1024)); + cache.putIfAbsent(ba, ba.contents); + return cache.get(ba); + } + + /** +* Returns the number of byte arrays in this cache. +* +* @return The number of byte arrays in this cache. +*/ + public int size() { + return cache.size(); + } + + private static class ByteArray { + private int hashCode; + private byte[] contents; + + private ByteArray(byte[] contents) { + this.contents = contents; + int multiplier = 1; + for (int i = 0; i < contents.length; i++) { + hashCode += contents[i] * multiplier; + int shifted = multiplier << 5; + multiplier = shifted - multiplier; + } + } + + @Override /* Object */ + public int hashCode() { + if (hashCode == 0) { + } + return hashCode; + } + + @Override /* Object */ + public boolean equals(Object o) { + if (o instanceof ByteArray) { + ByteArray ba = (ByteArray)o; + if (ba.hashCode == hashCode) + return Arrays.equals(ba.contents, contents); + } +
[15/51] [partial] incubator-juneau git commit: Merge changes from GitHub repo.
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/244cc21a/org.apache.juneau/src/main/java/org/apache/juneau/ContextFactory.java -- diff --git a/org.apache.juneau/src/main/java/org/apache/juneau/ContextFactory.java b/org.apache.juneau/src/main/java/org/apache/juneau/ContextFactory.java new file mode 100644 index 000..becf8f1 --- /dev/null +++ b/org.apache.juneau/src/main/java/org/apache/juneau/ContextFactory.java @@ -0,0 +1,1298 @@ +/*** + * 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.juneau; + +import static org.apache.juneau.BeanContext.*; + +import java.lang.reflect.*; +import java.util.*; +import java.util.concurrent.*; +import java.util.concurrent.locks.*; + +import org.apache.juneau.internal.*; +import org.apache.juneau.json.*; +import org.apache.juneau.parser.*; + +/** + * A factory for instantiating {@link Context} objects. + * + * The hierarchy of these objects are... + * + * {@link ContextFactory} - A thread-safe, modifiable context property store. + * Used to create {@link Context} objects. + * {@link Context} - A reusable, cachable, thread-safe, read-only context with configuration properties copied from the factory. + * Often used to create {@link Session} objects. + * {@link Session} - A one-time-use non-thread-safe object. + * Used by serializers and parsers to retrieve context properties and to be used as scratchpads. + * + * + * + * ContextFactory objects + * + * Context factories can be thought of as consisting of the following: + * + * A MapString,Object of context properties. + * A MapClass,Context of context instances. + * + * + * Context factories are used to create and cache {@link Context} objects using the {@link #getContext(Class)} method. + * + * As a general rule, {@link ContextFactory} objects are 'slow'. + * Setting and retrieving properties on a factory can involve relatively slow data conversion and synchronization. + * However, the {@link #getContext(Class)} method is fast, and will return cached context objects if the context properties have not changed. + * + * Context factories can be used to store context properties for a variety of contexts. + * For example, a single factory can store context properties for the JSON serializer, XML serializer, HTML serializer + * etc... and can thus be used to retrieve context objects for those serializers. + * + * Other notes: + * + * Context factories can be locked using the {@link #lock()} method. + * This prevents the context properties from being further modified. + * Context factories can be cloned using the {@link #clone} method. + * This will return a new unlocked factory with the same context properties. + * + * + * Context properties + * + * Context properties are 'settings' for serializers and parsers. + * For example, the {@link BeanContext#BEAN_sortProperties} context property defines whether + * bean properties should be serialized in alphabetical order. + * + * Each {@link Context} object should contain the context properties that apply to it as static + * fields (e.g {@link BeanContext#BEAN_sortProperties}). + * + * Context properties can be of the following types: + * + * SIMPLE - A simple property. + * Examples include: booleans, integers, Strings, Classes, etc... + * + * An example of this would be the {@link BeanContext#BEAN_sortProperties} property. + * It's name is simply "BeanContext.sortProperties". + * + * SET - A sorted set of objects. + * These are denoted by appending
[17/51] [partial] incubator-juneau git commit: Merge changes from GitHub repo.
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/244cc21a/org.apache.juneau/src/main/java/org/apache/juneau/BeanMap.java -- diff --git a/org.apache.juneau/src/main/java/org/apache/juneau/BeanMap.java b/org.apache.juneau/src/main/java/org/apache/juneau/BeanMap.java new file mode 100644 index 000..adef3ab --- /dev/null +++ b/org.apache.juneau/src/main/java/org/apache/juneau/BeanMap.java @@ -0,0 +1,489 @@ +/*** + * 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.juneau; + +import java.io.*; +import java.lang.reflect.*; +import java.util.*; + +import org.apache.juneau.annotation.*; +import org.apache.juneau.parser.*; +import org.apache.juneau.transform.*; +import org.apache.juneau.xml.annotation.*; + +/** + * Java bean wrapper class. + * + * + * Description + * + * A wrapper that wraps Java bean instances inside of a {@link Map} interface that allows + * properties on the wrapped object can be accessed using the {@link Map#get(Object) get()} and {@link Map#put(Object,Object) put()} methods. + * + * Use the {@link BeanContext} class to create instances of this class. + * + * + * Bean property order + * + * The order of the properties returned by the {@link Map#keySet() keySet()} and {@link Map#entrySet() entrySet()} methods are as follows: + * + * If {@link Bean @Bean} annotation is specified on class, then the order is the same as the list of properties in the annotation. + * If {@link Bean @Bean} annotation is not specified on the class, then the order is the same as that returned + * by the {@link java.beans.BeanInfo} class (i.e. ordered by definition in the class). + * + * + * The order can also be overridden through the use of a {@link BeanTransform}. + * + * + * POJO transforms + * + * If {@link PojoTransform PojoTransforms} are defined on the class types of the properties of this bean or the bean properties themselves, the + * {@link #get(Object)} and {@link #put(String, Object)} methods will automatically + * transform the property value to and from the serialized form. + * + * @author Barry M. Caceres + * @author James Bognar (james.bog...@salesforce.com) + * @param Specifies the type of object that this map encapsulates. + */ +public class BeanMap extends AbstractMapimplements Delegate { + + /** The wrapped object. */ + protected T bean; + + /** Temporary holding cache for beans with read-only properties. Normally null. */ + protected Map propertyCache; + + /** Temporary holding cache for bean properties of array types when the add() method is being used. */ + protected Map arrayPropertyCache; + + /** The BeanMeta associated with the class of the object. */ + protected BeanMeta meta; + + /** +* Instance of this class are instantiated through the BeanContext class. +* +* @param bean The bean to wrap inside this map. +* @param meta The metadata associated with the bean class. +*/ + protected BeanMap(T bean, BeanMeta meta) { + this.bean = bean; + this.meta = meta; + if (meta.constructorArgs.length > 0) + propertyCache = new TreeMap (); + } + + /** +* Returns the metadata associated with this bean map. +* +* @return The metadata associated with this bean map. +*/ + public BeanMeta getMeta() { + return meta; + } + + /** +* Returns the wrapped bean object. +* Triggers bean creation if bean has read-only properties set through a constructor +* defined by the {@link BeanConstructor} annotation. +* +* @return The inner bean object. +*/ + public T getBean() { +
[14/51] [partial] incubator-juneau git commit: Merge changes from GitHub repo.
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/30947fd7/com.ibm.team.juno.releng/bin/core/com/ibm/juno/core/jena/annotation/Rdf.java -- diff --git a/com.ibm.team.juno.releng/bin/core/com/ibm/juno/core/jena/annotation/Rdf.java b/com.ibm.team.juno.releng/bin/core/com/ibm/juno/core/jena/annotation/Rdf.java deleted file mode 100755 index ec52ab5..000 --- a/com.ibm.team.juno.releng/bin/core/com/ibm/juno/core/jena/annotation/Rdf.java +++ /dev/null @@ -1,58 +0,0 @@ -/*** - * Licensed Materials - Property of IBM - * (c) Copyright IBM Corporation 2014, 2015. All Rights Reserved. - * - * The source code for this program is not published or otherwise - * divested of its trade secrets, irrespective of what has been - * deposited with the U.S. Copyright Office. - ***/ -package com.ibm.juno.core.jena.annotation; - -import static java.lang.annotation.ElementType.*; -import static java.lang.annotation.RetentionPolicy.*; - -import java.lang.annotation.*; - -import com.ibm.juno.core.jena.*; - -/** - * Annotation for specifying options for RDF serializers. - * - * Can be applied to Java packages, types, fields, and methods. - * - * Can be used for the following: - * - * Override the default behavior of how collections and arrays are serialized. - * - * - * @author James Bognar (jbog...@us.ibm.com) - */ -@Documented -@Target({PACKAGE,TYPE,FIELD,METHOD}) -@Retention(RUNTIME) -@Inherited -public @interface Rdf { - - /** -* Sets the XML prefix of this property or class. -* -* Must either be matched to a {@link #namespace()} annotation on the same object, parent object, or a {@link RdfNs} with the same name -* through the {@link RdfSchema#rdfNs()} annotation on the package. -* -*/ - String prefix() default ""; - - /** -* Sets the namespace URI of this property or class. -* -* Must be matched with a {@link #prefix()} annotation on this object, a parent object, or a {@link RdfNs} with the same name -* through the {@link RdfSchema#rdfNs()} annotation on the package. -*/ - String namespace() default ""; - - /** -* The format for how collections (e.g. lists and arrays) are serialized in RDF. -* @see RdfCollectionFormat -*/ - RdfCollectionFormat collectionFormat() default RdfCollectionFormat.DEFAULT; -} http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/30947fd7/com.ibm.team.juno.releng/bin/core/com/ibm/juno/core/jena/annotation/RdfNs.class -- diff --git a/com.ibm.team.juno.releng/bin/core/com/ibm/juno/core/jena/annotation/RdfNs.class b/com.ibm.team.juno.releng/bin/core/com/ibm/juno/core/jena/annotation/RdfNs.class deleted file mode 100755 index 44818eb..000 Binary files a/com.ibm.team.juno.releng/bin/core/com/ibm/juno/core/jena/annotation/RdfNs.class and /dev/null differ http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/30947fd7/com.ibm.team.juno.releng/bin/core/com/ibm/juno/core/jena/annotation/RdfNs.java -- diff --git a/com.ibm.team.juno.releng/bin/core/com/ibm/juno/core/jena/annotation/RdfNs.java b/com.ibm.team.juno.releng/bin/core/com/ibm/juno/core/jena/annotation/RdfNs.java deleted file mode 100755 index 96ef14d..000 --- a/com.ibm.team.juno.releng/bin/core/com/ibm/juno/core/jena/annotation/RdfNs.java +++ /dev/null @@ -1,37 +0,0 @@ -/*** - * Licensed Materials - Property of IBM - * (c) Copyright IBM Corporation 2014, 2015. All Rights Reserved. - * - * The source code for this program is not published or otherwise - * divested of its trade secrets, irrespective of what has been - * deposited with the U.S. Copyright Office. - ***/ -package com.ibm.juno.core.jena.annotation; - -import static java.lang.annotation.RetentionPolicy.*; - -import java.lang.annotation.*; - -/** - * Namespace name/URL mapping pair. - * - * Used to identify a namespace/URI pair on a {@link RdfSchema#rdfNs()} annotation. - * - * @author James Bognar (jbog...@us.ibm.com) - */ -@Documented -@Target({}) -@Retention(RUNTIME) -@Inherited -public @interface RdfNs { - - /** -* RDF namespace prefix. -*/ - String prefix(); - - /** -* RDF namespace URL. -*/ - String namespaceURI(); -} http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/30947fd7/com.ibm.team.juno.releng/bin/core/com/ibm/juno/core/jena/annotation/RdfSchema.class
[39/51] [abbrv] [partial] incubator-juneau git commit: Merge changes from GitHub repo.
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/2c3a7cb5/com.ibm.team.juno.samples/src/main/java/org/apache/juneau/samples/addressbook/package-info.java -- diff --git a/com.ibm.team.juno.samples/src/main/java/org/apache/juneau/samples/addressbook/package-info.java b/com.ibm.team.juno.samples/src/main/java/org/apache/juneau/samples/addressbook/package-info.java deleted file mode 100755 index d079914..000 --- a/com.ibm.team.juno.samples/src/main/java/org/apache/juneau/samples/addressbook/package-info.java +++ /dev/null @@ -1,35 +0,0 @@ -/*** - * 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. - ***/ -// XML namespaces used in this package -@XmlSchema( - prefix="ab", - xmlNs={ - @XmlNs(prefix="ab", namespaceURI="http://www.ibm.com/addressBook/;), - @XmlNs(prefix="per", namespaceURI="http://www.ibm.com/person/;), - @XmlNs(prefix="addr", namespaceURI="http://www.ibm.com/address/;), - @XmlNs(prefix="mail", namespaceURI="http://www.ibm.com/mail/;) - } -) -@RdfSchema( - prefix="ab", - rdfNs={ - @RdfNs(prefix="ab", namespaceURI="http://www.ibm.com/addressBook/;), - @RdfNs(prefix="per", namespaceURI="http://www.ibm.com/person/;), - @RdfNs(prefix="addr", namespaceURI="http://www.ibm.com/address/;), - @RdfNs(prefix="mail", namespaceURI="http://www.ibm.com/mail/;) - } -) -package org.apache.juneau.samples.addressbook; -import org.apache.juneau.jena.annotation.*; -import org.apache.juneau.xml.annotation.*; - http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/2c3a7cb5/com.ibm.team.juno.samples/src/main/java/org/apache/juneau/samples/addressbook/package.html -- diff --git a/com.ibm.team.juno.samples/src/main/java/org/apache/juneau/samples/addressbook/package.html b/com.ibm.team.juno.samples/src/main/java/org/apache/juneau/samples/addressbook/package.html deleted file mode 100755 index 5ac8abc..000 --- a/com.ibm.team.juno.samples/src/main/java/org/apache/juneau/samples/addressbook/package.html +++ /dev/null @@ -1,27 +0,0 @@ - - - - /* For viewing in Page Designer */ - @IMPORT url("../../../../../../org.apache.juneau/javadoc.css"); - - /* For viewing in REST interface */ - @IMPORT url("../htdocs/javadoc.css"); - body { - margin: 20px; - } - - - /* Replace all @code and @link tags. */ - window.onload = function() { - document.body.innerHTML = document.body.innerHTML.replace(/\{\@code ([^\}]+)\}/g, '$1
'); - document.body.innerHTML = document.body.innerHTML.replace(/\{\@link (([^\}]+)\.)?([^\.\}]+)\}/g, '$3
'); - } - - - -Javadocs for Address Book Resource Example - - Pretend there is documentation here. - - - \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/2c3a7cb5/com.ibm.team.juno.samples/src/main/java/org/apache/juneau/server/samples/AdminGuard.java -- diff --git a/com.ibm.team.juno.samples/src/main/java/org/apache/juneau/server/samples/AdminGuard.java b/com.ibm.team.juno.samples/src/main/java/org/apache/juneau/server/samples/AdminGuard.java deleted file mode 100755 index b6e3d1a..000 --- a/com.ibm.team.juno.samples/src/main/java/org/apache/juneau/server/samples/AdminGuard.java +++ /dev/null @@ -1,26 +0,0 @@ -/*** - * Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file - *
[46/51] [abbrv] [partial] incubator-juneau git commit: Merge changes from GitHub repo.
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/2c3a7cb5/com.ibm.team.juno.microservice/.settings/org.eclipse.jdt.core.prefs -- diff --git a/com.ibm.team.juno.microservice/.settings/org.eclipse.jdt.core.prefs b/com.ibm.team.juno.microservice/.settings/org.eclipse.jdt.core.prefs deleted file mode 100755 index 54e4bf5..000 --- a/com.ibm.team.juno.microservice/.settings/org.eclipse.jdt.core.prefs +++ /dev/null @@ -1,306 +0,0 @@ -eclipse.preferences.version=1 -org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled -org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6 -org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve -org.eclipse.jdt.core.compiler.compliance=1.6 -org.eclipse.jdt.core.compiler.debug.lineNumber=generate -org.eclipse.jdt.core.compiler.debug.localVariable=generate -org.eclipse.jdt.core.compiler.debug.sourceFile=generate -org.eclipse.jdt.core.compiler.doc.comment.support=enabled -org.eclipse.jdt.core.compiler.problem.assertIdentifier=error -org.eclipse.jdt.core.compiler.problem.enumIdentifier=error -org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning -org.eclipse.jdt.core.compiler.problem.invalidJavadoc=warning -org.eclipse.jdt.core.compiler.problem.invalidJavadocTags=enabled -org.eclipse.jdt.core.compiler.problem.invalidJavadocTagsDeprecatedRef=disabled -org.eclipse.jdt.core.compiler.problem.invalidJavadocTagsNotVisibleRef=disabled -org.eclipse.jdt.core.compiler.problem.invalidJavadocTagsVisibility=protected -org.eclipse.jdt.core.compiler.problem.missingJavadocComments=warning -org.eclipse.jdt.core.compiler.problem.missingJavadocCommentsOverriding=disabled -org.eclipse.jdt.core.compiler.problem.missingJavadocCommentsVisibility=protected -org.eclipse.jdt.core.compiler.problem.missingJavadocTagDescription=return_tag -org.eclipse.jdt.core.compiler.problem.missingJavadocTags=warning -org.eclipse.jdt.core.compiler.problem.missingJavadocTagsMethodTypeParameters=disabled -org.eclipse.jdt.core.compiler.problem.missingJavadocTagsOverriding=disabled -org.eclipse.jdt.core.compiler.problem.missingJavadocTagsVisibility=protected -org.eclipse.jdt.core.compiler.source=1.6 -org.eclipse.jdt.core.formatter.align_type_members_on_columns=false -org.eclipse.jdt.core.formatter.alignment_for_arguments_in_allocation_expression=16 -org.eclipse.jdt.core.formatter.alignment_for_arguments_in_annotation=0 -org.eclipse.jdt.core.formatter.alignment_for_arguments_in_enum_constant=16 -org.eclipse.jdt.core.formatter.alignment_for_arguments_in_explicit_constructor_call=16 -org.eclipse.jdt.core.formatter.alignment_for_arguments_in_method_invocation=16 -org.eclipse.jdt.core.formatter.alignment_for_arguments_in_qualified_allocation_expression=16 -org.eclipse.jdt.core.formatter.alignment_for_assignment=0 -org.eclipse.jdt.core.formatter.alignment_for_binary_expression=16 -org.eclipse.jdt.core.formatter.alignment_for_compact_if=16 -org.eclipse.jdt.core.formatter.alignment_for_conditional_expression=80 -org.eclipse.jdt.core.formatter.alignment_for_enum_constants=0 -org.eclipse.jdt.core.formatter.alignment_for_expressions_in_array_initializer=16 -org.eclipse.jdt.core.formatter.alignment_for_method_declaration=0 -org.eclipse.jdt.core.formatter.alignment_for_multiple_fields=16 -org.eclipse.jdt.core.formatter.alignment_for_parameters_in_constructor_declaration=16 -org.eclipse.jdt.core.formatter.alignment_for_parameters_in_method_declaration=16 -org.eclipse.jdt.core.formatter.alignment_for_resources_in_try=80 -org.eclipse.jdt.core.formatter.alignment_for_selector_in_method_invocation=16 -org.eclipse.jdt.core.formatter.alignment_for_superclass_in_type_declaration=16 -org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_enum_declaration=16 -org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_type_declaration=16 -org.eclipse.jdt.core.formatter.alignment_for_throws_clause_in_constructor_declaration=16 -org.eclipse.jdt.core.formatter.alignment_for_throws_clause_in_method_declaration=16 -org.eclipse.jdt.core.formatter.alignment_for_union_type_in_multicatch=16 -org.eclipse.jdt.core.formatter.blank_lines_after_imports=1 -org.eclipse.jdt.core.formatter.blank_lines_after_package=1 -org.eclipse.jdt.core.formatter.blank_lines_before_field=0 -org.eclipse.jdt.core.formatter.blank_lines_before_first_class_body_declaration=0 -org.eclipse.jdt.core.formatter.blank_lines_before_imports=1 -org.eclipse.jdt.core.formatter.blank_lines_before_member_type=1 -org.eclipse.jdt.core.formatter.blank_lines_before_method=1 -org.eclipse.jdt.core.formatter.blank_lines_before_new_chunk=1 -org.eclipse.jdt.core.formatter.blank_lines_before_package=0 -org.eclipse.jdt.core.formatter.blank_lines_between_import_groups=1 -org.eclipse.jdt.core.formatter.blank_lines_between_type_declarations=1 -org.eclipse.jdt.core.formatter.brace_position_for_annotation_type_declaration=end_of_line
[10/51] [abbrv] [partial] incubator-juneau git commit: Merge changes from GitHub repo.
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/2c3a7cb5/com.ibm.team.juno/src/main/java/org/apache/juneau/dto/atom/Category.java -- diff --git a/com.ibm.team.juno/src/main/java/org/apache/juneau/dto/atom/Category.java b/com.ibm.team.juno/src/main/java/org/apache/juneau/dto/atom/Category.java deleted file mode 100644 index 2dce6c6..000 --- a/com.ibm.team.juno/src/main/java/org/apache/juneau/dto/atom/Category.java +++ /dev/null @@ -1,141 +0,0 @@ -/*** - * 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.juneau.dto.atom; - -import static org.apache.juneau.xml.annotation.XmlFormat.*; - -import java.net.*; - -import org.apache.juneau.xml.annotation.*; - -/** - * Represents an atomCategory construct in the RFC4287 specification. - * - * Schema - * - * atomCategory = - * element atom:category { - * atomCommonAttributes, - * attribute term { text }, - * attribute scheme { atomUri }?, - * attribute label { text }?, - * undefinedContent - * } - * - * - * Refer to {@link org.apache.juneau.dto.atom} for further information about ATOM support. - * - * - * @author James Bognar (james.bog...@salesforce.com) - */ -@Xml(name="category") -public class Category extends Common { - - private String term; - private URI scheme; - private String label; - - /** -* Normal constructor. -* @param term The category term. -*/ - public Category(String term) { - this.term = term; - } - - /** Bean constructor. */ - public Category() {} - - - // - // Bean properties - // - - /** -* @return The category term. -*/ - @Xml(format=ATTR) - public String getTerm() { - return term; - } - - /** -* Sets the category term. -* -* @param term The category term. -* @return This object (for method chaining). -*/ - public Category setTerm(String term) { - this.term = term; - return this; - } - - /** -* Returns the category scheme. -* -* @return The category scheme. -*/ - @Xml(format=ATTR) - public URI getScheme() { - return scheme; - } - - /** -* Sets the category scheme. -* -* @param scheme The category scheme. -* @return This object (for method chaining). -*/ - public Category setScheme(URI scheme) { - this.scheme = scheme; - return this; - } - - /** -* Returns the category label. -* -* @return The category label. -*/ - @Xml(format=ATTR) - public String getLabel() { - return label; - } - - /** -* Sets the category label. -* -* @param label The category label. -* @return This object (for method chaining). -*/ - public Category setLabel(String label) { - this.label = label; - return this; - } - - - // - // Overridden setters (to simplify method chaining) - // - - @Override /* Common */ - public Category setBase(URI base) { - super.setBase(base); - return this; - } - - @Override /* Common */ - public Category setLang(String lang) { - super.setLang(lang); - return this; -
[29/51] [abbrv] [partial] incubator-juneau git commit: Merge changes from GitHub repo.
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/2c3a7cb5/com.ibm.team.juno.server.test/src/test/java/org/apache/juneau/server/TestUtils.java -- diff --git a/com.ibm.team.juno.server.test/src/test/java/org/apache/juneau/server/TestUtils.java b/com.ibm.team.juno.server.test/src/test/java/org/apache/juneau/server/TestUtils.java deleted file mode 100755 index 996a185..000 --- a/com.ibm.team.juno.server.test/src/test/java/org/apache/juneau/server/TestUtils.java +++ /dev/null @@ -1,60 +0,0 @@ -/*** - * 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.juneau.server; - -import java.text.*; - -import org.apache.juneau.client.*; -import org.apache.juneau.json.*; -import org.apache.juneau.serializer.*; -import org.apache.juneau.transforms.*; -import org.junit.Assert; - -import junit.framework.*; - -public class TestUtils { - - private static JsonSerializer js2 = new JsonSerializer.Simple() - .addTransforms(IteratorTransform.class, EnumerationTransform.class); - - /** -* Assert that the object equals the specified string after running it through JsonSerializer.DEFAULT_LAX.toString(). -*/ - public static void assertObjectEquals(String s, Object o) { - assertObjectEquals(s, o, js2); - } - - /** -* Assert that the object equals the specified string after running it through ws.toString(). -*/ - public static void assertObjectEquals(String s, Object o, WriterSerializer ws) { - Assert.assertEquals(s, ws.toString(o)); - } - - public static void checkErrorResponse(boolean debug, RestCallException e, int status, String...contains) throws AssertionFailedError { - String r = e.getResponseMessage(); - if (debug) { - System.err.println(r); - e.printStackTrace(); - } - if (status != e.getResponseCode()) - throw new AssertionFailedError(MessageFormat.format("Response status code was not correct. Expected: ''{0}''. Actual: ''{1}''", status, e.getResponseCode())); - for (String s : contains) { - if (r == null || ! r.contains(s)) { - if (! debug) - System.err.println(r); - throw new AssertionFailedError(MessageFormat.format("Response did not have the following expected text: ''{0}''", s)); - } - } - } -} http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/2c3a7cb5/com.ibm.team.juno.server/.DS_Store -- diff --git a/com.ibm.team.juno.server/.DS_Store b/com.ibm.team.juno.server/.DS_Store deleted file mode 100644 index 5008ddf..000 Binary files a/com.ibm.team.juno.server/.DS_Store and /dev/null differ http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/2c3a7cb5/com.ibm.team.juno.server/.classpath -- diff --git a/com.ibm.team.juno.server/.classpath b/com.ibm.team.juno.server/.classpath deleted file mode 100755 index a953066..000 --- a/com.ibm.team.juno.server/.classpath +++ /dev/null @@ -1,24 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/2c3a7cb5/com.ibm.team.juno.server/.gitignore -- diff --git a/com.ibm.team.juno.server/.gitignore b/com.ibm.team.juno.server/.gitignore deleted file
[51/51] [abbrv] [partial] incubator-juneau git commit: Merge changes from GitHub repo.
Merge changes from GitHub repo. Project: http://git-wip-us.apache.org/repos/asf/incubator-juneau/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-juneau/commit/2c3a7cb5 Tree: http://git-wip-us.apache.org/repos/asf/incubator-juneau/tree/2c3a7cb5 Diff: http://git-wip-us.apache.org/repos/asf/incubator-juneau/diff/2c3a7cb5 Branch: refs/heads/master Commit: 2c3a7cb597df83c7549ff284efbae10fcfa436b4 Parents: 71180a6 Author: jamesbognarAuthored: Mon Aug 1 12:01:21 2016 -0400 Committer: jamesbognar Committed: Mon Aug 1 12:01:21 2016 -0400 -- .DS_Store | Bin 6148 -> 6148 bytes com.ibm.team.juno.client/.DS_Store | Bin 6148 -> 0 bytes com.ibm.team.juno.client/.classpath | 21 - com.ibm.team.juno.client/.gitignore |2 - com.ibm.team.juno.client/.project | 32 - .../.settings/com.ibm.etools.references.prefs |4 - ...ibm.etools.webtools.packagepreferences.prefs |3 - .../.settings/org.eclipse.jdt.apt.core.prefs|2 - .../.settings/org.eclipse.jdt.core.prefs| 402 - .../.settings/org.eclipse.jdt.ui.prefs | 120 - .../org.eclipse.ltk.core.refactoring.prefs |3 - .../.settings/org.eclipse.m2e.core.prefs|4 - .../.settings/org.eclipse.pde.core.prefs|3 - .../.settings/org.eclipse.pde.prefs | 15 - .../.settings/org.eclipse.wst.common.component |5 - ...rg.eclipse.wst.common.project.facet.core.xml | 22 - .../.settings/org.eclipse.wst.html.core.prefs | 37 - .../.settings/org.eclipse.wst.validation.prefs |9 - com.ibm.team.juno.client/META-INF/MANIFEST.MF | 36 - .../OSGI-INF/l10n/plugin.properties | 19 - com.ibm.team.juno.client/build.properties | 20 - com.ibm.team.juno.client/pom.xml| 29 - .../apache/juneau/client/AllowAllRedirects.java | 31 - .../org/apache/juneau/client/DateHeader.java| 43 - .../org/apache/juneau/client/HttpMethod.java| 64 - .../apache/juneau/client/NameValuePairs.java| 48 - .../apache/juneau/client/ResponsePattern.java | 138 - .../java/org/apache/juneau/client/RestCall.java | 947 --- .../apache/juneau/client/RestCallException.java | 153 - .../juneau/client/RestCallInterceptor.java | 60 - .../apache/juneau/client/RestCallLogger.java| 120 - .../org/apache/juneau/client/RestClient.java| 1423 .../apache/juneau/client/RestRequestEntity.java | 90 - .../java/org/apache/juneau/client/RetryOn.java | 39 - .../java/org/apache/juneau/client/SSLOpts.java | 189 - .../juneau/client/SerializedNameValuePair.java | 85 - .../juneau/client/SimpleX509TrustManager.java | 66 - .../java/org/apache/juneau/client/package.html | 857 -- .../.DS_Store | Bin 6148 -> 0 bytes .../.classpath | 30 - .../.gitignore |2 - .../.project| 23 - .../.settings/org.eclipse.jdt.core.prefs| 12 - .../.settings/org.eclipse.m2e.core.prefs|4 - .../META-INF/MANIFEST.MF| 18 - .../microservice.cfg| 196 - com.ibm.team.juno.microservice.template/pom.xml | 28 - .../src/.DS_Store | Bin 6148 -> 0 bytes .../microservice/sample/HelloWorldResource.java | 35 - .../microservice/sample/RootResources.java | 41 - .../microservice/sample/nls/Messages.properties | 19 - com.ibm.team.juno.microservice/.DS_Store| Bin 6148 -> 0 bytes com.ibm.team.juno.microservice/.classpath | 28 - com.ibm.team.juno.microservice/.gitignore |2 - com.ibm.team.juno.microservice/.project | 23 - .../.settings/org.eclipse.jdt.core.prefs| 306 - .../.settings/org.eclipse.jdt.ui.prefs | 62 - .../.settings/org.eclipse.m2e.core.prefs|4 - com.ibm.team.juno.microservice/Dockerfile | 16 - .../META-INF/MANIFEST.MF|7 - com.ibm.team.juno.microservice/build.properties | 18 - .../lib/commons-codec-1.9.jar | Bin 263965 -> 0 bytes .../lib/commons-io-1.2.jar | Bin 65621 -> 0 bytes .../lib/commons-logging-1.1.1.jar | Bin 60686 -> 0 bytes .../lib/httpclient-4.5.jar | Bin 727567 -> 0 bytes .../lib/httpcore-4.4.1.jar | Bin 322234 -> 0 bytes .../lib/httpmime-4.5.jar| Bin 40692 -> 0 bytes .../lib/javax.servlet-api-3.0.jar | Bin 85353 -> 0 bytes .../lib/jetty-all-8.1.0.jar | Bin 1774672 -> 0 bytes .../lib/org.apache.commons.fileupload_1.3.1.jar | Bin 69002 -> 0 bytes com.ibm.team.juno.microservice/pom.xml
[06/51] [abbrv] [partial] incubator-juneau git commit: Merge changes from GitHub repo.
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/2c3a7cb5/com.ibm.team.juno/src/main/java/org/apache/juneau/html/HtmlParser.java -- diff --git a/com.ibm.team.juno/src/main/java/org/apache/juneau/html/HtmlParser.java b/com.ibm.team.juno/src/main/java/org/apache/juneau/html/HtmlParser.java deleted file mode 100644 index bb1951d..000 --- a/com.ibm.team.juno/src/main/java/org/apache/juneau/html/HtmlParser.java +++ /dev/null @@ -1,732 +0,0 @@ -/*** - * 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.juneau.html; - -import static javax.xml.stream.XMLStreamConstants.*; -import static org.apache.juneau.html.HtmlParser.Tag.*; -import static org.apache.juneau.internal.StringUtils.*; - -import java.lang.reflect.*; -import java.util.*; - -import javax.xml.namespace.*; -import javax.xml.stream.*; -import javax.xml.stream.events.*; - -import org.apache.juneau.*; -import org.apache.juneau.annotation.*; -import org.apache.juneau.parser.*; -import org.apache.juneau.transform.*; - -/** - * Parses text generated by the {@link HtmlSerializer} class back into a POJO model. - * - * - * Media types - * - * Handles Content-Type types: text/html - * - * - * Description - * - * See the {@link HtmlSerializer} class for a description of the HTML generated. - * - * This class is used primarily for automated testing of the {@link HtmlSerializer} class. - * - * - * Configurable properties - * - * This class has the following properties associated with it: - * - * {@link HtmlSerializerContext} - * - * - * - * @author James Bognar (james.bog...@salesforce.com) - */ -@SuppressWarnings({ "rawtypes", "unchecked" }) -@Consumes({"text/html","text/html+stripped"}) -public final class HtmlParser extends ReaderParser { - - /** Default parser, all default settings.*/ - public static final HtmlParser DEFAULT = new HtmlParser().lock(); - - /* -* Reads anything starting at the current event. -* -* Precondition: Must be pointing at START_ELEMENT or CHARACTERS event. -* Postcondition: Pointing at next event to be processed. -*/ - private T parseAnything(HtmlParserSession session, ClassMeta nt, XMLEventReader r, Object outer) throws Exception { - - BeanContext bc = session.getBeanContext(); - if (nt == null) - nt = (ClassMeta)object(); - PojoTransformtransform = (PojoTransform )nt.getPojoTransform(); - ClassMeta ft = nt.getTransformedClassMeta(); - session.setCurrentClass(ft); - - Object o = null; - - XMLEvent event = r.nextEvent(); - while (! (event.isStartElement() || (event.isCharacters() && ! event.asCharacters().isWhiteSpace()) || event.isEndDocument())) - event = r.nextEvent(); - - if (event.isEndDocument()) - throw new XMLStreamException("Unexpected end of stream in parseAnything for type '"+nt+"'", event.getLocation()); - - if (event.isCharacters()) { - String text = parseCharacters(event, r); - if (ft.isObject()) - o = text; - else if (ft.isCharSequence()) - o = text; - else if (ft.isNumber()) - o = parseNumber(text, (Class)nt.getInnerClass()); - else if (ft.isChar()) - o = text.charAt(0); - else if (ft.isBoolean()) - o = Boolean.parseBoolean(text); - else if (ft.canCreateNewInstanceFromString(outer)) - o = ft.newInstanceFromString(outer, text); - else if
[44/51] [abbrv] [partial] incubator-juneau git commit: Merge changes from GitHub repo.
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/2c3a7cb5/com.ibm.team.juno.microservice/src/main/java/org/apache/juneau/microservice/resources/DirectoryResource.java -- diff --git a/com.ibm.team.juno.microservice/src/main/java/org/apache/juneau/microservice/resources/DirectoryResource.java b/com.ibm.team.juno.microservice/src/main/java/org/apache/juneau/microservice/resources/DirectoryResource.java deleted file mode 100755 index 53b79b9..000 --- a/com.ibm.team.juno.microservice/src/main/java/org/apache/juneau/microservice/resources/DirectoryResource.java +++ /dev/null @@ -1,357 +0,0 @@ -/*** - * 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.juneau.microservice.resources; - -import static java.util.logging.Level.*; -import static javax.servlet.http.HttpServletResponse.*; -import static org.apache.juneau.html.HtmlDocSerializerContext.*; -import static org.apache.juneau.server.RestServletContext.*; - -import java.io.*; -import java.net.*; -import java.util.*; -import java.util.logging.*; - -import javax.servlet.*; - -import org.apache.juneau.*; -import org.apache.juneau.annotation.*; -import org.apache.juneau.microservice.*; -import org.apache.juneau.server.*; -import org.apache.juneau.server.annotation.*; -import org.apache.juneau.server.converters.*; -import org.apache.juneau.transforms.*; -import org.apache.juneau.utils.*; - -/** - * REST resource that allows access to a file system directory. - * - * The root directory is specified in one of two ways: - * - * - * Specifying the location via a DirectoryResource.rootDir property. - * Overriding the {@link #getRootDir()} method. - * - * - * Read/write access control is handled through the following properties: - * - * - * DirectoryResource.allowViews - If true, allows view and download access to files. - * DirectoryResource.allowPuts - If true, allows files to be created or overwritten. - * DirectoryResource.allowDeletes - If true, allows files to be deleted. - * - * - * Access can also be controlled by overriding the {@link #checkAccess(RestRequest)} method. - * - */ -@RestResource( - label="File System Explorer", - description="Contents of $A{path}", - messages="nls/DirectoryResource", - properties={ - @Property(name=HTML_uriAnchorText, value=PROPERTY_NAME), - @Property(name=HTMLDOC_links, value="{up:'$R{requestParentURI}',options:'?method=OPTIONS',source:'$R{servletParentURI}/source?classes=(org.apache.juneau.server.samples.DirectoryResource)'}"), - @Property(name=REST_allowMethodParam, value="*"), - @Property(name="DirectoryResource.rootDir", value=""), - @Property(name="DirectoryResource.allowViews", value="false"), - @Property(name="DirectoryResource.allowDeletes", value="false"), - @Property(name="DirectoryResource.allowPuts", value="false") - } -) -public class DirectoryResource extends Resource { - private static final long serialVersionUID = 1L; - - private File rootDir; // The root directory - - // Settings enabled through servlet init parameters - private boolean allowDeletes, allowPuts, allowViews; - - private static Logger logger = Logger.getLogger(DirectoryResource.class.getName()); - - @Override /* Servlet */ - public void init() throws ServletException { - ObjectMap p = getProperties(); - rootDir = new File(p.getString("DirectoryResource.rootDir")); - allowViews = p.getBoolean("DirectoryResource.allowViews", false); - allowDeletes = p.getBoolean("DirectoryResource.allowDeletes", false); - allowPuts = p.getBoolean("DirectoryResource.allowPuts", false); - } - - /** -* Returns the root directory defined by the 'rootDir' init parameter. -*
[13/51] [abbrv] [partial] incubator-juneau git commit: Merge changes from GitHub repo.
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/2c3a7cb5/com.ibm.team.juno/src/main/java/org/apache/juneau/ContextFactory.java -- diff --git a/com.ibm.team.juno/src/main/java/org/apache/juneau/ContextFactory.java b/com.ibm.team.juno/src/main/java/org/apache/juneau/ContextFactory.java deleted file mode 100644 index becf8f1..000 --- a/com.ibm.team.juno/src/main/java/org/apache/juneau/ContextFactory.java +++ /dev/null @@ -1,1298 +0,0 @@ -/*** - * 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.juneau; - -import static org.apache.juneau.BeanContext.*; - -import java.lang.reflect.*; -import java.util.*; -import java.util.concurrent.*; -import java.util.concurrent.locks.*; - -import org.apache.juneau.internal.*; -import org.apache.juneau.json.*; -import org.apache.juneau.parser.*; - -/** - * A factory for instantiating {@link Context} objects. - * - * The hierarchy of these objects are... - * - * {@link ContextFactory} - A thread-safe, modifiable context property store. - * Used to create {@link Context} objects. - * {@link Context} - A reusable, cachable, thread-safe, read-only context with configuration properties copied from the factory. - * Often used to create {@link Session} objects. - * {@link Session} - A one-time-use non-thread-safe object. - * Used by serializers and parsers to retrieve context properties and to be used as scratchpads. - * - * - * - * ContextFactory objects - * - * Context factories can be thought of as consisting of the following: - * - * A MapString,Object of context properties. - * A MapClass,Context of context instances. - * - * - * Context factories are used to create and cache {@link Context} objects using the {@link #getContext(Class)} method. - * - * As a general rule, {@link ContextFactory} objects are 'slow'. - * Setting and retrieving properties on a factory can involve relatively slow data conversion and synchronization. - * However, the {@link #getContext(Class)} method is fast, and will return cached context objects if the context properties have not changed. - * - * Context factories can be used to store context properties for a variety of contexts. - * For example, a single factory can store context properties for the JSON serializer, XML serializer, HTML serializer - * etc... and can thus be used to retrieve context objects for those serializers. - * - * Other notes: - * - * Context factories can be locked using the {@link #lock()} method. - * This prevents the context properties from being further modified. - * Context factories can be cloned using the {@link #clone} method. - * This will return a new unlocked factory with the same context properties. - * - * - * Context properties - * - * Context properties are 'settings' for serializers and parsers. - * For example, the {@link BeanContext#BEAN_sortProperties} context property defines whether - * bean properties should be serialized in alphabetical order. - * - * Each {@link Context} object should contain the context properties that apply to it as static - * fields (e.g {@link BeanContext#BEAN_sortProperties}). - * - * Context properties can be of the following types: - * - * SIMPLE - A simple property. - * Examples include: booleans, integers, Strings, Classes, etc... - * - * An example of this would be the {@link BeanContext#BEAN_sortProperties} property. - * It's name is simply "BeanContext.sortProperties". - * - * SET - A sorted set of objects. - * These are denoted by appending
[38/51] [abbrv] [partial] incubator-juneau git commit: Merge changes from GitHub repo.
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/2c3a7cb5/com.ibm.team.juno.samples/src/main/java/org/apache/juneau/server/samples/addressbook/AddressBookResource.java -- diff --git a/com.ibm.team.juno.samples/src/main/java/org/apache/juneau/server/samples/addressbook/AddressBookResource.java b/com.ibm.team.juno.samples/src/main/java/org/apache/juneau/server/samples/addressbook/AddressBookResource.java deleted file mode 100755 index 78608e1..000 --- a/com.ibm.team.juno.samples/src/main/java/org/apache/juneau/server/samples/addressbook/AddressBookResource.java +++ /dev/null @@ -1,331 +0,0 @@ -/*** - * 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.juneau.server.samples.addressbook; - -import static javax.servlet.http.HttpServletResponse.*; -import static org.apache.juneau.html.HtmlDocSerializerContext.*; -import static org.apache.juneau.jena.RdfCommonContext.*; -import static org.apache.juneau.jena.RdfSerializerContext.*; -import static org.apache.juneau.samples.addressbook.AddressBook.*; -import static org.apache.juneau.server.RestServletContext.*; -import static org.apache.juneau.server.labels.DefaultLabels.*; - -import java.util.*; - -import org.apache.juneau.*; -import org.apache.juneau.dto.*; -import org.apache.juneau.dto.cognos.*; -import org.apache.juneau.encoders.*; -import org.apache.juneau.microservice.*; -import org.apache.juneau.samples.addressbook.*; -import org.apache.juneau.server.*; -import org.apache.juneau.server.annotation.*; -import org.apache.juneau.server.converters.*; -import org.apache.juneau.server.labels.*; -import org.apache.juneau.server.samples.*; -import org.apache.juneau.transform.*; -import org.apache.juneau.utils.*; - -/** - * Proof-of-concept resource that shows off the capabilities of working with POJO resources. - * Consists of an in-memory address book repository. - */ -@RestResource( - path="/addressBook", - messages="nls/AddressBookResource", - properties={ - @Property(name=REST_allowMethodParam, value="*"), - @Property(name=HTML_uriAnchorText, value=TO_STRING), - @Property(name=SERIALIZER_quoteChar, value="'"), - @Property(name=RDF_rdfxml_tab, value="5"), - @Property(name=RDF_addRootProperty, value="true"), - @Property(name=HTMLDOC_links, value="{up:'$R{requestParentURI}',options:'$R{servletURI}?method=OPTIONS',source:'$R{servletParentURI}/source?classes=(org.apache.juneau.server.samples.addressbook.AddressBookResource,org.apache.juneau.samples.addressbook.Address,org.apache.juneau.samples.addressbook.AddressBook,org.apache.juneau.samples.addressbook.CreateAddress,org.apache.juneau.samples.addressbook.CreatePerson,org.apache.juneau.samples.addressbook.IAddressBook,org.apache.juneau.samples.addressbook.Person)'}"), - // Resolve all relative URIs so that they're relative to this servlet! - @Property(name=SERIALIZER_relativeUriBase, value="$R{servletURI}"), - }, - stylesheet="styles/devops.css", - encoders=GzipEncoder.class -) -public class AddressBookResource extends ResourceJena { - private static final long serialVersionUID = 1L; - - // The in-memory address book - private AddressBook addressBook; - - @Override /* Servlet */ - public void init() { - - try { - // Create the address book - addressBook = new AddressBook(java.net.URI.create("")); - - // Add some people to our address book by default - addressBook.createPerson( - new CreatePerson( - "Barack Obama", - toCalendar("Aug 4, 1961"), - new CreateAddress("1600 Pennsylvania Ave", "Washington", "DC", 20500, true),
[49/51] [abbrv] [partial] incubator-juneau git commit: Merge changes from GitHub repo.
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/2c3a7cb5/com.ibm.team.juno.client/src/main/java/org/apache/juneau/client/RestCall.java -- diff --git a/com.ibm.team.juno.client/src/main/java/org/apache/juneau/client/RestCall.java b/com.ibm.team.juno.client/src/main/java/org/apache/juneau/client/RestCall.java deleted file mode 100755 index 8b79d13..000 --- a/com.ibm.team.juno.client/src/main/java/org/apache/juneau/client/RestCall.java +++ /dev/null @@ -1,947 +0,0 @@ -/*** - * 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.juneau.client; - -import java.io.*; -import java.net.*; -import java.util.*; -import java.util.logging.*; -import java.util.regex.*; - -import org.apache.http.*; -import org.apache.http.client.*; -import org.apache.http.client.config.*; -import org.apache.http.client.methods.*; -import org.apache.http.impl.client.*; -import org.apache.http.util.*; -import org.apache.juneau.*; -import org.apache.juneau.encoders.*; -import org.apache.juneau.internal.*; -import org.apache.juneau.parser.*; -import org.apache.juneau.parser.ParseException; -import org.apache.juneau.serializer.*; -import org.apache.juneau.utils.*; - -/** - * Represents a connection to a remote REST resource. - * - * Instances of this class are created by the various {@code doX()} methods on the {@link RestClient} class. - * - * This class uses only Java standard APIs. Requests can be built up using a fluent interface with method chaining, like so... - * - * - * RestClient client = new RestClient(); - * RestCall c = client.doPost(URL).setInput(o).setHeader(x,y); - * MyBean b = c.getResponse(MyBean.class); - * - * - * The actual connection and request/response transaction occurs when calling one of the getResponseXXX() methods. - * - * Additional Information - * - * org.apache.juneau.client REST client API for more information and code examples. - * - * - * @author James Bognar (james.bog...@salesforce.com) - */ -public final class RestCall { - - private final RestClient client; // The client that created this call. - private final HttpRequestBase request; // The request. - private HttpResponse response; // The response. - private List interceptors = new ArrayList(); // Used for intercepting and altering requests. - - private boolean isConnected = false; // connect() has been called. - private boolean allowRedirectsOnPosts; - private int retries = 1; - private int redirectOnPostsTries = 5; - private long retryInterval = -1; - private RetryOn retryOn = RetryOn.DEFAULT; - private boolean ignoreErrors; - private boolean byLines = false; - private TeeWriter writers = new TeeWriter(); - private StringWriter capturedResponseWriter; - private String capturedResponse; - private TeeOutputStream outputStreams = new TeeOutputStream(); - private boolean isClosed = false; - private boolean isFailed = false; - - /** -* Constructs a REST call with the specified method name. -* -* @param client The client that created this request. -* @param request The wrapped Apache HTTP client request object. -* @throws RestCallException If an exception or non-200 response code occurred during the connection attempt. -*/ - protected RestCall(RestClient client, HttpRequestBase request) throws RestCallException { - this.client = client; - this.request = request; - for (RestCallInterceptor i : this.client.interceptors) - addInterceptor(i); - } - - /** -* Sets the input for this REST call. -* -* @param input The input to be sent to the REST resource (only valid for PUT and POST)
[18/51] [abbrv] [partial] incubator-juneau git commit: Merge changes from GitHub repo.
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/2c3a7cb5/com.ibm.team.juno/.settings/org.eclipse.jdt.core.prefs -- diff --git a/com.ibm.team.juno/.settings/org.eclipse.jdt.core.prefs b/com.ibm.team.juno/.settings/org.eclipse.jdt.core.prefs deleted file mode 100755 index 4d9ce5d..000 --- a/com.ibm.team.juno/.settings/org.eclipse.jdt.core.prefs +++ /dev/null @@ -1,406 +0,0 @@ -eclipse.preferences.version=1 -org.eclipse.jdt.core.codeComplete.argumentPrefixes= -org.eclipse.jdt.core.codeComplete.argumentSuffixes= -org.eclipse.jdt.core.codeComplete.fieldPrefixes= -org.eclipse.jdt.core.codeComplete.fieldSuffixes= -org.eclipse.jdt.core.codeComplete.localPrefixes= -org.eclipse.jdt.core.codeComplete.localSuffixes= -org.eclipse.jdt.core.codeComplete.staticFieldPrefixes= -org.eclipse.jdt.core.codeComplete.staticFieldSuffixes= -org.eclipse.jdt.core.codeComplete.staticFinalFieldPrefixes= -org.eclipse.jdt.core.codeComplete.staticFinalFieldSuffixes= -org.eclipse.jdt.core.compiler.annotation.inheritNullAnnotations=disabled -org.eclipse.jdt.core.compiler.annotation.missingNonNullByDefaultAnnotation=ignore -org.eclipse.jdt.core.compiler.annotation.nonnull=org.eclipse.jdt.annotation.NonNull -org.eclipse.jdt.core.compiler.annotation.nonnullbydefault=org.eclipse.jdt.annotation.NonNullByDefault -org.eclipse.jdt.core.compiler.annotation.nullable=org.eclipse.jdt.annotation.Nullable -org.eclipse.jdt.core.compiler.annotation.nullanalysis=disabled -org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled -org.eclipse.jdt.core.compiler.codegen.methodParameters=do not generate -org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6 -org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve -org.eclipse.jdt.core.compiler.compliance=1.6 -org.eclipse.jdt.core.compiler.debug.lineNumber=generate -org.eclipse.jdt.core.compiler.debug.localVariable=generate -org.eclipse.jdt.core.compiler.debug.sourceFile=generate -org.eclipse.jdt.core.compiler.doc.comment.support=enabled -org.eclipse.jdt.core.compiler.problem.annotationSuperInterface=warning -org.eclipse.jdt.core.compiler.problem.assertIdentifier=error -org.eclipse.jdt.core.compiler.problem.autoboxing=ignore -org.eclipse.jdt.core.compiler.problem.comparingIdentical=warning -org.eclipse.jdt.core.compiler.problem.deadCode=warning -org.eclipse.jdt.core.compiler.problem.deprecation=warning -org.eclipse.jdt.core.compiler.problem.deprecationInDeprecatedCode=disabled -org.eclipse.jdt.core.compiler.problem.deprecationWhenOverridingDeprecatedMethod=disabled -org.eclipse.jdt.core.compiler.problem.discouragedReference=warning -org.eclipse.jdt.core.compiler.problem.emptyStatement=warning -org.eclipse.jdt.core.compiler.problem.enumIdentifier=error -org.eclipse.jdt.core.compiler.problem.explicitlyClosedAutoCloseable=ignore -org.eclipse.jdt.core.compiler.problem.fallthroughCase=warning -org.eclipse.jdt.core.compiler.problem.fatalOptionalError=enabled -org.eclipse.jdt.core.compiler.problem.fieldHiding=warning -org.eclipse.jdt.core.compiler.problem.finalParameterBound=warning -org.eclipse.jdt.core.compiler.problem.finallyBlockNotCompletingNormally=warning -org.eclipse.jdt.core.compiler.problem.forbiddenReference=error -org.eclipse.jdt.core.compiler.problem.hiddenCatchBlock=warning -org.eclipse.jdt.core.compiler.problem.includeNullInfoFromAsserts=disabled -org.eclipse.jdt.core.compiler.problem.incompatibleNonInheritedInterfaceMethod=warning -org.eclipse.jdt.core.compiler.problem.incompleteEnumSwitch=warning -org.eclipse.jdt.core.compiler.problem.indirectStaticAccess=warning -org.eclipse.jdt.core.compiler.problem.invalidJavadoc=warning -org.eclipse.jdt.core.compiler.problem.invalidJavadocTags=enabled -org.eclipse.jdt.core.compiler.problem.invalidJavadocTagsDeprecatedRef=enabled -org.eclipse.jdt.core.compiler.problem.invalidJavadocTagsNotVisibleRef=enabled -org.eclipse.jdt.core.compiler.problem.invalidJavadocTagsVisibility=protected -org.eclipse.jdt.core.compiler.problem.localVariableHiding=warning -org.eclipse.jdt.core.compiler.problem.methodWithConstructorName=warning -org.eclipse.jdt.core.compiler.problem.missingDefaultCase=ignore -org.eclipse.jdt.core.compiler.problem.missingDeprecatedAnnotation=warning -org.eclipse.jdt.core.compiler.problem.missingEnumCaseDespiteDefault=disabled -org.eclipse.jdt.core.compiler.problem.missingHashCodeMethod=warning -org.eclipse.jdt.core.compiler.problem.missingJavadocComments=warning -org.eclipse.jdt.core.compiler.problem.missingJavadocCommentsOverriding=disabled -org.eclipse.jdt.core.compiler.problem.missingJavadocCommentsVisibility=protected -org.eclipse.jdt.core.compiler.problem.missingJavadocTagDescription=return_tag -org.eclipse.jdt.core.compiler.problem.missingJavadocTags=warning -org.eclipse.jdt.core.compiler.problem.missingJavadocTagsMethodTypeParameters=disabled -org.eclipse.jdt.core.compiler.problem.missingJavadocTagsOverriding=disabled
[17/51] [abbrv] [partial] incubator-juneau git commit: Merge changes from GitHub repo.
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/2c3a7cb5/com.ibm.team.juno/src/main/java/doc-files/Samples.RequestEchoResource.1.htmlschema.png -- diff --git a/com.ibm.team.juno/src/main/java/doc-files/Samples.RequestEchoResource.1.htmlschema.png b/com.ibm.team.juno/src/main/java/doc-files/Samples.RequestEchoResource.1.htmlschema.png deleted file mode 100644 index 0e822c0..000 Binary files a/com.ibm.team.juno/src/main/java/doc-files/Samples.RequestEchoResource.1.htmlschema.png and /dev/null differ http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/2c3a7cb5/com.ibm.team.juno/src/main/java/doc-files/Samples.RequestEchoResource.1.json.png -- diff --git a/com.ibm.team.juno/src/main/java/doc-files/Samples.RequestEchoResource.1.json.png b/com.ibm.team.juno/src/main/java/doc-files/Samples.RequestEchoResource.1.json.png deleted file mode 100644 index 67bc6b8..000 Binary files a/com.ibm.team.juno/src/main/java/doc-files/Samples.RequestEchoResource.1.json.png and /dev/null differ http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/2c3a7cb5/com.ibm.team.juno/src/main/java/doc-files/Samples.RequestEchoResource.1.jsonschema.png -- diff --git a/com.ibm.team.juno/src/main/java/doc-files/Samples.RequestEchoResource.1.jsonschema.png b/com.ibm.team.juno/src/main/java/doc-files/Samples.RequestEchoResource.1.jsonschema.png deleted file mode 100644 index dbd6db3..000 Binary files a/com.ibm.team.juno/src/main/java/doc-files/Samples.RequestEchoResource.1.jsonschema.png and /dev/null differ http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/2c3a7cb5/com.ibm.team.juno/src/main/java/doc-files/Samples.RequestEchoResource.1.jsonsimple.png -- diff --git a/com.ibm.team.juno/src/main/java/doc-files/Samples.RequestEchoResource.1.jsonsimple.png b/com.ibm.team.juno/src/main/java/doc-files/Samples.RequestEchoResource.1.jsonsimple.png deleted file mode 100644 index da569c0..000 Binary files a/com.ibm.team.juno/src/main/java/doc-files/Samples.RequestEchoResource.1.jsonsimple.png and /dev/null differ http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/2c3a7cb5/com.ibm.team.juno/src/main/java/doc-files/Samples.RequestEchoResource.1.png -- diff --git a/com.ibm.team.juno/src/main/java/doc-files/Samples.RequestEchoResource.1.png b/com.ibm.team.juno/src/main/java/doc-files/Samples.RequestEchoResource.1.png deleted file mode 100644 index 305c913..000 Binary files a/com.ibm.team.juno/src/main/java/doc-files/Samples.RequestEchoResource.1.png and /dev/null differ http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/2c3a7cb5/com.ibm.team.juno/src/main/java/doc-files/Samples.RequestEchoResource.1.uon.png -- diff --git a/com.ibm.team.juno/src/main/java/doc-files/Samples.RequestEchoResource.1.uon.png b/com.ibm.team.juno/src/main/java/doc-files/Samples.RequestEchoResource.1.uon.png deleted file mode 100644 index 4329dc4..000 Binary files a/com.ibm.team.juno/src/main/java/doc-files/Samples.RequestEchoResource.1.uon.png and /dev/null differ http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/2c3a7cb5/com.ibm.team.juno/src/main/java/doc-files/Samples.RequestEchoResource.1.urlencoding.png -- diff --git a/com.ibm.team.juno/src/main/java/doc-files/Samples.RequestEchoResource.1.urlencoding.png b/com.ibm.team.juno/src/main/java/doc-files/Samples.RequestEchoResource.1.urlencoding.png deleted file mode 100644 index 4982033..000 Binary files a/com.ibm.team.juno/src/main/java/doc-files/Samples.RequestEchoResource.1.urlencoding.png and /dev/null differ http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/2c3a7cb5/com.ibm.team.juno/src/main/java/doc-files/Samples.RequestEchoResource.1.xml.png -- diff --git a/com.ibm.team.juno/src/main/java/doc-files/Samples.RequestEchoResource.1.xml.png b/com.ibm.team.juno/src/main/java/doc-files/Samples.RequestEchoResource.1.xml.png deleted file mode 100644 index d563523..000 Binary files a/com.ibm.team.juno/src/main/java/doc-files/Samples.RequestEchoResource.1.xml.png and /dev/null differ http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/2c3a7cb5/com.ibm.team.juno/src/main/java/doc-files/Samples.RequestEchoResource.1.xmlschema.png -- diff --git a/com.ibm.team.juno/src/main/java/doc-files/Samples.RequestEchoResource.1.xmlschema.png
[33/51] [partial] incubator-juneau git commit: Merge changes from GitHub repo.
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/30947fd7/com.ibm.team.juno.releng/bin/core.test/com/ibm/juno/core/test/filters/CT_BeanFilter$E3.class -- diff --git a/com.ibm.team.juno.releng/bin/core.test/com/ibm/juno/core/test/filters/CT_BeanFilter$E3.class b/com.ibm.team.juno.releng/bin/core.test/com/ibm/juno/core/test/filters/CT_BeanFilter$E3.class deleted file mode 100755 index b914073..000 Binary files a/com.ibm.team.juno.releng/bin/core.test/com/ibm/juno/core/test/filters/CT_BeanFilter$E3.class and /dev/null differ http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/30947fd7/com.ibm.team.juno.releng/bin/core.test/com/ibm/juno/core/test/filters/CT_BeanFilter$F1.class -- diff --git a/com.ibm.team.juno.releng/bin/core.test/com/ibm/juno/core/test/filters/CT_BeanFilter$F1.class b/com.ibm.team.juno.releng/bin/core.test/com/ibm/juno/core/test/filters/CT_BeanFilter$F1.class deleted file mode 100755 index e7b717c..000 Binary files a/com.ibm.team.juno.releng/bin/core.test/com/ibm/juno/core/test/filters/CT_BeanFilter$F1.class and /dev/null differ http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/30947fd7/com.ibm.team.juno.releng/bin/core.test/com/ibm/juno/core/test/filters/CT_BeanFilter$F2.class -- diff --git a/com.ibm.team.juno.releng/bin/core.test/com/ibm/juno/core/test/filters/CT_BeanFilter$F2.class b/com.ibm.team.juno.releng/bin/core.test/com/ibm/juno/core/test/filters/CT_BeanFilter$F2.class deleted file mode 100755 index 4327c10..000 Binary files a/com.ibm.team.juno.releng/bin/core.test/com/ibm/juno/core/test/filters/CT_BeanFilter$F2.class and /dev/null differ http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/30947fd7/com.ibm.team.juno.releng/bin/core.test/com/ibm/juno/core/test/filters/CT_BeanFilter$F3.class -- diff --git a/com.ibm.team.juno.releng/bin/core.test/com/ibm/juno/core/test/filters/CT_BeanFilter$F3.class b/com.ibm.team.juno.releng/bin/core.test/com/ibm/juno/core/test/filters/CT_BeanFilter$F3.class deleted file mode 100755 index 9c1d8a9..000 Binary files a/com.ibm.team.juno.releng/bin/core.test/com/ibm/juno/core/test/filters/CT_BeanFilter$F3.class and /dev/null differ http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/30947fd7/com.ibm.team.juno.releng/bin/core.test/com/ibm/juno/core/test/filters/CT_BeanFilter$Test2.class -- diff --git a/com.ibm.team.juno.releng/bin/core.test/com/ibm/juno/core/test/filters/CT_BeanFilter$Test2.class b/com.ibm.team.juno.releng/bin/core.test/com/ibm/juno/core/test/filters/CT_BeanFilter$Test2.class deleted file mode 100755 index 26d8a26..000 Binary files a/com.ibm.team.juno.releng/bin/core.test/com/ibm/juno/core/test/filters/CT_BeanFilter$Test2.class and /dev/null differ http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/30947fd7/com.ibm.team.juno.releng/bin/core.test/com/ibm/juno/core/test/filters/CT_BeanFilter.class -- diff --git a/com.ibm.team.juno.releng/bin/core.test/com/ibm/juno/core/test/filters/CT_BeanFilter.class b/com.ibm.team.juno.releng/bin/core.test/com/ibm/juno/core/test/filters/CT_BeanFilter.class deleted file mode 100755 index 5c548ff..000 Binary files a/com.ibm.team.juno.releng/bin/core.test/com/ibm/juno/core/test/filters/CT_BeanFilter.class and /dev/null differ http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/30947fd7/com.ibm.team.juno.releng/bin/core.test/com/ibm/juno/core/test/filters/CT_BeanMap$A.class -- diff --git a/com.ibm.team.juno.releng/bin/core.test/com/ibm/juno/core/test/filters/CT_BeanMap$A.class b/com.ibm.team.juno.releng/bin/core.test/com/ibm/juno/core/test/filters/CT_BeanMap$A.class deleted file mode 100755 index 0854c8e..000 Binary files a/com.ibm.team.juno.releng/bin/core.test/com/ibm/juno/core/test/filters/CT_BeanMap$A.class and /dev/null differ http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/30947fd7/com.ibm.team.juno.releng/bin/core.test/com/ibm/juno/core/test/filters/CT_BeanMap$B.class -- diff --git a/com.ibm.team.juno.releng/bin/core.test/com/ibm/juno/core/test/filters/CT_BeanMap$B.class b/com.ibm.team.juno.releng/bin/core.test/com/ibm/juno/core/test/filters/CT_BeanMap$B.class deleted file mode 100755 index 4e2a038..000 Binary files a/com.ibm.team.juno.releng/bin/core.test/com/ibm/juno/core/test/filters/CT_BeanMap$B.class and /dev/null differ
[02/51] [partial] incubator-juneau git commit: Merge changes from GitHub repo.
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/30947fd7/com.ibm.team.juno.releng/bin/core/com/ibm/juno/core/utils/ProcBuilder.java -- diff --git a/com.ibm.team.juno.releng/bin/core/com/ibm/juno/core/utils/ProcBuilder.java b/com.ibm.team.juno.releng/bin/core/com/ibm/juno/core/utils/ProcBuilder.java deleted file mode 100755 index 3050209..000 --- a/com.ibm.team.juno.releng/bin/core/com/ibm/juno/core/utils/ProcBuilder.java +++ /dev/null @@ -1,382 +0,0 @@ -/*** - * Licensed Materials - Property of IBM - * (c) Copyright IBM Corporation 2015. All Rights Reserved. - * - * The source code for this program is not published or otherwise - * divested of its trade secrets, irrespective of what has been - * deposited with the U.S. Copyright Office. - ***/ -package com.ibm.juno.core.utils; - -import java.io.*; -import java.lang.reflect.*; -import java.util.*; -import java.util.logging.*; - -import com.ibm.juno.core.utils.IOPipe.LineProcessor; - -/** - * Utility class for running operating system processes. - * - * Similar to {@link java.lang.ProcessBuilder} but with additional features. - * - * @author James Bognar (jbog...@us.ibm.com) - */ -@SuppressWarnings("hiding") -public class ProcBuilder { - - private java.lang.ProcessBuilder pb = new java.lang.ProcessBuilder(); - private TeeWriter outWriters = new TeeWriter(), logWriters = new TeeWriter(); - private LineProcessor lp; - private Process p; - private int maxExitStatus = 0; - private boolean byLines; - private String divider = ""; - - /** -* Creates a process builder with the specified arguments. -* Equivalent to calling ProcessBuilder.create().command(args); -* -* @param args The command-line arguments. -* @return A new process builder. -*/ - public static ProcBuilder create(Object...args) { - return new ProcBuilder().command(args); - } - - /** -* Creates an empty process builder. -* -* @return A new process builder. -*/ - public static ProcBuilder create() { - return new ProcBuilder().command(); - } - - /** -* Command arguments. -* Arguments can be collections or arrays and will be automatically expanded. -* -* @param args The command-line arguments. -* @return This object (for method chaining). -*/ - public ProcBuilder command(Object...args) { - return commandIf(ANY, args); - } - - /** -* Command arguments if the specified matcher matches. -* Can be used for specifying os-specific commands. -* Example: -* -* ProcessBuilder pb = ProcessBuilder -* .create() -* .commandIf(WINDOWS, "cmd /c dir") -* .commandIf(UNIX, "bash -c ls") -* .merge() -* .execute(); -* -* -* @param m The matcher. -* @param args The command line arguments if matcher matches. -* @return This object (for method chaining). -*/ - public ProcBuilder commandIf(Matcher m, Object...args) { - if (m.matches()) - pb.command(toList(args)); - return this; - } - - /** -* Append to the command arguments. -* Arguments can be collections or arrays and will be automatically expanded. -* -* @param args The command-line arguments. -* @return This object (for method chaining). -*/ - public ProcBuilder append(Object...args) { - return appendIf(ANY, args); - } - - /** -* Append to the command arguments if the specified matcher matches. -* Arguments can be collections or arrays and will be automatically expanded. -* -* @param m The matcher. -* @param args The command line arguments if matcher matches. -* @return This object (for method chaining). -*/ - public ProcBuilder appendIf(Matcher m, Object...args) { - if (m.matches()) - pb.command().addAll(toList(args)); - return this; - } - - /** -* Merge STDOUT and STDERR into a single stream. -* -* @return This object (for method chaining). -*/ - public ProcBuilder merge() { - pb.redirectErrorStream(true); - return this; - } - - /** -* Use by-lines mode. -* Flushes output after every line of input. -* -* @return
[35/51] [partial] incubator-juneau git commit: Merge changes from GitHub repo.
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/30947fd7/com.ibm.team.juno.releng/bin/core.test/com/ibm/juno/core/test/CT_BeanContext$DummyPojoFilterB.class -- diff --git a/com.ibm.team.juno.releng/bin/core.test/com/ibm/juno/core/test/CT_BeanContext$DummyPojoFilterB.class b/com.ibm.team.juno.releng/bin/core.test/com/ibm/juno/core/test/CT_BeanContext$DummyPojoFilterB.class deleted file mode 100755 index 9c63aa9..000 Binary files a/com.ibm.team.juno.releng/bin/core.test/com/ibm/juno/core/test/CT_BeanContext$DummyPojoFilterB.class and /dev/null differ http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/30947fd7/com.ibm.team.juno.releng/bin/core.test/com/ibm/juno/core/test/CT_BeanContext$DummyPojoFilterC.class -- diff --git a/com.ibm.team.juno.releng/bin/core.test/com/ibm/juno/core/test/CT_BeanContext$DummyPojoFilterC.class b/com.ibm.team.juno.releng/bin/core.test/com/ibm/juno/core/test/CT_BeanContext$DummyPojoFilterC.class deleted file mode 100755 index eec3b3a..000 Binary files a/com.ibm.team.juno.releng/bin/core.test/com/ibm/juno/core/test/CT_BeanContext$DummyPojoFilterC.class and /dev/null differ http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/30947fd7/com.ibm.team.juno.releng/bin/core.test/com/ibm/juno/core/test/CT_BeanContext$Person.class -- diff --git a/com.ibm.team.juno.releng/bin/core.test/com/ibm/juno/core/test/CT_BeanContext$Person.class b/com.ibm.team.juno.releng/bin/core.test/com/ibm/juno/core/test/CT_BeanContext$Person.class deleted file mode 100755 index ea0c680..000 Binary files a/com.ibm.team.juno.releng/bin/core.test/com/ibm/juno/core/test/CT_BeanContext$Person.class and /dev/null differ http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/30947fd7/com.ibm.team.juno.releng/bin/core.test/com/ibm/juno/core/test/CT_BeanContext$ReadOnlyPerson.class -- diff --git a/com.ibm.team.juno.releng/bin/core.test/com/ibm/juno/core/test/CT_BeanContext$ReadOnlyPerson.class b/com.ibm.team.juno.releng/bin/core.test/com/ibm/juno/core/test/CT_BeanContext$ReadOnlyPerson.class deleted file mode 100755 index 6d6e25c..000 Binary files a/com.ibm.team.juno.releng/bin/core.test/com/ibm/juno/core/test/CT_BeanContext$ReadOnlyPerson.class and /dev/null differ http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/30947fd7/com.ibm.team.juno.releng/bin/core.test/com/ibm/juno/core/test/CT_BeanContext$TestEnum.class -- diff --git a/com.ibm.team.juno.releng/bin/core.test/com/ibm/juno/core/test/CT_BeanContext$TestEnum.class b/com.ibm.team.juno.releng/bin/core.test/com/ibm/juno/core/test/CT_BeanContext$TestEnum.class deleted file mode 100755 index 7006ae7..000 Binary files a/com.ibm.team.juno.releng/bin/core.test/com/ibm/juno/core/test/CT_BeanContext$TestEnum.class and /dev/null differ http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/30947fd7/com.ibm.team.juno.releng/bin/core.test/com/ibm/juno/core/test/CT_BeanContext.class -- diff --git a/com.ibm.team.juno.releng/bin/core.test/com/ibm/juno/core/test/CT_BeanContext.class b/com.ibm.team.juno.releng/bin/core.test/com/ibm/juno/core/test/CT_BeanContext.class deleted file mode 100755 index 44382fd..000 Binary files a/com.ibm.team.juno.releng/bin/core.test/com/ibm/juno/core/test/CT_BeanContext.class and /dev/null differ http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/30947fd7/com.ibm.team.juno.releng/bin/core.test/com/ibm/juno/core/test/CT_BeanFilter$A.class -- diff --git a/com.ibm.team.juno.releng/bin/core.test/com/ibm/juno/core/test/CT_BeanFilter$A.class b/com.ibm.team.juno.releng/bin/core.test/com/ibm/juno/core/test/CT_BeanFilter$A.class deleted file mode 100755 index 2f26e34..000 Binary files a/com.ibm.team.juno.releng/bin/core.test/com/ibm/juno/core/test/CT_BeanFilter$A.class and /dev/null differ http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/30947fd7/com.ibm.team.juno.releng/bin/core.test/com/ibm/juno/core/test/CT_BeanFilter$A1.class -- diff --git a/com.ibm.team.juno.releng/bin/core.test/com/ibm/juno/core/test/CT_BeanFilter$A1.class b/com.ibm.team.juno.releng/bin/core.test/com/ibm/juno/core/test/CT_BeanFilter$A1.class deleted file mode 100755 index d5bf7ac..000 Binary files a/com.ibm.team.juno.releng/bin/core.test/com/ibm/juno/core/test/CT_BeanFilter$A1.class and /dev/null differ
[43/51] [partial] incubator-juneau git commit: Merge changes from GitHub repo.
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/30947fd7/com.ibm.team.juno.microservice/bin/.gitignore -- diff --git a/com.ibm.team.juno.microservice/bin/.gitignore b/com.ibm.team.juno.microservice/bin/.gitignore deleted file mode 100644 index c2d9872..000 --- a/com.ibm.team.juno.microservice/bin/.gitignore +++ /dev/null @@ -1 +0,0 @@ -/com/ http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/30947fd7/com.ibm.team.juno.microservice/build.properties -- diff --git a/com.ibm.team.juno.microservice/build.properties b/com.ibm.team.juno.microservice/build.properties index f32e521..8fe52e5 100755 --- a/com.ibm.team.juno.microservice/build.properties +++ b/com.ibm.team.juno.microservice/build.properties @@ -1,15 +1,17 @@ -### -# -# Licensed Materials - Property of IBM -# (c) Copyright IBM Corporation 2015. All Rights Reserved. -# -# Note to U.S. Government Users Restricted Rights: -# Use, duplication or disclosure restricted by GSA ADP Schedule -# Contract with IBM Corp. -# -### -source.. = src/ -output.. = bin/ +# *** +# * 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. * +# *** +source.. = src/main/java +output.. = target/classes bin.includes = META-INF/,\ . jar = microservice.jar http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/30947fd7/com.ibm.team.juno.microservice/src/com/ibm/juno/microservice/Microservice.java -- diff --git a/com.ibm.team.juno.microservice/src/com/ibm/juno/microservice/Microservice.java b/com.ibm.team.juno.microservice/src/com/ibm/juno/microservice/Microservice.java deleted file mode 100755 index c175f5f..000 --- a/com.ibm.team.juno.microservice/src/com/ibm/juno/microservice/Microservice.java +++ /dev/null @@ -1,521 +0,0 @@ -/*** - * Licensed Materials - Property of IBM - * © Copyright IBM Corporation 2015. All Rights Reserved. - * - * The source code for this program is not published or otherwise - * divested of its trade secrets, irrespective of what has been - * deposited with the U.S. Copyright Office. - ***/ -package com.ibm.juno.microservice; - -import java.io.Console; -import java.io.File; -import java.io.FileInputStream; -import java.io.IOException; -import java.net.URL; -import java.net.URLClassLoader; -import java.util.Map; -import java.util.Set; -import java.util.jar.Manifest; - -import com.ibm.juno.core.ObjectMap; -import com.ibm.juno.core.utils.*; -import com.ibm.juno.core.ini.ConfigFile; -import com.ibm.juno.core.ini.ConfigFileListener; -import com.ibm.juno.core.ini.ConfigMgr; - -/** - * Parent class for all microservices. - * - * A microservice defines a simple API for starting and stopping simple Java services - * contained in executable jars. - * - * The general command for invoking these services is... - * - * java -jar mymicroservice.jar [mymicroservice.cfg] - * - * - * Your microservice class must be specified as the Main-Class entry in - * the manifest file of your microservice jar file. - * - * Microservice Configuration - * - *
[20/51] [partial] incubator-juneau git commit: Merge changes from GitHub repo.
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/30947fd7/com.ibm.team.juno.releng/bin/core/com/ibm/juno/core/filter/PojoFilter.java -- diff --git a/com.ibm.team.juno.releng/bin/core/com/ibm/juno/core/filter/PojoFilter.java b/com.ibm.team.juno.releng/bin/core/com/ibm/juno/core/filter/PojoFilter.java deleted file mode 100755 index afddef1..000 --- a/com.ibm.team.juno.releng/bin/core/com/ibm/juno/core/filter/PojoFilter.java +++ /dev/null @@ -1,261 +0,0 @@ -/*** - * Licensed Materials - Property of IBM - * (c) Copyright IBM Corporation 2011, 2015. All Rights Reserved. - * - * The source code for this program is not published or otherwise - * divested of its trade secrets, irrespective of what has been - * deposited with the U.S. Copyright Office. - ***/ -package com.ibm.juno.core.filter; - -import java.lang.reflect.*; -import java.util.*; - -import com.ibm.juno.core.*; -import com.ibm.juno.core.parser.*; -import com.ibm.juno.core.serializer.*; -import com.ibm.juno.core.utils.*; - -/** - * Used to convert non-serializable objects to a serializable form. - * - * - * Description - * - * PojoFilters are used to extend the functionality of the serializers and parsers to be able to handle POJOs - * that aren't automatically handled by the serializers or parsers. For example, JSON does not have a standard - * representation for rendering dates. By defining a special {@code Date} filter and associating it with a serializer and - * parser, you can convert a {@code Date} object to a {@code String} during serialization, and convert that {@code String} object back into - * a {@code Date} object during parsing. - * - * Object filters MUST declare a public no-arg constructor so that the bean context can instantiate them. - * - * PojoFilters are associated with instances of {@link BeanContext BeanContexts} by passing the filter class to - * the {@link BeanContextFactory#addFilters(Class...)} method. - * When associated with a bean context, fields of the specified type will automatically be converted when the - * {@link BeanMap#get(Object)} or {@link BeanMap#put(String, Object)} methods are called. - * - * PojoFilters have two parameters: - * - * {@code } - The filtered representation of an object. - * {@code } - The normal representation of an object. - * - * - * {@link Serializer Serializers} use object filters to convert objects of type T into objects of type F, and on calls to {@link BeanMap#get(Object)}. - * {@link Parser Parsers} use object filters to convert objects of type F into objects of type T, and on calls to {@link BeanMap#put(String,Object)}. - * - * - * Filtered Class Type {@code } - * - * The filtered object representation of an object must be an object type that the serializers can - * natively convert to JSON (or language-specific equivalent). The list of valid filtered types are as follows... - * - * {@link String} - * {@link Number} - * {@link Boolean} - * {@link Collection} containing anything on this list. - * {@link Map} containing anything on this list. - * A java bean with properties of anything on this list. - * An array of anything on this list. - * - * - * - * Normal Class Type {@code } - * - * The normal object representation of an object. - * - * - * One-way vs. Two-way Serialization - * - * Note that while there is a unified interface for handling filtering during both serialization and parsing, - * in many cases only one of the {@link #filter(Object)} or {@link #unfilter(Object, ClassMeta)} methods will be defined - * because the filter is one-way. For example, a filter may be defined to convert an {@code Iterator} to a {@code ObjectList}, but - * it's not possible to unfilter an {@code Iterator}. In that case, the {@code generalize(Object}} method would - * be implemented, but the {@code narrow(ObjectMap)} object would not, and the filter would be associated on - * the serializer, but not the parser. Also, you may choose to serialize objects like {@code Dates} to readable {@code Strings}, - * in which case it's not possible to reparse it back into a {@code Date}, since there is no way for the {@code Parser} to - * know it's a {@code Date} from just the JSON or XML text. - * - * - * Additional information - * See {@link com.ibm.juno.core.filter} for more information. - * - * - * @author James Bognar (jbog...@us.ibm.com) - * @param The normal form of the class. - * @param The filtered form of the class. - */ -public abstract class PojoFilterextends Filter { - - /** Represents no
[39/51] [partial] incubator-juneau git commit: Merge changes from GitHub repo.
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/30947fd7/com.ibm.team.juno.microservice/src/main/java/org/apache/juneau/microservice/resources/DirectoryResource.java -- diff --git a/com.ibm.team.juno.microservice/src/main/java/org/apache/juneau/microservice/resources/DirectoryResource.java b/com.ibm.team.juno.microservice/src/main/java/org/apache/juneau/microservice/resources/DirectoryResource.java new file mode 100755 index 000..53b79b9 --- /dev/null +++ b/com.ibm.team.juno.microservice/src/main/java/org/apache/juneau/microservice/resources/DirectoryResource.java @@ -0,0 +1,357 @@ +/*** + * 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.juneau.microservice.resources; + +import static java.util.logging.Level.*; +import static javax.servlet.http.HttpServletResponse.*; +import static org.apache.juneau.html.HtmlDocSerializerContext.*; +import static org.apache.juneau.server.RestServletContext.*; + +import java.io.*; +import java.net.*; +import java.util.*; +import java.util.logging.*; + +import javax.servlet.*; + +import org.apache.juneau.*; +import org.apache.juneau.annotation.*; +import org.apache.juneau.microservice.*; +import org.apache.juneau.server.*; +import org.apache.juneau.server.annotation.*; +import org.apache.juneau.server.converters.*; +import org.apache.juneau.transforms.*; +import org.apache.juneau.utils.*; + +/** + * REST resource that allows access to a file system directory. + * + * The root directory is specified in one of two ways: + * + * + * Specifying the location via a DirectoryResource.rootDir property. + * Overriding the {@link #getRootDir()} method. + * + * + * Read/write access control is handled through the following properties: + * + * + * DirectoryResource.allowViews - If true, allows view and download access to files. + * DirectoryResource.allowPuts - If true, allows files to be created or overwritten. + * DirectoryResource.allowDeletes - If true, allows files to be deleted. + * + * + * Access can also be controlled by overriding the {@link #checkAccess(RestRequest)} method. + * + */ +@RestResource( + label="File System Explorer", + description="Contents of $A{path}", + messages="nls/DirectoryResource", + properties={ + @Property(name=HTML_uriAnchorText, value=PROPERTY_NAME), + @Property(name=HTMLDOC_links, value="{up:'$R{requestParentURI}',options:'?method=OPTIONS',source:'$R{servletParentURI}/source?classes=(org.apache.juneau.server.samples.DirectoryResource)'}"), + @Property(name=REST_allowMethodParam, value="*"), + @Property(name="DirectoryResource.rootDir", value=""), + @Property(name="DirectoryResource.allowViews", value="false"), + @Property(name="DirectoryResource.allowDeletes", value="false"), + @Property(name="DirectoryResource.allowPuts", value="false") + } +) +public class DirectoryResource extends Resource { + private static final long serialVersionUID = 1L; + + private File rootDir; // The root directory + + // Settings enabled through servlet init parameters + private boolean allowDeletes, allowPuts, allowViews; + + private static Logger logger = Logger.getLogger(DirectoryResource.class.getName()); + + @Override /* Servlet */ + public void init() throws ServletException { + ObjectMap p = getProperties(); + rootDir = new File(p.getString("DirectoryResource.rootDir")); + allowViews = p.getBoolean("DirectoryResource.allowViews", false); + allowDeletes = p.getBoolean("DirectoryResource.allowDeletes", false); + allowPuts = p.getBoolean("DirectoryResource.allowPuts", false); + } + + /** +* Returns the root directory defined by the 'rootDir' init parameter. +*
[27/51] [partial] incubator-juneau git commit: Merge changes from GitHub repo.
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/30947fd7/com.ibm.team.juno.releng/bin/core/com/ibm/juno/core/BeanPropertyMeta.java -- diff --git a/com.ibm.team.juno.releng/bin/core/com/ibm/juno/core/BeanPropertyMeta.java b/com.ibm.team.juno.releng/bin/core/com/ibm/juno/core/BeanPropertyMeta.java deleted file mode 100755 index ea9fc3c..000 --- a/com.ibm.team.juno.releng/bin/core/com/ibm/juno/core/BeanPropertyMeta.java +++ /dev/null @@ -1,803 +0,0 @@ -/*** - * Licensed Materials - Property of IBM - * (c) Copyright IBM Corporation 2011, 2015. All Rights Reserved. - * - * The source code for this program is not published or otherwise - * divested of its trade secrets, irrespective of what has been - * deposited with the U.S. Copyright Office. - ***/ -package com.ibm.juno.core; - -import static com.ibm.juno.core.Visibility.*; -import static com.ibm.juno.core.utils.ClassUtils.*; -import static com.ibm.juno.core.utils.CollectionUtils.*; -import static com.ibm.juno.core.utils.ReflectionUtils.*; - -import java.lang.annotation.*; -import java.lang.reflect.*; -import java.net.*; -import java.util.*; - -import com.ibm.juno.core.annotation.*; -import com.ibm.juno.core.annotation.URI; -import com.ibm.juno.core.filter.*; -import com.ibm.juno.core.html.*; -import com.ibm.juno.core.jena.*; -import com.ibm.juno.core.parser.*; -import com.ibm.juno.core.serializer.*; -import com.ibm.juno.core.utils.*; -import com.ibm.juno.core.xml.*; - -/** - * Contains metadata about a bean property. - * - * Contains information such as type of property (e.g. field/getter/setter), class type of property value, - * and whether any filters are associated with this property. - * - * Developers will typically not need access to this class. The information provided by it is already - * exposed through several methods on the {@link BeanMap} API. - * - * @param The class type of the bean that this metadata applies to. - * @author James Bognar (jbog...@us.ibm.com) - */ -@SuppressWarnings({ "rawtypes", "unchecked" }) -public class BeanPropertyMeta { - - private Field field; - private Method getter, setter; - private boolean isConstructorArg, isBeanUri, isUri; - - private final BeanMeta beanMeta; - - private String name; - private ClassMeta - rawTypeMeta, // The real class type of the bean property. - typeMeta; // The filtered class type of the bean property. - private String[] properties; - private PojoFilter filter; // PojoFilter defined only via @BeanProperty annotation. - - /** HTML related metadata on this bean property. */ - protected HtmlBeanPropertyMeta htmlMeta; - - /** XML related metadata on this bean property. */ - protected XmlBeanPropertyMeta xmlMeta; - - /** RDF related metadata on this bean property. */ - protected RdfBeanPropertyMeta rdfMeta; // - - BeanPropertyMeta(BeanMeta beanMeta, String name) { - this.beanMeta = beanMeta; - this.name = name; - } - - BeanPropertyMeta(BeanMeta beanMeta, String name, ClassMeta rawTypeMeta) { - this(beanMeta, name); - this.rawTypeMeta = rawTypeMeta; - } - - BeanPropertyMeta(BeanMeta beanMeta, String name, Method getter, Method setter) { - this(beanMeta, name); - setGetter(getter); - setSetter(setter); - } - - /** -* Returns the name of this bean property. -* -* @return The name of the bean property. -*/ - public String getName() { - return name; - } - - /** -* Returns the bean meta that this property belongs to. -* -* @return The bean meta that this property belongs to. -*/ - @BeanIgnore - public BeanMeta getBeanMeta() { - return beanMeta; - } - - /** -* Returns the getter method for this property. -* -* @return The getter method for this bean property, or null if there is no getter method. -*/ - public Method getGetter() { - return getter; - } - - /** -* Returns the setter method for this property. -* -* @return The setter method for this bean property, or null if there is no setter method. -*/ - public Method getSetter() { - return setter; - } - - /** -* Returns the field for this property. -* -* @return The field for this bean property, or null if there is no field associated with this bean property. -*/ - public Field
[38/51] [partial] incubator-juneau git commit: Merge changes from GitHub repo.
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/30947fd7/com.ibm.team.juno.releng/bin/client/com/ibm/juno/client/RestCall.java -- diff --git a/com.ibm.team.juno.releng/bin/client/com/ibm/juno/client/RestCall.java b/com.ibm.team.juno.releng/bin/client/com/ibm/juno/client/RestCall.java deleted file mode 100755 index 67cbff2..000 --- a/com.ibm.team.juno.releng/bin/client/com/ibm/juno/client/RestCall.java +++ /dev/null @@ -1,942 +0,0 @@ -/*** - * Licensed Materials - Property of IBM - * (c) Copyright IBM Corporation 2014, 2015. All Rights Reserved. - * - * The source code for this program is not published or otherwise - * divested of its trade secrets, irrespective of what has been - * deposited with the U.S. Copyright Office. - ***/ -package com.ibm.juno.client; - -import java.io.*; -import java.net.*; -import java.util.*; -import java.util.logging.*; -import java.util.regex.*; - -import org.apache.http.*; -import org.apache.http.client.*; -import org.apache.http.client.config.*; -import org.apache.http.client.methods.*; -import org.apache.http.impl.client.*; -import org.apache.http.util.*; - -import com.ibm.juno.core.*; -import com.ibm.juno.core.encoders.*; -import com.ibm.juno.core.parser.*; -import com.ibm.juno.core.parser.ParseException; -import com.ibm.juno.core.serializer.*; -import com.ibm.juno.core.utils.*; - -/** - * Represents a connection to a remote REST resource. - * - * Instances of this class are created by the various {@code doX()} methods on the {@link RestClient} class. - * - * This class uses only Java standard APIs. Requests can be built up using a fluent interface with method chaining, like so... - * - * - * RestClient client = new RestClient(); - * RestCall c = client.doPost(URL).setInput(o).setHeader(x,y); - * MyBean b = c.getResponse(MyBean.class); - * - * - * The actual connection and request/response transaction occurs when calling one of the getResponseXXX() methods. - * - * Additional Information - * - * com.ibm.juno.client REST client API for more information and code examples. - * - * - * @author James Bognar (jbog...@us.ibm.com) - */ -public final class RestCall { - - private final RestClient client; // The client that created this call. - private final HttpRequestBase request; // The request. - private HttpResponse response; // The response. - private List interceptors = new ArrayList(); // Used for intercepting and altering requests. - - private boolean isConnected = false; // connect() has been called. - private boolean allowRedirectsOnPosts; - private int retries = 1; - private int redirectOnPostsTries = 5; - private long retryInterval = -1; - private RetryOn retryOn = RetryOn.DEFAULT; - private boolean ignoreErrors; - private boolean byLines = false; - private TeeWriter writers = new TeeWriter(); - private StringWriter capturedResponseWriter; - private String capturedResponse; - private TeeOutputStream outputStreams = new TeeOutputStream(); - private boolean isClosed = false; - private boolean isFailed = false; - - /** -* Constructs a REST call with the specified method name. -* -* @param client The client that created this request. -* @param request The wrapped Apache HTTP client request object. -* @throws RestCallException If an exception or non-200 response code occurred during the connection attempt. -*/ - protected RestCall(RestClient client, HttpRequestBase request) throws RestCallException { - this.client = client; - this.request = request; - for (RestCallInterceptor i : this.client.interceptors) - addInterceptor(i); - } - - /** -* Sets the input for this REST call. -* -* @param input The input to be sent to the REST resource (only valid for PUT and POST) requests. -* Can be of the following types: -* -* {@link Reader} - Raw contents of {@code Reader} will be serialized to remote resource. -* {@link InputStream} - Raw contents of {@code InputStream} will be serialized to remote resource. -* {@link Object} - POJO to be converted to text using the {@link Serializer} registered with the {@link RestClient}. -* {@link HttpEntity} - Bypass Juno serialization and pass HttpEntity directly to HttpClient. -* -* @return This object (for method chaining). -* @throws RestCallException If a retry
[24/51] [partial] incubator-juneau git commit: Merge changes from GitHub repo.
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/30947fd7/com.ibm.team.juno.releng/bin/core/com/ibm/juno/core/annotation/BeanProperty.java -- diff --git a/com.ibm.team.juno.releng/bin/core/com/ibm/juno/core/annotation/BeanProperty.java b/com.ibm.team.juno.releng/bin/core/com/ibm/juno/core/annotation/BeanProperty.java deleted file mode 100755 index 363947f..000 --- a/com.ibm.team.juno.releng/bin/core/com/ibm/juno/core/annotation/BeanProperty.java +++ /dev/null @@ -1,182 +0,0 @@ -/*** - * Licensed Materials - Property of IBM - * (c) Copyright IBM Corporation 2011, 2014. All Rights Reserved. - * - * The source code for this program is not published or otherwise - * divested of its trade secrets, irrespective of what has been - * deposited with the U.S. Copyright Office. - ***/ -package com.ibm.juno.core.annotation; - -import static java.lang.annotation.ElementType.*; -import static java.lang.annotation.RetentionPolicy.*; - -import java.lang.annotation.*; -import java.util.*; - -import com.ibm.juno.core.*; -import com.ibm.juno.core.filter.*; -import com.ibm.juno.core.jena.*; -import com.ibm.juno.core.xml.*; -import com.ibm.juno.core.xml.annotation.*; - -/** - * Used tailor how bean properties get interpreted by the framework. - * - * Can be used to do the following: - * - * Override the name of a property. - * Identify a getter or setter with a non-standard naming convention. - * Identify a specific subclass for a property with a general class type. - * Identify class types of elements in properties of type Collection or Map. - * Hide properties during serialization. - * Associate filters with bean property values, such as a filter to convert a Calendar field to a string. - * Override the list of properties during serialization on child elements of a property of type Collection or Map. - * Identify a property as the URL for a bean. - * Identify a property as the ID for a bean. - * - * - * This annotation is applied to public fields and public getter/setter methods of beans. - * - * @author James Bognar (jbog...@us.ibm.com) - */ -@Documented -@Target({FIELD,METHOD}) -@Retention(RUNTIME) -@Inherited -public @interface BeanProperty { - - /** -* Identifies the name of the property. -* -* Normally, this is automatically inferred from the field name or getter method name -* of the property. However, this property can be used to assign a different -* property name from the automatically inferred value. -* -* If the {@link BeanContextProperties#BEAN_beanFieldVisibility} setting on the bean context excludes this field (e.g. the visibility -* is set to PUBLIC, but the field is PROTECTED), this annotation can be used to force the field to be identified as a property. -*/ - String name() default ""; - - /** -* Identifies a specialized class type for the property. -* -* Normally this can be inferred through reflection of the field type or getter return type. -* However, you'll want to specify this value if you're parsing beans where the bean property class -* is an interface or abstract class to identify the bean type to instantiate. Otherwise, you may -* cause an {@link InstantiationException} when trying to set these fields. -* -* This property must denote a concrete bean class with a no-arg constructor. -* -* -* Example: -* -* -* public class MyBean { -* -* // Identify concrete map type. -* @BeanProperty(type=HashMap.class) -* public Map p1; -* } -* -* -* -*/ - Class type() default Object.class; - - /** -* For bean properties of maps and collections, this annotation can be used to identify -* the class types of the contents of the bean property object when the generic parameter -* types are interfaces or abstract classes. -* -* -* Example: -* -* -* public class MyBean { -* -* // Identify concrete map type with String keys and Integer values. -* @BeanProperty(type=HashMap.class, params={String.class,Integer.class}) -* public Map p1; -* } -* -* -* -*/ - Class[] params() default {}; - - /** -* Associates an object filter with this bean property that will convert it -* to a
[46/51] [partial] incubator-juneau git commit: Merge changes from GitHub repo.
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/30947fd7/com.ibm.team.juno.client/src/main/java/org/apache/juneau/client/RestCall.java -- diff --git a/com.ibm.team.juno.client/src/main/java/org/apache/juneau/client/RestCall.java b/com.ibm.team.juno.client/src/main/java/org/apache/juneau/client/RestCall.java new file mode 100755 index 000..8b79d13 --- /dev/null +++ b/com.ibm.team.juno.client/src/main/java/org/apache/juneau/client/RestCall.java @@ -0,0 +1,947 @@ +/*** + * 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.juneau.client; + +import java.io.*; +import java.net.*; +import java.util.*; +import java.util.logging.*; +import java.util.regex.*; + +import org.apache.http.*; +import org.apache.http.client.*; +import org.apache.http.client.config.*; +import org.apache.http.client.methods.*; +import org.apache.http.impl.client.*; +import org.apache.http.util.*; +import org.apache.juneau.*; +import org.apache.juneau.encoders.*; +import org.apache.juneau.internal.*; +import org.apache.juneau.parser.*; +import org.apache.juneau.parser.ParseException; +import org.apache.juneau.serializer.*; +import org.apache.juneau.utils.*; + +/** + * Represents a connection to a remote REST resource. + * + * Instances of this class are created by the various {@code doX()} methods on the {@link RestClient} class. + * + * This class uses only Java standard APIs. Requests can be built up using a fluent interface with method chaining, like so... + * + * + * RestClient client = new RestClient(); + * RestCall c = client.doPost(URL).setInput(o).setHeader(x,y); + * MyBean b = c.getResponse(MyBean.class); + * + * + * The actual connection and request/response transaction occurs when calling one of the getResponseXXX() methods. + * + * Additional Information + * + * org.apache.juneau.client REST client API for more information and code examples. + * + * + * @author James Bognar (james.bog...@salesforce.com) + */ +public final class RestCall { + + private final RestClient client; // The client that created this call. + private final HttpRequestBase request; // The request. + private HttpResponse response; // The response. + private List interceptors = new ArrayList(); // Used for intercepting and altering requests. + + private boolean isConnected = false; // connect() has been called. + private boolean allowRedirectsOnPosts; + private int retries = 1; + private int redirectOnPostsTries = 5; + private long retryInterval = -1; + private RetryOn retryOn = RetryOn.DEFAULT; + private boolean ignoreErrors; + private boolean byLines = false; + private TeeWriter writers = new TeeWriter(); + private StringWriter capturedResponseWriter; + private String capturedResponse; + private TeeOutputStream outputStreams = new TeeOutputStream(); + private boolean isClosed = false; + private boolean isFailed = false; + + /** +* Constructs a REST call with the specified method name. +* +* @param client The client that created this request. +* @param request The wrapped Apache HTTP client request object. +* @throws RestCallException If an exception or non-200 response code occurred during the connection attempt. +*/ + protected RestCall(RestClient client, HttpRequestBase request) throws RestCallException { + this.client = client; + this.request = request; + for (RestCallInterceptor i : this.client.interceptors) + addInterceptor(i); + } + + /** +* Sets the input for this REST call. +* +* @param input The input to be sent to the REST resource (only valid for PUT and POST)
[06/51] [partial] incubator-juneau git commit: Merge changes from GitHub repo.
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/30947fd7/com.ibm.team.juno.releng/bin/core/com/ibm/juno/core/urlencoding/UrlEncodingSerializer.java -- diff --git a/com.ibm.team.juno.releng/bin/core/com/ibm/juno/core/urlencoding/UrlEncodingSerializer.java b/com.ibm.team.juno.releng/bin/core/com/ibm/juno/core/urlencoding/UrlEncodingSerializer.java deleted file mode 100755 index e4894df..000 --- a/com.ibm.team.juno.releng/bin/core/com/ibm/juno/core/urlencoding/UrlEncodingSerializer.java +++ /dev/null @@ -1,515 +0,0 @@ -/*** - * Licensed Materials - Property of IBM - * (c) Copyright IBM Corporation 2011, 2015. All Rights Reserved. - * - * The source code for this program is not published or otherwise - * divested of its trade secrets, irrespective of what has been - * deposited with the U.S. Copyright Office. - ***/ -package com.ibm.juno.core.urlencoding; - -import static com.ibm.juno.core.urlencoding.UonSerializerProperties.*; -import static com.ibm.juno.core.urlencoding.UrlEncodingProperties.*; - -import java.io.*; -import java.lang.reflect.*; -import java.net.*; -import java.util.*; - -import com.ibm.juno.core.*; -import com.ibm.juno.core.annotation.*; -import com.ibm.juno.core.filter.*; -import com.ibm.juno.core.serializer.*; -import com.ibm.juno.core.utils.*; - -/** - * Serializes POJO models to URL-encoded notation with UON-encoded values (a notation for URL-encoded query paramter values). - * - * - * Media types - * - * Handles Accept types: application/x-www-form-urlencoded - * - * Produces Content-Type types: application/x-www-form-urlencoded - * - * - * Description - * - * This serializer provides several serialization options. Typically, one of the predefined DEFAULT serializers will be sufficient. - * However, custom serializers can be constructed to fine-tune behavior. - * - * - * Configurable properties - * - * This class has the following properties associated with it: - * - * {@link UonSerializerProperties} - * {@link SerializerProperties} - * {@link BeanContextProperties} - * - * - * The following shows a sample object defined in Javascript: - * - * - * { - * id: 1, - * name: 'John Smith', - * uri: 'http://sample/addressBook/person/1', - * addressBookUri: 'http://sample/addressBook', - * birthDate: '1946-08-12T00:00:00Z', - * otherIds: null, - * addresses: [ - * { - * uri: 'http://sample/addressBook/address/1', - * personUri: 'http://sample/addressBook/person/1', - * id: 1, - * street: '100 Main Street', - * city: 'Anywhereville', - * state: 'NY', - * zip: 12345, - * isCurrent: true, - * } - * ] - * } - * - * - * Using the "strict" syntax defined in this document, the equivalent - * URL-encoded notation would be as follows: - * - * - * id=$n(1) - * name=John+Smith, - * uri=http://sample/addressBook/person/1, - * addressBookUri=http://sample/addressBook, - * birthDate=1946-08-12T00:00:00Z, - * otherIds=%00, - * addresses=$a( - * $o( - * uri=http://sample/addressBook/address/1, - * personUri=http://sample/addressBook/person/1, - * id=$n(1), - * street=100+Main+Street, - * city=Anywhereville, - * state=NY, - * zip=$n(12345), - * isCurrent=$b(true) - * ) - * ) - * - * - * A secondary "lax" syntax is available when the data type of the - * values are already known on the receiving end of the transmission: - * - * - * id=1, - * name=John+Smith, - * uri=http://sample/addressBook/person/1, - * addressBookUri=http://sample/addressBook, - * birthDate=1946-08-12T00:00:00Z, - * otherIds=%00, - * addresses=( - * ( - * uri=http://sample/addressBook/address/1, - * personUri=http://sample/addressBook/person/1, - * id=1, - * street=100+Main+Street, - * city=Anywhereville, - * state=NY, - * zip=12345, - * isCurrent=true - * ) - * ) - * - * - * - * Examples - * - * // Serialize a Map - * Map m = new ObjectMap("{a:'b',c:1,d:false,e:['f',1,false],g:{h:'i'}}"); - * - * //
[07/51] [partial] incubator-juneau git commit: Merge changes from GitHub repo.
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/30947fd7/com.ibm.team.juno.releng/bin/core/com/ibm/juno/core/urlencoding/UonParserReader.java -- diff --git a/com.ibm.team.juno.releng/bin/core/com/ibm/juno/core/urlencoding/UonParserReader.java b/com.ibm.team.juno.releng/bin/core/com/ibm/juno/core/urlencoding/UonParserReader.java deleted file mode 100755 index 621164e..000 --- a/com.ibm.team.juno.releng/bin/core/com/ibm/juno/core/urlencoding/UonParserReader.java +++ /dev/null @@ -1,195 +0,0 @@ -/*** - * Licensed Materials - Property of IBM - * (c) Copyright IBM Corporation 2014, 2015. All Rights Reserved. - * - * The source code for this program is not published or otherwise - * divested of its trade secrets, irrespective of what has been - * deposited with the U.S. Copyright Office. - ***/ -package com.ibm.juno.core.urlencoding; - -import java.io.*; - -import com.ibm.juno.core.parser.*; - -/** - * Same functionality as {@link ParserReader} except automatically decoded %xx escape sequences. - * - * Escape sequences are assumed to be encoded UTF-8. Extended Unicode (\u1) is supported. - * - * If decoding is enabled, the following character replacements occur so that boundaries are not lost: - * - * '&' - '\u0001' - * '=' - '\u0002' - * - * - * @author James Bognar (jbog...@us.ibm.com) - */ -public final class UonParserReader extends ParserReader { - - private final boolean decodeChars; - private final char[] buff; - private int iCurrent, iEnd; - - /** -* Constructor for input from a {@link CharSequence}. -* -* @param in The character sequence being read from. -* @param decodeChars If true, decode %xx escape sequences. -*/ - public UonParserReader(CharSequence in, boolean decodeChars) { - super(in); - this.decodeChars = decodeChars; - if (in == null || ! decodeChars) - this.buff = new char[0]; - else - this.buff = new char[in.length() < 1024 ? in.length() : 1024]; - } - - /** -* Constructor for input from a {@link Reader}). -* -* @param r The Reader being wrapped. -* @param buffSize Buffer size. -* @param decodeChars If true, decode %xx escape sequences. -*/ - public UonParserReader(Reader r, int buffSize, boolean decodeChars) { - super(r, buffSize); - this.decodeChars = decodeChars; - buffSize = decodeChars ? (buffSize <= 0 ? 1024 : Math.max(buffSize, 20)) : 0; - this.buff = new char[buffSize]; - } - - @Override /* Reader */ - public final int read(char[] cbuf, int off, int len) throws IOException { - - if (! decodeChars) - return super.read(cbuf, off, len); - - // Copy any remainder to the beginning of the buffer. - int remainder = iEnd - iCurrent; - if (remainder > 0) - System.arraycopy(buff, iCurrent, buff, 0, remainder); - iCurrent = 0; - - int expected = buff.length - remainder; - - int x = super.read(buff, remainder, expected); - if (x == -1 && remainder == 0) - return -1; - - iEnd = remainder + (x == -1 ? 0 : x); - - int i = 0; - while (i < len) { - if (iCurrent >= iEnd) - return i; - char c = buff[iCurrent++]; - if (c == '+') { - cbuf[off + i++] = ' '; - } else if (c == '&') { - cbuf[off + i++] = '\u0001'; - } else if (c == '=') { - cbuf[off + i++] = '\u0002'; - } else if (c != '%') { - cbuf[off + i++] = c; - } else { - int iMark = iCurrent-1; // Keep track of current position. - - // Stop if there aren't at least two more characters following '%' in the buffer, - // or there aren't at least two more positions open in cbuf to handle double-char chars. - if (iMark+2 >= iEnd || i+2 > len) { - iCurrent--; - return i; - } - - int b0 = readEncodedByte(); - int cx; - - // 0xxx -
[10/51] [partial] incubator-juneau git commit: Merge changes from GitHub repo.
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/30947fd7/com.ibm.team.juno.releng/bin/core/com/ibm/juno/core/package.html -- diff --git a/com.ibm.team.juno.releng/bin/core/com/ibm/juno/core/package.html b/com.ibm.team.juno.releng/bin/core/com/ibm/juno/core/package.html deleted file mode 100755 index 98cb75a..000 --- a/com.ibm.team.juno.releng/bin/core/com/ibm/juno/core/package.html +++ /dev/null @@ -1,210 +0,0 @@ - - - - - - - /* For viewing in Page Designer */ - @IMPORT url("../../../../../javadoc.css"); - - /* For viewing in REST interface */ - @IMPORT url("../htdocs/javadoc.css"); - body { - margin: 20px; - } - - - /* Replace all @code and @link tags. */ - window.onload = function() { - document.body.innerHTML = document.body.innerHTML.replace(/\{\@code ([^\}]+)\}/g, '$1
'); - document.body.innerHTML = document.body.innerHTML.replace(/\{\@link (([^\}]+)\.)?([^\.\}]+)\}/g, '$3
'); - } - - - -Base toolkit for serializers, parsers, and bean contexts - - - function toggle(x) { - var div = x.nextSibling; - while (div != null && div.nodeType != 1) - div = div.nextSibling; - if (div != null) { - var d = div.style.display; - if (d == 'block' || d == '') { - div.style.display = 'none'; - x.className += " closed"; - } else { - div.style.display = 'block'; - x.className = x.className.replace(/(?:^|\s)closed(?!\S)/g , '' ); - } - } - } - - -Table of Contents - - Bean Context API - - The BeanMap class - The BeanContext class - Bean annotations - - ObjectMap and ObjectList APIs - POJO Categories - - - - -1 - Bean Context API - - - The {@link com.ibm.juno.core.BeanContext} class is the core class in the Juno architecture. It serves multiple functions... - - - It provides the ability to create instances of {@link com.ibm.juno.core.BeanMap BeanMaps}. - It serves as a repository for {@link com.ibm.juno.core.filter.Filter Filters}, which are used to tailor how beans and non-beans are handled. - It's used by all built-in {@link com.ibm.juno.core.serializer.Serializer Serializers} and {@link com.ibm.juno.core.parser.Parser Parsers} for working with POJOs in a consistent way. - - - - - 1.1 - The BeanMap class - - - The {@link com.ibm.juno.core.BeanMap} class allows you to access the properties of a bean through the familiar {@code Map} interface. - So, for example, you can use the {@code Map.get(key)} method to retrieve a property value in leu of it's getter method, and the {@code Map.put(key, value)} method to set a property value in leu of it's setter method. - - - The serialization and parsing of beans in Juno is accomplished by wrapping Java beans inside instances of the class {@code BeanMap}. - - - Note: Instances of {@link com.ibm.juno.core.BeanMap} objects are always retrieved through the {@link com.ibm.juno.core.BeanContext} class. You cannot instantiate {@code BeanMaps} directly since the rules for defining what constitutes a bean depend on various settings in the bean context. - - - In general, the performance on using the {@link com.ibm.juno.core.BeanMap} class to access properties is equivalent to using reflection directly. - - - See the {@link com.ibm.juno.core.BeanMap} javadoc for more information. - - - - - - 1.2 - The BeanContext class - - - The {@link com.ibm.juno.core.BeanContext} class is the workhorse class used to wrap Java beans inside {@link com.ibm.juno.core.BeanMap BeanMaps}. - There are several options provided on the {@link com.ibm.juno.core.BeanContext} class to tailor the definition of a bean. - - - The following is a very simple example of how to wrap a bean inside a {@link com.ibm.juno.core.BeanMap} wrapper and use the wrapper interface to get and set property values on the bean. - In
[13/51] [partial] incubator-juneau git commit: Merge changes from GitHub repo.
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/30947fd7/com.ibm.team.juno.releng/bin/core/com/ibm/juno/core/jena/package.html -- diff --git a/com.ibm.team.juno.releng/bin/core/com/ibm/juno/core/jena/package.html b/com.ibm.team.juno.releng/bin/core/com/ibm/juno/core/jena/package.html deleted file mode 100755 index 0e707c9..000 --- a/com.ibm.team.juno.releng/bin/core/com/ibm/juno/core/jena/package.html +++ /dev/null @@ -1,1687 +0,0 @@ - - - - - - - /* For viewing in Page Designer */ - @IMPORT url("../../../../../../javadoc.css"); - - /* For viewing in REST interface */ - @IMPORT url("../htdocs/javadoc.css"); - body { - margin: 20px; - } - - - /* Replace all @code and @link tags. */ - window.onload = function() { - document.body.innerHTML = document.body.innerHTML.replace(/\{\@code ([^\}]+)\}/g, '$1
'); - document.body.innerHTML = document.body.innerHTML.replace(/\{\@link (([^\}]+)\.)?([^\.\}]+)\}/g, '$3
'); - } - - - -Jena-based RDF serialization and parsing support - - function toggle(x) { - var div = x.nextSibling; - while (div != null && div.nodeType != 1) - div = div.nextSibling; - if (div != null) { - var d = div.style.display; - if (d == 'block' || d == '') { - div.style.display = 'none'; - x.className += " closed"; - } else { - div.style.display = 'block'; - x.className = x.className.replace(/(?:^|\s)closed(?!\S)/g , '' ); - } - } - } - - -Table of Contents - - RDF support overview - - Example - - RdfSerializer class - - Namespaces - URI properties - @Bean and @BeanProperty annotations - Collections - Root property - Typed literals - Non-tree models and recursion detection - Configurable properties - Other notes - - RdfParser class - - Parsing into generic POJO models - Configurable properties - Other notes - - REST API support - - REST server support - - Using RestServletJenaDefault - Using RestServlet with annotations - Using JAX-RS DefaultJenaProvider - Using JAX-RS BaseProvider with annotations - - REST client support - - - - - - -1 - RDF support overview - - - Juno supports serializing and parsing arbitrary POJOs to and from the following RDF formats: - - - RDF/XML - Abbreviated RDF/XML - N-Triple - Turtle - N3 - - - Juno can serialize and parse instances of any of the following POJO types: - - - Java primitive objects (e.g. String, Integer, Boolean, Float). - Java collections framework objects (e.g. HashSet, TreeMap) containing anything on this list. - Multi-dimensional arrays of any type on this list. - Java Beans with properties of any type on this list. - Classes with standard transformations to and from Strings (e.g. classes containing toString(), - fromString(), valueOf(), constructor(String)). - - - In addition to the types shown above, Juno includes the ability to define filters to transform non-standard object and - property types to serializable forms (e.g. to transform Calendars to and from ISO8601 strings, - or byte[] arrays to and from base-64 encoded strings). - These filters can be associated with serializers/parsers, or can be associated with classes or bean properties through type and method annotations. - - - Refer to POJO Categories for a complete definition of supported POJOs. - - Prerequisites - - Juno uses the Jena library for these formats. - The predefined serializers and parsers convert POJOs to and from RDF models and then uses Jena to convert them to and from the various RDF languages. - - - Since Juno is 100% pure IBM code, the Jena libraries must be provided on the classpath separately
[18/51] [partial] incubator-juneau git commit: Merge changes from GitHub repo.
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/30947fd7/com.ibm.team.juno.releng/bin/core/com/ibm/juno/core/html/HtmlParser.java -- diff --git a/com.ibm.team.juno.releng/bin/core/com/ibm/juno/core/html/HtmlParser.java b/com.ibm.team.juno.releng/bin/core/com/ibm/juno/core/html/HtmlParser.java deleted file mode 100755 index cf96164..000 --- a/com.ibm.team.juno.releng/bin/core/com/ibm/juno/core/html/HtmlParser.java +++ /dev/null @@ -1,743 +0,0 @@ -/*** - * Licensed Materials - Property of IBM - * (c) Copyright IBM Corporation 2014, 2015. All Rights Reserved. - * - * The source code for this program is not published or otherwise - * divested of its trade secrets, irrespective of what has been - * deposited with the U.S. Copyright Office. - ***/ -package com.ibm.juno.core.html; - -import static com.ibm.juno.core.html.HtmlParser.Tag.*; -import static com.ibm.juno.core.utils.StringUtils.*; -import static javax.xml.stream.XMLStreamConstants.*; - -import java.io.*; -import java.lang.reflect.*; -import java.util.*; - -import javax.xml.namespace.*; -import javax.xml.stream.*; -import javax.xml.stream.events.*; - -import com.ibm.juno.core.*; -import com.ibm.juno.core.annotation.*; -import com.ibm.juno.core.filter.*; -import com.ibm.juno.core.parser.*; - -/** - * Parses text generated by the {@link HtmlSerializer} class back into a POJO model. - * - * - * Media types - * - * Handles Content-Type types: text/html - * - * - * Description - * - * See the {@link HtmlSerializer} class for a description of the HTML generated. - * - * This class is used primarily for automated testing of the {@link HtmlSerializer} class. - * - * - * Configurable properties - * - * This class has the following properties associated with it: - * - * {@link ParserProperties} - * {@link BeanContextProperties} - * - * - * - * @author James Bognar (jbog...@us.ibm.com) - */ -@SuppressWarnings({ "rawtypes", "unchecked" }) -@Consumes({"text/html","text/html+stripped"}) -public final class HtmlParser extends ReaderParser { - - /** Default parser, all default settings.*/ - public static final HtmlParser DEFAULT = new HtmlParser().lock(); - - /** HTML specific properties currently defined on this class */ - protected transient HtmlParserProperties hpp = new HtmlParserProperties(); - - /* -* Reads anything starting at the current event. -* -* Precondition: Must be pointing at START_ELEMENT or CHARACTERS event. -* Postcondition: Pointing at next event to be processed. -*/ - private T parseAnything(HtmlParserContext ctx, ClassMeta nt, XMLEventReader r, Object outer, Object name) throws ParseException, IOException { - - try { - BeanContext bc = ctx.getBeanContext(); - if (nt == null) - nt = (ClassMeta)object(); - PojoFilterfilter = (PojoFilter )nt.getPojoFilter(); - ClassMeta ft = nt.getFilteredClassMeta(); - - Object o = null; - - XMLEvent event = r.nextEvent(); - while (! (event.isStartElement() || (event.isCharacters() && ! event.asCharacters().isWhiteSpace()) || event.isEndDocument())) - event = r.nextEvent(); - - if (event.isEndDocument()) - throw new XMLStreamException("Unexpected end of stream in parseAnything for type '"+nt+"'", event.getLocation()); - - if (event.isCharacters()) { - String text = parseCharacters(event, r); - if (ft.isObject()) - o = text; - else if (ft.isCharSequence()) - o = text; - else if (ft.isNumber()) - o = parseNumber(text, (Class)nt.getInnerClass()); - else if (ft.isChar()) - o = text.charAt(0); - else if (ft.isBoolean()) - o = Boolean.parseBoolean(text); - else if (ft.canCreateNewInstanceFromString(outer)) - o = ft.newInstanceFromString(outer, text); - else - throw new XMLStreamException("Unexpected characters '"+event.asCharacters().getData()+"' for type '"+nt+"'", event.getLocation()); - - } else { -
[26/51] [partial] incubator-juneau git commit: Merge changes from GitHub repo.
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/30947fd7/com.ibm.team.juno.releng/bin/core/com/ibm/juno/core/CoreApi.java -- diff --git a/com.ibm.team.juno.releng/bin/core/com/ibm/juno/core/CoreApi.java b/com.ibm.team.juno.releng/bin/core/com/ibm/juno/core/CoreApi.java deleted file mode 100755 index 304bc25..000 --- a/com.ibm.team.juno.releng/bin/core/com/ibm/juno/core/CoreApi.java +++ /dev/null @@ -1,172 +0,0 @@ -/*** - * Licensed Materials - Property of IBM - * (c) Copyright IBM Corporation 2014, 2015. All Rights Reserved. - * - * The source code for this program is not published or otherwise - * divested of its trade secrets, irrespective of what has been - * deposited with the U.S. Copyright Office. - ***/ -package com.ibm.juno.core; - -/** - * Common super class for all core-API serializers, parsers, and serializer/parser groups. - * - * Description - * - * Maintains an inner {@link BeanContextFactory} instance that can be used by serializer and parser subclasses - * to work with beans in a consistent way. - * - * Provides several duplicate convenience methods from the {@link BeanContextFactory} class to set properties on that class from this class. - * - * Also implements the {@link Lockable} interface to allow for easy locking and cloning. - * - * - * @author James Bognar (jbog...@us.ibm.com) - */ -public abstract class CoreApi extends Lockable { - - /** The bean context used by this object. */ - protected transient BeanContextFactory beanContextFactory = new BeanContextFactory(); - private BeanContext beanContext; - - - /** -* Returns the current value of the {@code beanContext} setting. -* -* @return The current setting value. -*/ - public final BeanContext getBeanContext() { - if (beanContext == null) - beanContext = beanContextFactory.getBeanContext(); - return beanContext; - } - - /** -* Sets a property on this class. -* -* @param property The property name. -* @param value The property value. -* @return This class (for method chaining). -* @throws LockedException If {@link #lock()} has been called on this object. -*/ - public CoreApi setProperty(String property, Object value) throws LockedException { - checkLock(); - beanContextFactory.setProperty(property, value); - return this; - } - - /** -* Sets multiple properties on this class. -* -* @param properties The properties to set on this class. -* @return This class (for method chaining). -* @throws LockedException If {@link #lock()} has been called on this object. -*/ - public CoreApi setProperties(ObjectMap properties) throws LockedException { - checkLock(); - beanContextFactory.setProperties(properties); - return this; - } - - /** -* Shortcut for calling getBeanContext().addNotBeanClasses(Class...). -* -* @see BeanContextFactory#addNotBeanClasses(Class...) -* @param classes The new setting value for the bean context. -* @throws LockedException If {@link BeanContextFactory#lock()} was called on this class or the bean context. -* @return This object (for method chaining). -*/ - public CoreApi addNotBeanClasses(Class...classes) throws LockedException { - checkLock(); - beanContextFactory.addNotBeanClasses(classes); - return this; - } - - /** -* Shortcut for calling getBeanContext().addFilters(Class...). -* -* @see BeanContextFactory#addFilters(Class...) -* @param classes The new setting value for the bean context. -* @throws LockedException If {@link BeanContextFactory#lock()} was called on this class or the bean context. -* @return This object (for method chaining). -*/ - public CoreApi addFilters(Class...classes) throws LockedException { - checkLock(); - beanContextFactory.addFilters(classes); - return this; - } - - /** -* Shortcut for calling getBeanContext().addImplClass(Class, Class). -* -* @see BeanContextFactory#addImplClass(Class, Class) -* @param interfaceClass The interface class. -* @param implClass The implementation class. -* @throws LockedException If {@link BeanContextFactory#lock()} was called on this class or the bean context. -* @param The class type of the interface. -* @return This object (for method chaining).
[08/51] [partial] incubator-juneau git commit: Merge changes from GitHub repo.
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/30947fd7/com.ibm.team.juno.releng/bin/core/com/ibm/juno/core/serializer/SerializerProperties.java -- diff --git a/com.ibm.team.juno.releng/bin/core/com/ibm/juno/core/serializer/SerializerProperties.java b/com.ibm.team.juno.releng/bin/core/com/ibm/juno/core/serializer/SerializerProperties.java deleted file mode 100755 index 669a832..000 --- a/com.ibm.team.juno.releng/bin/core/com/ibm/juno/core/serializer/SerializerProperties.java +++ /dev/null @@ -1,303 +0,0 @@ -/*** - * Licensed Materials - Property of IBM - * (c) Copyright IBM Corporation 2014, 2015. All Rights Reserved. - * - * The source code for this program is not published or otherwise - * divested of its trade secrets, irrespective of what has been - * deposited with the U.S. Copyright Office. - ***/ -package com.ibm.juno.core.serializer; - -import com.ibm.juno.core.*; - -/** - * Configurable properties common to all {@link Serializer} classes. - * - * Use the {@link Serializer#setProperty(String, Object)} method to set property values. - * - * @author James Bognar (jbog...@us.ibm.com) - */ -public final class SerializerProperties implements Cloneable { - - /** -* Max depth ({@link Integer}, default=100). -* -* Abort serialization if specified depth is reached in the POJO tree. -* If this depth is exceeded, an exception is thrown. -* This prevents stack overflows from occurring when trying to serialize models with recursive references. -*/ - public static final String SERIALIZER_maxDepth = "Serializer.maxDepth"; - - /** -* Initial depth ({@link Integer}, default=0). -* -* The initial indentation level at the root. -* Useful when constructing document fragments that need to be indented at a certain level. -*/ - public static final String SERIALIZER_initialDepth = "Serializer.initialDepth"; - - /** -* Automatically detect POJO recursions ({@link Boolean}, default=false). -* -* Specifies that recursions should be checked for during serialization. -* -* Recursions can occur when serializing models that aren't true trees, but rather contain loops. -* -* The behavior when recursions are detected depends on the value for {@link #SERIALIZER_ignoreRecursions}. -* -* For example, if a model contains the links A-B-C-A, then the JSON generated will look like -* the following when SERIALIZER_ignoreRecursions is true... -* {A:{B:{C:null}}} -* -* Note: Checking for recursion can cause a small performance penalty. -*/ - public static final String SERIALIZER_detectRecursions = "Serializer.detectRecursions"; - - /** -* Ignore recursion errors ({@link Boolean}, default=false). -* -* Used in conjunction with {@link #SERIALIZER_detectRecursions}. -* Setting is ignored if SERIALIZER_detectRecursions is false. -* -* If true, when we encounter the same object when serializing a tree, -* we set the value to null. -* Otherwise, an exception is thrown. -*/ - public static final String SERIALIZER_ignoreRecursions = "Serializer.ignoreRecursions"; - - /** -* Debug mode ({@link Boolean}, default=false). -* -* Enables the following additional information during serialization: -* -* When bean getters throws exceptions, the exception includes the object stack information -* in order to determine how that method was invoked. -* Enables {#link SERIALIZER_detectRecursions}. -* -*/ - public static final String SERIALIZER_debug = "Serializer.debug"; - - /** -* Use indentation in output ({@link Boolean}, default=false). -* -* If true, newlines and indentation is added to the output to improve readability. -*/ - public static final String SERIALIZER_useIndentation = "Serializer.useIndentation"; - - /** -* Add class attributes to output ({@link Boolean}, default=false). -* -* If true, then "_class" attributes will be added to beans if their type cannot be inferred through reflection. -* This is used to recreate the correct objects during parsing if the object types cannot be inferred. -* For example, when serializing a {@code Map} field, where the bean class cannot be determined from the value type. -*/ - public static final String SERIALIZER_addClassAttrs = "Serializer.addClassAttrs"; - - /** -* Quote
[19/51] [partial] incubator-juneau git commit: Merge changes from GitHub repo.
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/30947fd7/com.ibm.team.juno.releng/bin/core/com/ibm/juno/core/filters/CalendarFilter.java -- diff --git a/com.ibm.team.juno.releng/bin/core/com/ibm/juno/core/filters/CalendarFilter.java b/com.ibm.team.juno.releng/bin/core/com/ibm/juno/core/filters/CalendarFilter.java deleted file mode 100755 index af88d87..000 --- a/com.ibm.team.juno.releng/bin/core/com/ibm/juno/core/filters/CalendarFilter.java +++ /dev/null @@ -1,289 +0,0 @@ -/*** - * Licensed Materials - Property of IBM - * (c) Copyright IBM Corporation 2011, 2015. All Rights Reserved. - * - * The source code for this program is not published or otherwise - * divested of its trade secrets, irrespective of what has been - * deposited with the U.S. Copyright Office. - ***/ -package com.ibm.juno.core.filters; - -import java.text.*; -import java.util.*; - -import javax.xml.bind.*; - -import com.ibm.juno.core.*; -import com.ibm.juno.core.filter.*; -import com.ibm.juno.core.parser.ParseException; -import com.ibm.juno.core.utils.*; - -/** - * Transforms {@link Calendar Calendars} to {@link String Strings}. - * - * - * Behavior-specific subclasses - * - * The following direct subclasses are provided for convenience: - * - * {@link ToString} - Transforms to {@link String Strings} using the {@code Date.toString()} method. - * {@link ISO8601DT} - Transforms to ISO8601 date-time strings. - * {@link ISO8601DTZ} - Same as {@link ISO8601DT}, except always serializes in GMT. - * {@link RFC2822DT} - Transforms to RFC2822 date-time strings. - * {@link RFC2822DTZ} - Same as {@link RFC2822DT}, except always serializes in GMT. - * {@link RFC2822D} - Transforms to RFC2822 date strings. - * {@link Simple} - Transforms to simple "/MM/dd HH:mm:ss" strings. - * {@link Medium} - Transforms to {@link DateFormat#MEDIUM} strings. - * - * - * - * @author James Bognar (jbog...@us.ibm.com) - */ -public class CalendarFilter extends PojoFilter{ - - private static final TimeZone GMT = TimeZone.getTimeZone("GMT"); - - /** -* Transforms {@link Calendar Calendars} to {@link String Strings} using the {@code Date.toString()} method. -* -* -* Example output: -* -* -* "Wed Jul 04 15:30:45 EST 2001" -* -* -* -*/ - public static class ToString extends CalendarFilter { - /** Constructor */ - public ToString() { - super("EEE MMM dd HH:mm:ss zzz "); - } - } - - /** -* Transforms {@link Calendar Calendars} to ISO8601 date-time strings. -* -* -* Example output: -* -* -* "2001-07-04T15:30:45-05:00" -* "2001-07-04T15:30:45Z" -* -* -* Example input: -* -* -* "2001-07-04T15:30:45-05:00" -* "2001-07-04T15:30:45Z" -* "2001-07-04T15:30:45.1Z" -* "2001-07-04T15:30Z" -* "2001-07-04" -* "2001-07" -* "2001" -* -* -* -*/ - public static class ISO8601DT extends CalendarFilter { - - /** Constructor */ - public ISO8601DT() {} - - @Override /* PojoFilter */ - public Calendar unfilter(String o, ClassMeta hint) throws ParseException { - try { - if (StringUtils.isEmpty(o)) - return null; - return convert(DatatypeConverter.parseDateTime(o), hint); - } catch (Exception e) { - throw new ParseException(e); - } - } - - @Override /* PojoFilter */ - public String filter(Calendar o) { - return DatatypeConverter.printDateTime(o); - } - } - - /** -* Same as {@link ISO8601DT}, except always serializes in GMT. -* -* Example output: "2001-07-04T15:30:45Z" -*/ - public static class ISO8601DTZ extends CalendarFilter { - - /** Constructor */ - public ISO8601DTZ() {} - - @Override /* PojoFilter */ - public Calendar unfilter(String o, ClassMeta hint) throws ParseException { - try { - if (StringUtils.isEmpty(o)) - return null; - return