From: <bsc...@us...> - 2007-04-07 20:12:57
|
Revision: 603 http://svn.sourceforge.net/unicore/?rev=603&view=rev Author: bschuller Date: 2007-04-07 13:12:56 -0700 (Sat, 07 Apr 2007) Log Message: ----------- more JMX; add "global" handler definition in services.xml; fix some minor issues Modified Paths: -------------- wsrflite/wsrfcore/trunk/src/main/java/de/fzj/unicore/wsrflite/Kernel.java wsrflite/wsrfcore/trunk/src/main/java/de/fzj/unicore/wsrflite/admin/WSRFHome.java wsrflite/wsrfcore/trunk/src/main/java/de/fzj/unicore/wsrflite/admin/WSRFHomeMBean.java wsrflite/wsrfcore/trunk/src/main/java/de/fzj/unicore/wsrflite/messaging/impl/MessageQueueStore.java wsrflite/wsrfcore/trunk/src/main/java/de/fzj/unicore/wsrflite/persistence/HsqldbPersist.java wsrflite/wsrfcore/trunk/src/main/java/de/fzj/unicore/wsrflite/utils/ServiceConfigReader.java wsrflite/wsrfcore/trunk/src/main/java/de/fzj/unicore/wsrflite/xmlbeans/client/Consumer.java wsrflite/wsrfcore/trunk/src/main/java/de/fzj/unicore/wsrflite/xmlbeans/impl/WSResourceImpl.java wsrflite/wsrfcore/trunk/src/main/java/de/fzj/unicore/wsrflite/xmlbeans/wsn/impl/NotificationProducerImpl.java wsrflite/wsrfcore/trunk/src/test/java/de/fzj/unicore/wsrflite/exampleservice/ExampleFactoryImpl.java wsrflite/wsrfcore/trunk/src/test/java/de/fzj/unicore/wsrflite/functional/SimpleLoadTest.java Added Paths: ----------- wsrflite/wsrfcore/trunk/src/main/java/de/fzj/unicore/wsrflite/admin/KernelAdmin.java wsrflite/wsrfcore/trunk/src/main/java/de/fzj/unicore/wsrflite/admin/KernelAdminMBean.java Modified: wsrflite/wsrfcore/trunk/src/main/java/de/fzj/unicore/wsrflite/Kernel.java =================================================================== --- wsrflite/wsrfcore/trunk/src/main/java/de/fzj/unicore/wsrflite/Kernel.java 2007-04-07 15:05:40 UTC (rev 602) +++ wsrflite/wsrfcore/trunk/src/main/java/de/fzj/unicore/wsrflite/Kernel.java 2007-04-07 20:12:56 UTC (rev 603) @@ -34,13 +34,15 @@ package de.fzj.unicore.wsrflite; import java.io.FileInputStream; -import java.rmi.RemoteException; import java.util.Collections; import java.util.HashMap; import java.util.Map; import java.util.Properties; +import java.util.logging.Level; import java.util.logging.Logger; +import de.fzj.unicore.wsrflite.admin.JMX; +import de.fzj.unicore.wsrflite.admin.KernelAdmin; import de.fzj.unicore.wsrflite.jetty.JettyServer; import de.fzj.unicore.wsrflite.messaging.IMessaging; import de.fzj.unicore.wsrflite.messaging.MessagingImpl; @@ -51,8 +53,10 @@ import de.fzj.unicore.wsrflite.xfire.XFireKernel; /** - * register and lookup of WSRF instances + * Main class for WSRFlite standalone use<br/> * + * serves for lookup of components, services, and properties + * * @author schuller * @version $Id: Kernel.java,v 1.6 2006/11/16 07:05:04 bschuller Exp $ */ @@ -109,9 +113,13 @@ properties=new Properties(); securityProperties=new KernelSecurityProperties(this); XFireKernel.addUnderstoodHeaders(AddressingConstants.supported); - + initJMX(); } + private void initJMX(){ + JMX.registerMBean(new KernelAdmin(),"Kernel"); + } + /** * shutdown all services in a clean manner */ @@ -154,7 +162,6 @@ specMap.put(name,spec); } - /** * set the security properties on this kernel * @param securityProperties @@ -170,29 +177,6 @@ public ISecurityProperties getSecurityProperties(){ return securityProperties; } - - /** - * create a new WSResource instance - */ - public String createServiceInstance(String serviceName, Map<String,Object> initParams)throws Exception{ - Home home=homeMap.get(serviceName); - if(home==null){ - throw new RemoteException("Cannot make instance service <"+serviceName+">"); - } - return home.createWSRFServiceInstance(initParams); - } - /** - * create a new WSResource instance - */ - public String createServiceInstance(String serviceName)throws Exception{ - return createServiceInstance(serviceName,new HashMap<String,Object>()); - } - /** - * create a new WSResource instance - */ - public void destroyWSRFServiceInstance(WSRFInstance wsrf)throws Exception{ - getServiceHome(wsrf.getServiceName()).destroyWSRFServiceInstance(wsrf.getUniqueID()); - } public String getProperty(String key){ return (String) properties.get(key); @@ -235,7 +219,7 @@ try{ new JettyServer().start(); }catch(Exception e){ - e.printStackTrace(); + logger.log(Level.SEVERE,"Could not start server.",e); } } } Added: wsrflite/wsrfcore/trunk/src/main/java/de/fzj/unicore/wsrflite/admin/KernelAdmin.java =================================================================== --- wsrflite/wsrfcore/trunk/src/main/java/de/fzj/unicore/wsrflite/admin/KernelAdmin.java (rev 0) +++ wsrflite/wsrfcore/trunk/src/main/java/de/fzj/unicore/wsrflite/admin/KernelAdmin.java 2007-04-07 20:12:56 UTC (rev 603) @@ -0,0 +1,37 @@ +package de.fzj.unicore.wsrflite.admin; + +import de.fzj.unicore.wsrflite.Kernel; +import de.fzj.unicore.wsrflite.security.ISecurityProperties; + +public class KernelAdmin implements KernelAdminMBean { + + /* (non-Javadoc) + * @see de.fzj.unicore.wsrflite.admin.KernelAdminMBean#getBaseURL() + */ + public String getBaseURL(){ + return Kernel.getKernel().getProperty(Kernel.WSRF_BASEURL); + } + + /* (non-Javadoc) + * @see de.fzj.unicore.wsrflite.admin.KernelAdminMBean#getHost() + */ + public String getHost(){ + return Kernel.getKernel().getProperty(Kernel.WSRF_HOST); + } + + /* (non-Javadoc) + * @see de.fzj.unicore.wsrflite.admin.KernelAdminMBean#getPort() + */ + public String getPort(){ + return Kernel.getKernel().getProperty(Kernel.WSRF_PORT); + } + + /* (non-Javadoc) + * @see de.fzj.unicore.wsrflite.admin.KernelAdminMBean#getSSLEnabled() + */ + public String getSSLEnabled(){ + return Kernel.getKernel().getProperty(ISecurityProperties.WSRF_SSL); + } + + +} Added: wsrflite/wsrfcore/trunk/src/main/java/de/fzj/unicore/wsrflite/admin/KernelAdminMBean.java =================================================================== --- wsrflite/wsrfcore/trunk/src/main/java/de/fzj/unicore/wsrflite/admin/KernelAdminMBean.java (rev 0) +++ wsrflite/wsrfcore/trunk/src/main/java/de/fzj/unicore/wsrflite/admin/KernelAdminMBean.java 2007-04-07 20:12:56 UTC (rev 603) @@ -0,0 +1,13 @@ +package de.fzj.unicore.wsrflite.admin; + +public interface KernelAdminMBean { + + public abstract String getBaseURL(); + + public abstract String getHost(); + + public abstract String getPort(); + + public abstract String getSSLEnabled(); + +} \ No newline at end of file Modified: wsrflite/wsrfcore/trunk/src/main/java/de/fzj/unicore/wsrflite/admin/WSRFHome.java =================================================================== --- wsrflite/wsrfcore/trunk/src/main/java/de/fzj/unicore/wsrflite/admin/WSRFHome.java 2007-04-07 15:05:40 UTC (rev 602) +++ wsrflite/wsrfcore/trunk/src/main/java/de/fzj/unicore/wsrflite/admin/WSRFHome.java 2007-04-07 20:12:56 UTC (rev 603) @@ -33,13 +33,25 @@ package de.fzj.unicore.wsrflite.admin; +import java.text.DateFormat; +import java.text.SimpleDateFormat; +import java.util.Calendar; +import java.util.Date; +import java.util.logging.Level; +import java.util.logging.Logger; + import de.fzj.unicore.wsrflite.Home; import de.fzj.unicore.wsrflite.persistence.PersistenceManager; public class WSRFHome implements WSRFHomeMBean{ + protected static Logger logger=Logger.getLogger(WSRFHome.class.getName()); + private Home home; + //format expected for setting termination time + private String format="yyyy-MM-dd hh:mm"; + public WSRFHome(Home home){ this.home=home; } @@ -60,4 +72,40 @@ } } + + public String getTerminationTime(String resID) { + try{ + Calendar tt=home.getTerminationTime(resID); + return formatDate(tt); + }catch(Exception e){ + return null; + } + } + + public String getServerTime() { + try{ + return formatDate(Calendar.getInstance()); + }catch(Exception e){ + return null; + } + } + + public String setTerminationTime(String resID, String date){ + try { + Date d=new SimpleDateFormat(format).parse(date); + Calendar newTT=Calendar.getInstance(); + newTT.setTime(d); + home.setTerminationTime(resID, newTT); + return "New TerminationTime: "+formatDate(newTT); + }catch(Exception e){ + logger.log(Level.WARNING,"",e); + return "Could not parse date, expect format: "+format; + } + + } + + public static String formatDate(Calendar cal){ + return DateFormat.getDateTimeInstance(DateFormat.FULL, DateFormat.FULL).format(cal.getTime()); + } + } Modified: wsrflite/wsrfcore/trunk/src/main/java/de/fzj/unicore/wsrflite/admin/WSRFHomeMBean.java =================================================================== --- wsrflite/wsrfcore/trunk/src/main/java/de/fzj/unicore/wsrflite/admin/WSRFHomeMBean.java 2007-04-07 15:05:40 UTC (rev 602) +++ wsrflite/wsrfcore/trunk/src/main/java/de/fzj/unicore/wsrflite/admin/WSRFHomeMBean.java 2007-04-07 20:12:56 UTC (rev 603) @@ -34,6 +34,7 @@ package de.fzj.unicore.wsrflite.admin; + /** * management interface for wsrf home via jmx * @author schuller @@ -45,5 +46,10 @@ public String[] listInstances(); + public String getTerminationTime(String resID); + public String setTerminationTime(String resID, String date); + + public String getServerTime(); + } Modified: wsrflite/wsrfcore/trunk/src/main/java/de/fzj/unicore/wsrflite/messaging/impl/MessageQueueStore.java =================================================================== --- wsrflite/wsrfcore/trunk/src/main/java/de/fzj/unicore/wsrflite/messaging/impl/MessageQueueStore.java 2007-04-07 15:05:40 UTC (rev 602) +++ wsrflite/wsrfcore/trunk/src/main/java/de/fzj/unicore/wsrflite/messaging/impl/MessageQueueStore.java 2007-04-07 20:12:56 UTC (rev 603) @@ -165,7 +165,7 @@ //create tables if not existing createTablesAndPreparedStatements(); } catch (Exception e) { - e.printStackTrace(); + log.log(Level.SEVERE,"Error initialising database.",e); throw new RuntimeException(e); } } Modified: wsrflite/wsrfcore/trunk/src/main/java/de/fzj/unicore/wsrflite/persistence/HsqldbPersist.java =================================================================== --- wsrflite/wsrfcore/trunk/src/main/java/de/fzj/unicore/wsrflite/persistence/HsqldbPersist.java 2007-04-07 15:05:40 UTC (rev 602) +++ wsrflite/wsrfcore/trunk/src/main/java/de/fzj/unicore/wsrflite/persistence/HsqldbPersist.java 2007-04-07 20:12:56 UTC (rev 603) @@ -144,7 +144,7 @@ createTablesAndPreparedStatements(); getUniqueIDs(); } catch (Exception e) { - e.printStackTrace(); + logger.log(Level.SEVERE,"Error initialising database for <"+serviceName+">",e); throw new RuntimeException(e); } } Modified: wsrflite/wsrfcore/trunk/src/main/java/de/fzj/unicore/wsrflite/utils/ServiceConfigReader.java =================================================================== --- wsrflite/wsrfcore/trunk/src/main/java/de/fzj/unicore/wsrflite/utils/ServiceConfigReader.java 2007-04-07 15:05:40 UTC (rev 602) +++ wsrflite/wsrfcore/trunk/src/main/java/de/fzj/unicore/wsrflite/utils/ServiceConfigReader.java 2007-04-07 20:12:56 UTC (rev 603) @@ -36,6 +36,7 @@ import java.io.InputStream; import java.net.InetAddress; import java.util.ArrayList; +import java.util.List; import java.util.logging.Level; import java.util.logging.Logger; @@ -61,6 +62,8 @@ * <service name="..." wsrf="true|false" persistent="true|false"><br/> * <interface class="" /> <!-- the interface defining your service --><br/> * <implementation class=""/> <!-- the implementation of the service --><br/> + * <handler type="in|out" class="..."/> <!-- an in/out handler to add --><br/> + * * </service><br/> * ...<br/> * @@ -84,8 +87,12 @@ private boolean isPersistent; //activate persistence for service? private String handlerType,handlerClass; private String propertyName,propertyValue; - ArrayList<String> inhandlers=new ArrayList<String>(); - ArrayList<String> outhandlers=new ArrayList<String>(); + private ArrayList<String> inhandlers=new ArrayList<String>(); + private ArrayList<String> outhandlers=new ArrayList<String>(); + private ArrayList<String> globalOutHandlers=new ArrayList<String>(); + private ArrayList<String> globalInHandlers=new ArrayList<String>(); + + public ServiceConfigReader() { } @@ -151,6 +158,20 @@ */ public void startElement(String uri, String localName, String qName, Attributes attributes) throws SAXException { + + if("globalHandler".equals(localName)){ + String globalHandlerType=attributes.getValue("type"); + String globalHandlerClass=attributes.getValue("class"); + if(globalHandlerClass!=null){ + if("in".equalsIgnoreCase(globalHandlerType)){ + globalInHandlers.add(globalHandlerClass); + } + else if("out".equalsIgnoreCase(globalHandlerType)){ + globalOutHandlers.add(globalHandlerClass); + } + } + } + if("service".equals(qName)){ current=attributes.getValue("name"); isWSRF=Boolean.parseBoolean(attributes.getValue("wsrf")); @@ -207,12 +228,15 @@ Service s=XFireKernel.exposeAsService(name, Class.forName(iFace),Class.forName(impl), isWSRF,isPersistent); - addHandlers(s); + addInHandlers(s,inhandlers); + addOutHandlers(s,outhandlers); + addInHandlers(s,globalInHandlers); + addOutHandlers(s,globalOutHandlers); return s; } - protected void addHandlers(Service s){ - for(String h: inhandlers){ + protected void addInHandlers(Service s, List<String>handlers){ + for(String h: handlers){ try{ Handler handler=(Handler)Class.forName(h).newInstance(); s.addInHandler(handler); @@ -221,8 +245,10 @@ logger.log(Level.SEVERE,"Could not add handler",e); } } - - for(String h: outhandlers){ + } + + protected void addOutHandlers(Service s, List<String>handlers){ + for(String h: handlers){ try{ Handler handler=(Handler)Class.forName(h).newInstance(); s.addOutHandler(handler); @@ -231,7 +257,6 @@ logger.log(Level.SEVERE,"Could not add handler",e); } } - } } Modified: wsrflite/wsrfcore/trunk/src/main/java/de/fzj/unicore/wsrflite/xmlbeans/client/Consumer.java =================================================================== --- wsrflite/wsrfcore/trunk/src/main/java/de/fzj/unicore/wsrflite/xmlbeans/client/Consumer.java 2007-04-07 15:05:40 UTC (rev 602) +++ wsrflite/wsrfcore/trunk/src/main/java/de/fzj/unicore/wsrflite/xmlbeans/client/Consumer.java 2007-04-07 20:12:56 UTC (rev 603) @@ -102,8 +102,7 @@ try{ o.update(null,msg); }catch(Exception e){ - e.printStackTrace(); - logger.warning("Could not notify "+o.toString()); + logger.log(Level.WARNING,"Could not notify "+o.toString(),e); } } } Modified: wsrflite/wsrfcore/trunk/src/main/java/de/fzj/unicore/wsrflite/xmlbeans/impl/WSResourceImpl.java =================================================================== --- wsrflite/wsrfcore/trunk/src/main/java/de/fzj/unicore/wsrflite/xmlbeans/impl/WSResourceImpl.java 2007-04-07 15:05:40 UTC (rev 602) +++ wsrflite/wsrfcore/trunk/src/main/java/de/fzj/unicore/wsrflite/xmlbeans/impl/WSResourceImpl.java 2007-04-07 20:12:56 UTC (rev 603) @@ -250,7 +250,6 @@ res.set(getResourcePropertyResponseDocument()); return resDoc; } catch (Exception e) { - e.printStackTrace(); logger.log(Level.SEVERE,"Could not build resourceproperty document.",e); throw BaseFault.createFault(e.getMessage()); } Modified: wsrflite/wsrfcore/trunk/src/main/java/de/fzj/unicore/wsrflite/xmlbeans/wsn/impl/NotificationProducerImpl.java =================================================================== --- wsrflite/wsrfcore/trunk/src/main/java/de/fzj/unicore/wsrflite/xmlbeans/wsn/impl/NotificationProducerImpl.java 2007-04-07 15:05:40 UTC (rev 602) +++ wsrflite/wsrfcore/trunk/src/main/java/de/fzj/unicore/wsrflite/xmlbeans/wsn/impl/NotificationProducerImpl.java 2007-04-07 20:12:56 UTC (rev 603) @@ -267,8 +267,7 @@ return os.length>0; } catch(Exception e){ - e.printStackTrace(); - logger.info("Reject sending message: "+e.getLocalizedMessage()); + logger.log(Level.INFO,"Reject sending message: "+e.getLocalizedMessage(),e); return false; } Modified: wsrflite/wsrfcore/trunk/src/test/java/de/fzj/unicore/wsrflite/exampleservice/ExampleFactoryImpl.java =================================================================== --- wsrflite/wsrfcore/trunk/src/test/java/de/fzj/unicore/wsrflite/exampleservice/ExampleFactoryImpl.java 2007-04-07 15:05:40 UTC (rev 602) +++ wsrflite/wsrfcore/trunk/src/test/java/de/fzj/unicore/wsrflite/exampleservice/ExampleFactoryImpl.java 2007-04-07 20:12:56 UTC (rev 603) @@ -71,6 +71,6 @@ * @return */ protected String makeNewInstance() throws Exception { - return Kernel.getKernel().createServiceInstance("service"); + return Kernel.getKernel().getServiceHome("service").createWSRFServiceInstance(null); } } Modified: wsrflite/wsrfcore/trunk/src/test/java/de/fzj/unicore/wsrflite/functional/SimpleLoadTest.java =================================================================== --- wsrflite/wsrfcore/trunk/src/test/java/de/fzj/unicore/wsrflite/functional/SimpleLoadTest.java 2007-04-07 15:05:40 UTC (rev 602) +++ wsrflite/wsrfcore/trunk/src/test/java/de/fzj/unicore/wsrflite/functional/SimpleLoadTest.java 2007-04-07 20:12:56 UTC (rev 603) @@ -105,6 +105,13 @@ XFireKernel.exposeAsService("testservice",WSResource.class,TestWSResourceHomeImpl.class,true,true); } + @Override + public void test()throws Exception{ + super.test(); + while(true){ + Thread.sleep(1000); + } + } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |