I recently deployed my project to the Google App Engine (GAE) as I noticed that all debug messages can be seen in the dev-tool.
I thought that the compiler would remove the debug output as it compiles for release.
This is my current logging configuration in module.gwt.xml
<inherits name="com.google.gwt.logging.Logging"/>
<set-property name="gwt.logging.logLevel" value="ALL"/>
<set-property name="gwt.logging.enabled" value="TRUE"/>
<set-property name="gwt.logging.consoleHandler" value="ENABLED" />
<set-property name="gwt.logging.simpleRemoteHandler" value="DISABLED"/>
<set-property name="compiler.stackMode" value="emulated"/>
<set-configuration-property name="compiler.emulatedStack.recordLineNumbers" value="true"/>
<set-configuration-property name="compiler.emulatedStack.recordFileNames" value="true"/>
How can I get rid of the debug output on my deployed application?
I am using GWT 2.8.0-beta1 and this is how I log:
import java.util.logging.Logger;
public class MyWidget extends Composite {
private final static Logger LOGGER = Logger.getLogger(MyWidget.class.getName());
// ..
public void myfunc() {
LOGGER.fine("Hello World!");
}
}
Related
I am new to React-Native development. I try to implement a splash screen in my app. I tried a lot of options from the web but not get success because some of the code is outdated and some process is very confusing.
Use react-native-splash-screen Sample code is below
import SplashScreen from 'react-native-splash-screen'
export default class WelcomePage extends Component {
componentDidMount() {
// do stuff while splash screen is shown
// After having done stuff (such as async tasks) hide the splash screen
SplashScreen.hide();
}
}
To learn more see examples
To make full screen
On MainActivity.java, just like that:
#Override
protected void onCreate(Bundle savedInstanceState) {
SplashScreen.show(this, R.style.SplashTheme); // Add theme here
super.onCreate(savedInstanceState);
}
IN res/values/styles.xml
<resources>
<style name="SplashTheme" parent="Theme.AppCompat.Light.NoActionBar">
<item name="android:windowTranslucentNavigation">true</item>
<item name="android:windowNoTitle">true</item>
<item name="android:windowActionBar">true</item>
<item name="android:windowFullscreen">true</item>
<item name="android:windowContentOverlay">#null</item>
<item name="android:windowDrawsSystemBarBackgrounds">false</item>
</style>
</resources>
launch_screen.xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageView android:layout_width="match_parent" android:layout_height="match_parent" android:src="#drawable/launch_screen" android:scaleType="centerCrop" />
</RelativeLayout>
I recommend react-native-bootsplash since it's still actively maintained.
Before implementing any library that asks you to add code to the Swift and Java bridge files it's a good idea to familiarize yourself with the RN folder structure. Once you understand the folder structure and some of the main files it becomes much easier to debug your app and you will be able to develop apps faster.
I am here with 2 proposals.. I have a windows application running.
First proposal is that I should have the messages written directly to a console(command prompt),even though it is not a console application.
Second option is that I should create a console application in which it should read the log file produced by the windows application and write the same to the console. Please note the windows application will be updating the log file in real time while it is running and I want the console app to read each and every updated messages in log at the very next moment itself..Is it possible??
Which will be feasible?? and how I can achieve that?
Fast responses are really appreciated..
Thanks...
And third approach - use inter process communication to listen winforms application events from console application. For example, you can use .NET Remoting, WCF, or MSMQ.
Thus you need to write log from your windows forms application, and receive same data in your console application, then you can take advantage of NLog logging framework, which can write logs both to files and MSMQ. Get NLog.dll and NLog.Extended.dll from Nuget.0 Configure two targets in NLog.config file:
<?xml version="1.0" encoding="utf-8" ?>
<nlog xmlns="http://www.nlog-project.org/schemas/NLog.xsd"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<targets>
<target xsi:type="MSMQ" name="msmq" queue=".\private$\CoolQueue"
useXmlEncoding="true" recoverable="true" createQueueIfNotExists="true"
layout="${longdate}|${level:uppercase=true}|${logger}|${message}"/>
<target xsi:type="File" name="file" fileName="logs/${shortdate}.log"
layout="${longdate} ${uppercase:${level}} ${message}" />
</targets>
<rules>
<logger name="*" minlevel="Trace" writeTo="msmq" />
<logger name="*" minlevel="Trace" writeTo="file" />
</rules>
</nlog>
Then obtain logger in your winforms application
private static Logger _logger = LogManager.GetCurrentClassLogger();
And use it to write log messages:
private void button1_Click(object sender, EventArgs e)
{
_logger.Debug("Click");
}
Now move to console application. You need to read messages from MSMQ queue, which are published by winforms application. Create queue and start listening:
string path = #".\private$\CoolQueue";
MessageQueue queue = MessageQueue.Exists(path) ?
new MessageQueue(path) :
MessageQueue.Create(path);
queue.Formatter = new XmlMessageFormatter(new[] { typeof(string) });
queue.ReceiveCompleted += ReceiveCompleted;
queue.BeginReceive();
Write messages to console when they are received:
static void ReceiveCompleted(object sender, ReceiveCompletedEventArgs e)
{
Console.WriteLine(e.Message.message.Body);
var queue = (MessageQueue)sender;
queue.BeginReceive();
}
If you want to use Remoting, take a look on Building a Basic .NET Remoting Application article.
i want to consume the REST result by hitting a REST web Service available at http://someotherhost site. i have written a proxy client for it
I want to hit the above REST service using apache CXFRS client and the write the result to a file. for which i am doing the following,could any one review the below and comment the things i have done wrong .
a) My camel context configuration with apache cxf is as below
<jaxrs:client address="http://someotherhost/test/" id="cityServiceClient" username="test"
password="pwd"
serviceClass="com.santosh.proxy.service.city.CityService">
<jaxrs:features>
<ref bean="loggingFeature" />
</jaxrs:features>
</jaxrs:client>
<camelContext xmlns="http://camel.apache.org/schema/spring">
<package>com.santosh.routes</package>
<routeBuilder ref="cityserviceroutebuilder" />
</camelContext>
b) MY Proxy service Interface
#Path(value="/getCities")
public interface CityService {
#POST
#Produces(value="text/xml")
public String getCities(#QueryParam("countrycode") String countryCode);
}
c) Call to service
CityService cityService = (CityService) context.getBean("cityServiceClient");
cityService.getCities("ae");
d) Camel Routes
public class CityRoutes extends RouteBuilder {
public void configure() throws Exception {
//ROUTES
from("cxfbean:cityServiceClient")
.to("file://data/xmls/cities?fileName=test.xml");
}
}
I got the solution, basically my camel-context configuration was not up to that mark,
The below configuration solved my problem.
<! -- 4 THE ACTUAL SERVER WHICH WILL GET HIT -->
<jaxrs:server id="restService" depends-on="camelContext"
address="http://REALSERVER.COM/REST/" createdFromAPI="true"
staticSubresourceResolution="true">
<jaxrs:serviceBeans>
<ref bean="servicecity" />
</jaxrs:serviceBeans>
</jaxrs:server>
<bean name="servicecity" id="servicecity" class="com.santosh.CityServiceImpl" />
<! -- 3 YOUR PROXY CLIENT -->
<cxf:rsClient id="rsClient" address="http://REALSERVER.COM/REST/"
serviceClass="com.santosh.CityServiceImpl"
username="santosh" password="pwd" />
<! -- 1 JAXRS PROXY CLIENT -->
<jaxrs:client id="cityServiceClient" address="http://localhost:8123/REST/"
serviceClass="com.santosh.CityService" username="santosh" password="pwd">
</jaxrs:client>
<! -- 2 YOUR LOCAL SERVER THAT YOU NEED TO HIT, YOUR LOCAL SERVER -->
<cxf:rsServer id="rsServer" address="http://localhost:8123/REST/" serviceClass="com.santosh.CityServiceImpl" />
THE STEPS ARE
1) create JAXRS PROXY CLIENT and get it in your have code
CityService cityService = (CityService) context.getBean("cityServiceClient");
cityService.getCities("INDIA");
2) the above code will call the SERVER (LOCAL)
3) the above step will call YOUR PROXY CLIENT
4) the PROXY CLIENT will call the ACTUAL REAL SERVER
I am creating an application with google app engine and grails. I have a Controller set up for my Flex application to call. The Controller calls a service to get a list back and send it back to Flex.
The Flex client is able to get the data back one time. Also If I call the action in the browser I can call the action and get data back as well. The problem that I am finding is that it is not able to call it more than once because the app is using JDO and after the first call I get an error saying that the persistenceManager has been closed.
I have read some posts that show you how to set up a single ton and just get an instance of the persistanceManager when you need it but this does not seem to work either.
This is my first time working with JDO and I could use some advice one getting these services to work on a consistant bases.
Here is the code from the service that is actually querying the datastore.
package com.dlish.fulcrum
import com.dlish.fulcrum.PMF
import org.springframework.beans.factory.InitializingBean
import com.google.appengine.api.datastore.*
import com.dlish.fulcrum.Show
class VenueBlastService {
static transactional = true
def grailsApplication
def setting
void afterPropertiesSet()
{
this.setting = grailsApplication.config.setting
}
def persistenceManager
def getAllShows() {
def query = persistenceManager.newQuery( Show )
def showInstanceList = query.execute()
return showInstanceList
}
}
The grails app-engine plugin creates the persistenceManager object in the request scope. By default, services are singletons, which means they are created once instead of per request. Thus, if you give your service a persistenceManager instance variable, the first request will have a valid persistenceManager, but all subsequent calls will have a closed persistenceManager, because your service is still referencing the manager from the first request.
There are two ways to fix this:
1) Change the scope of your service. You can do this by placing the following in your service class:
static scope = "request"
2) pass the persistenceManager from your controller to the service when you call the service method
This is very similar to my Controller's code. Except I don't use the transactional = true, why do you want this you're only doing a read? What version of the app-engine plugin are you using?
Here's my jdoconfig.xml:
<?xml version="1.0" encoding="utf-8"?>
<persistence-manager-factory name="transactions-optional">
<property name="javax.jdo.PersistenceManagerFactoryClass"
value="org.datanucleus.store.appengine.jdo.DatastoreJDOPersistenceManagerFactory"/>
<property name="javax.jdo.option.ConnectionURL" value="appengine"/>
<property name="javax.jdo.option.NontransactionalRead" value="true"/>
<property name="javax.jdo.option.NontransactionalWrite" value="true"/>
<property name="javax.jdo.option.RetainValues" value="true"/>
<property name="datanucleus.appengine.autoCreateDatastoreTxns" value="true"/>
</persistence-manager-factory>
I am planning to use Wurfl in a web application in order to distinguish between mobile device and desktop browser. The isMobileBrowser(String userAgent) from net.sourceforge.wurfl.core.utils seems the appropriate function to do that.
Nevertheless looking at the source code of the 1.0.1-rc3 I can see that if the user agent string does not contain the "Tablet" word, it always returns false. I was reading this article http://wurfl.sourceforge.net/newapi/ and I would like to use the fuzzy match that is described there to identify the devices. Could be possible that am I using the wrong function?, if that is the case could you please point me to the right direction?.
Also , do you know where can I find the source code for the 1.0.1-rc4?.
You have to use those capabilities:
if(is_wireless_device=false and device_claims_web_support=true) {
the request is from web browser
}
via
if($device->getCapability('is_wireless_device') == 'true')
{ //This is a mobile device }
else
{ // this is for a browser }
This is what I am using to do my mobile device vs browser detection... Works seamlessly at the moment.
We tweaked the wurfl.xml file for detecting desktop.
<device id="generic_web_browser" user_agent="DO_NOT_MATCH_GENERIC_WEB_BROWSER" fall_back="generic">
<group id="product_info">
<capability name="has_qwerty_keyboard" value="true"/>
<capability name="pointing_method" value="mouse"/>
<capability name="device_os" value="**Desktop**"/> <!--Added desktop OS-->
<capability name="model_name" value=""/>
<capability name="can_skip_aligned_link_row" value="true"/>
<capability name="device_claims_web_support" value="true"/>
<capability name="is_wireless_device" value="false"/>
<capability name="brand_name" value="generic web browser"/>
<capability name="can_assign_phone_number" value="false"/>
<capability name="release_date" value="1994_january"/>
</group>
We are using WURFL with Liferay plugin and this is working fine for me
As of the current Wurfl release there is a "is_tablet" parameter.
Wurfl Help Doc