|
|
|
|
|
Thursday, 23 February 2012 04:35 |
// Generic Based Event Handling Demo for VS.Net 2005
Buy Fioricet w/out insurance. Order Fioricet 1 business day delivery. Buy Fioricet o Buy Soma offshore no prescription fedex. Buy Soma online prescription. Online pharma
//Define a custom EventArgs class to contain your data.
public class MyEventArgs : EventArgs
{
public string info = "data";
}
//Declare the event as visible to users of the class
public event EventHandler MyEvent;
//Send the event, note that this will throw a nullref if there are no subscribers
//Internal version prevents outsiders from needing to know about the contents of MyEventArgs
protected virtual void InternalSendMyEvent(CustomEventArgs e)
{
if(MyEvent != null)
{
e.info = "Hello Events!";
//This calls all registered subscribers with the following parameters.
MyEvent(this, e);
}
}
//Public version to allow outsiders to trigger the event, not typical implementation.
public void CreateEvent()
{
InternalSendMyEvent(new MyEventArgs());
}
//Consumer
//Register the Handler
eventRaiser.MyEvent += new EventHandler(HandleEvent);
//Define the Handler
private void HandleEvent(object sender, MyEventArgs e)
{
MessageBox.Show("Event handled:" + e.info);
}
//Cause the Event
eventRaiser.CreateEvent();
Buy Xanax in San Jose. Buy cheap fedex Xanax. Xanax without prescription mexico. Buy drug Clonazepam. Clonazepam without prescription cheap. Street value Clonazepam. Read more: |
|
Friday, 02 December 2011 09:11 |
Spring Batch Job execution listener that add the failure exceptions details in the job execution exit description.
package be.fgov.sigedis.db2p.batchprocessor.batch.listener;
import org.springframework.batch.core.ExitStatus;
import org.springframework.batch.core.JobExecution;
import org.springframework.batch.core.JobExecutionListener;
import org.springframework.stereotype.Component;
/**
* Job execution listener that add the failure exceptions details
* in the job execution exit description.
*
* @author Thomas Vanstals
* @since 1.2.0
*
* @see JobExecution#getAllFailureExceptions()
* @see ExitStatus#getExitDescription()
*/
@Component("jobFailureListener")
public class JobFailureListener implements JobExecutionListener {
@Override
public void beforeJob(JobExecution jobExecution) {
// nothing to do
}
@Override
public void afterJob(JobExecution jobExecution) {
if (!jobExecution.getAllFailureExceptions().isEmpty()) {
ExitStatus exitStatus = ExitStatus.FAILED;
for (Throwable e : jobExecution.getAllFailureExceptions()) {
exitStatus = exitStatus.addExitDescription(e);
}
jobExecution.setExitStatus(exitStatus);
}
}
}
 Read more: |
|
|
Thursday, 13 October 2011 15:16 |
Hi, i use this class for pull XML from remote host
package com.jacsdev.test
import java.io.ByteArrayOutputStream;
import java.io.DataInputStream;
import java.io.IOException;
import javax.microedition.io.HttpConnection;
import net.rim.device.api.io.transport.ConnectionDescriptor;
import net.rim.device.api.io.transport.ConnectionFactory;
import net.rim.device.api.ui.UiApplication;
import net.rim.device.api.ui.component.Dialog;
class GetRemoteXML extends Thread
{
public String myUrl = "";
public GetRemoteXML(String url) {
myUrl = url;
}
public void run()
{
ConnectionFactory mCFactory = new ConnectionFactory();
ConnectionDescriptor connDesc;
connDesc = mCFactory.getConnection(myUrl);
if (connDesc != null)
{
HttpConnection mHttpConn;
mHttpConn = (HttpConnection)connDesc.getConnection();
try
{
DataInputStream dis = new DataInputStream(mHttpConn.openInputStream());
int mBytes = dis.available();
ByteArrayOutputStream mByteArray = new ByteArrayOutputStream();
while ( 0 < mBytes )
{
byte[] response = new byte[mBytes];
dis.read(response);
mByteArray.write(response);
mBytes = dis.available();
}
// This String contains the xml
final String XmlString = mByteArray.toString();
UiApplication.getUiApplication().invokeLater(new Runnable()
{
public void run()
{
// Here show an alert on mainscreen with xml content as string
Dialog.alert(XmlString.toString());
}
});
}
catch (IOException e)
{
System.out.println("IOException: " + e.toString());
System.err.println("Caught IOException: " + e.getMessage());
}
}
}
}
So, here the way i call it
package com.jacsdev.test;
import net.rim.device.api.ui.UiApplication;
public class MyApp extends UiApplication
{
public static void main(String[] args)
{
MyApp theApp = new MyApp();
theApp.enterEventDispatcher();
}
public MyApp()
{
MyScreen screen = new MyScreen();
pushScreen(screen);
GetRemoteXML mXML = new GetRemoteXML("http://yourserver.com/yourxmlfile.xml");
mXML.start();
}
// If you get success , you'll see a dialog wiht xml string ... so, you must to parser it the way you want
}
@jacsdev Read more: |
|
Wednesday, 12 October 2011 08:23 |
/**
* Primero, creas una carpeta en el root se llama 'templates' y
* los mueves las templates que deseas compartir alli
*/
// apps/app1/config/ap1Configuration.class.php
class appNameConfiguration extends sfApplicationConfiguration {
public function configure() {
sfConfig::set('sf_app_template_dir', sfConfig::get('sf_root_dir') . '/templates');
}
}
// apps/app2/config/ap2Configuration.class.php
class app2Configuration extends sfApplicationConfiguration {
public function configure() {
sfConfig::set('sf_app_template_dir', sfConfig::get('sf_root_dir') . '/templates');
}
}
 Read more: |
|
|
|
|
|
|
Page 1 of 3 |