logo       

[cvs] openejb/src/facilities/org/openejb/alt/config Deploy.java: msg#00087

java.openejb.devel

Subject: [cvs] openejb/src/facilities/org/openejb/alt/config Deploy.java

Modified: src/facilities/org/openejb/alt/config Deploy.java
Log:


Added prompt for OQL for cmp entity find and create methods



By Tim Urberg, on 0103/02/22 12:45:59



Revision Changes Path
1.22 +316 -195 openejb/src/facilities/org/openejb/alt/config/Deploy.java

Index: Deploy.java
===================================================================
RCS file:
/cvsroot/openejb/openejb/src/facilities/org/openejb/alt/config/Deploy.java,v
retrieving revision 1.21
retrieving revision 1.22
diff -u -r1.21 -r1.22
--- Deploy.java 28 Dec 2002 19:20:37 -0000 1.21
+++ Deploy.java 22 Feb 2003 20:45:59 -0000 1.22
@@ -40,20 +40,25 @@
*
* Copyright 2001 (C) The OpenEJB Group. All Rights Reserved.
*
- * $Id: Deploy.java,v 1.21 2002/12/28 19:20:37 tim273 Exp $
+ * $Id: Deploy.java,v 1.22 2003/02/22 20:45:59 tim273 Exp $
*/
package org.openejb.alt.config;

import java.io.DataInputStream;
import java.io.InputStream;
import java.io.PrintStream;
+import java.lang.reflect.Method;
import java.net.URL;
+import java.util.List;
import java.util.Properties;
+import java.util.Vector;

import org.openejb.OpenEJBException;
import org.openejb.alt.config.ejb11.EjbDeployment;
import org.openejb.alt.config.ejb11.EjbJar;
+import org.openejb.alt.config.ejb11.MethodParams;
import org.openejb.alt.config.ejb11.OpenejbJar;
+import org.openejb.alt.config.ejb11.QueryMethod;
import org.openejb.alt.config.ejb11.ResourceLink;
import org.openejb.alt.config.ejb11.ResourceRef;
import org.openejb.alt.config.sys.Connector;
@@ -61,7 +66,8 @@
import org.openejb.alt.config.sys.Openejb;
import org.openejb.util.JarUtils;
import org.openejb.util.Messages;
-
+import org.openejb.util.SafeToolkit;
+import org.openejb.util.StringUtilities;

