xlawrence 2004/12/22 10:22:49 CET
Added files:
src/java/org/jahia/suite/calendar/util JORAMAdmin.java
Log:
Moved to utility package
Revision Changes Path
1.1 +109 -0
uwcal_JSR168/src/java/org/jahia/suite/calendar/util/JORAMAdmin.java (new)
http://jahia.mine.nu:8080/cgi-bin/cvsweb.cgi/uwcal_JSR168/src/java/org/jahia/suite/calendar/util/JORAMAdmin.java?rev=1.1&content-type=text/plain
Index: JORAMAdmin.java
====================================================================
/*
* ____.
* __/\ ______| |__/\. _______
* __ .____| | \ | +----+ \
* _______| /--| | | - \ _ | : - \_________
* \\______: :---| : : | : | \________>
* |__\---\_____________:______: :____|____:_____\
* /_____|
*
* . . . i n j a h i a w e t r u s t . . .
*
*
*
* ----- BEGIN LICENSE BLOCK -----
* Version: JCSL 1.0
*
* The contents of this file are subject to the Jahia Community Source License
* 1.0 or later (the "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License at
* http://www.jahia.org/license
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the rights, obligations and limitations governing use of the contents
* of the file. The Original and Upgraded Code is the Jahia CMS and Portal
* Server. The developer of the Original and Upgraded Code is JAHIA Ltd. JAHIA
* Ltd. owns the copyrights in the portions it created. All Rights Reserved.
*
* The Shared Modifications are Jahia View Helper.
*
* The Developer of the Shared Modifications is Jahia Solution S�rl.
* Portions created by the Initial Developer are Copyright (C) 2002 by the
* Initial Developer. All Rights Reserved.
*
* ----- END LICENSE BLOCK -----
*/
package org.jahia.suite.calendar.util;
import org.objectweb.joram.client.jms.admin.AdminModule;
import org.objectweb.joram.client.jms.admin.User;
import org.objectweb.joram.client.jms.Queue;
import org.objectweb.joram.client.jms.tcp.QueueTcpConnectionFactory;
import org.apache.log4j.Logger;
import javax.naming.Context;
import java.util.Hashtable;
import org.jahia.suite.calendar.calServer.JMSAgent;
/**
* Simple JORAM configuration program to create needed JMS ressources on the
* JMS server.
*
* @author Xavier Lawrence
*/
public class JORAMAdmin {
static Logger log = Logger.getLogger(JORAMAdmin.class);
public void start() throws Exception {
log.info("JORAM Server administration...");
AdminModule.connect("root", "root", 60);
// Create only the 1 Queue needed
Queue calQueue = Queue.create(0);
log.info("Queue created");
// Create the 2 users
User calServer = User.create("calServer", "calServer", 0);
User syncServer = User.create("syncServer", "syncServer", 0);
javax.jms.QueueConnectionFactory cnxFact =
QueueTcpConnectionFactory.create("localhost", 16010);
log.info("QueueConnectionFactory created");
// Setting reading and writing access
calQueue.setReader(calServer);
calQueue.setWriter(syncServer);
// Create the JNDI context
Hashtable context = new Hashtable(0);
context.put(Context.INITIAL_CONTEXT_FACTORY,
"fr.dyade.aaa.jndi2.client.NamingContextFactory");
context.put("java.naming.factory.host", "localhost");
context.put("java.naming.factory.port", "16400");
Context jndiCtx = new javax.naming.InitialContext(context);
jndiCtx.bind(JMSAgent.CAL_SERVER_QUEUE, calQueue);
jndiCtx.bind(JMSAgent.CONN_FACTORY, cnxFact);
jndiCtx.close();
log.info("Ressources bound into JNDI");
AdminModule.disconnect();
log.info("Admin closed.");
}
/**
* Start the program
* @param args the command line arguments
*/
public static void main(String[] args) throws Exception {
JORAMAdmin app = new JORAMAdmin();
app.start();
}
}