| CODENOTIFIER | HelpYou are not signed inSign in |
Project: PEtALS
Revision: 8839
Author: mcarpentier
Date: 06 Aug 2008 12:41:49
Changes:a client to ease the access of the channelClient jmx server
Files:| ... | ...@@ -0,0 +1,129 @@ | |
| 1 | /** | |
| 2 | * PETALS - PETALS Services Platform. | |
| 3 | * Copyright (c) 2008 EBM Websourcing, http://www.ebmwebsourcing.com/ | |
| 4 | * | |
| 5 | * This library is free software; you can redistribute it and/or | |
| 6 | * modify it under the terms of the GNU Lesser General Public | |
| 7 | * License as published by the Free Software Foundation; either | |
| 8 | * version 2.1 of the License, or (at your option) any later version. | |
| 9 | * This library is distributed in the hope that it will be useful, | |
| 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
| 12 | * Lesser General Public License for more details. | |
| 13 | * | |
| 14 | * You should have received a copy of the GNU Lesser General Public | |
| 15 | * License along with this library; if not, write to the Free Software | |
| 16 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
| 17 | * | |
| 18 | */ | |
| 19 | ||
| 20 | package org.ow2.petals.tools.channelclient.jmxclient; | |
| 21 | ||
| 22 | import java.io.IOException; | |
| 23 | ||
| 24 | import javax.management.AttributeNotFoundException; | |
| 25 | import javax.management.InstanceNotFoundException; | |
| 26 | import javax.management.MBeanException; | |
| 27 | import javax.management.MBeanServerConnection; | |
| 28 | import javax.management.ObjectName; | |
| 29 | import javax.management.ReflectionException; | |
| 30 | import javax.management.ServiceNotFoundException; | |
| 31 | ||
| 32 | import org.ow2.petals.tools.channelclient.jmxclient.exception.AttributeErrorException; | |
| 33 | import org.ow2.petals.tools.channelclient.jmxclient.exception.PerformActionDoesNotExistException; | |
| 34 | import org.ow2.petals.tools.channelclient.jmxclient.exception.PerformActionErrorException; | |
| 35 | ||
| 36 | /** | |
| 37 | * The Channel Client JMX Client API | |
| 38 | * | |
| 39 | * @author mcarpentier - EBM WebSourcing | |
| 40 | * | |
| 41 | */ | |
| 42 | public abstract class ChannelClientAbstractServiceClient { | |
| 43 | ||
| 44 | protected final static String JMX_FIELD_TYPE = "type"; | |
| 45 | ||
| 46 | protected final static String JMX_FIELD_NAME = "name"; | |
| 47 | ||
| 48 | protected final static String JMX_SERVICE_TYPE = "service"; | |
| 49 | ||
| 50 | protected String petalsDomain = null; | |
| 51 | ||
| 52 | protected ObjectName mbeanName = null; | |
| 53 | ||
| 54 | protected MBeanServerConnection mBeanServerConnection = null; | |
| 55 | ||
| 56 | /** | |
| 57 | * Creates a new instance of {@link ChannelClientAbstractServiceClient} | |
| 58 | * | |
| 59 | * @param petalsDomain | |
| 60 | * @param mBeanServerConnection | |
| 61 | */ | |
| 62 | public ChannelClientAbstractServiceClient(String petalsDomain, | |
| 63 | MBeanServerConnection mBeanServerConnection) { | |
| 64 | this.petalsDomain = petalsDomain; | |
| 65 | this.mBeanServerConnection = mBeanServerConnection; | |
| 66 | } | |
| 67 | ||
| 68 | /** | |
| 69 | * Perform an action on the MBean service | |
| 70 | * | |
| 71 | * @param action | |
| 72 | * @return | |
| 73 | * @throws PerformActionErrorException | |
| 74 | */ | |
| 75 | protected Object performAction(String action, Object[] objectsLoad, String[] stringsLoad) | |
| 76 | throws PerformActionErrorException { | |
| 77 | ||
| 78 | try { | |
| 79 | return this.mBeanServerConnection.invoke(this.mbeanName, action, objectsLoad, | |
| 80 | stringsLoad); | |
| 81 | ||
| 82 | } catch (MBeanException e) { | |
| 83 | if (e.getCause() instanceof ServiceNotFoundException) { | |
| 84 | // The requested action does not exist on the server MBean side | |
| 85 | throw new PerformActionDoesNotExistException(action, this.mbeanName, e); | |
| 86 | } else { | |
| 87 | throw new PerformActionErrorException(e); | |
| 88 | } | |
| 89 | } catch (Exception e) { | |
| 90 | throw new PerformActionErrorException(e); | |
| 91 | } | |
| 92 | } | |
| 93 | ||
| 94 | protected Object getAttribute(String attributeName) throws AttributeErrorException { | |
| 95 | try { | |
| 96 | return this.mBeanServerConnection.getAttribute(this.mbeanName, attributeName); | |
| 97 | ||
| 98 | } catch (AttributeNotFoundException e) { | |
| 99 | throw new AttributeErrorException(e); | |
| 100 | } catch (InstanceNotFoundException e) { | |
| 101 | throw new AttributeErrorException(e); | |
| 102 | } catch (MBeanException e) { | |
| 103 | throw new AttributeErrorException(e); | |
| 104 | } catch (ReflectionException e) { | |
| 105 | throw new AttributeErrorException(e); | |
| 106 | } catch (IOException e) { | |
| 107 | throw new AttributeErrorException(e); | |
| 108 | } | |
| 109 | } | |
| 110 | ||
| 111 | protected Object getAttribute(ObjectName mbeanName, String attributeName) | |
| 112 | throws AttributeErrorException { | |
| 113 | try { | |
| 114 | return this.mBeanServerConnection.getAttribute(mbeanName, attributeName); | |
| 115 | ||
| 116 | } catch (AttributeNotFoundException e) { | |
| 117 | throw new AttributeErrorException(e); | |
| 118 | } catch (InstanceNotFoundException e) { | |
| 119 | throw new AttributeErrorException(e); | |
| 120 | } catch (MBeanException e) { | |
| 121 | throw new AttributeErrorException(e); | |
| 122 | } catch (ReflectionException e) { | |
| 123 | throw new AttributeErrorException(e); | |
| 124 | } catch (IOException e) { | |
| 125 | throw new AttributeErrorException(e); | |
| 126 | } | |
| 127 | } | |
| 128 | ||
| 129 | } |
| ... | ...@@ -0,0 +1,44 @@ | |
| 1 | /** | |
| 2 | * PETALS - PETALS Services Platform. | |
| 3 | * Copyright (c) 2005 EBM Websourcing, http://www.ebmwebsourcing.com/ | |
| 4 | * | |
| 5 | * This library is free software; you can redistribute it and/or | |
| 6 | * modify it under the terms of the GNU Lesser General Public | |
| 7 | * License as published by the Free Software Foundation; either | |
| 8 | * version 2.1 of the License, or (at your option) any later version. | |
| 9 | * This library is distributed in the hope that it will be useful, | |
| 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
| 12 | * Lesser General Public License for more details. | |
| 13 | * | |
| 14 | * You should have received a copy of the GNU Lesser General Public | |
| 15 | * License along with this library; if not, write to the Free Software | |
| 16 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
| 17 | * | |
| 18 | */ | |
| 19 | ||
| 20 | package org.ow2.petals.tools.channelclient.jmxclient.exception; | |
| 21 | ||
| 22 | /** | |
| 23 | * This exception is thrown if an error occurs when working with the Channel | |
| 24 | * Client | |
| 25 | * | |
| 26 | * @author mcarpentier - EBM Websourcing | |
| 27 | * | |
| 28 | */ | |
| 29 | public class ChannelClientServiceErrorException extends PetalsJMXClientException { | |
| 30 | ||
| 31 | /** | |
| 32 | * Serial UID | |
| 33 | */ | |
| 34 | private static final long serialVersionUID = -2476192740405434424L; | |
| 35 | ||
| 36 | public ChannelClientServiceErrorException(Throwable cause) { | |
| 37 | super(cause); | |
| 38 | } | |
| 39 | ||
| 40 | public ChannelClientServiceErrorException(String message) { | |
| 41 | super(message); | |
| 42 | } | |
| 43 | ||
| 44 | } |
| ... | ...@@ -0,0 +1,50 @@ | |
| 1 | /** | |
| 2 | * PETALS - PETALS Services Platform. | |
| 3 | * Copyright (c) 2005 EBM Websourcing, http://www.ebmwebsourcing.com/ | |
| 4 | * | |
| 5 | * This library is free software; you can redistribute it and/or | |
| 6 | * modify it under the terms of the GNU Lesser General Public | |
| 7 | * License as published by the Free Software Foundation; either | |
| 8 | * version 2.1 of the License, or (at your option) any later version. | |
| 9 | * This library is distributed in the hope that it will be useful, | |
| 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
| 12 | * Lesser General Public License for more details. | |
| 13 | * | |
| 14 | * You should have received a copy of the GNU Lesser General Public | |
| 15 | * License along with this library; if not, write to the Free Software | |
| 16 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
| 17 | * | |
| 18 | */ | |
| 19 | ||
| 20 | package org.ow2.petals.tools.channelclient.jmxclient.exception; | |
| 21 | ||
| 22 | /** | |
| 23 | * This exception is the JMX Client API abstract exception | |
| 24 | * | |
| 25 | * @author mcarpentier - EBM WebSourcing | |
| 26 | */ | |
| 27 | public abstract class PetalsJMXClientException extends Exception { | |
| 28 | ||
| 29 | /** | |
| 30 | * | |
| 31 | */ | |
| 32 | private static final long serialVersionUID = 2882458832085864351L; | |
| 33 | ||
| 34 | public PetalsJMXClientException() { | |
| 35 | super(); | |
| 36 | } | |
| 37 | ||
| 38 | public PetalsJMXClientException(Throwable cause) { | |
| 39 | super(cause); | |
| 40 | } | |
| 41 | ||
| 42 | public PetalsJMXClientException(String message) { | |
| 43 | super(message); | |
| 44 | } | |
| 45 | ||
| 46 | public PetalsJMXClientException(String message, Throwable cause) { | |
| 47 | super(message, cause); | |
| 48 | } | |
| 49 | ||
| 50 | } |
| ... | ...@@ -0,0 +1,40 @@ | |
| 1 | <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> | |
| 2 | <modelVersion>4.0.0</modelVersion> | |
| 3 | ||
| 4 | <parent> | |
| 5 | <artifactId>petals-tools</artifactId> | |
| 6 | <groupId>org.ow2.petals</groupId> | |
| 7 | <version>9-SNAPSHOT</version> | |
| 8 | </parent> | |
| 9 | ||
| 10 | <groupId>org.ow2.petals</groupId> | |
| 11 | <artifactId>petals-channelclient-jmxclient</artifactId> | |
| 12 | <name>PEtALS :: ChannelClient JMX client</name> | |
| 13 | <version>1.0-SNAPSHOT</version> | |
| 14 | <packaging>jar</packaging> | |
| 15 | ||
| 16 | <description>PEtALS Channel client JMX utilities library</description> | |
| 17 | ||
| 18 | <properties> | |
| 19 | <topDirectoryLocation>..</topDirectoryLocation> | |
| 20 | </properties> | |
| 21 | ||
| 22 | <dependencies> | |
| 23 | <dependency> | |
| 24 | <groupId>junit</groupId> | |
| 25 | <artifactId>junit</artifactId> | |
| 26 | <scope>test</scope> | |
| 27 | </dependency> | |
| 28 | ||
| 29 | <dependency> | |
| 30 | <groupId>org.ow2.petals</groupId> | |
| 31 | <artifactId>petals-jbi</artifactId> | |
| 32 | </dependency> | |
| 33 | ||
| 34 | <dependency> | |
| 35 | <groupId>org.ow2.petals</groupId> | |
| 36 | <artifactId>petals-jmx-api</artifactId> | |
| 37 | <version>1.3-SNAPSHOT</version> | |
| 38 | </dependency> | |
| 39 | </dependencies> | |
| 40 | </project> |
| ... | ...@@ -0,0 +1,94 @@ | |
| 1 | /** | |
| 2 | * PETALS - PETALS Services Platform. | |
| 3 | * Copyright (c) 2005 EBM Websourcing, http://www.ebmwebsourcing.com/ | |
| 4 | * | |
| 5 | * This library is free software; you can redistribute it and/or | |
| 6 | * modify it under the terms of the GNU Lesser General Public | |
| 7 | * License as published by the Free Software Foundation; either | |
| 8 | * version 2.1 of the License, or (at your option) any later version. | |
| 9 | * This library is distributed in the hope that it will be useful, | |
| 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
| 12 | * Lesser General Public License for more details. | |
| 13 | * | |
| 14 | * You should have received a copy of the GNU Lesser General Public | |
| 15 | * License along with this library; if not, write to the Free Software | |
| 16 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
| 17 | * | |
| 18 | */ | |
| 19 | ||
| 20 | package org.ow2.petals.tools.channelclient.jmxclient; | |
| 21 | ||
| 22 | import org.ow2.petals.tools.channelclient.jmxclient.exception.ChannelClientDoesNotExistException; | |
| 23 | import org.ow2.petals.tools.channelclient.jmxclient.exception.ChannelClientServiceErrorException; | |
| 24 | import org.ow2.petals.tools.channelclient.jmxclient.exception.ConnectionErrorException; | |
| 25 | ||
| 26 | /** | |
| 27 | * The Channel JMX Client API | |
| 28 | * | |
| 29 | * @author mcarpentier - EBM WebSourcing | |
| 30 | */ | |
| 31 | public final class ChannelClientJMXClient { | |
| 32 | ||
| 33 | private final static String PETALS_DOMAIN = "Petals"; | |
| 34 | ||
| 35 | /** Default Port opened by ChannelClient BC RMI Server | |
| 36 | * TODO: make it configurable | |
| 37 | **/ | |
| 38 | public static final int DEFAULT_RMIPORT = 7777; | |
| 39 | ||
| 40 | private ChannelClientJMXConnection jmxConnection = null; | |
| 41 | ||
| 42 | /** | |
| 43 | * Creates a new instance of {@link ChannelClientJMXClient} | |
| 44 | * | |
| 45 | * @param host | |
| 46 | * @param port | |
| 47 | * @param username | |
| 48 | * @param password | |
| 49 | * @throws ConnectionErrorException | |
| 50 | */ | |
| 51 | public ChannelClientJMXClient(String host, Integer port, String username, String password) | |
| 52 | throws ConnectionErrorException { | |
| 53 | this.jmxConnection = new ChannelClientJMXConnection(host, port, username, password); | |
| 54 | } | |
| 55 | ||
| 56 | /** | |
| 57 | * Retrieve the PEtALS Channel Client service client API | |
| 58 | * | |
| 59 | * @return the Petals Admin service client API | |
| 60 | * @throws PetalsAdminDoesNotExistException | |
| 61 | * @throws PetalsAdminServiceErrorException | |
| 62 | * @throws ConnectionErrorException | |
| 63 | * @throws ChannelClientServiceErrorException | |
| 64 | * @throws ChannelClientDoesNotExistException | |
| 65 | */ | |
| 66 | public ChannelClientServiceClient getChannelClientServiceClient() | |
| 67 | throws ConnectionErrorException, ChannelClientDoesNotExistException, | |
| 68 | ChannelClientServiceErrorException { | |
| 69 | ||
| 70 | return new ChannelClientServiceClient(PETALS_DOMAIN, jmxConnection | |
| 71 | .getMBeanServerConnection()); | |
| 72 | ||
| 73 | } | |
| 74 | ||
| 75 | /** | |
| 76 | * Release the connection to the JMX server | |
| 77 | * | |
| 78 | * @throws ConnectionErrorException | |
| 79 | */ | |
| 80 | public void disconnect() throws ConnectionErrorException { | |
| 81 | if (this.jmxConnection != null) { | |
| 82 | this.jmxConnection.disconnect(); | |
| 83 | } | |
| 84 | } | |
| 85 | ||
| 86 | /** | |
| 87 | * Check if JMX server is still reachable | |
| 88 | * | |
| 89 | */ | |
| 90 | public boolean isAlive() { | |
| 91 | return this.jmxConnection.isAlive(); | |
| 92 | } | |
| 93 | ||
| 94 | } |
| ... | ...@@ -0,0 +1,43 @@ | |
| 1 | /** | |
| 2 | * PETALS - PETALS Services Platform. | |
| 3 | * Copyright (c) 2005 EBM Websourcing, http://www.ebmwebsourcing.com/ | |
| 4 | * | |
| 5 | * This library is free software; you can redistribute it and/or | |
| 6 | * modify it under the terms of the GNU Lesser General Public | |
| 7 | * License as published by the Free Software Foundation; either | |
| 8 | * version 2.1 of the License, or (at your option) any later version. | |
| 9 | * This library is distributed in the hope that it will be useful, | |
| 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
| 12 | * Lesser General Public License for more details. | |
| 13 | * | |
| 14 | * You should have received a copy of the GNU Lesser General Public | |
| 15 | * License along with this library; if not, write to the Free Software | |
| 16 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
| 17 | * | |
| 18 | */ | |
| 19 | ||
| 20 | package org.ow2.petals.tools.channelclient.jmxclient.exception; | |
| 21 | ||
| 22 | /** | |
| 23 | * This exception is thrown when an error occurs during the connection to the | |
| 24 | * JMX Server. | |
| 25 | * | |
| 26 | * @author mcarpentier - EBM WebSourcing | |
| 27 | */ | |
| 28 | public class ConnectionErrorException extends PetalsJMXClientException { | |
| 29 | ||
| 30 | /** | |
| 31 | * | |
| 32 | */ | |
| 33 | private static final long serialVersionUID = -735371285089299858L; | |
| 34 | ||
| 35 | public ConnectionErrorException(Throwable cause) { | |
| 36 | super(cause); | |
| 37 | } | |
| 38 | ||
| 39 | public ConnectionErrorException(String message, Throwable cause) { | |
| 40 | super(message, cause); | |
| 41 | } | |
| 42 | ||
| 43 | } |
| ... | ...@@ -0,0 +1,204 @@ | |
| 1 | /** | |
| 2 | * PETALS - PETALS Services Platform. | |
| 3 | * Copyright (c) 2008 EBM Websourcing, http://www.ebmwebsourcing.com/ | |
| 4 | * | |
| 5 | * This library is free software; you can redistribute it and/or | |
| 6 | * modify it under the terms of the GNU Lesser General Public | |
| 7 | * License as published by the Free Software Foundation; either | |
| 8 | * version 2.1 of the License, or (at your option) any later version. | |
| 9 | * This library is distributed in the hope that it will be useful, | |
| 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
| 12 | * Lesser General Public License for more details. | |
| 13 | * | |
| 14 | * You should have received a copy of the GNU Lesser General Public | |
| 15 | * License along with this library; if not, write to the Free Software | |
| 16 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
| 17 | * | |
| 18 | */ | |
| 19 | ||
| 20 | package org.ow2.petals.tools.channelclient.jmxclient; | |
| 21 | ||
| 22 | import java.io.File; | |
| 23 | import java.io.IOException; | |
| 24 | import java.util.Hashtable; | |
| 25 | import java.util.List; | |
| 26 | import java.util.Map; | |
| 27 | import java.util.Set; | |
| 28 | ||
| 29 | import javax.management.InstanceNotFoundException; | |
| 30 | import javax.management.ListenerNotFoundException; | |
| 31 | import javax.management.MBeanServerConnection; | |
| 32 | import javax.management.MalformedObjectNameException; | |
| 33 | import javax.management.NotificationFilterSupport; | |
| 34 | import javax.management.NotificationListener; | |
| 35 | import javax.management.ObjectName; | |
| 36 | import javax.security.auth.Subject; | |
| 37 | ||
| 38 | import org.ow2.petals.tools.channelclient.jmxclient.exception.ChannelClientDoesNotExistException; | |
| 39 | import org.ow2.petals.tools.channelclient.jmxclient.exception.ChannelClientServiceErrorException; | |
| 40 | import org.ow2.petals.tools.channelclient.jmxclient.exception.PerformActionErrorException; | |
| 41 | import org.ow2.petals.jmx.api.IPetalsAdminService; | |
| 42 | ||
| 43 | /** | |
| 44 | * Client API of the JMX Sample Client service. | |
| 45 | * | |
| 46 | * @author mcarpentier - EBM WebSourcing | |
| 47 | * | |
| 48 | */ | |
| 49 | public class ChannelClientServiceClient extends ChannelClientAbstractServiceClient implements | |
| 50 | IPetalsAdminService { | |
| 51 | ||
| 52 | public final static String SAMPLECLIENT_JMX_NAME = "ChannelClient"; | |
| 53 | ||
| 54 | public final static String SEND_SYNC = "sendSync"; | |
| 55 | ||
| 56 | public final static String SEND_ASYNC = "sendASync"; | |
| 57 | ||
| 58 | /** | |
| 59 | * Creates a new instance of {@link ChannelClientServiceClient} | |
| 60 | * | |
| 61 | * @param petalsDomain | |
| 62 | * @param beanServerConnection | |
| 63 | * @throws PetalsAdminDoesNotExistException | |
| 64 | * @throws PetalsAdminServiceErrorException | |
| 65 | */ | |
| 66 | public ChannelClientServiceClient(final String petalsDomain, | |
| 67 | final MBeanServerConnection beanServerConnection) | |
| 68 | throws ChannelClientDoesNotExistException, ChannelClientServiceErrorException { | |
| 69 | ||
| 70 | super(petalsDomain, beanServerConnection); | |
| 71 | try { | |
| 72 | Set<ObjectName> objNames; | |
| 73 | ||
| 74 | Hashtable<String, String> attributes = new Hashtable<String, String>(); | |
| 75 | attributes.put(JMX_FIELD_NAME, SAMPLECLIENT_JMX_NAME); | |
| 76 | attributes.put(JMX_FIELD_TYPE, JMX_SERVICE_TYPE); | |
| 77 | ObjectName objName = new ObjectName(petalsDomain, attributes); | |
| 78 | objNames = this.mBeanServerConnection.queryNames(objName, null); | |
| 79 | if (objNames != null && objNames.size() == 1) { | |
| 80 | this.mbeanName = objNames.iterator().next(); | |
| 81 | } else { | |
| 82 | throw new ChannelClientDoesNotExistException("Can't find Sample Client Service"); | |
| 83 | } | |
| 84 | } catch (MalformedObjectNameException e) { | |
| 85 | throw new ChannelClientServiceErrorException(e); | |
| 86 | } catch (IOException e) { | |
| 87 | throw new ChannelClientServiceErrorException(e); | |
| 88 | } | |
| 89 | } | |
| 90 | ||
| 91 | /** | |
| 92 | * Send a message to PEtALS asynchronously. You need a listener to get the | |
| 93 | * response back | |
| 94 | * | |
| 95 | * @param callBackListener | |
| 96 | * a listener to get the response back | |
| 97 | * @param interfaceName | |
| 98 | * @param serviceName | |
| 99 | * @param operationName | |
| 100 | * @param endpointName | |
| 101 | * @param mep | |
| 102 | * @param content | |
| 103 | * @param attachmentFiles | |
| 104 | * @param properties | |
| 105 | * @param subject | |
| 106 | * @throws PerformActionErrorException | |
| 107 | * @throws ChannelClientDoesNotExistException | |
| 108 | */ | |
| 109 | @SuppressWarnings("unchecked") | |
| 110 | public String sendASync(NotificationListener callBackListener, final String interfaceName, | |
| 111 | final String serviceName, final String operationName, final String endpointName, | |
| 112 | final String mep, final String content, final List<File> attachmentFiles, | |
| 113 | final Map<String, String> properties, final Subject subject) | |
| 114 | throws PerformActionErrorException, ChannelClientDoesNotExistException { | |
| 115 | try { | |
| 116 | ||
| 117 | NotificationFilterSupport myFilter = new NotificationFilterSupport(); | |
| 118 | ||
| 119 | this.mBeanServerConnection.addNotificationListener(new ObjectName( | |
| 120 | "Petals:name="+SAMPLECLIENT_JMX_NAME+",type=service"), callBackListener, null, null); | |
| 121 | ||
| 122 | Object[] objectsLoad = new Object[] { interfaceName, serviceName, operationName, | |
| 123 | endpointName, mep, content, attachmentFiles, properties, subject }; | |
| 124 | String[] stringsLoad = new String[] { "java.lang.String", "java.lang.String", | |
| 125 | "java.lang.String", "java.lang.String", "java.lang.String", "java.lang.String", | |
| 126 | "java.util.List", "java.util.Map", "javax.security.auth.Subject" }; | |
| 127 | ||
| 128 | String petalsMeId = (String) this.performAction(SEND_ASYNC, objectsLoad, stringsLoad); | |
| 129 | return petalsMeId; | |
| 130 | ||
| 131 | } catch (InstanceNotFoundException e) { | |
| 132 | throw new ChannelClientDoesNotExistException("Can't find sampleclient bean", e); | |
| 133 | } catch (MalformedObjectNameException e) { | |
| 134 | throw new ChannelClientDoesNotExistException(e); | |
| 135 | } catch (IOException e) { | |
| 136 | throw new ChannelClientDoesNotExistException(e); | |
| 137 | } | |
| 138 | ||
| 139 | } | |
| 140 | ||
| 141 | /** | |
| 142 | * Remove a listener from JMX server ; strongly recommended after an asynch | |
| 143 | * call. | |
| 144 | * | |
| 145 | * @param listener | |
| 146 | * @throws ChannelClientDoesNotExistException | |
| 147 | */ | |
| 148 | public void removeNotificationListener(NotificationListener listener) | |
| 149 | throws ChannelClientDoesNotExistException { | |
| 150 | try { | |
| 151 | ||
| 152 | this.mBeanServerConnection.removeNotificationListener(new ObjectName( | |
| 153 | "Petals:name=SampleClient,type=service"), listener); | |
| 154 | ||
| 155 | } catch (ListenerNotFoundException e) { | |
| 156 | throw new ChannelClientDoesNotExistException(e); | |
| 157 | } catch (NullPointerException e) { | |
| 158 | throw new ChannelClientDoesNotExistException(e); | |
| 159 | } catch (InstanceNotFoundException e) { | |
| 160 | throw new ChannelClientDoesNotExistException(e); | |
| 161 | } catch (MalformedObjectNameException e) { | |
| 162 | throw new ChannelClientDoesNotExistException(e); | |
| 163 | } catch (IOException e) { | |
| 164 | throw new ChannelClientDoesNotExistException(e); | |
| 165 | } | |
| 166 | } | |
| 167 | ||
| 168 | /** | |
| 169 | * Send a message to PEtALS synchronously | |
| 170 | * | |
| 171 | * @param interfaceName | |
| 172 | * @param serviceName | |
| 173 | * @param operationName | |
| 174 | * @param endpointName | |
| 175 | * @param mep | |
| 176 | * @param content | |
| 177 | * @param attachmentFiles | |
| 178 | * @param properties | |
| 179 | * @param subject | |
| 180 | * @throws PerformActionErrorException | |
| 181 | */ | |
| 182 | @SuppressWarnings("unchecked") | |
| 183 | public Map<String, Object> sendSync(final String interfaceName, final String serviceName, | |
| 184 | final String operationName, final String endpointName, final String mep, | |
| 185 | final String content, final List<File> attachmentFiles, | |
| 186 | final Map<String, String> properties, final Subject subject) | |
| 187 | throws PerformActionErrorException { | |
| 188 | ||
| 189 | Object[] objectsLoad = new Object[] { interfaceName, serviceName, operationName, | |
| 190 | endpointName, mep, content, attachmentFiles, properties, subject }; | |
| 191 | String[] stringsLoad = new String[] { "java.lang.String", "java.lang.String", | |
| 192 | "java.lang.String", "java.lang.String", "java.lang.String", "java.lang.String", | |
| 193 | "java.util.List", "java.util.Map", "javax.security.auth.Subject" }; | |
| 194 | ||
| 195 | Object result = this.performAction(SEND_SYNC, objectsLoad, stringsLoad); | |
| 196 | if (!(result instanceof Map)) { | |
| 197 | throw new PerformActionErrorException("Unexpected result type"); | |
| 198 | } else { | |
| 199 | return (Map<String, Object>) result; | |
| 200 | } | |
| 201 | ||
| 202 | } | |
| 203 | ||
| 204 | } |
| ... | ...@@ -0,0 +1,504 @@ | |
| 1 | GNU LESSER GENERAL PUBLIC LICENSE | |
| 2 | Version 2.1, February 1999 | |
| 3 | ||
| 4 | Copyright (C) 1991, 1999 Free Software Foundation, Inc. | |
| 5 | 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA | |
| 6 | Everyone is permitted to copy and distribute verbatim copies | |
| 7 | of this license document, but changing it is not allowed. | |
| 8 | ||
| 9 | [This is the first released version of the Lesser GPL. It also counts | |
| 10 | as the successor of the GNU Library Public License, version 2, hence | |
| 11 | the version number 2.1.] | |
| 12 | ||
| 13 | Preamble | |
| 14 | ||
| 15 | The licenses for most software are designed to take away your | |
| 16 | freedom to share and change it. By contrast, the GNU General Public | |
| 17 | Licenses are intended to guarantee your freedom to share and change | |
| 18 | free software--to make sure the software is free for all its users. | |
| 19 | ||
| 20 | This license, the Lesser General Public License, applies to some | |
| 21 | specially designated software packages--typically libraries--of the | |
| 22 | Free Software Foundation and other authors who decide to use it. You | |
| 23 | can use it too, but we suggest you first think carefully about whether | |
| 24 | this license or the ordinary General Public License is the better | |
| 25 | strategy to use in any particular case, based on the explanations below. | |
| 26 | ||
| 27 | When we speak of free software, we are referring to freedom of use, | |
| 28 | not price. Our General Public Licenses are designed to make sure that | |
| 29 | you have the freedom to distribute copies of free software (and charge | |
| 30 | for this service if you wish); that you receive source code or can get | |
| 31 | it if you want it; that you can change the software and use pieces of | |
| 32 | it in new free programs; and that you are informed that you can do | |
| 33 | these things. | |
| 34 | ||
| 35 | To protect your rights, we need to make restrictions that forbid | |
| 36 | distributors to deny you these rights or to ask you to surrender these | |
| 37 | rights. These restrictions translate to certain responsibilities for | |
| 38 | you if you distribute copies of the library or if you modify it. | |
| 39 | ||
| 40 | For example, if you distribute copies of the library, whether gratis | |
| 41 | or for a fee, you must give the recipients all the rights that we gave | |
| 42 | you. You must make sure that they, too, receive or can get the source | |
| 43 | code. If you link other code with the library, you must provide | |
| 44 | complete object files to the recipients, so that they can relink them | |
| 45 | with the library after making changes to the library and recompiling | |
| 46 | it. And you must show them these terms so they know their rights. | |
| 47 | ||
| 48 | We protect your rights with a two-step method: (1) we copyright the | |
| 49 | library, and (2) we offer you this license, which gives you legal | |
| 50 | permission to copy, distribute and/or modify the library. | |
| 51 | ||
| 52 | To protect each distributor, we want to make it very clear that | |
| 53 | there is no warranty for the free library. Also, if the library is | |
| 54 | modified by someone else and passed on, the recipients should know | |
| 55 | that what they have is not the original version, so that the original | |
| 56 | author's reputation will not be affected by problems that might be | |
| 57 | introduced by others. | |
| 58 | ||
| 59 | Finally, software patents pose a constant threat to the existence of | |
| 60 | any free program. We wish to make sure that a company cannot | |
| 61 | effectively restrict the users of a free program by obtaining a | |
| 62 | restrictive license from a patent holder. Therefore, we insist that | |
| 63 | any patent license obtained for a version of the library must be | |
| 64 | consistent with the full freedom of use specified in this license. | |
| 65 | ||
| 66 | Most GNU software, including some libraries, is covered by the | |
| 67 | ordinary GNU General Public License. This license, the GNU Lesser | |
| 68 | General Public License, applies to certain designated libraries, and | |
| 69 | is quite different from the ordinary General Public License. We use | |
| 70 | this license for certain libraries in order to permit linking those | |
| 71 | libraries into non-free programs. | |
| 72 | ||
| 73 | When a program is linked with a library, whether statically or using | |
| 74 | a shared library, the combination of the two is legally speaking a | |
| 75 | combined work, a derivative of the original library. The ordinary | |
| 76 | General Public License therefore permits such linking only if the | |
| 77 | entire combination fits its criteria of freedom. The Lesser General | |
| 78 | Public License permits more lax criteria for linking other code with | |
| 79 | the library. | |
| 80 | ||
| 81 | We call this license the "Lesser" General Public License because it | |
| 82 | does Less to protect the user's freedom than the ordinary General | |
| 83 | Public License. It also provides other free software developers Less | |
| 84 | of an advantage over competing non-free programs. These disadvantages | |
| 85 | are the reason we use the ordinary General Public License for many | |
| 86 | libraries. However, the Lesser license provides advantages in certain | |
| 87 | special circumstances. | |
| 88 | ||
| 89 | For example, on rare occasions, there may be a special need to | |
| 90 | encourage the widest possible use of a certain library, so that it becomes | |
| 91 | a de-facto standard. To achieve this, non-free programs must be | |
| 92 | allowed to use the library. A more frequent case is that a free | |
| 93 | library does the same job as widely used non-free libraries. In this | |
| 94 | case, there is little to gain by limiting the free library to free | |
| 95 | software only, so we use the Lesser General Public License. | |
| 96 | ||
| 97 | In other cases, permission to use a particular library in non-free | |
| 98 | programs enables a greater number of people to use a large body of | |
| 99 | free software. For example, permission to use the GNU C Library in | |
| 100 | non-free programs enables many more people to use the whole GNU | |
| 101 | operating system, as well as its variant, the GNU/Linux operating | |
| 102 | system. | |
| 103 | ||
| 104 | Although the Lesser General Public License is Less protective of the | |
| 105 | users' freedom, it does ensure that the user of a program that is | |
| 106 | linked with the Library has the freedom and the wherewithal to run | |
| 107 | that program using a modified version of the Library. | |
| 108 | ||
| 109 | The precise terms and conditions for copying, distribution and | |
| 110 | modification follow. Pay close attention to the difference between a | |
| 111 | "work based on the library" and a "work that uses the library". The | |
| 112 | former contains code derived from the library, whereas the latter must | |
| 113 | be combined with the library in order to run. | |
| 114 | ||
| 115 | GNU LESSER GENERAL PUBLIC LICENSE | |
| 116 | TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION | |
| 117 | ||
| 118 | 0. This License Agreement applies to any software library or other | |
| 119 | program which contains a notice placed by the copyright holder or | |
| 120 | other authorized party saying it may be distributed under the terms of | |
| 121 | this Lesser General Public License (also called "this License"). | |
| 122 | Each licensee is addressed as "you". | |
| 123 | ||
| 124 | A "library" means a collection of software functions and/or data | |
| 125 | prepared so as to be conveniently linked with application programs | |
| 126 | (which use some of those functions and data) to form executables. | |
| 127 | ||
| 128 | The "Library", below, refers to any such software library or work | |
| 129 | which has been distributed under these terms. A "work based on the | |
| 130 | Library" means either the Library or any derivative work under | |
| 131 | copyright law: that is to say, a work containing the Library or a | |
| 132 | portion of it, either verbatim or with modifications and/or translated | |
| 133 | straightforwardly into another language. (Hereinafter, translation is | |
| 134 | included without limitation in the term "modification".) | |
| 135 | ||
| 136 | "Source code" for a work means the preferred form of the work for | |
| 137 | making modifications to it. For a library, complete source code means | |
| 138 | all the source code for all modules it contains, plus any associated | |
| 139 | interface definition files, plus the scripts used to control compilation | |
| 140 | and installation of the library. | |
| 141 | ||
| 142 | Activities other than copying, distribution and modification are not | |
| 143 | covered by this License; they are outside its scope. The act of | |
| 144 | running a program using the Library is not restricted, and output from | |
| 145 | such a program is covered only if its contents constitute a work based | |
| 146 | on the Library (independent of the use of the Library in a tool for | |
| 147 | writing it). Whether that is true depends on what the Library does | |
| 148 | and what the program that uses the Library does. | |
| 149 | ||
| 150 | 1. You may copy and distribute verbatim copies of the Library's | |
| 151 | complete source code as you receive it, in any medium, provided that | |
| 152 | you conspicuously and appropriately publish on each copy an | |
| 153 | appropriate copyright notice and disclaimer of warranty; keep intact | |
| 154 | all the notices that refer to this License and to the absence of any | |
| 155 | warranty; and distribute a copy of this License along with the | |
| 156 | Library. | |
| 157 | ||
| 158 | You may charge a fee for the physical act of transferring a copy, | |
| 159 | and you may at your option offer warranty protection in exchange for a | |
| 160 | fee. | |
| 161 | ||
| 162 | 2. You may modify your copy or copies of the Library or any portion | |
| 163 | of it, thus forming a work based on the Library, and copy and | |
| 164 | distribute such modifications or work under the terms of Section 1 | |
| 165 | above, provided that you also meet all of these conditions: | |
| 166 | ||
| 167 | a) The modified work must itself be a software library. | |
| 168 | ||
| 169 | b) You must cause the files modified to carry prominent notices | |
| 170 | stating that you changed the files and the date of any change. | |
| 171 | ||
| 172 | c) You must cause the whole of the work to be licensed at no | |
| 173 | charge to all third parties under the terms of this License. | |
| 174 | ||
| 175 | d) If a facility in the modified Library refers to a function or a | |
| 176 | table of data to be supplied by an application program that uses | |
| 177 | the facility, other than as an argument passed when the facility | |
| 178 | is invoked, then you must make a good faith effort to ensure that, | |
| 179 | in the event an application does not supply such function or | |
| 180 | table, the facility still operates, and performs whatever part of | |
| 181 | its purpose remains meaningful. | |
| 182 | ||
| 183 | (For example, a function in a library to compute square roots has | |
| 184 | a purpose that is entirely well-defined independent of the | |
| 185 | application. Therefore, Subsection 2d requires that any | |
| 186 | application-supplied function or table used by this function must | |
| 1 |