org.beigesoft.android.ajetty.FactoryAppBeansAndroid Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of a-jetty Show documentation
Show all versions of a-jetty Show documentation
A-Jetty for Android. It is Jetty 9.2 adapted for Android
configured as minimum server with WebAppDeployer that can deploy ordinal WAR (JSP/JSTL must be pre-compiled into servlets by A-Tomcat).
It's only for tests purposes. It doesn't comply to the latest Android policy (loading executable binaries from outside)!
package org.beigesoft.android.ajetty;
/*
* Copyright (c) 2016 Beigesoft ™
*
* Licensed under the GNU General Public License (GPL), Version 2.0
* (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.gnu.org/licenses/old-licenses/gpl-2.0.en.html
*/
import android.content.Context;
import org.beigesoft.afactory.IFactoryAppBeans;
/**
* Factory app-beans for standart Java.
*
* @author Yury Demidenko
*/
public class FactoryAppBeansAndroid implements IFactoryAppBeans {
/**
* Factory of WebAppClassLoaderAndroid.
**/
private FactoryWebAppClassLoaderAndroid factoryWebAppClassLoaderAndroid;
/**
* Android context.
**/
private final Context context;
/**
* Setter for context.
* @param pContext reference
**/
public FactoryAppBeansAndroid(final Context pContext) {
this.context = pContext;
}
/**
* Get bean in lazy mode (if bean is null then initialize it).
* @param pBeanName - bean name
* @return Object - requested bean
* @throws Exception - an exception
*/
@Override
public final synchronized Object lazyGet(
final String pBeanName) throws Exception {
if ("IFactoryParam"
.equals(pBeanName)) {
return lazyGetFactoryWebAppClassLoaderAndroid();
}
throw new Exception("There is no bean: " + pBeanName);
}
/**
* Getter for factoryWebAppClassLoaderAndroid.
* @return FactoryWebAppClassLoaderAndroid
**/
public final FactoryWebAppClassLoaderAndroid
lazyGetFactoryWebAppClassLoaderAndroid() {
if (this.factoryWebAppClassLoaderAndroid == null) {
this.factoryWebAppClassLoaderAndroid =
new FactoryWebAppClassLoaderAndroid(this.context);
}
return this.factoryWebAppClassLoaderAndroid;
}
}