Skip to content

Commit 2b3f39d

Browse files
committed
Debugging for release 1.1.1 - determined that loading PHP from JAR files is not supported by Resin 3.1... maybe in version 4?
1 parent 3e07883 commit 2b3f39d

File tree

5 files changed

+34
-14
lines changed

5 files changed

+34
-14
lines changed

lib/resin-3.1.jar

15.1 MB
Binary file not shown.

pom.xml

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<groupId>net.collegeman.phpinjava</groupId>
55
<artifactId>php-in-java</artifactId>
66
<packaging>jar</packaging>
7-
<version>1.1.0</version>
7+
<version>1.1.1</version>
88
<name>php-in-java</name>
99
<url>http://aaroncollegeman.com/projects/php-in-java</url>
1010

@@ -75,17 +75,22 @@
7575

7676
<!-- quercus: -->
7777
<dependency>
78-
<groupId>com.coucho</groupId>
78+
<groupId>com.caucho</groupId>
7979
<artifactId>quercus</artifactId>
8080
<version>3.1</version>
81+
</dependency>
82+
<dependency>
83+
<groupId>com.caucho</groupId>
84+
<artifactId>resin</artifactId>
85+
<version>3.1</version>
8186
</dependency>
8287
<dependency>
83-
<groupId>com.coucho</groupId>
88+
<groupId>com.caucho</groupId>
8489
<artifactId>resin-support</artifactId>
8590
<version>3.1</version>
8691
</dependency>
8792
<dependency>
88-
<groupId>com.coucho</groupId>
93+
<groupId>com.caucho</groupId>
8994
<artifactId>resin-util</artifactId>
9095
<version>3.1</version>
9196
</dependency>

src/main/java/net/collegeman/phpinjava/PHP.java

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,6 @@ public PHP(String url, ClassLoader classLoader) {
102102
if (classLoader == null)
103103
throw new IllegalArgumentException("[classLoader] parameter must be defined");
104104

105-
106105
// classpath reference
107106
if (url.indexOf("classpath:/") == 0) {
108107
URL resource = classLoader.getResource(url.substring(11));
@@ -113,16 +112,8 @@ public PHP(String url, ClassLoader classLoader) {
113112
// remote script
114113
else if (url.indexOf("http://") == 0 || url.indexOf("https://") == 0) {
115114
try {
116-
StringBuilder script = new StringBuilder();
117115
URLConnection conn = new URL(url).openConnection();
118-
BufferedReader in = new BufferedReader(new InputStreamReader(conn.getInputStream()));
119-
String line;
120-
while ((line = in.readLine()) != null) {
121-
script.append(line);
122-
script.append("\n");
123-
}
124-
125-
snippet(script.toString());
116+
initByInputStream(conn.getInputStream());
126117
} catch (Exception e) {
127118
throw new RuntimeException(e);
128119
}
@@ -143,6 +134,22 @@ public PHP(File file) {
143134
initByFile(file);
144135
}
145136

137+
private void initByInputStream(InputStream stream) {
138+
try {
139+
StringBuilder sourceCode = new StringBuilder(1024);
140+
BufferedReader in = new BufferedReader(new InputStreamReader(stream));
141+
char[] buffer = new char[1024];
142+
int read = 0;
143+
while ((read = in.read(buffer)) != -1)
144+
sourceCode.append(buffer, 0, read);
145+
in.close();
146+
147+
snippet(sourceCode.toString());
148+
} catch (Exception e) {
149+
throw new RuntimeException(e);
150+
}
151+
}
152+
146153
private void initByFile(File ref) {
147154
if (!ref.exists()) {
148155
throw new RuntimeException(new FileNotFoundException("No PHP file or directory at ["+ref.getAbsolutePath()+"]"));
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<?php
2+
3+
function fx_in_lib() {
4+
return true;
5+
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
<?php
2+
3+
require('lib/lib.php');

0 commit comments

Comments
 (0)