deltaspike-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gpetra...@apache.org
Subject git commit: DELTASPIKE-399 simplified usage of ExternalResourceProvider
Date Mon, 03 Mar 2014 08:24:05 GMT
Repository: deltaspike
Updated Branches:
  refs/heads/master 1b40518a7 -> 34b5304f5


DELTASPIKE-399 simplified usage of ExternalResourceProvider


Project: http://git-wip-us.apache.org/repos/asf/deltaspike/repo
Commit: http://git-wip-us.apache.org/repos/asf/deltaspike/commit/34b5304f
Tree: http://git-wip-us.apache.org/repos/asf/deltaspike/tree/34b5304f
Diff: http://git-wip-us.apache.org/repos/asf/deltaspike/diff/34b5304f

Branch: refs/heads/master
Commit: 34b5304f55a89ef177f7042a69bc13cf30436eea
Parents: 1b40518
Author: gpetracek <gpetracek@apache.org>
Authored: Mon Mar 3 09:23:21 2014 +0100
Committer: gpetracek <gpetracek@apache.org>
Committed: Mon Mar 3 09:23:21 2014 +0100

----------------------------------------------------------------------
 .../ExternalResourceProducer.java               | 112 ------------------
 .../ExternalResourceProducer.java               | 114 +++++++++++++++++++
 .../resourceloader/ResourceLoaderExtension.java |   1 -
 3 files changed, 114 insertions(+), 113 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/deltaspike/blob/34b5304f/deltaspike/core/api/src/main/java/org/apache/deltaspike/core/api/resourceloader/ExternalResourceProducer.java
