Update of /cvsroot/ejtools/applications/deployment/src/main/net/sourceforge/ejtools/deploy/model
In directory usw-pr-cvs1:/tmp/cvs-serv19144/src/main/net/sourceforge/ejtools/deploy/model
Added Files:
FactoryManagerService.java FactoryManagerServiceProvider.java
Log Message:
Initial Import
--- NEW FILE: FactoryManagerService.java ---
package net.sourceforge.ejtools.deploy.model;
import java.util.Set;
import java.util.Iterator;
import javax.management.Attribute;
import javax.management.MBeanInfo;
import javax.management.ObjectName;
import javax.management.QueryExp;
import javax.naming.InitialContext;
import javax.rmi.PortableRemoteObject;
import org.jboss.jmx.adaptor.interfaces.Adaptor;
import org.jboss.jmx.adaptor.interfaces.AdaptorHome;
/**
* Description of the Class
*
* @author letiembl
* @created 13 décembre 2001
*/
public interface FactoryManagerService
{
public void loadFactories();
public Iterator listFactories();
}
--- NEW FILE: FactoryManagerServiceProvider.java ---
package net.sourceforge.ejtools.deploy.model;
import java.beans.beancontext.BeanContextServiceProvider;
import java.beans.beancontext.BeanContextServices;
import java.beans.beancontext.BeanContextServicesSupport;
import java.util.Iterator;
import java.util.Vector;
import java.net.URLClassLoader;
import java.net.URL;
import java.net.JarURLConnection;
import java.util.jar.Attributes;
import javax.enterprise.deploy.spi.factories.DeploymentFactoryManager;
/**
* Description of the Class
*
* @author letiembl
* @created 13 décembre 2001
*/
public class FactoryManagerServiceProvider extends BeanContextServicesSupport implements BeanContextServiceProvider, FactoryManagerService
{
protected final static String TAG = "J2EE-DeploymentFactoryManager-Implementation-Class";
protected Vector managers = new Vector();
public void loadFactories() {
try {
// Find list of managers
URL[] urls = ((URLClassLoader) Thread.currentThread().getContextClassLoader()).getURLs();
for (int i = 0; i < urls.length; i++) {
if (urls[i].getFile().endsWith(".jar")) {
Attributes attr = ((JarURLConnection) new URL("jar:" + urls[i] + "!/").openConnection()).getMainAttributes();
String factoryClass = attr.getValue(FactoryManagerServiceProvider.TAG);
System.out.println("URL " + urls[i] + " " + factoryClass);
if (factoryClass != null) {
try {
DeploymentFactoryManager manager = (DeploymentFactoryManager) Class.forName(factoryClass).newInstance();
}catch(Exception e){
e.printStackTrace();
}
}
}
}
}catch(Exception e){
e.printStackTrace();
}
Iterator it = listFactories();
while(it.hasNext()) {
DeploymentFactoryManager manager = (DeploymentFactoryManager) it.next();
System.out.println(manager.toString());
System.out.println(manager.getDeploymentFactories());
}
}
public Iterator listFactories() {
return managers.iterator();
}
/**
* Getter for the currentServiceSelectors attribute
*
* @param bcs Description of Parameter
* @param serviceClass Description of Parameter
* @return The value
*/
public Iterator getCurrentServiceSelectors(BeanContextServices bcs, java.lang.Class serviceClass)
{
return (new Vector()).iterator();
}
/**
* Getter for the service attribute
*
* @param bcs Description of Parameter
* @param requestor Description of Parameter
* @param serviceClass Description of Parameter
* @param serviceSelector Description of Parameter
* @return The value
*/
public Object getService(BeanContextServices bcs, java.lang.Object requestor, java.lang.Class serviceClass, java.lang.Object serviceSelector)
{
return this;
}
/**
* Description of the Method
*
* @param bcs Description of Parameter
* @param requestor Description of Parameter
* @param service Description of Parameter
*/
public void releaseService(BeanContextServices bcs, java.lang.Object requestor, java.lang.Object service) { }
/** Description of the Method */
protected void initializeBeanContextResources()
{
((BeanContextServices) getBeanContext()).addService(FactoryManagerService.class, this);
}
protected void releaseBeanContextResources() {
((BeanContextServices) getBeanContext()).revokeService(FactoryManagerService.class, this, true);
}
}
|