use of org.apache.openejb.assembler.Deployer in project tomee by apache.
the class TomEEContainer method lookupDeployerWithRetry.
protected Deployer lookupDeployerWithRetry(final int retry) throws NamingException {
try {
final Properties properties = new Properties();
properties.setProperty(Context.INITIAL_CONTEXT_FACTORY, "org.apache.openejb.client.RemoteInitialContextFactory");
properties.setProperty(Context.PROVIDER_URL, providerUrl());
return (Deployer) new InitialContext(properties).lookup("openejb/DeployerBusinessRemote");
} catch (final RuntimeException ne) {
// surely "org.apache.openejb.client.ClientRuntimeException: Invalid response from server: -1"
if (retry > 1) {
try {
// wait a bit before retrying
Thread.sleep(200);
} catch (final InterruptedException ignored) {
// no-op
}
return lookupDeployerWithRetry(retry - 1);
}
if (Boolean.getBoolean("openejb.arquillian.debug") && retry >= 0) {
try {
// wait a lot to be sure that's not a timing issue
Thread.sleep(10000);
} catch (final InterruptedException ignored) {
// no-op
}
return lookupDeployerWithRetry(-1);
}
throw ne;
}
}
use of org.apache.openejb.assembler.Deployer in project tomee by apache.
the class JMXDeployer method deployer.
private static Deployer deployer() throws NamingException {
final Properties p = new Properties();
p.setProperty(Context.INITIAL_CONTEXT_FACTORY, LocalInitialContextFactory.class.getName());
final ClassLoader oldCl = Thread.currentThread().getContextClassLoader();
Thread.currentThread().setContextClassLoader(DeployerEjb.class.getClassLoader());
try {
return (Deployer) new InitialContext(p).lookup("openejb/DeployerBusinessRemote");
} finally {
Thread.currentThread().setContextClassLoader(oldCl);
}
}
use of org.apache.openejb.assembler.Deployer in project tomee by apache.
the class DeployMojo method execute.
@Override
public void execute() throws MojoExecutionException, MojoFailureException {
final Deployer deployer = (Deployer) lookup("openejb/DeployerBusinessRemote");
if ((!"localhost".equals(tomeeHost) && !tomeeHost.startsWith("127.")) || useBinaries) {
final ByteArrayOutputStream baos = new ByteArrayOutputStream();
final byte[] archive;
FileInputStream fis = null;
try {
fis = new FileInputStream(path);
IO.copy(fis, baos);
archive = baos.toByteArray();
} catch (final Exception e) {
throw new TomEEException(e.getMessage(), e);
} finally {
IO.close(fis);
IO.close(baos);
}
try {
final Properties prop = new Properties();
prop.putAll(systemVariables);
prop.put(DeployerEjb.OPENEJB_USE_BINARIES, "true");
prop.put(DeployerEjb.OPENEJB_PATH_BINARIES, new File(path).getName());
prop.put(DeployerEjb.OPENEJB_VALUE_BINARIES, archive);
deployer.deploy(path, prop);
} catch (final OpenEJBException e) {
throw new TomEEException(e.getMessage(), e);
}
} else {
try {
if (systemVariables.isEmpty()) {
deployer.deploy(path);
} else {
final Properties prop = new Properties();
prop.putAll(systemVariables);
deployer.deploy(path, prop);
}
} catch (final OpenEJBException e) {
throw new TomEEException(e.getMessage(), e);
}
}
}
use of org.apache.openejb.assembler.Deployer in project tomee by apache.
the class ListEjbMojo method execute.
@Override
public void execute() throws MojoExecutionException, MojoFailureException {
final Deployer deployer = (Deployer) lookup("openejb/DeployerBusinessRemote");
final Collection<AppInfo> infos = deployer.getDeployedApps();
final Lines lines = new Lines();
lines.add(new Line("Name", "Class", "Interface Type", "Bean Type"));
for (final AppInfo info : infos) {
for (final EjbJarInfo ejbJar : info.ejbJars) {
for (final EnterpriseBeanInfo bean : ejbJar.enterpriseBeans) {
lines.add(new Line(bean.ejbDeploymentId, bean.ejbClass, getType(bean), componentType(bean)));
}
}
}
lines.print(new LogPrinterStream(getLog()));
}
use of org.apache.openejb.assembler.Deployer in project tomee by apache.
the class UnDeployMojo method execute.
@Override
public void execute() throws MojoExecutionException, MojoFailureException {
final Deployer deployer = (Deployer) lookup("openejb/DeployerBusinessRemote");
try {
final Collection<AppInfo> apps = deployer.getDeployedApps();
final Collection<String> paths = new ArrayList<String>(apps.size());
for (final AppInfo info : apps) {
paths.add(info.path);
}
if (paths.contains(path)) {
// exact matching
deployer.undeploy(path);
} else {
for (final String proposed : paths) {
// exact matching + extension
if (path.equals(proposed + ".war") || path.equals(proposed + ".ear") || path.equals(proposed + ".jar")) {
deployer.undeploy(proposed);
return;
}
}
for (final String proposed : paths) {
// just the app/folder name
if (proposed.endsWith("/" + path) || proposed.endsWith("\\" + path)) {
deployer.undeploy(proposed);
return;
}
}
}
} catch (final OpenEJBException e) {
throw new TomEEException(e.getMessage(), e);
}
}
Aggregations