Methods Summary |
---|
protected java.lang.ClassLoader | createClassLoader(java.net.URL jar)Create a classloader that load the service.
URL[] classpath = null;
try {
classpath = AddonClassPath.getClassPath(jar,
getInstallRoot().getCanonicalPath(), getLogger());
} catch (Exception e) {
throw new AddonFatalException(e);
}
return new URLClassLoader(classpath, this.getClass().getClassLoader());
|
protected java.lang.String | findApiBasedService(java.util.jar.JarFile jF)Find the api based service from the jar file.
try {
ZipEntry zE = jF.getEntry(getServiceInterface());
if (zE != null) {
InputStream in = jF.getInputStream(zE);
BufferedReader br = new BufferedReader(
new InputStreamReader(in));
return br.readLine();
}
} catch (Exception e) {
getLogger().log(Level.FINE, e.getMessage(), e);
throw new AddonFatalException(e);
}
return null;
|
protected java.lang.String | findMainClassBasedService(java.util.jar.JarFile jF)Find the main class based service from the jarFile.
try {
Manifest mf = jF.getManifest();
if(mf != null) {
Attributes attrs = mf.getMainAttributes();
if(attrs != null) {
String main = attrs.getValue(Attributes.Name.MAIN_CLASS);
if(main != null) {
return main;
}
}
}
} catch (Exception e) {
throw new AddonFatalException(e);
}
return null;
|
public static AddonConfigurationController | getAddonConfigurationController()Create a controller class for Addon Configuration.
return new AddonConfigurationController();
|
public static AddonInstallationController | getAddonInstallationController()Create a controller class for Addon Installation.
return new AddonInstallationController();
|
protected java.util.HashMap | getApiBasedServices()Return the services that are based on the java api for addons.
return apiBasedServices;
|
java.io.File | getDomainRoot()
return this.domainRoot;
|
protected abstract java.io.FilenameFilter | getFilenameFilter()Each controller use specific naming scheme for the
finding the plugins.
|
protected java.io.File | getInstallRoot()Return the installation root directory.
return this.installRoot;
|
protected synchronized java.util.logging.Logger | getLogger()Return the logger instance used for logging.
if (logger == null) {
return Logger.getAnonymousLogger();
}
return logger;
|
protected java.util.HashMap | getMainClassBasedServices()Return the services that are based on the manifest main class.
return mainClassBasedServices;
|
protected abstract java.lang.String | getName(java.io.File jar)Retrive the name of the addon from the file name.
|
protected abstract java.lang.String | getServiceInterface()Return the service interface name.
|
protected abstract java.io.File | getServiceJarLocation()Return the directory where the plugin jar files
will be kept.
|
protected java.util.HashMap | getSimpleJars()Return the services that are neither api based nor main class
based. These are simple jar files.
return simpleJars;
|
protected void | loadServices(java.io.File jarDir)
/*
* Examine the plugins and load the necessary services.
* The loaded services and their names will be saved in HashMap
* that can be used by others.
*/
if (servicesAreLoaded) {
return;
} else {
servicesAreLoaded = true;
}
try {
File[] jars = jarDir.listFiles(getFilenameFilter());
if (jars == null) return;
for (File jar : jars) {
if (jar != null) {
if (jar.getName().startsWith("grizzly")) {
continue;
} else if (jar.getName().startsWith("freemarker")) {
continue;
} else if (jar.getName().startsWith("wadl2java")) {
continue;
}
}
JarFile jF = new JarFile(jar);
String serviceName = findApiBasedService(jF);
ClassLoader cl = createClassLoader(jar.toURI().toURL());
if (serviceName != null) {
apiBasedServices.put(cl.loadClass
(serviceName).newInstance(), getName(jar));
} else {
String mainClass = findMainClassBasedService(jF);
if (mainClass != null) {
mainClassBasedServices.put(cl.loadClass
(mainClass).newInstance(), getName(jar));
} else {
simpleJars.put(jar, getName(jar));
}
}
}
} catch (AddonFatalException afe) {
throw afe;
}catch (Exception e) {
throw new AddonFatalException(e);
}
|
private void | populateAdminCredentials()
try {
String domainXMLLocation =
(getDomainRoot().getCanonicalPath()) + File.separator +
"config" + File.separator + "domain.xml";
File domainXML=new File(domainXMLLocation);
ConfigContext configContext=ConfigFactory.createConfigContext(
domainXML.getAbsolutePath());
HttpListener as=ServerHelper.getHttpListener(configContext,
"server", ServerHelper.ADMIN_HTTP_LISTNER_ID);
String host="localhost";
int port=Integer.parseInt(as.getPort());
final LoginInfoStore store = LoginInfoStoreFactory.getStore(null);
if (store.exists(host, port)) {
LoginInfo login = store.read(host, port);
adminPassword = login.getPassword();
adminUser = login.getUser();
if (adminUser == null) {
adminUser = DEFAULT_ADMIN_USER;
adminPassword = DEFAULT_ADMIN_PASSWORD;
}
}
} catch (Exception e) {
adminUser = DEFAULT_ADMIN_USER;
adminPassword = DEFAULT_ADMIN_PASSWORD;
getLogger().log(Level.WARNING, e.getMessage(), e);
}
|
public void | setAdminCredentials(com.sun.appserv.addons.ConfigurationContext cc)
if ((adminPassword == null) || (adminPassword.length() < 1)) {
populateAdminCredentials();
}
cc.setAdminUser(adminUser);
cc.setAdminPassword(adminPassword);
|
void | setDomainRoot(java.io.File domainRoot)
this.domainRoot = domainRoot;
|
public void | setInstallRoot(java.io.File installRoot)Set the installation root directory.
this.installRoot = installRoot;
|
public void | setLogger(java.util.logging.Logger logger)Set an appropriate logger.
this.logger = logger;
|