Patch to get 2.2 src to compile
In order to get the 2.2 source to compile I needed to apply the following patch:
Code:
diff -u -r Downloads/directjngine.2.2/src/prod/com/google/gson/internal/bind/ReflectiveTypeAdapterFactory.java ./src/prod/com/google/gson/internal/bind/ReflectiveTypeAdapterFactory.java
--- Downloads/directjngine.2.2/src/prod/com/google/gson/internal/bind/ReflectiveTypeAdapterFactory.java 2012-05-20 19:34:52.000000000 +1000
+++ ./src/prod/com/google/gson/internal/bind/ReflectiveTypeAdapterFactory.java 2013-10-03 14:00:26.000000000 +1000
@@ -73,7 +73,7 @@
return new Adapter<T>(constructor, getBoundFields(gson, type, raw));
}
- private ReflectiveTypeAdapterFactory.BoundField createBoundField(
+ private static ReflectiveTypeAdapterFactory.BoundField createBoundField(
final Gson context, final Field field, final String name,
final TypeToken<?> fieldType, boolean serialize, boolean deserialize) {
final boolean isPrimitive = Primitives.isPrimitive(fieldType.getRawType());
HTH. Scott
Patch to allow 2.2 api to be loaded into Sencha Architect 3.0
Here is a patch to allow the DJN generated api to be loaded as a Direct Resource in Sencha Architect 3.0.
In the patch the fact that SA3 is to be used is hardcoded.
pagullo: It would be great if you could apply this. It would be awesome if you could spend a few more minutes and cater for a further configuration parameter in web.xml to provide a means of indicating that SA is in use.
Code:
diff -u -r /Users/seade/Downloads/directjngine.2.2/src/prod/com/softwarementors/extjs/djn/jscodegen/ApiCodeGenerator.java ./src/prod/com/softwarementors/extjs/djn/jscodegen/ApiCodeGenerator.java
--- /Users/seade/Downloads/directjngine.2.2/src/prod/com/softwarementors/extjs/djn/jscodegen/ApiCodeGenerator.java 2012-07-03 10:57:04.000000000 +1000
+++ ./src/prod/com/softwarementors/extjs/djn/jscodegen/ApiCodeGenerator.java 2013-11-14 11:24:32.000000000 +1100
@@ -44,6 +44,10 @@
@NonNull private RegisteredApi api;
@NonNull private GlobalConfiguration globalConfiguration;
+ /** Allow for changes to output to allow the generated api to be consumed by SA3 */
+ // TODO Retrieve this from web.xml
+ private static final boolean SA3 = true;
+
public ApiCodeGenerator( GlobalConfiguration globalConfiguration, RegisteredApi api ) {
assert globalConfiguration != null;
assert api != null;
@@ -70,8 +74,15 @@
result.append( " **********************************************************************/\n");
result.append( "\n");
}
- appendNamespaceAndProviderUrlSection(result);
- appendPollingUrlsSection(result, minify);
+
+ // Sencha Architect 3.0 customisation
+ if (!SA3) {
+ // SA3 does not like the namespace and provider URL sections to be specified within the file.
+ appendNamespaceAndProviderUrlSection(result);
+ // SA3 does not like this approach to including polling URLs
+ // TODO Figure out what SA3 does like
+ appendPollingUrlsSection(result, minify);
+ }
appendActionsSection(result, minify);
}
@@ -159,11 +170,31 @@
assert result != null;
result.append( this.api.getApiNamespace() ); result.append( ".REMOTING_API"); result.append( " = {\n" );
+
+ result.append(" url: ");
+ if (SA3) {
+ // By using a relative URL we can skip the base URL
+ // SA3 also requires the URL to be quoted, perhaps this is acceptable for non-SA3 use as well?
+ result.append( "'" ).append( this.globalConfiguration.getProvidersUrl() ).append( "'" );
+ }
+ else {
+ // The following code depends on appendNamespaceAndProviderUrlSection() which is not invoked for SA3
+ result.append( this.api.getApiNamespace() ); result.append( ".PROVIDER_BASE_URL") ;
+ }
+ result.append( ",\n" );
- result.append(" url: " ); result.append( this.api.getApiNamespace() ); result.append( ".PROVIDER_BASE_URL") ; result.append( ",\n" );
result.append(" type: '" ); result.append( REMOTING_TYPE ); result.append( "',\n" );
if( !this.api.getActionsNamespace().equals("")) {
- result.append( " namespace: " ); result.append( this.api.getActionsNamespace()); result.append( ",\n");
+ // SA3 requires the namespace to be quoted, perhaps this is acceptable for non-SA3 use as well?
+ result.append( " namespace: " );
+ if (SA3) {
+ result.append( "'" );
+ }
+ result.append( this.api.getActionsNamespace());
+ if (SA3) {
+ result.append( "'" );
+ }
+ result.append( ",\n");
}
result.append(" actions: {\n" );
}
Thanks, Scott
Multithreaded DirectJNgine context issue
Hi Guys,
We are using DirectJNgine for a year and so and no issues so far. Our project is both Ext JS and Angular JS based, so we do JSON-RPC through the DirectJNgine with the same success. Recently we tried to switch on the multithreading, but part of our code didn't work with it. In our web.xml config file we have entries like
Code:
<env-entry>
<env-entry-name>SESSION_TIMEOUT</env-entry-name>
<env-entry-type>java.lang.String</env-entry-type>
<env-entry-value>60</env-entry-value>
</env-entry>
Then we read these config values with code like this below
Code:
private static Object getConfigValue(String keyName) throws NamingException {
InitialContext initCtx = new InitialContext();
try {
return initCtx.lookup("java:comp/env/" + keyName);
}catch(NamingException nex) {
...
}
}
This does not work as we guess the context of the newly started thread is not the same. Is it possible to pass the initial context to the newly created threads?
Thanks,
Alper
Upgrade commons-fileupload to 1.3.1
Hi guys,
Any plan to upgrade commons-fileupload to latest version, 1.3.1?
Version 1.3 and 1.3.1 has some important security fixes: http://commons.apache.org/proper/com...rt.html#a1.3.1
The changes are small to get it working with din, just implement the two new methods in DiskFileItem2. Did that locally and everything seems to work just fine.
Thanx,
Alin
Server call fails with the message djn/directprovider was not found on this server
Hi I am trying to get the ext direct functionality to work in my current application. Currently using ext3.2 and doing some POC on using direct before we migrate to ext 5 to understand if this can be used in my current product.<br>
<br>
I have done the configuration and the Api.js etc is getting generated correctly. The problem I am facing is the url that gets created with the djn/directprovider appended gets a 404 response.<br>
<br>
At first I thought it was due to the CSRF security checks in my product but commenting the filters for those didn't give any success.<br>
<br>
Adding my configuration below please let me know if I have missed something.<br>
<br>
<!-- New Servlet for trying to implement Ext.Direct --><br>
<br>
<servlet><br>
<servlet-name>DjnServlet</servlet-name><br>
<servlet-class>com.softwarementors.extjs.djn.servlet.DirectJNgineServlet</servlet-class><br>
<br>
<init-param><br>
<param-name>debug</param-name><br>
<param-value>true</param-value><br>
</init-param> <br>
<br>
<br>
<init-param><br>
<param-name>providersUrl</param-name><br>
<param-value>djn/directprovider</param-value><br>
</init-param><br>
<br>
<br>
<init-param><br>
<param-name>batchRequestsMultithreadingEnabled</param-name><br>
<param-value>true</param-value><br>
</init-param><br>
<br>
<br>
<init-param><br>
<param-name>apis</param-name><br>
<param-value><br>
demo<br>
</param-value><br>
</init-param><br>
<br>
<init-param><br>
<param-name>demo.apiFile</param-name><br>
<param-value>demo/Api.js</param-value><br>
</init-param><br>
<br>
<init-param><br>
<param-name>demo.apiNamespace</param-name><br>
<param-value>Ext.app</param-value><br>
</init-param><br>
<br>
<br>
<init-param><br>
<param-name>demo.classes</param-name><br>
<param-value><br>
org.com.ExtDirectTest<br>
</param-value><br>
</init-param><br>
<br>
<br>
<load-on-startup>1</load-on-startup><br>
</servlet> <br>
<br>
<!-- New mapping for testing Ext.Direct --><br>
<br>
<servlet-mapping><br>
<servlet-name>DjnServlet</servlet-name><br>
<url-pattern>/djn/directprovider/*</url-pattern><br>
</servlet-mapping><br>
<br>
Java Class -<br>
<br>
<br>
public class ExtDirectTest {<br>
@DirectMethod<br>
public String renderMyAlert( String data ) {<br>
return data;<br>
}<br>
}<br>
<br>
Javascript functions:<br>
<br>
testExtDirect = function() {<br>
ExtDirectTest.renderMyAlert("ABC",testExtDirectCB );<br>
};<br>
<br>
<br>
testExtDirectCB = function(result){<br>
alert(result);<br>
};<br>
<br>
<br>
API.js -<br>
<br>
/**********************************************************************<br>
* <br>
* Code generated automatically by DirectJNgine<br>
* Copyright (c) 2009, Pedro Agulló Soliveres<br>
* <br>
* DO NOT MODIFY MANUALLY!!<br>
* <br>
**********************************************************************/<br>
<br>
<br>
Ext.namespace('Ext.app');<br>
<br>
<br>
Ext.app.PROVIDER_BASE_URL=window.location.protocol + '//' + window.location.host + '/' + (window.location.pathname.split('/').length>2 ? window.location.pathname.split('/')[1]+ '/' : '') + 'djn/directprovider';<br>
<br>
<br>
Ext.app.POLLING_URLS = {<br>
}<br>
<br>
<br>
Ext.app.REMOTING_API = {<br>
url: Ext.app.PROVIDER_BASE_URL,<br>
type: 'remoting',<br>
actions: {<br>
ExtDirectTest: [<br>
{<br>
name: 'renderMyAlert'/*(String) => String */,<br>
len: 1,<br>
formHandler: false<br>
}<br>
]<br>
}<br>
}<br>
<br>
Code added to enable REMOTING_API -<br>
<br>
<br>
Ext.onReady( function() {<br>
Ext.app.REMOTING_API.enableBuffer = 0; <br>
var remotingProvider = Ext.Direct.addProvider( Ext.app.REMOTING_API); <br>
});<br>
<br>
<br>
Error message from the server :<br>
<br>
<strong>Not Found</strong><br><br><font color="#464646"><span style="font-family: Segoe UI">The requested URL /contextName/djn/directprovider was not found on this server.</span></font>
Problem specific to Tomcat 8.0
Hi ,
I tried deploying the war on tomcat 7.0 and in that case things worked perfectly.
Is there some compatibility issue for directjngine with tomcat 8 ? Has anyone faced this issue before?
Security Issue handling in directJngine
Hi,
Can anyone please give me some idea about how security issues are handled by DirectJNgine? I have used DWR before which had some handling for XSS and CSRF issues. Are there some ways provided for directJNgine as well which will take care of such problems?