[java-support] 04/04: Add a basic CleanerSupport utility class
Brent Putman
putmanb at georgetown.edu
Wed Feb 19 17:18:27 EST 2020
This is an automated email from the git hooks/post-receive script.
putmanb pushed a commit to branch master
in repository java-support.
View the commit online:
http://git.shibboleth.net/view/?p=java-support.git;a=commit;h=8929a85ab6545ba303c8f12ecce5e4b0e250d4a7
commit 8929a85ab6545ba303c8f12ecce5e4b0e250d4a7
Author: Brent Putman <putmanb at georgetown.edu>
AuthorDate: Wed Feb 19 16:51:08 2020 -0500
Add a basic CleanerSupport utility class
---
.../java/support/primitive/CleanerSupport.java | 52 ++++++++++++++++++++++
1 file changed, 52 insertions(+)
diff --git a/src/main/java/net/shibboleth/utilities/java/support/primitive/CleanerSupport.java b/src/main/java/net/shibboleth/utilities/java/support/primitive/CleanerSupport.java
new file mode 100644
index 0000000..9aaa8db
--- /dev/null
+++ b/src/main/java/net/shibboleth/utilities/java/support/primitive/CleanerSupport.java
@@ -0,0 +1,52 @@
+/*
+ * Licensed to the University Corporation for Advanced Internet Development,
+ * Inc. (UCAID) under one or more contributor license agreements. See the
+ * NOTICE file distributed with this work for additional information regarding
+ * copyright ownership. The UCAID 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 net.shibboleth.utilities.java.support.primitive;
+
+import java.lang.ref.Cleaner;
+
+import javax.annotation.Nonnull;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * Utility methods for working with {@link Cleaner}.
+ */
+public final class CleanerSupport {
+
+ /** Logger. */
+ private static final Logger LOG = LoggerFactory.getLogger(CleanerSupport.class);
+
+ /** Constructor. */
+ private CleanerSupport() {}
+
+ /**
+ * Obtain a new {@link Cleaner} instance.
+ *
+ * @param requester the class which requests the cleaner instance
+ *
+ * @return the cleaner instance
+ */
+ public static Cleaner getInstance(@Nonnull final Class<?> requester) {
+ // Current approach here is to create a new Cleaner on each call. A given class requester/owner
+ // is assumed to call only once and store in static storage.
+ LOG.debug("Creating new java.lang.ref.Cleaner instance requested by class: {}", requester.getName());
+ return Cleaner.create();
+ }
+
+}
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
More information about the commits
mailing list