Write Service File
/*
*Copyright (c) Jmin. All rights reserved.
*/
package first;
import org.jmin.kernel.framework.ext.J2eeAbstractService;
/**
* service sample.
*
* @author Chris liao
* @version 1.0
*/
public class JobService extends J2eeAbstractService{
/**
* Here, you need't put down anything.
* It is simple ?
*/
}
Write Job file
/*
*Copyright (c) jmin Organization. All rights reserved.
*/
package first;
import org.jmin.kernel.aspect.msg.job.JobAssistant;
/**
* Job sample.
*
* @author Chris liao
* @version 1.0
*/
public class HelloJobAssisant implements JobAssistant{
/**
* handle job
*/
public void handle(Job job){
System.out.println("Job : " + job);
}
}
กก
Define xml description file
//*file:service.xml
<?xml version="1.0"?>
<service id="admin">
<components>
<component id="JobService" type="service">
<class>first.JobService </class>
<property name="aspectPool">
<map>
<entry key="hello" class="first.HelloJobAssisant "/>
</map>
</property>
</component>
</components>
</service>
กก
Deploy Service file
Make a jar file include all class files and
description file, then put the jar to Jmin deploy folder
กก
Testing
/*
*Copyright (c) jmin Organization. All rights reserved.
*/
package first;
import org.jmin.kernel.aspect.msg.job.*;
import org.jmin.kernel.aspect.net.*;
import org.jmin.kernel.framework.aspect.J2eeAspectAddress;
/**
* Job Testing sample.
*
* @author Chris liao
* @version 1.0
*/
public class TestJobService {
public static void main(String args[])throws Exception{
NSRB nsrb = NSRB.init();
NetContext context = nsrb.createNetContext("socket://localhost:9988");
JobProxy proxy = new JobProxy();
proxy.bind(context);
Job job = new Job();
J2eeAspectAddress destination = new J2eeAspectAddress();
destination.setServiceID("JobService");
destination.setAspectName("hello");
proxy.publish(destination,job);
}
} |