Class AdminHelper
- java.lang.Object
-
- org.objectweb.joram.tools.rest.admin.AdminHelper
-
public final class AdminHelper extends Object
Creates a JMS administration point through Rest API. Be careful, currently only the local broker can be administered. this could be easily changed by specifying a connection factory.
-
-
Field Summary
Fields Modifier and Type Field Description static StringBUNDLE_JMS_PASSstatic StringBUNDLE_JMS_USERstatic StringBUNDLE_JNDI_FACTORY_HOST_PROPstatic StringBUNDLE_JNDI_FACTORY_INITIAL_PROPstatic StringBUNDLE_JNDI_FACTORY_PORT_PROPstatic StringBUNDLE_REST_ADMIN_IP_ALLOWEDstatic StringBUNDLE_REST_ADMIN_PASSstatic StringBUNDLE_REST_ADMIN_ROOTprivate org.osgi.framework.BundleContextbundleContextprivate jakarta.jms.Connectioncnxprivate static booleanDEBUGprivate static AdminHelperhelperprivate InitialContextictxprivate IPFilteripfilter(package private) StringjmsRootPassword(package private) StringjmsRootUserprivate PropertiesjndiPropsprivate JoramAdminjoramAdminprivate static Loggerloggerprivate StringrestAdminIPAllowedprivate StringrestAdminPassprivate StringrestAdminRoot
-
Constructor Summary
Constructors Modifier Constructor Description privateAdminHelper()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanauthenticationRequired()booleancheckIpAllowed(String addr)Check if the addr is authorized (all local address is authorized).jakarta.jms.ConnectionFactorycreatelocalConnectionFactory()DestinationcreateQueue(int serverId, String name)DestinationcreateQueue(int serverId, String name, String className, Properties props)DestinationcreateQueue(String name)jakarta.jms.ConnectionFactorycreateTcpConnectionFactory()jakarta.jms.ConnectionFactorycreateTcpConnectionFactory(String host, int port, String reliableClass)DestinationcreateTopic(int serverId, String name)DestinationcreateTopic(int serverId, String name, String className, Properties props)DestinationcreateTopic(String name)UsercreateUser(String name, String password)UsercreateUser(String name, String password, int serverId, String identityClassName, Properties props)voiddeleteQueue(int serverId, String name)voiddeleteTopic(int serverId, String name)voiddeleteUser(String name, String password, int serverId)static AdminHelpergetInstance()JoramAdmingetJoramAdmin()intgetLocalServerId()ArrayList<Destination>getQueueNames(int serverId)StringgetRestAdminIPAllowed()StringgetRestAdminPass()StringgetRestAdminRoot()ArrayList<Destination>getTopicNames(int serverId)voidinit(org.osgi.framework.BundleContext bundleContext)voidrebind(String name, jakarta.jms.ConnectionFactory cf)voidrebind(String name, Destination dest)voidstartJoramAdmin(String name)voidstopJoramAdmin()voidunbind(String name)
-
-
-
Field Detail
-
logger
private static final Logger logger
-
DEBUG
private static final boolean DEBUG
-
BUNDLE_JNDI_FACTORY_INITIAL_PROP
public static final String BUNDLE_JNDI_FACTORY_INITIAL_PROP
- See Also:
- Constant Field Values
-
BUNDLE_JNDI_FACTORY_HOST_PROP
public static final String BUNDLE_JNDI_FACTORY_HOST_PROP
- See Also:
- Constant Field Values
-
BUNDLE_JNDI_FACTORY_PORT_PROP
public static final String BUNDLE_JNDI_FACTORY_PORT_PROP
- See Also:
- Constant Field Values
-
BUNDLE_REST_ADMIN_ROOT
public static final String BUNDLE_REST_ADMIN_ROOT
- See Also:
- Constant Field Values
-
BUNDLE_REST_ADMIN_PASS
public static final String BUNDLE_REST_ADMIN_PASS
- See Also:
- Constant Field Values
-
BUNDLE_REST_ADMIN_IP_ALLOWED
public static final String BUNDLE_REST_ADMIN_IP_ALLOWED
- See Also:
- Constant Field Values
-
BUNDLE_JMS_USER
public static final String BUNDLE_JMS_USER
- See Also:
- Constant Field Values
-
BUNDLE_JMS_PASS
public static final String BUNDLE_JMS_PASS
- See Also:
- Constant Field Values
-
helper
private static AdminHelper helper
-
ictx
private InitialContext ictx
-
bundleContext
private org.osgi.framework.BundleContext bundleContext
-
jndiProps
private Properties jndiProps
-
joramAdmin
private JoramAdmin joramAdmin
-
cnx
private jakarta.jms.Connection cnx
-
restAdminRoot
private String restAdminRoot
-
restAdminPass
private String restAdminPass
-
restAdminIPAllowed
private String restAdminIPAllowed
-
ipfilter
private IPFilter ipfilter
-
jmsRootUser
String jmsRootUser
-
jmsRootPassword
String jmsRootPassword
-
-
Method Detail
-
getInstance
public static AdminHelper getInstance()
-
getRestAdminRoot
public String getRestAdminRoot()
- Returns:
- the restAdminRoot
-
getRestAdminPass
public String getRestAdminPass()
- Returns:
- the restAdminPass
-
getRestAdminIPAllowed
public String getRestAdminIPAllowed()
- Returns:
- the restAdminIPAllowed
-
checkIpAllowed
public boolean checkIpAllowed(String addr)
Check if the addr is authorized (all local address is authorized).- Parameters:
addr- The ip address to check- Returns:
- true if authorized
- Throws:
UnknownHostExceptionSocketException
-
authenticationRequired
public boolean authenticationRequired()
-
startJoramAdmin
public void startJoramAdmin(String name) throws ConnectException, AdminException, jakarta.jms.JMSException
- Throws:
ConnectExceptionAdminExceptionjakarta.jms.JMSException
-
stopJoramAdmin
public void stopJoramAdmin()
-
getJoramAdmin
public JoramAdmin getJoramAdmin()
-
init
public void init(org.osgi.framework.BundleContext bundleContext) throws Exception- Throws:
Exception
-
getQueueNames
public ArrayList<Destination> getQueueNames(int serverId) throws ConnectException, AdminException
- Throws:
ConnectExceptionAdminException
-
createQueue
public Destination createQueue(String name) throws ConnectException, AdminException
- Throws:
ConnectExceptionAdminException
-
createQueue
public Destination createQueue(int serverId, String name) throws ConnectException, AdminException
- Throws:
ConnectExceptionAdminException
-
createQueue
public Destination createQueue(int serverId, String name, String className, Properties props) throws ConnectException, AdminException
- Throws:
ConnectExceptionAdminException
-
deleteQueue
public void deleteQueue(int serverId, String name) throws ConnectException, AdminException, jakarta.jms.JMSException- Throws:
ConnectExceptionAdminExceptionjakarta.jms.JMSException
-
getTopicNames
public ArrayList<Destination> getTopicNames(int serverId) throws ConnectException, AdminException
- Throws:
ConnectExceptionAdminException
-
createTopic
public Destination createTopic(String name) throws ConnectException, AdminException
- Throws:
ConnectExceptionAdminException
-
createTopic
public Destination createTopic(int serverId, String name) throws ConnectException, AdminException
- Throws:
ConnectExceptionAdminException
-
createTopic
public Destination createTopic(int serverId, String name, String className, Properties props) throws ConnectException, AdminException
- Throws:
ConnectExceptionAdminException
-
deleteTopic
public void deleteTopic(int serverId, String name) throws ConnectException, AdminException, jakarta.jms.JMSException- Throws:
ConnectExceptionAdminExceptionjakarta.jms.JMSException
-
createUser
public User createUser(String name, String password) throws ConnectException, AdminException
- Throws:
ConnectExceptionAdminException
-
createUser
public User createUser(String name, String password, int serverId, String identityClassName, Properties props) throws ConnectException, AdminException
- Throws:
ConnectExceptionAdminException
-
deleteUser
public void deleteUser(String name, String password, int serverId) throws ConnectException, AdminException
- Throws:
ConnectExceptionAdminException
-
createTcpConnectionFactory
public jakarta.jms.ConnectionFactory createTcpConnectionFactory()
-
createTcpConnectionFactory
public jakarta.jms.ConnectionFactory createTcpConnectionFactory(String host, int port, String reliableClass)
-
createlocalConnectionFactory
public jakarta.jms.ConnectionFactory createlocalConnectionFactory()
-
rebind
public void rebind(String name, Destination dest) throws NamingException
- Throws:
NamingException
-
rebind
public void rebind(String name, jakarta.jms.ConnectionFactory cf) throws NamingException
- Throws:
NamingException
-
unbind
public void unbind(String name) throws NamingException
- Throws:
NamingException
-
getLocalServerId
public int getLocalServerId() throws ConnectException, AdminException- Throws:
ConnectExceptionAdminException
-
-