/**
* This class represents a command line tool for deploying beans.
@@ -90,19 +96,22 @@
*/
public class Deploy {

- static protected Messages _messages = new Messages(
"org.openejb.alt.util.resources" );
+ static protected Messages _messages = new
Messages("org.openejb.alt.util.resources");
+
+ private final String DEPLOYMENT_ID_HELP =
+ "\nDeployment ID ----- \n\nA name for the ejb that is unique not only
in this jar, but \nin all the jars in the container system. This name will
\nallow OpenEJB to place the bean in a global index and \nreference the bean
quickly. OpenEJB will also use this name \nas the global JNDI name for the
Remote Server and the Local \nServer. Clients of the Remote or Local servers
can use this\nname to perform JNDI lookups.\n\nThe other EJB Server's using
OpenEJB as the EJB Container \nSystem may also use this name to as part of a
global JNDI \nnamespace available to remote application clients.\n\nExample:
/my/acme/bugsBunnyBean\n\nSee http://openejb.sf.net/deploymentids.html for
details.\n";
+ private final String CONTAINER_ID_HELP =
+ "\nContainer ID ----- \n\nThe name of the container where this ejb
should run. \nContainers are declared and configured in the
openejb.conf\nfile.\n";
+ private final String CONNECTOR_ID_HELP =
+ "\nConnector ID ----- \n\nThe name of the connector or JDBC resource
this resoure \nreference should be mapped to. Connectors and JDBC resources
\nare declared and configured in the openejb.conf file.\n";
+
+ /*=======----------TODO----------=======
+ Neat options that this Deploy tool
+ could support
+
+ Contributions and ideas welcome!!!
+ =======----------TODO----------=======*/

- private final String DEPLOYMENT_ID_HELP = "\nDeployment ID ----- \n\nA
name for the ejb that is unique not only in this jar, but \nin all the jars in
the container system. This name will \nallow OpenEJB to place the bean in a
global index and \nreference the bean quickly. OpenEJB will also use this name
\nas the global JNDI name for the Remote Server and the Local \nServer.
Clients of the Remote or Local servers can use this\nname to perform JNDI
lookups.\n\nThe other EJB Server's using OpenEJB as the EJB Container \nSystem
may also use this name to as part of a global JNDI \nnamespace available to
remote application clients.\n\nExample: /my/acme/bugsBunnyBean\n\nSee
http://openejb.sf.net/deploymentids.html for details.\n";
- private final String CONTAINER_ID_HELP = "\nContainer ID ----- \n\nThe
name of the container where this ejb should run. \nContainers are declared and
configured in the openejb.conf\nfile.\n";
- private final String CONNECTOR_ID_HELP = "\nConnector ID ----- \n\nThe
name of the connector or JDBC resource this resoure \nreference should be
mapped to. Connectors and JDBC resources \nare declared and configured in the
openejb.conf file.\n";
-
- /*=======----------TODO----------=======
- Neat options that this Deploy tool
- could support
-
- Contributions and ideas welcome!!!
- =======----------TODO----------=======*/
-
/**
* Idea for a command line option
*
@@ -113,7 +122,7 @@
* not implemented
*/
private boolean AUTO_ASSIGN;
-
+
/**
* Idea for a command line option
*
@@ -122,7 +131,7 @@
* not implemented
*/
private boolean MOVE_JAR;
-
+
/**
* Idea for a command line option
*
@@ -131,7 +140,7 @@
* not implemented
*/
private boolean FORCE_OVERWRITE_JAR;
-
+
/**
* Idea for a command line option
*
@@ -191,8 +200,7 @@
* not implemented
*/
private boolean GENERATE_DEPLOYMENT_ID;
-
-
+
/**
* Idea for a command line option
*
@@ -216,38 +224,36 @@
/*------------------------------------------------------*/
/* Constructors */
/*------------------------------------------------------*/
- public Deploy() throws OpenEJBException {
- }
+ public Deploy() throws OpenEJBException {}

- public void init(String openejbConfigFile) throws OpenEJBException{
+ public void init(String openejbConfigFile) throws OpenEJBException {
try {
- if( System.getProperty( "openejb.nobanner" ) == null ) {
+ if (System.getProperty("openejb.nobanner") == null) {
printVersion();
System.out.println("");
}
-
-
- in = new DataInputStream(System.in);
+
+ in = new DataInputStream(System.in);
out = System.out;

configFile = openejbConfigFile;
if (configFile == null) {
- try{
+ try {
configFile = System.getProperty("openejb.configuration");
- } catch (Exception e){}
+ } catch (Exception e) {}
}
if (configFile == null) {
configFile = ConfigUtils.searchForConfiguration();
}
config = ConfigUtils.readConfig(configFile);
-
+
/* Load container list */
containers = config.getContainer();

/* Load resource list */
resources = config.getConnector();

- } catch ( Exception e ) {
+ } catch (Exception e) {
// TODO: Better exception handling.
e.printStackTrace();
throw new OpenEJBException(e.getMessage());
@@ -255,42 +261,41 @@

}

-
/*------------------------------------------------------*/
/* Methods for starting the deployment process */
/*------------------------------------------------------*/

- private void deploy(String jarLocation) throws OpenEJBException{
+ private void deploy(String jarLocation) throws OpenEJBException {
EjbValidator validator = new EjbValidator();

- EjbSet set = validator.validateJar( jarLocation );
+ EjbSet set = validator.validateJar(jarLocation);

if (set.hasErrors() || set.hasFailures()) {
- validator.printResults( set );
+ validator.printResults(set);
System.out.println();
- System.out.println("Jar not deployable." );
+ System.out.println("Jar not deployable.");
System.out.println();
- System.out.println("Use the validator for more details" );
+ System.out.println("Use the validator for more details");
return;
}
EjbJar jar = set.getEjbJar();
-
+
OpenejbJar openejbJar = new OpenejbJar();
-
+
Bean[] beans = getBeans(jar);

listBeanNames(beans);

- for ( int i=0; i < beans.length; i++ ) {
- openejbJar.addEjbDeployment(deployBean(beans[i]));
+ for (int i = 0; i < beans.length; i++) {
+ openejbJar.addEjbDeployment(deployBean(beans[i], jarLocation));
}
-
+
if (MOVE_JAR) {
jarLocation = moveJar(jarLocation);
} else if (COPY_JAR) {
jarLocation = copyJar(jarLocation);
}
-
+
/* TODO: Automatically updating the users
config file might not be desireable for
some people. We could make this a
@@ -299,104 +304,197 @@
addDeploymentEntryToConfig(jarLocation);

saveChanges(jarLocation, openejbJar);
-

}

- private EjbDeployment deployBean(Bean bean) throws OpenEJBException{
+ private EjbDeployment deployBean(Bean bean, String jarLocation) throws
OpenEJBException {
EjbDeployment deployment = new EjbDeployment();
+ Class tempBean = SafeToolkit.loadTempClass(bean.getHome(),
jarLocation);


out.println("\n-----------------------------------------------------------");
- out.println("Deploying bean: "+bean.getEjbName());
+ out.println("Deploying bean: " + bean.getEjbName());

out.println("-----------------------------------------------------------");
- deployment.setEjbName( bean.getEjbName() );
-
+ deployment.setEjbName(bean.getEjbName());
+
if (GENERATE_DEPLOYMENT_ID) {
- deployment.setDeploymentId( autoAssignDeploymentId( bean ) );
+ deployment.setDeploymentId(autoAssignDeploymentId(bean));
} else {
- deployment.setDeploymentId( promptForDeploymentId() );
+ deployment.setDeploymentId(promptForDeploymentId());
}

if (AUTO_ASSIGN) {
- deployment.setContainerId( autoAssignContainerId(bean) );
+ deployment.setContainerId(autoAssignContainerId(bean));
} else {
- deployment.setContainerId( promptForContainerId(bean) );
+ deployment.setContainerId(promptForContainerId(bean));
}
-
+
ResourceRef[] refs = bean.getResourceRef();
- if ( refs.length > 0 ) {
+ if (refs.length > 0) {
out.println("\n==--- Step 3 ---==");
out.println("\nThis bean contains the following references to
external \nresources:");

out.println("\nName\t\t\tType\n");

- for ( int i=0; i < refs.length; i++ ) {
- out.print(refs[i].getResRefName()+"\t");
+ for (int i = 0; i < refs.length; i++) {
+ out.print(refs[i].getResRefName() + "\t");
out.println(refs[i].getResType());
}

- out.println("\nThese references must be linked to the available
resources\ndeclared in your config file.");
+ out.println(
+ "\nThese references must be linked to the available
resources\ndeclared in your config file.");

out.println("Available resources are:");
listResources(resources);
- for ( int i=0; i < refs.length; i++ ) {
- deployment.addResourceLink( resolveResourceRef( refs[i] ));
+ for (int i = 0; i < refs.length; i++) {
+ deployment.addResourceLink(resolveResourceRef(refs[i]));
}
}

+ //check for OQL statement
+ if (bean.getType().equals("CMP_ENTITY")) {
+ promptForOQLForEntityBeans(tempBean, deployment);
+ }
+
return deployment;
}

+ private void promptForOQLForEntityBeans(Class bean, EjbDeployment
deployment)
+ throws OpenEJBException {
+ org.openejb.alt.config.ejb11.Query query;
+ QueryMethod queryMethod;
+ MethodParams methodParams;
+ boolean instructionsPrinted = false;
+
+ Method[] methods = bean.getMethods();
+ Class[] parameterList;
+ Class[] exceptionList;
+ List ignoredMethods = new Vector();
+ String answer;
+
+ ignoredMethods.add("remove");
+ ignoredMethods.add("getEJBMetaData");
+ ignoredMethods.add("getHomeHandle");
+ ignoredMethods.add("findByPrimaryKey");
+
+ for (int i = 0; i < methods.length; i++) {
+ if (ignoredMethods.contains(methods[i].getName())) {
+ continue;
+ }
+
+ if (!instructionsPrinted) {
+ out.println("\n==--- Step 4 ---==");
+ out.println(
+ "\nThis part of the application allows you to add OQL
(Object\n"
+ + "Query Language) statements to your methods. Below
is a list\n"
+ + "of methods which you may give an optional OQL
statement. If\n"
+ + "you do not want to add a statement, leave the
prompt blank.\n");
+
+ instructionsPrinted = true;
+ }
+
+ out.print("Method: ");
+ parameterList = methods[i].getParameterTypes();
+ exceptionList = methods[i].getExceptionTypes();
+
+ out.print(methods[i].getName() + "(");
+
+ for (int j = 0; j < parameterList.length; j++) {
+
out.print(StringUtilities.getLastToken(parameterList[j].getName(), "."));
+
+ if (j != (parameterList.length - 1)) {
+ out.print(", ");
+ }
+ }
+ out.print(") ");
+
+ if (exceptionList.length > 0) {
+ out.print("throws ");
+ }
+
+ for (int j = 0; j < exceptionList.length; j++) {
+
out.print(StringUtilities.getLastToken(exceptionList[j].getName(), "."));
+
+ if (j != (exceptionList.length - 1)) {
+ out.print(", ");
+ }
+ }
+
+ out.println();
+
+ try {
+ out.println("Please enter your OQL Statement here.");
+ out.print("\nOQL Statement: ");
+ answer = in.readLine();
+ } catch (Exception e) {
+ throw new OpenEJBException(e.getMessage());
+ }
+
+ //create a new query and add it to the deployment
+ if (answer != null && !answer.equals("")) {
+ query = new org.openejb.alt.config.ejb11.Query();
+ methodParams = new MethodParams();
+ queryMethod = new QueryMethod();
+
+ queryMethod.setMethodParams(methodParams);
+ queryMethod.setMethodName(methods[i].getName());
+ query.setQueryMethod(queryMethod);
+ query.setObjectQl(answer);
+
+ deployment.addQuery(query);
+
+ out.println("\nYour OQL statement was successfully added to
the jar.\n");
+ }
+ }
+ }

/*------------------------------------------------------*/
/* Methods for deployment id mapping */
/*------------------------------------------------------*/
private void listBeanNames(Bean[] beans) {
out.println("This jar contains the following beans:");
- for ( int i=0; i < beans.length; i++ ) {
- out.println(" "+beans[i].getEjbName());
+ for (int i = 0; i < beans.length; i++) {
+ out.println(" " + beans[i].getEjbName());
}
out.println();
}

- private String promptForDeploymentId() throws OpenEJBException{
+ private String promptForDeploymentId() throws OpenEJBException {
String answer = null;
try {
boolean replied = false;
out.println("\n==--- Step 1 ---==");
out.println("\nPlease specify a deployment id for this bean.");

- while ( !replied ) {
+ while (!replied) {
out.println("Type the id or -help for more information.");
out.print("\nDeployment ID: ");
- answer = in.readLine();
- if ( "-help".equals( answer ) ) {
+ answer = in.readLine();
+ if ("-help".equals(answer)) {
out.println(DEPLOYMENT_ID_HELP);
- } else if ( answer.length() > 0 ) {
+ } else if (answer.length() > 0) {
replied = true;
}
}
- } catch ( Exception e ) {
+ } catch (Exception e) {
throw new OpenEJBException(e.getMessage());
}
return answer;
}

- private String autoAssignDeploymentId(Bean bean) throws OpenEJBException{
+ private String autoAssignDeploymentId(Bean bean) throws OpenEJBException {
String answer = bean.getEjbName();
out.println("\n==--- Step 1 ---==");
out.println("\nAuto assigning the ejb-name as the deployment id for
this bean.");
- out.print("\nDeployment ID: "+answer);
+ out.print("\nDeployment ID: " + answer);

return answer;
}

-
/*------------------------------------------------------*/
/* Methods for container mapping */
/*------------------------------------------------------*/

- private String promptForContainerId(Bean bean) throws OpenEJBException{
+ private String promptForContainerId(Bean bean) throws OpenEJBException {
String answer = null;
boolean replied = false;
out.println("\n==--- Step 2 ---==");
@@ -405,7 +503,7 @@

Container[] cs = getUsableContainers(bean);

- if ( cs.length == 0 ) {
+ if (cs.length == 0) {
/* TODO: Allow or Automatically create a useable container
* Stopping the deployment process because there is no
* container of the right bean type is a terrible way
@@ -415,10 +513,18 @@
* 2) Allow them to create their own container.
* 3) Some combination of 1 and 2.
*/
- out.println("!! There are no "+bean.getType()+" containers
declared in "+configFile+" !!");
- out.println("A "+bean.getType()+" container must be declared and
\nconfigured in your configuration file before this jar can\nbe deployed.");
+ out.println(
+ "!! There are no "
+ + bean.getType()
+ + " containers declared in "
+ + configFile
+ + " !!");
+ out.println(
+ "A "
+ + bean.getType()
+ + " container must be declared and \nconfigured in your
configuration file before this jar can\nbe deployed.");
System.exit(-1);
- } else if ( cs.length == 0 ) {
+ } else if (cs.length == 0) {
/* TODO: Automatically assign the bean to the container
* Since this is the only container in the system that
* can service this bean type, either
@@ -431,35 +537,36 @@
int choice = 0;
try {

- while ( !replied ) {
- out.println("\nType the number of the container\n-options to
view the list again\nor -help for more information.");
+ while (!replied) {
+ out.println(
+ "\nType the number of the container\n-options to view the
list again\nor -help for more information.");
out.print("\nContainer: ");
- answer = in.readLine();
- if ( "-help".equals( answer ) ) {
+ answer = in.readLine();
+ if ("-help".equals(answer)) {
out.println(CONTAINER_ID_HELP);
- } else if ( "-options".equals( answer ) ) {
+ } else if ("-options".equals(answer)) {
listContainers(cs);
- } else if ( answer.length() > 0 ) {
+ } else if (answer.length() > 0) {
try {
choice = Integer.parseInt(answer);
- } catch ( NumberFormatException nfe ) {
- out.println("\'"+answer+"\' is not a numer.");
+ } catch (NumberFormatException nfe) {
+ out.println("\'" + answer + "\' is not a numer.");
continue;
}
- if ( choice > cs.length || choice < 1 ) {
- out.println(choice+" is not an option.");
+ if (choice > cs.length || choice < 1) {
+ out.println(choice + " is not an option.");
continue;
}
replied = true;
}
}
- } catch ( Exception e ) {
+ } catch (Exception e) {
throw new OpenEJBException(e.getMessage());
}
- return cs[choice-1].getId();
+ return cs[choice - 1].getId();
}

- private String autoAssignContainerId(Bean bean) throws OpenEJBException{
+ private String autoAssignContainerId(Bean bean) throws OpenEJBException {
String answer = null;
boolean replied = false;
out.println("\n==--- Step 2 ---==");
@@ -467,7 +574,7 @@

Container[] cs = getUsableContainers(bean);

- if ( cs.length == 0 ) {
+ if (cs.length == 0) {
/* TODO: Allow or Automatically create a useable container
* Stopping the deployment process because there is no
* container of the right bean type is a terrible way
@@ -477,45 +584,53 @@
* 2) Allow them to create their own container.
* 3) Some combination of 1 and 2.
*/
- out.println("!! There are no "+bean.getType()+" containers
declared in "+configFile+" !!");
- out.println("A "+bean.getType()+" container must be declared and
\nconfigured in your configuration file before this jar can\nbe deployed.");
+ out.println(
+ "!! There are no "
+ + bean.getType()
+ + " containers declared in "
+ + configFile
+ + " !!");
+ out.println(
+ "A "
+ + bean.getType()
+ + " container must be declared and \nconfigured in your
configuration file before this jar can\nbe deployed.");
System.exit(-1);
}
-
- out.println("\nContainer: "+cs[0].getId());
+
+ out.println("\nContainer: " + cs[0].getId());
return cs[0].getId();
}

private void listContainers(Container[] containers) {
out.println("\nNum \tType \tID\n");

- for ( int i=0; i < containers.length; i++ ) {
- out.print((i+1)+"\t");
- out.print(containers[i].getCtype()+"\t");
+ for (int i = 0; i < containers.length; i++) {
+ out.print((i + 1) + "\t");
+ out.print(containers[i].getCtype() + "\t");
out.println(containers[i].getId());
}
}

-
/*------------------------------------------------------*/
/* Methods for connection(resource) mapping */
/*------------------------------------------------------*/
- private ResourceLink resolveResourceRef(ResourceRef ref) throws
OpenEJBException{
+ private ResourceLink resolveResourceRef(ResourceRef ref) throws
OpenEJBException {
String answer = null;
boolean replied = false;

- out.println("\nPlease link reference: "+ref.getResRefName());
+ out.println("\nPlease link reference: " + ref.getResRefName());

- if ( resources.length == 0 ) {
+ if (resources.length == 0) {
/* TODO: 1, 2 or 3
* 1) Automatically create a connector and link the reference to
it.
* 2) Something more creative
* 3) Some ultra flexible combination of 1 and 2.
*/
- out.println("!! There are no resources declared in "+configFile+"
!!");
- out.println("A resource connector must be declared and configured
in \nyour configuration file before this jar can be deployed.");
+ out.println("!! There are no resources declared in " + configFile
+ " !!");
+ out.println(
+ "A resource connector must be declared and configured in
\nyour configuration file before this jar can be deployed.");
System.exit(-2);
- } else if ( resources.length == 0 ) {
+ } else if (resources.length == 0) {
/* TODO: 1, 2 or 3
* 1) Automatically link the reference to the connector
* 2) Something more creative
@@ -525,88 +640,88 @@

int choice = 0;
try {
- while ( !replied ) {
- out.println("\nType the number of the resource to link the
bean's \nreference to, -options to view the list again, or -help\nfor more
information.");
+ while (!replied) {
+ out.println(
+ "\nType the number of the resource to link the bean's
\nreference to, -options to view the list again, or -help\nfor more
information.");
out.print("\nResource: ");
- answer = in.readLine();
- if ( "-help".equals( answer ) ) {
+ answer = in.readLine();
+ if ("-help".equals(answer)) {
out.println(CONNECTOR_ID_HELP);
- } else if ( "-options".equals( answer ) ) {
+ } else if ("-options".equals(answer)) {
listResources(resources);
- } else if ( answer.length() > 0 ) {
+ } else if (answer.length() > 0) {
try {
choice = Integer.parseInt(answer);
- } catch ( NumberFormatException nfe ) {
- out.println("\'"+answer+"\' is not a numer.");
+ } catch (NumberFormatException nfe) {
+ out.println("\'" + answer + "\' is not a number.");
continue;
}
- if ( choice > resources.length || choice < 1 ) {
- out.println(choice+" is not an option.");
+ if (choice > resources.length || choice < 1) {
+ out.println(choice + " is not an option.");
continue;
}
replied = true;
}
}
- } catch ( Exception e ) {
+ } catch (Exception e) {
throw new OpenEJBException(e.getMessage());
}

ResourceLink link = new ResourceLink();
- link.setResRefName( ref.getResRefName() );
- link.setResId(resources[choice-1].getId());
+ link.setResRefName(ref.getResRefName());
+ link.setResId(resources[choice - 1].getId());
return link;
}

private void listResources(Connector[] connectors) {
out.println("\nNum \tID\n");

- for ( int i=0; i < connectors.length; i++ ) {
- out.print((i+1)+"\t");
+ for (int i = 0; i < connectors.length; i++) {
+ out.print((i + 1) + "\t");
out.println(connectors[i].getId());
}
}

-
-
- private void saveChanges(String jarFile, OpenejbJar openejbJar) throws
OpenEJBException{
+ private void saveChanges(String jarFile, OpenejbJar openejbJar) throws
OpenEJBException {

out.println("\n-----------------------------------------------------------");
out.println("Done collecting deployment information!");
-
+
out.print("Creating the openejb-jar.xml file...");
ConfigUtils.writeOpenejbJar("META-INF/openejb-jar.xml", openejbJar);
-
+
out.println("done");

out.print("Writing openejb-jar.xml to the jar...");
JarUtils.addFileToJar(jarFile, "META-INF/openejb-jar.xml");
-
+
out.println("done");
-
+
if (configChanged) {
out.print("Updating your system config...");
- ConfigUtils.writeConfig(configFile,config);
-
+ ConfigUtils.writeConfig(configFile, config);
+
out.println("done");
}

out.println("\nCongratulations! Your jar is ready to use with
OpenEJB.");
- out.println("\nIf the OpenEJB remote server is already running, you
will\nneed to restart it in order for OpenEJB to recognize your bean.");
- out.println("\nNOTE: If you move or rename your jar file, you will
have to\nupdate the path in this jar's deployment entry in your \nOpenEJB
config file.");
+ out.println(
+ "\nIf the OpenEJB remote server is already running, you will\nneed
to restart it in order for OpenEJB to recognize your bean.");
+ out.println(
+ "\nNOTE: If you move or rename your jar file, you will have
to\nupdate the path in this jar's deployment entry in your \nOpenEJB config
file.");

}

-
/*------------------------------------------------------*/
/* Methods for exception handling */
/*------------------------------------------------------*/
- private void logException(String m) throws OpenEJBException{
- System.out.println("[OpenEJB] "+m);
+ private void logException(String m) throws OpenEJBException {
+ System.out.println("[OpenEJB] " + m);
throw new OpenEJBException(m);
}

- private void logException(String m, Exception e) throws OpenEJBException{
- m += " : "+e.getMessage();
- System.out.println("[OpenEJB] "+m);
+ private void logException(String m, Exception e) throws OpenEJBException {
+ m += " : " + e.getMessage();
+ System.out.println("[OpenEJB] " + m);
//e.printStackTrace();
throw new OpenEJBException(m);
}
@@ -616,10 +731,10 @@
/*------------------------------------------------------*/

public static void main(String args[]) {
- try{
+ try {
org.openejb.util.ClasspathUtils.addJarsToPath("lib");
org.openejb.util.ClasspathUtils.addJarsToPath("dist");
- } catch (Exception e){
+ } catch (Exception e) {
e.printStackTrace();
}
try {
@@ -629,47 +744,47 @@
printHelp();
return;
}
-
- for (int i=0; i < args.length; i++){
+
+ for (int i = 0; i < args.length; i++) {
//AUTODEPLOY
- if (args[i].equals("-a")){
+ if (args[i].equals("-a")) {
d.AUTO_ASSIGN = true;
d.GENERATE_DEPLOYMENT_ID = true;
- } else if (args[i].equals("-m")){
+ } else if (args[i].equals("-m")) {
d.MOVE_JAR = true;
- } else if (args[i].equals("-f")){
+ } else if (args[i].equals("-f")) {
d.FORCE_OVERWRITE_JAR = true;
- } else if (args[i].equals("-c")){
+ } else if (args[i].equals("-c")) {
d.COPY_JAR = true;
- } else if (args[i].equals("-C")){
+ } else if (args[i].equals("-C")) {
d.AUTO_ASSIGN = true;
- } else if (args[i].equals("-D")){
+ } else if (args[i].equals("-D")) {
d.GENERATE_DEPLOYMENT_ID = true;
- } else if (args[i].equals("-conf")){
- if (args.length > i+1 ) {
+ } else if (args[i].equals("-conf")) {
+ if (args.length > i + 1) {
System.setProperty("openejb.configuration", args[++i]);
}
- } else if (args[i].equals("-l")){
- if (args.length > i+1 ) {
+ } else if (args[i].equals("-l")) {
+ if (args.length > i + 1) {
System.setProperty("log4j.configuration", args[++i]);
}
- } else if (args[i].equals("-d")){
- if (args.length > i+1 ) {
+ } else if (args[i].equals("-d")) {
+ if (args.length > i + 1) {
System.setProperty("openejb.home", args[++i]);
}
- } else if (args[i].equals("-help")){
+ } else if (args[i].equals("-help")) {
printHelp();
- } else if (args[i].equals("-examples")){
+ } else if (args[i].equals("-examples")) {
printExamples();
- } else if (args[i].equals("-version")){
+ } else if (args[i].equals("-version")) {
printVersion();
} else {
// We must have reached the jar list
d.init(null);
- for (; i < args.length; i++){
- try{
- d.deploy( args[i] );
- } catch (Exception e){
+ for (; i < args.length; i++) {
+ try {
+ d.deploy(args[i]);
+ } catch (Exception e) {
System.out.print("\nERROR in ");
System.out.println(args[i]);
System.out.println(e.getMessage());
@@ -677,8 +792,8 @@
}
}
}
-
- } catch ( Exception e ) {
+
+ } catch (Exception e) {
System.out.println(e.getMessage());
//e.printStackTrace();
}
@@ -692,37 +807,43 @@

try {
JarUtils.setHandlerSystemProperty();
- versionInfo.load( new URL( "resource:/openejb-version.properties"
).openConnection().getInputStream() );
- } catch (java.io.IOException e) {
- }
-
- System.out.println( "OpenEJB Deploy Tool " + versionInfo.get(
"version" ) +" build: "+versionInfo.get( "date" )+"-"+versionInfo.get(
"time" ));
- System.out.println( "" + versionInfo.get( "url" ) );
+ versionInfo.load(
+ new
URL("resource:/openejb-version.properties").openConnection().getInputStream());
+ } catch (java.io.IOException e) {}
+
+ System.out.println(
+ "OpenEJB Deploy Tool "
+ + versionInfo.get("version")
+ + " build: "
+ + versionInfo.get("date")
+ + "-"
+ + versionInfo.get("time"));
+ System.out.println("" + versionInfo.get("url"));
}
-
+
private static void printHelp() {
String header = "OpenEJB Deploy Tool ";
try {
JarUtils.setHandlerSystemProperty();
Properties versionInfo = new Properties();
- versionInfo.load( new URL( "resource:/openejb-version.properties"
).openConnection().getInputStream() );
- header += versionInfo.get( "version" );
- } catch (java.io.IOException e) {
- }
-
- System.out.println( header );
-
+ versionInfo.load(
+ new
URL("resource:/openejb-version.properties").openConnection().getInputStream());
+ header += versionInfo.get("version");
+ } catch (java.io.IOException e) {}
+
+ System.out.println(header);
+
// Internationalize this
try {
- InputStream in = new URL( "resource:/openejb/deploy.txt"
).openConnection().getInputStream();
+ InputStream in =
+ new
URL("resource:/openejb/deploy.txt").openConnection().getInputStream();

int b = in.read();
while (b != -1) {
- System.out.write( b );
+ System.out.write(b);
b = in.read();
}
- } catch (java.io.IOException e) {
- }
+ } catch (java.io.IOException e) {}
}

private static void printExamples() {
@@ -730,46 +851,46 @@
try {
JarUtils.setHandlerSystemProperty();
Properties versionInfo = new Properties();
- versionInfo.load( new URL( "resource:/openejb-version.properties"
).openConnection().getInputStream() );
- header += versionInfo.get( "version" );
- } catch (java.io.IOException e) {
- }
-
- System.out.println( header );
-
+ versionInfo.load(
+ new
URL("resource:/openejb-version.properties").openConnection().getInputStream());
+ header += versionInfo.get("version");
+ } catch (java.io.IOException e) {}
+
+ System.out.println(header);
+
// Internationalize this
try {
- InputStream in = new URL( "resource:/openejb/deploy-examples.txt"
).openConnection().getInputStream();
+ InputStream in =
+ new
URL("resource:/openejb/deploy-examples.txt").openConnection().getInputStream();

int b = in.read();
while (b != -1) {
- System.out.write( b );
+ System.out.write(b);
b = in.read();
}
- } catch (java.io.IOException e) {
- }
+ } catch (java.io.IOException e) {}
}

/*------------------------------------------------------*/
/* Refactored Methods */
/*------------------------------------------------------*/
private Bean[] getBeans(EjbJar jar) {
- return EjbJarUtils.getBeans( jar );
+ return EjbJarUtils.getBeans(jar);
}

- private String moveJar(String jar) throws OpenEJBException{
- return EjbJarUtils.moveJar(jar, FORCE_OVERWRITE_JAR );
+ private String moveJar(String jar) throws OpenEJBException {
+ return EjbJarUtils.moveJar(jar, FORCE_OVERWRITE_JAR);
}

- private String copyJar(String jar) throws OpenEJBException{
- return EjbJarUtils.copyJar(jar, FORCE_OVERWRITE_JAR );
+ private String copyJar(String jar) throws OpenEJBException {
+ return EjbJarUtils.copyJar(jar, FORCE_OVERWRITE_JAR);
}

private Container[] getUsableContainers(Bean bean) {
return EjbJarUtils.getUsableContainers(containers, bean);
}

- private void addDeploymentEntryToConfig(String jarLocation){
- configChanged = ConfigUtils.addDeploymentEntryToConfig(jarLocation,
config );
+ private void addDeploymentEntryToConfig(String jarLocation) {
+ configChanged = ConfigUtils.addDeploymentEntryToConfig(jarLocation,
config);
}
}





-------------------------------------------------------
This SF.net email is sponsored by: SlickEdit Inc. Develop an edge.
The most comprehensive and flexible code editor you can use.
Code faster. C/C++, C#, Java, HTML, XML, many more. FREE 30-Day Trial.
www.slickedit.com/sourceforge
_______________________________________________
http://OpenEJB.sf.net
OpenEJB-development mailing list
OpenEJB-development@xxxxxxxxxxxxxxxxxxxxx
https://lists.sourceforge.net/lists/listinfo/openejb-development



<Prev in Thread] Current Thread [Next in Thread>
Google Custom Search

News | FAQ | advertise