openamf/src/java/org/openamf/invoker EJBServiceInvoker.java,1.8,1.9 JMXServiceInvoker.java,1.9,1.10 JavaServiceInvoker.java,1.23,1.24 PageableResultSetServiceInvoker.java,1.8,1.9 RankedMethod.java,1.16,1.17 ServiceInvocationException.java,1.16,1.17 ServiceInvoker.java,1.11,1.12 ServletLogger.java,1.5,1.6 SessionControlInvoker.java,1.4,1.5 WebServiceInvoker.java,1.23,1.24
[email protected] Fri, 15 Aug 2003 15:03:44 -0700
| Newsgroups | gmane.comp.java.openamf.cvs |
|---|---|
| Message-ID | <[email protected]> |
Update of /cvsroot/openamf/openamf/src/java/org/openamf/invoker In directory sc8-pr-cvs1:/tmp/cvs-serv16796 Modified Files: EJBServiceInvoker.java JMXServiceInvoker.java JavaServiceInvoker.java PageableResultSetServiceInvoker.java RankedMethod.java ServiceInvocationException.java ServiceInvoker.java ServletLogger.java SessionControlInvoker.java WebServiceInvoker.java Log Message: Index: EJBServiceInvoker.java =================================================================== RCS file: /cvsroot/openamf/openamf/src/java/org/openamf/invoker/EJBServiceInvoker.java,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** EJBServiceInvoker.java 15 Aug 2003 16:54:45 -0000 1.8 --- EJBServiceInvoker.java 15 Aug 2003 22:03:42 -0000 1.9 *************** *** 25,28 **** --- 25,30 ---- /** + * Simple EJB Service Invoker + * * @author Jason Calabrese <[email protected]> * @author Roberto Saccon <[email protected]> *************** *** 45,51 **** public Object invokeService() throws ServiceInvocationException { - Object serviceResult = null; - try { Object ejb = null; --- 47,51 ---- *************** *** 84,99 **** throw new ServiceInvocationException(request, e); } - return serviceResult; - } private boolean checkPersistService(Object home) throws RemoteException { - boolean persistService = false; - if (home instanceof EJBHome) { EJBMetaData metaData = ((EJBHome)home).getEJBMetaData(); - if (metaData.isSession()) { if (metaData.isStatelessSession()) { --- 84,94 ---- *************** *** 120,125 **** boolean supports = false; try { ! InitialContext context = new InitialContext(); ! getHome(request); supports = true; } catch (Exception e) { --- 115,119 ---- boolean supports = false; try { ! getHome(request); supports = true; } catch (Exception e) { *************** *** 133,137 **** */ public void prepare(ServiceRequest request) { - try { persistService = checkPersistService(getHome(request)); --- 127,130 ---- *************** *** 141,154 **** private Object getHome(ServiceRequest request) throws NamingException { - InitialContext context = new InitialContext(); - if (home == null) { home = context.lookup(request.getServiceName()); } - return home; - } - } --- 134,142 ---- Index: JMXServiceInvoker.java =================================================================== RCS file: /cvsroot/openamf/openamf/src/java/org/openamf/invoker/JMXServiceInvoker.java,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** JMXServiceInvoker.java 9 Aug 2003 16:59:22 -0000 1.9 --- JMXServiceInvoker.java 15 Aug 2003 22:03:42 -0000 1.10 *************** *** 21,24 **** --- 21,26 ---- /** + * Simple JMX Service Invoker + * * @author Jason Calabrese <[email protected]> * @author Roberto Saccon <[email protected]> *************** *** 40,47 **** Object serviceResult = null; - List serverList = MBeanServerFactory.findMBeanServer(null); - MBeanServer server = (MBeanServer) serverList.iterator().next(); - try { ObjectName objectName = new ObjectName(request.getServiceName()); Object[] parameters = request.getParameters().toArray(); --- 42,51 ---- Object serviceResult = null; try { + List serverList = MBeanServerFactory.findMBeanServer(null); + if (serverList == null || serverList.size()==0) { + throw new Exception("MBeanServers not found"); + } + MBeanServer server = (MBeanServer) serverList.get(0); ObjectName objectName = new ObjectName(request.getServiceName()); Object[] parameters = request.getParameters().toArray(); Index: JavaServiceInvoker.java =================================================================== RCS file: /cvsroot/openamf/openamf/src/java/org/openamf/invoker/JavaServiceInvoker.java,v retrieving revision 1.23 retrieving revision 1.24 diff -C2 -d -r1.23 -r1.24 *** JavaServiceInvoker.java 9 Aug 2003 16:59:22 -0000 1.23 --- JavaServiceInvoker.java 15 Aug 2003 22:03:42 -0000 1.24 *************** *** 38,42 **** public Object invokeService() throws ServiceInvocationException { - Class serviceClass = null; Object service = null; --- 38,41 ---- *************** *** 44,56 **** try { ! serviceClass = ! Thread.currentThread().getContextClassLoader().loadClass( ! request.getServiceName()); service = persistantServiceObject; if (service == null) { service = serviceClass.newInstance(); } ! serviceResult = ! invokeServiceMethod( service, serviceClass, --- 43,52 ---- try { ! serviceClass = Thread.currentThread().getContextClassLoader().loadClass(request.getServiceName()); service = persistantServiceObject; if (service == null) { service = serviceClass.newInstance(); } ! serviceResult = invokeServiceMethod( service, serviceClass, *************** *** 89,95 **** InvocationTargetException { ! RankedMethod serviceMethod = ! getServiceMethod(serviceClass, methodName, parameters); ! return serviceMethod.invoke(service); --- 85,89 ---- InvocationTargetException { ! RankedMethod serviceMethod = getServiceMethod(serviceClass, methodName, parameters); return serviceMethod.invoke(service); *************** *** 139,151 **** public boolean supports(ServiceRequest request) { ! boolean supports = false; try { ! Thread.currentThread().getContextClassLoader().loadClass( ! request.getServiceName()); supports = true; } catch (Exception e) { } - return supports; } --- 133,146 ---- public boolean supports(ServiceRequest request) { ! if (request!=null) { ! log.debug("check supports "+ request.getServiceName()); ! } boolean supports = false; try { ! Thread.currentThread().getContextClassLoader().loadClass(request.getServiceName()); supports = true; } catch (Exception e) { + log.debug("exception: "+e); } return supports; } Index: PageableResultSetServiceInvoker.java =================================================================== RCS file: /cvsroot/openamf/openamf/src/java/org/openamf/invoker/PageableResultSetServiceInvoker.java,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** PageableResultSetServiceInvoker.java 13 Aug 2003 18:27:14 -0000 1.8 --- PageableResultSetServiceInvoker.java 15 Aug 2003 22:03:42 -0000 1.9 *************** *** 28,34 **** public Object invokeService() throws ServiceInvocationException { - Object serviceResult = null; - String serviceMethodName = request.getServiceMethodName(); if (serviceMethodName.equalsIgnoreCase("getRecords")) { --- 28,32 ---- *************** *** 37,54 **** releaseRecordSet(); } - return serviceResult; } private Object getRecords() { - String rsId = (String)getRequest().getParameters().get(0); ASRecordSet recordSet = (ASRecordSet) getHttpServletRequest().getSession().getAttribute(rsId); - int from = ((Number)getRequest().getParameters().get(1)).intValue() - 1; int count = ((Number)getRequest().getParameters().get(2)).intValue(); - return recordSet.getRecords(from, count); - } --- 35,47 ---- Index: RankedMethod.java =================================================================== RCS file: /cvsroot/openamf/openamf/src/java/org/openamf/invoker/RankedMethod.java,v retrieving revision 1.16 retrieving revision 1.17 diff -C2 -d -r1.16 -r1.17 *** RankedMethod.java 9 Aug 2003 16:59:22 -0000 1.16 --- RankedMethod.java 15 Aug 2003 22:03:42 -0000 1.17 *************** *** 142,154 **** } } ! ! return rank; } public int compareTo(Object o) { - int compareTo = 0; RankedMethod rankedMethod = (RankedMethod) o; - if (getRank() > rankedMethod.getRank()) { compareTo = -1; --- 142,151 ---- } } ! return rank; } public int compareTo(Object o) { int compareTo = 0; RankedMethod rankedMethod = (RankedMethod) o; if (getRank() > rankedMethod.getRank()) { compareTo = -1; *************** *** 156,162 **** compareTo = 1; } - return compareTo; } - } --- 153,157 ---- Index: ServiceInvocationException.java =================================================================== RCS file: /cvsroot/openamf/openamf/src/java/org/openamf/invoker/ServiceInvocationException.java,v retrieving revision 1.16 retrieving revision 1.17 diff -C2 -d -r1.16 -r1.17 *** ServiceInvocationException.java 9 Aug 2003 16:59:22 -0000 1.16 --- ServiceInvocationException.java 15 Aug 2003 22:03:42 -0000 1.17 *************** *** 24,60 **** */ public class ServiceInvocationException extends NestableException { - - private static final Log log = LogFactory.getLog(ServiceInvocationException.class); - protected AMFBody requestBody; protected ServiceRequest request; - protected Throwable cause; - - public ServiceInvocationException( - AMFBody requestBody, - Throwable cause) { super(cause); - - this.cause = cause; this.requestBody = requestBody; } ! public ServiceInvocationException( ! ServiceRequest request, ! Throwable cause) { ! super(cause); - - this.cause = cause; this.request = request; } public AMFError getAMFError() { - AMFError amfError = new AMFError(); ! ! Throwable rootCause = getRootCause(); ! amfError.setCode(getErrorValue(rootCause, "getCode", "SERVER.PROCESSING")); amfError.setLevel(getErrorValue(rootCause, "getError", "error")); --- 24,43 ---- */ public class ServiceInvocationException extends NestableException { protected AMFBody requestBody; protected ServiceRequest request; + public ServiceInvocationException( AMFBody requestBody, Throwable cause) { super(cause); this.requestBody = requestBody; } ! public ServiceInvocationException(ServiceRequest request, Throwable cause) { super(cause); this.request = request; } public AMFError getAMFError() { AMFError amfError = new AMFError(); ! Throwable rootCause = getCause(); amfError.setCode(getErrorValue(rootCause, "getCode", "SERVER.PROCESSING")); amfError.setLevel(getErrorValue(rootCause, "getError", "error")); *************** *** 62,86 **** amfError.setDetails(ExceptionUtils.getStackTrace(rootCause)); amfError.setDescription(getErrorValue(rootCause, "getDescription", rootCause.getMessage())); - return amfError; - - } - - public Throwable getRootCause() { - - Throwable rootCause = null; - - Throwable[] throwables = getThrowables(); - - rootCause = throwables[getThrowableCount()-1]; - - return rootCause; - } private String getErrorValue(Throwable cause, String methodName, String defaultValue) { - String value = null; - try { Method method = cause.getClass().getMethod(methodName, new Class[0]); --- 45,53 ---- *************** *** 91,95 **** value = defaultValue; } - return value; } --- 58,61 ---- Index: ServiceInvoker.java =================================================================== RCS file: /cvsroot/openamf/openamf/src/java/org/openamf/invoker/ServiceInvoker.java,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** ServiceInvoker.java 15 Aug 2003 16:53:12 -0000 1.11 --- ServiceInvoker.java 15 Aug 2003 22:03:42 -0000 1.12 *************** *** 89,93 **** } - public static ServiceInvoker load( String className, --- 89,92 ---- *************** *** 102,111 **** InvocationTargetException { ! ServiceInvoker serviceInvoker; ! Class serviceInvokerClass = ! Thread.currentThread().getContextClassLoader().loadClass(className); ! Constructor constructor = ! serviceInvokerClass.getConstructor( new Class[] { ServiceRequest.class, --- 101,107 ---- InvocationTargetException { ! Class serviceInvokerClass = Thread.currentThread().getContextClassLoader().loadClass(className); ! Constructor constructor = serviceInvokerClass.getConstructor( new Class[] { ServiceRequest.class, *************** *** 113,121 **** ServletContext.class }); ! serviceInvoker = ! (ServiceInvoker) constructor.newInstance( ! new Object[] { request, httpServletRequest, servletContext }); return serviceInvoker; } - } --- 109,115 ---- ServletContext.class }); ! ServiceInvoker serviceInvoker = (ServiceInvoker) constructor.newInstance( ! new Object[] { request, httpServletRequest, servletContext }); return serviceInvoker; } } Index: ServletLogger.java =================================================================== RCS file: /cvsroot/openamf/openamf/src/java/org/openamf/invoker/ServletLogger.java,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** ServletLogger.java 9 Aug 2003 16:59:22 -0000 1.5 --- ServletLogger.java 15 Aug 2003 22:03:42 -0000 1.6 *************** *** 10,13 **** --- 10,14 ---- import java.util.*; import javax.servlet.*; + import org.apache.tools.ant.*; import org.apache.tools.ant.util.*; *************** *** 19,113 **** */ public class ServletLogger implements BuildListener { ! private GenericServlet servlet; ! private long startTime = System.currentTimeMillis(); ! public ServletLogger( GenericServlet servlet) { ! this.servlet = servlet; ! } ! ! public ServletLogger(){} ! public void buildStarted( BuildEvent event) { ! startTime = System.currentTimeMillis(); ! System.out.println("build started"); ! } ! public void buildFinished( BuildEvent event) { ! Throwable error = event.getException(); ! StringBuffer message = new StringBuffer(); ! if( error==null) { ! message.append( StringUtils.LINE_SEP); ! message.append( "BUILD SUCCESSFUL"); ! ! } else { ! message.append( StringUtils.LINE_SEP); ! message.append( "BUILD FAILED"); ! message.append( StringUtils.LINE_SEP); - if( !( error instanceof BuildException)) { - message.append( StringUtils.getStackTrace( error)); - - } else { - if( error instanceof BuildException) { - message.append( error.toString()).append( StringUtils.LINE_SEP); } else { ! message.append( error.getMessage()).append( StringUtils.LINE_SEP); ! } ! } ! ! } ! message.append( StringUtils.LINE_SEP); ! message.append( "Total time: "); ! message.append(( System.currentTimeMillis()-startTime)/1000); ! //System.out.println( message.toString()); ! } ! public void targetStarted( BuildEvent event) { ! //System.out.println( StringUtils.LINE_SEP+event.getTarget().getName()+":"); ! } ! public void targetFinished( BuildEvent event) { ! // System.out.println(); ! } ! public void taskStarted( BuildEvent event) { ! // System.out.println(); ! } ! public void taskFinished( BuildEvent event) { ! // System.out.println(); ! } ! public void messageLogged( BuildEvent event) { ! StringBuffer message = new StringBuffer(); ! if( event.getTask()!=null) { ! // Print out the name of the task if we're in one ! String name = event.getTask().getTaskName(); ! String label = "["+name +"] "; ! int size = 10-label.length(); ! StringBuffer tmp = new StringBuffer(); ! for( int i = 0; i < size; i++) tmp.append( " "); ! tmp.append( label); ! label = tmp.toString(); ! StringTokenizer tok = new StringTokenizer( event.getMessage(), "\r\n", false); ! boolean first = true; ! while( tok.hasMoreTokens()) { ! if( !first) message.append( StringUtils.LINE_SEP); ! first = false; ! message.append( label); ! message.append( tok.nextToken()); ! } ! } else { ! message.append( event.getMessage()); } ! System.out.println( message.toString()); ! } ! } --- 20,111 ---- */ public class ServletLogger implements BuildListener { ! private GenericServlet servlet; ! private long startTime = System.currentTimeMillis(); ! public ServletLogger(GenericServlet servlet) { ! this.servlet = servlet; ! } + public ServletLogger() { + } ! public void buildStarted(BuildEvent event) { ! startTime = System.currentTimeMillis(); ! System.out.println("build started"); ! } ! public void buildFinished(BuildEvent event) { ! Throwable error = event.getException(); ! StringBuffer message = new StringBuffer(); ! if (error == null) { ! message.append(StringUtils.LINE_SEP); ! message.append("BUILD SUCCESSFUL"); } else { ! message.append(StringUtils.LINE_SEP); ! message.append("BUILD FAILED"); ! message.append(StringUtils.LINE_SEP); ! if (!(error instanceof BuildException)) { ! message.append(StringUtils.getStackTrace(error)); ! } else { ! if (error instanceof BuildException) { ! message.append(error.toString()).append(StringUtils.LINE_SEP); ! } else { ! message.append(error.getMessage()).append(StringUtils.LINE_SEP); ! } ! } ! } ! message.append(StringUtils.LINE_SEP); ! message.append("Total time: "); ! message.append((System.currentTimeMillis() - startTime) / 1000); ! //System.out.println( message.toString()); ! } ! public void targetStarted(BuildEvent event) { ! //System.out.println( StringUtils.LINE_SEP+event.getTarget().getName()+":"); ! } ! public void targetFinished(BuildEvent event) { ! // System.out.println(); ! } ! public void taskStarted(BuildEvent event) { ! // System.out.println(); ! } ! public void taskFinished(BuildEvent event) { ! // System.out.println(); } ! public void messageLogged(BuildEvent event) { ! StringBuffer message = new StringBuffer(); ! if (event.getTask() != null) { ! // Print out the name of the task if we're in one ! String name = event.getTask().getTaskName(); ! String label = "[" + name + "] "; ! int size = 10 - label.length(); ! StringBuffer tmp = new StringBuffer(); ! for (int i = 0; i < size; i++) tmp.append(" "); ! tmp.append(label); ! label = tmp.toString(); ! StringTokenizer tok = new StringTokenizer(event.getMessage(), "\r\n", false); ! boolean first = true; ! while (tok.hasMoreTokens()) { ! if (!first) message.append(StringUtils.LINE_SEP); ! first = false; ! message.append(label); ! message.append(tok.nextToken()); ! } ! } else { ! message.append(event.getMessage()); ! } ! System.out.println(message.toString()); ! } ! } Index: SessionControlInvoker.java =================================================================== RCS file: /cvsroot/openamf/openamf/src/java/org/openamf/invoker/SessionControlInvoker.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** SessionControlInvoker.java 9 Aug 2003 16:59:22 -0000 1.4 --- SessionControlInvoker.java 15 Aug 2003 22:03:42 -0000 1.5 *************** *** 16,19 **** --- 16,21 ---- /** + * Simple Session management Service + * * @author Jason Calabrese <[email protected]> * @version $Revision$, $Date$ *************** *** 32,38 **** public Object invokeService() throws ServiceInvocationException { - Boolean result = Boolean.FALSE; - if (getRequest().getServiceMethodName().equals("close")) { getHttpServletRequest().getSession().invalidate(); --- 34,38 ---- *************** *** 40,45 **** result = Boolean.TRUE; } ! ! return result; } --- 40,44 ---- result = Boolean.TRUE; } ! return result; } Index: WebServiceInvoker.java =================================================================== RCS file: /cvsroot/openamf/openamf/src/java/org/openamf/invoker/WebServiceInvoker.java,v retrieving revision 1.23 retrieving revision 1.24 diff -C2 -d -r1.23 -r1.24 *** WebServiceInvoker.java 9 Aug 2003 16:59:22 -0000 1.23 --- WebServiceInvoker.java 15 Aug 2003 22:03:42 -0000 1.24 *************** *** 44,56 **** public Object invokeService() throws ServiceInvocationException { - Object result = null; - String serviceName = request.getServiceName(); log.debug("SERVICE NAME: " + serviceName); String requestedMethodName = request.getServiceMethodName(); - String packageFolder = "ws" + serviceName.hashCode(); - //remove -'s and .'s packageFolder = removeChar(packageFolder, '-'); --- 44,52 ---- *************** *** 60,66 **** try { ! ! String webservicesDir = ! servletContext.getRealPath("/WEB-INF/classes"); runAntBuild(serviceName, packageFolder, webservicesDir); --- 56,60 ---- try { ! String webservicesDir = servletContext.getRealPath("/WEB-INF/classes"); runAntBuild(serviceName, packageFolder, webservicesDir); *************** *** 95,101 **** private String removeChar(String s, char c) { - StringBuffer b = new StringBuffer(s.length()); - for (int i = 0; i < s.length(); ++i) { if (s.charAt(i) != c) --- 89,93 ---- *************** *** 111,128 **** File testDir = new File(webservicesDir + "/" + packageFolder); if (!testDir.exists()) { - Project project = new Project(); project.init(); //this is a ton of debug code //project.addBuildListener(new ServletLogger()); ! String webInfPath = ! servletContext.getRealPath("/WEB-INF"); File buildFile = new File(webInfPath + "/build-webservice.xml"); - log.debug("buildfile exists: " + buildFile.exists()); - project.setProperty("endpoint", serviceName); project.setProperty("packagename", packageFolder); - ProjectHelper.configureProject(project, buildFile); project.executeTarget(project.getDefaultTarget()); --- 103,115 ---- File testDir = new File(webservicesDir + "/" + packageFolder); if (!testDir.exists()) { Project project = new Project(); project.init(); //this is a ton of debug code //project.addBuildListener(new ServletLogger()); ! String webInfPath = servletContext.getRealPath("/WEB-INF"); File buildFile = new File(webInfPath + "/build-webservice.xml"); log.debug("buildfile exists: " + buildFile.exists()); project.setProperty("endpoint", serviceName); project.setProperty("packagename", packageFolder); ProjectHelper.configureProject(project, buildFile); project.executeTarget(project.getDefaultTarget()); *************** *** 200,204 **** throws InstantiationException, - IntrospectionException, IllegalAccessException, InvocationTargetException, --- 187,190 ---- *************** *** 223,228 **** public boolean supports(ServiceRequest request) { ! return ( ! request.getServiceName().toLowerCase().lastIndexOf("wsdl") != -1); } --- 209,213 ---- public boolean supports(ServiceRequest request) { ! return (request.getServiceName().toLowerCase().lastIndexOf("wsdl") != -1); } ------------------------------------------------------- This SF.Net email sponsored by: Free pre-built ASP.NET sites including Data Reports, E-commerce, Portals, and Forums are available now. Download today and enter to win an XBOX or Visual Studio .NET. http://aspnet.click-url.com/go/psa00100003ave/direct;at.aspnet_072303_01/01