ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sevdoki...@apache.org
Subject incubator-ignite git commit: IGNITE-1185 Locate configuration in class path.
Date Sat, 01 Aug 2015 08:46:13 GMT
Repository: incubator-ignite
Updated Branches:
  refs/heads/ignite-1185 [created] c3a8fa045


IGNITE-1185 Locate configuration in class path.


Project: http://git-wip-us.apache.org/repos/asf/incubator-ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-ignite/commit/c3a8fa04
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ignite/tree/c3a8fa04
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ignite/diff/c3a8fa04

Branch: refs/heads/ignite-1185
Commit: c3a8fa0455df8690df0ffef89ab564d8e9dee565
Parents: 41c76a7
Author: sevdokimov <sergey.evdokimov@jetbrains.com>
Authored: Sat Aug 1 11:46:02 2015 +0300
Committer: sevdokimov <sergey.evdokimov@jetbrains.com>
Committed: Sat Aug 1 11:46:02 2015 +0300

----------------------------------------------------------------------
 .../org/apache/ignite/internal/IgnitionEx.java  |  2 +
 .../util/protocols/classpath/Handler.java       | 68 ++++++++++++++++++++
 2 files changed, 70 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/c3a8fa04/modules/core/src/main/java/org/apache/ignite/internal/IgnitionEx.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/IgnitionEx.java b/modules/core/src/main/java/org/apache/ignite/internal/IgnitionEx.java
index 73de99a..0d5086e 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/IgnitionEx.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/IgnitionEx.java
@@ -140,6 +140,8 @@ public class IgnitionEx {
         // http://www.oracle.com/technetwork/java/javase/2col/6u34-bugfixes-1733379.html
         // http://hg.openjdk.java.net/jdk6/jdk6/jdk/rev/563d392b3e5c
         UUID.randomUUID();
+
+        org.apache.ignite.internal.util.protocols.classpath.Handler.setup();
     }
 
     /**

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/c3a8fa04/modules/core/src/main/java/org/apache/ignite/internal/util/protocols/classpath/Handler.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/util/protocols/classpath/Handler.java
b/modules/core/src/main/java/org/apache/ignite/internal/util/protocols/classpath/Handler.java
new file mode 100644
index 0000000..1b90741
--- /dev/null
+++ b/modules/core/src/main/java/org/apache/ignite/internal/util/protocols/classpath/Handler.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.ignite.internal.util.protocols.classpath;
+
+import org.jetbrains.annotations.*;
+
+import java.io.*;
+import java.net.*;
+
+/**
+ * Handler for 'classpath' protocol. Needed to open URL like 'classpath:cfg/ignite-config.xml'.
+ *
+ * The class name is important, do not rename!
+ */
+public class Handler extends URLStreamHandler {
+    /** {@inheritDoc} */
+    @NotNull @Override protected URLConnection openConnection(URL url) throws IOException
{
+        String path = url.getFile();
+
+        URL rsrc = Thread.currentThread().getContextClassLoader().getResource(path);
+
+        if (rsrc == null)
+            throw new IOException("Resource not found: " + url.getFile());
+
+        return rsrc.openConnection();
+    }
+
+    /**
+     * Register this handler.
+     */
+    public static void setup() {
+        assert Handler.class.getSimpleName().equals("Handle" + 'r'); // make sure that class
was not renamed.
+
+        String pkgs = System.getProperty("java.protocol.handler.pkgs");
+
+        String cpPkgName = Handler.class.getPackage().getName();
+
+        assert cpPkgName.endsWith(".classpath");
+
+        String protocolsPkgName = cpPkgName.substring(0, cpPkgName.length() - ".classpath".length());
+
+        if (pkgs != null) {
+            if (pkgs.contains(protocolsPkgName))
+                return;
+
+            pkgs += '|' + protocolsPkgName;
+        }
+        else
+            pkgs = protocolsPkgName;
+
+        System.setProperty("java.protocol.handler.pkgs", pkgs);
+    }
+}


Mime
View raw message