Methods Summary |
---|
public void | create()
try
{
for (String resource : deployDirsByResource)
{
Enumeration<URL> urls = classLoader.getResources(resource);
while (urls.hasMoreElements())
{
URL url = urls.nextElement();
URL deployUrl = getDeployDirFromResource(url, resource);
deployDirs.add(deployUrl);
}
}
for (URL url : deployDirs)
{
File dir = new File(url.toURI());
for (File fp : dir.listFiles())
{
if (fp.isDirectory())
{
archives.add(fp.toURL());
continue;
}
try
{
ZipFile zip = new ZipFile(fp);
zip.entries();
zip.close();
archives.add(fp.toURL());
}
catch (IOException e)
{
}
}
}
for (String resource : archivesByResource)
{
Enumeration<URL> urls = classLoader.getResources(resource);
while (urls.hasMoreElements())
{
URL url = urls.nextElement();
URL archiveUrl = getContainingUrlFromResource(url, resource);
archives.add(archiveUrl);
}
}
if (defaultPersistenceProperties == null)
{
InputStream is = Thread.currentThread().getContextClassLoader().getResourceAsStream("default.persistence.properties");
if (is == null) throw new RuntimeException("cannot find default.persistence.properties");
Properties defaults = new Properties();
defaults.load(is);
defaultPersistenceProperties = defaults;
}
for (URL archive : archives)
{
DeployerUnit du = new DeployerUnit(classLoader, archive, defaultPersistenceProperties, jndiProperties);
EJB3StandaloneDeployment deployment = new EJB3StandaloneDeployment(du, kernel, mbeanServer);
deployments.add(deployment);
deployment.create();
}
}
catch (Exception e)
{
e.printStackTrace();
throw e;
}
|
public void | destroy()
for (EJB3StandaloneDeployment deployment : deployments)
{
deployment.destroy();
}
|
public java.util.Set | getArchives()A set of URLs of jar archives to search for annotated EJB classes
return archives;
|
public java.util.Set | getArchivesByResource()All strings in this set will be used with ClassLoader.getResources()
All URLs returned will be used to search for annotated classes.
return archivesByResource;
|
public java.lang.ClassLoader | getClassLoader()
return classLoader;
|
public static java.net.URL | getContainingUrlFromResource(java.net.URL url, java.lang.String resource)
if (url.getProtocol().equals("jar"))
{
URL jarURL = url;
URLConnection urlConn = jarURL.openConnection();
JarURLConnection jarConn = (JarURLConnection) urlConn;
// Extract the archive to dest/jarName-contents/archive
String parentArchiveName = jarConn.getJarFile().getName();
File fp = new File(parentArchiveName);
return fp.toURL();
}
// its a file
String base = url.toString();
int idx = base.lastIndexOf(resource);
base = base.substring(0, idx);
return new URL(base);
|
public java.util.Map | getDefaultPersistenceProperties()
return defaultPersistenceProperties;
|
public static java.net.URL | getDeployDirFromResource(java.net.URL url, java.lang.String resource)
if (url.getProtocol().equals("jar"))
{
URL jarURL = url;
URLConnection urlConn = jarURL.openConnection();
JarURLConnection jarConn = (JarURLConnection) urlConn;
// Extract the archive to dest/jarName-contents/archive
String parentArchiveName = jarConn.getJarFile().getName();
File fp = new File(parentArchiveName);
return fp.getParentFile().toURL();
}
// its a file
String base = url.toString();
int idx = base.lastIndexOf(resource);
base = base.substring(0, idx);
File fp = new File(base);
return fp.getParentFile().toURL();
|
public java.util.Set | getDeployDirs()Set of directories where there are jar files and directories
The deployer will search through all archives and directories for
annotated classes
return deployDirs;
|
public java.util.Set | getDeployDirsByResource()All strings in this set will be used with ClassLoader.getResources().
All URLs returned will be create a set of deploy directories that will
be used to find archives and directories that will be searched for annotated classes
return deployDirsByResource;
|
public java.util.List | getDeployments()Returns a list of deployments found in this
return deployments;
|
public java.util.Hashtable | getJndiProperties()
return jndiProperties;
|
public org.jboss.kernel.Kernel | getKernel()
return kernel;
|
public javax.management.MBeanServer | getMbeanServer()This is used by deployer for @Service beans that have @Management interfaces
return mbeanServer;
|
private void | loadMbeanServer()
if (mbeanServer == null)
{
ControllerContext context = kernel.getController().getInstalledContext("MBeanServer");
if (context != null)
mbeanServer = (MBeanServer) context.getTarget();
else
{
ArrayList servers = MBeanServerFactory.findMBeanServer(null);
if (servers.size() == 0)
mbeanServer = MBeanServerFactory.createMBeanServer();
else
mbeanServer = (MBeanServer)MBeanServerFactory.findMBeanServer(null).get(0);
}
}
|
private void | lookup(java.lang.String name)
System.out.println("lookup " + name);
try {
InitialContext jndiContext = new InitialContext();
NamingEnumeration names = jndiContext.list(name);
if (names != null){
while (names.hasMore()){
System.out.println(" " + names.next());
}
}
} catch (Exception e){
}
|
public void | setArchives(java.util.Set archives)
new Exception().printStackTrace();
this.archives = archives;
|
public void | setArchivesByResource(java.util.Set archivesByResource)
this.archivesByResource = archivesByResource;
|
public void | setClassLoader(java.lang.ClassLoader classLoader)You can set the classloader that will be used
this.classLoader = classLoader;
|
public void | setDefaultPersistenceProperties(java.util.Map defaultPersistenceProperties)If you do not specifiy the default persistence properties, the resource
"default.persistence.properties" will be search for in your classpath
this.defaultPersistenceProperties = defaultPersistenceProperties;
|
public void | setDeployDirs(java.util.Set deployDirs)
this.deployDirs = deployDirs;
|
public void | setDeployDirsByResource(java.util.Set deployDirsByResource)
this.deployDirsByResource = deployDirsByResource;
|
public void | setDeployments(java.util.List deployments)
this.deployments = deployments;
|
public void | setJndiProperties(java.util.Hashtable jndiProperties)
this.jndiProperties = jndiProperties;
|
public void | setKernel(org.jboss.kernel.Kernel kernel)
this.kernel = kernel;
|
public void | setMbeanServer(javax.management.MBeanServer mbeanServer)
this.mbeanServer = mbeanServer;
|
public void | start()
try
{
loadMbeanServer();
for (EJB3StandaloneDeployment deployment : deployments)
{
if (deployment.getMbeanServer() == null)
{
deployment.setMbeanServer(mbeanServer);
}
deployment.start();
lookup("");
}
}
catch (Exception e)
{
e.printStackTrace();
throw e;
}
|
public void | stop()
for (EJB3StandaloneDeployment deployment : deployments)
{
deployment.stop();
}
|