1 19 package org.lucane.server; 20 21 import java.lang.reflect.InvocationTargetException ; 22 import java.lang.reflect.Method ; 23 24 import org.lucane.common.Message; 25 import org.lucane.common.net.ObjectConnection; 26 27 32 public abstract class Service 33 { 34 39 public String getName() 40 { 41 return this.getClass().getPackage().getName(); 42 } 43 44 49 public String getDirectory() 50 { 51 String pack = this.getClass().getPackage().getName(); 52 String url = "jar:file:///" + Server.getInstance().getWorkingDirectory() 53 + Server.APPLICATIONS_DIRECTORY + pack + ".jar!/"; 54 return url.replace('\\', '/'); 55 } 56 57 65 public Object invoke(String method, Class [] types, Object [] params) 66 throws SecurityException , NoSuchMethodException , IllegalArgumentException , IllegalAccessException , InvocationTargetException 67 { 68 Method m = this.getClass().getDeclaredMethod(method, types); 69 return m.invoke(this, params); 70 } 71 72 78 public abstract void process(ObjectConnection oc, Message message); 79 80 86 public void init(Server parent) {} 87 88 92 public void install() {} 93 94 98 public void shutdown() {} 99 } 100 | Popular Tags |