----------------------------------------------------------------------
diff --git a/deltaspike/core/api/src/main/java/org/apache/deltaspike/core/api/resourceloader/ExternalResourceProducer.java
b/deltaspike/core/api/src/main/java/org/apache/deltaspike/core/api/resourceloader/ExternalResourceProducer.java
deleted file mode 100644
index bad0966..0000000
--- a/deltaspike/core/api/src/main/java/org/apache/deltaspike/core/api/resourceloader/ExternalResourceProducer.java
+++ /dev/null
@@ -1,112 +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.deltaspike.core.api.resourceloader;
-
-import org.apache.deltaspike.core.api.provider.BeanProvider;
-
-import javax.enterprise.context.ApplicationScoped;
-import javax.enterprise.inject.Any;
-import javax.enterprise.inject.Disposes;
-import javax.enterprise.inject.Instance;
-import javax.enterprise.inject.Produces;
-import javax.enterprise.inject.spi.InjectionPoint;
-import javax.inject.Inject;
-import java.io.IOException;
-import java.io.InputStream;
-import java.lang.annotation.Annotation;
-import java.util.List;
-import java.util.Properties;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-
-/**
- * Handles the creation/loading of external resources.
- *
- */
-@ApplicationScoped
-public class ExternalResourceProducer
-{
-    private static final Logger logger = Logger.getLogger(ExternalResourceProducer.class.getName());
-
-    @Inject
-    @Any
-    private Instance<ExternalResourceProvider> resourceProviders;
-
-    @Produces
-    @ExternalResource(resourceProvider = ExternalResourceProvider.class,location = "")
-    public InputStream getInputStream(final InjectionPoint injectionPoint)
-    {
-        ExternalResource externalResource = getAnnotation(injectionPoint);
-        ExternalResourceProvider provider = BeanProvider.getContextualReference(externalResource.resourceProvider());
-        final InputStream is = provider.readStream(externalResource);
-        return is;
-    }
-
-    @Produces
-    @ExternalResource(resourceProvider = ExternalResourceProvider.class,location = "")
-    public List<InputStream> getInputStreams(final InjectionPoint injectionPoint)
-    {
-        ExternalResource externalResource = getAnnotation(injectionPoint);
-        ExternalResourceProvider provider = BeanProvider.getContextualReference(externalResource.resourceProvider());
-        return provider.readStreams(externalResource);
-    }
-
-    @Produces
-    @ExternalResource(resourceProvider = ExternalResourceProvider.class,location = "")
-    public Properties getProperties(final InjectionPoint injectionPoint) throws IOException
-    {
-        ExternalResource externalResource = getAnnotation(injectionPoint);
-        ExternalResourceProvider provider = BeanProvider.getContextualReference(externalResource.resourceProvider());
-        final Properties properties = provider.readProperties(externalResource);
-        return properties;
-    }
-
-    public void closeInputStream(@Disposes
-                                 @ExternalResource(resourceProvider = ExternalResourceProvider.class,
location = "")
-                                 InputStream inputStream)
-    {
-        if (inputStream != null)
-        {
-            try
-            {
-                inputStream.close();
-            }
-            catch (IOException e)
-            {
-                if (logger.isLoggable(Level.FINE))
-                {
-                    logger.log(Level.FINE,"Unable to close input stream ",e);
-                }
-            }
-        }
-    }
-
-    private ExternalResource getAnnotation(final InjectionPoint injectionPoint)
-    {
-        for (Annotation annotation : injectionPoint.getQualifiers())
-        {
-            if (annotation instanceof ExternalResource)
-            {
-                return (ExternalResource)annotation;
-            }
-        }
-        return null;
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/deltaspike/blob/34b5304f/deltaspike/core/impl/src/main/java/org/apache/deltaspike/core/impl/resourceloader/ExternalResourceProducer.java
----------------------------------------------------------------------
diff --git a/deltaspike/core/impl/src/main/java/org/apache/deltaspike/core/impl/resourceloader/ExternalResourceProducer.java
b/deltaspike/core/impl/src/main/java/org/apache/deltaspike/core/impl/resourceloader/ExternalResourceProducer.java
new file mode 100644
index 0000000..1da6526
--- /dev/null
+++ b/deltaspike/core/impl/src/main/java/org/apache/deltaspike/core/impl/resourceloader/ExternalResourceProducer.java
@@ -0,0 +1,114 @@
+/*
+ * 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.deltaspike.core.impl.resourceloader;
+
+import org.apache.deltaspike.core.api.provider.BeanProvider;
+import org.apache.deltaspike.core.api.resourceloader.ExternalResource;
+import org.apache.deltaspike.core.api.resourceloader.ExternalResourceProvider;
+
+import javax.enterprise.context.ApplicationScoped;
+import javax.enterprise.inject.Any;
+import javax.enterprise.inject.Disposes;
+import javax.enterprise.inject.Instance;
+import javax.enterprise.inject.Produces;
+import javax.enterprise.inject.spi.InjectionPoint;
+import javax.inject.Inject;
+import java.io.IOException;
+import java.io.InputStream;
+import java.lang.annotation.Annotation;
+import java.util.List;
+import java.util.Properties;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+/**
+ * Handles the creation/loading of external resources.
+ *
+ */
+@ApplicationScoped
+public class ExternalResourceProducer
+{
+    private static final Logger logger = Logger.getLogger(ExternalResourceProducer.class.getName());
+
+    @Inject
+    @Any
+    private Instance<ExternalResourceProvider> resourceProviders;
+
+    @Produces
+    @ExternalResource(resourceProvider = ExternalResourceProvider.class,location = "")
+    public InputStream getInputStream(final InjectionPoint injectionPoint)
+    {
+        ExternalResource externalResource = getAnnotation(injectionPoint);
+        ExternalResourceProvider provider = BeanProvider.getContextualReference(externalResource.resourceProvider());
+        final InputStream is = provider.readStream(externalResource);
+        return is;
+    }
+
+    @Produces
+    @ExternalResource(resourceProvider = ExternalResourceProvider.class,location = "")
+    public List<InputStream> getInputStreams(final InjectionPoint injectionPoint)
+    {
+        ExternalResource externalResource = getAnnotation(injectionPoint);
+        ExternalResourceProvider provider = BeanProvider.getContextualReference(externalResource.resourceProvider());
+        return provider.readStreams(externalResource);
+    }
+
+    @Produces
+    @ExternalResource(resourceProvider = ExternalResourceProvider.class,location = "")
+    public Properties getProperties(final InjectionPoint injectionPoint) throws IOException
+    {
+        ExternalResource externalResource = getAnnotation(injectionPoint);
+        ExternalResourceProvider provider = BeanProvider.getContextualReference(externalResource.resourceProvider());
+        final Properties properties = provider.readProperties(externalResource);
+        return properties;
+    }
+
+    public void closeInputStream(@Disposes
+                                 @ExternalResource(resourceProvider = ExternalResourceProvider.class,
location = "")
+                                 InputStream inputStream)
+    {
+        if (inputStream != null)
+        {
+            try
+            {
+                inputStream.close();
+            }
+            catch (IOException e)
+            {
+                if (logger.isLoggable(Level.FINE))
+                {
+                    logger.log(Level.FINE,"Unable to close input stream ",e);
+                }
+            }
+        }
+    }
+
+    private ExternalResource getAnnotation(final InjectionPoint injectionPoint)
+    {
+        for (Annotation annotation : injectionPoint.getQualifiers())
+        {
+            if (annotation instanceof ExternalResource)
+            {
+                return (ExternalResource)annotation;
+            }
+        }
+        return null;
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/deltaspike/blob/34b5304f/deltaspike/core/impl/src/main/java/org/apache/deltaspike/core/impl/resourceloader/ResourceLoaderExtension.java
----------------------------------------------------------------------
diff --git a/deltaspike/core/impl/src/main/java/org/apache/deltaspike/core/impl/resourceloader/ResourceLoaderExtension.java
b/deltaspike/core/impl/src/main/java/org/apache/deltaspike/core/impl/resourceloader/ResourceLoaderExtension.java
index c1c2c7d..ca0c2d6 100644
--- a/deltaspike/core/impl/src/main/java/org/apache/deltaspike/core/impl/resourceloader/ResourceLoaderExtension.java
+++ b/deltaspike/core/impl/src/main/java/org/apache/deltaspike/core/impl/resourceloader/ResourceLoaderExtension.java
@@ -19,7 +19,6 @@
 package org.apache.deltaspike.core.impl.resourceloader;
 
 import org.apache.deltaspike.core.api.resourceloader.ClasspathResourceProvider;
-import org.apache.deltaspike.core.api.resourceloader.ExternalResourceProducer;
 import org.apache.deltaspike.core.api.resourceloader.FileResourceProvider;
 
 import javax.enterprise.inject.spi.AnnotatedType;


Mime
View raw message