You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@directory.apache.org by er...@apache.org on 2005/08/31 16:54:37 UTC
svn commit: r265057 - in /directory/sandbox/trunk/osgi-core/trunk:
jmx/src/main/java/org/apache/jmx/ launcher/src/main/java/org/apache/launcher/
loader/src/main/java/org/apache/ldap/server/loader/
network/src/main/java/org/apache/mina/
Author: erodriguez
Date: Wed Aug 31 07:54:29 2005
New Revision: 265057
URL: http://svn.apache.org/viewcvs?rev=265057&view=rev
Log:
Formatting: imports, line breaks, whitespace, or other code convention.
Modified:
directory/sandbox/trunk/osgi-core/trunk/jmx/src/main/java/org/apache/jmx/JmxLogger.java
directory/sandbox/trunk/osgi-core/trunk/jmx/src/main/java/org/apache/jmx/JmxLoggerMBean.java
directory/sandbox/trunk/osgi-core/trunk/launcher/src/main/java/org/apache/launcher/Launcher.java
directory/sandbox/trunk/osgi-core/trunk/loader/src/main/java/org/apache/ldap/server/loader/Activator.java
directory/sandbox/trunk/osgi-core/trunk/loader/src/main/java/org/apache/ldap/server/loader/LdifFileLoader.java
directory/sandbox/trunk/osgi-core/trunk/network/src/main/java/org/apache/mina/Activator.java
Modified: directory/sandbox/trunk/osgi-core/trunk/jmx/src/main/java/org/apache/jmx/JmxLogger.java
URL: http://svn.apache.org/viewcvs/directory/sandbox/trunk/osgi-core/trunk/jmx/src/main/java/org/apache/jmx/JmxLogger.java?rev=265057&r1=265056&r2=265057&view=diff
==============================================================================
--- directory/sandbox/trunk/osgi-core/trunk/jmx/src/main/java/org/apache/jmx/JmxLogger.java (original)
+++ directory/sandbox/trunk/osgi-core/trunk/jmx/src/main/java/org/apache/jmx/JmxLogger.java Wed Aug 31 07:54:29 2005
@@ -25,15 +25,14 @@
import org.osgi.framework.BundleException;
import org.osgi.framework.ServiceReference;
-
public class JmxLogger implements BundleActivator, JmxLoggerMBean
{
private ObjectName osgiName = null;
-
+
public void start( BundleContext context ) throws Exception
{
ServiceReference sr = context.getServiceReference( MBeanServer.class.getName() );
-
+
if ( sr != null )
{
MBeanServer server = (MBeanServer) context.getService( sr );
@@ -45,31 +44,30 @@
throw new BundleException( "No JMX Agent" );
}
}
-
+
public void stop( BundleContext context )
{
ServiceReference sr = context.getServiceReference( MBeanServer.class.getName() );
-
+
if ( sr != null )
{
MBeanServer server = (MBeanServer) context.getService( sr );
-
+
try
{
server.unregisterMBean( osgiName );
}
- catch (Exception e)
+ catch ( Exception e )
{
e.printStackTrace();
}
}
-
+
osgiName = null;
}
-
+
public void log()
{
System.out.println( "JMX Logger says SUCCESS." );
}
}
-
Modified: directory/sandbox/trunk/osgi-core/trunk/jmx/src/main/java/org/apache/jmx/JmxLoggerMBean.java
URL: http://svn.apache.org/viewcvs/directory/sandbox/trunk/osgi-core/trunk/jmx/src/main/java/org/apache/jmx/JmxLoggerMBean.java?rev=265057&r1=265056&r2=265057&view=diff
==============================================================================
--- directory/sandbox/trunk/osgi-core/trunk/jmx/src/main/java/org/apache/jmx/JmxLoggerMBean.java (original)
+++ directory/sandbox/trunk/osgi-core/trunk/jmx/src/main/java/org/apache/jmx/JmxLoggerMBean.java Wed Aug 31 07:54:29 2005
@@ -17,9 +17,7 @@
package org.apache.jmx;
-
public interface JmxLoggerMBean
{
public void log();
}
-
Modified: directory/sandbox/trunk/osgi-core/trunk/launcher/src/main/java/org/apache/launcher/Launcher.java
URL: http://svn.apache.org/viewcvs/directory/sandbox/trunk/osgi-core/trunk/launcher/src/main/java/org/apache/launcher/Launcher.java?rev=265057&r1=265056&r2=265057&view=diff
==============================================================================
--- directory/sandbox/trunk/osgi-core/trunk/launcher/src/main/java/org/apache/launcher/Launcher.java (original)
+++ directory/sandbox/trunk/osgi-core/trunk/launcher/src/main/java/org/apache/launcher/Launcher.java Wed Aug 31 07:54:29 2005
@@ -34,19 +34,15 @@
{
/** Description of the Field */
private final static String DFLT_HOME_KEY = "launcher.home";
- private final static String DFLT_PROFILE = "launcher";
-
+ private final static String DFLT_PROFILE = "launcher";
+
/** Array of launchable program "names", together with classes which contain their main methods */
- private static String[] launchables = {
- "app1", "app2", "app3", "app4"
- };
-
- private static String[] mainClasses = {
- "com.myco.app1", "com.myco.app2", "com.myco.app3", "com.myco.app4"
- };
-
+ private static String[] launchables = { "app1", "app2", "app3", "app4" };
+
+ private static String[] mainClasses = { "com.myco.app1", "com.myco.app2", "com.myco.app3", "com.myco.app4" };
+
private static String launcherHome = "";
-
+
/**
* The main program for the VtLauncher class.
*
@@ -60,29 +56,26 @@
}
launcherHome = System.getProperty( DFLT_HOME_KEY );
- if ( launcherHome == null )
+ if ( launcherHome == null )
{
- throw new IllegalArgumentException ( "launcher.home not set" );
+ throw new IllegalArgumentException( "launcher.home not set" );
}
// add properties for log4j.root and vtalk.root for those programs
// that need it
String sp = File.separator;
String p = File.pathSeparator;
- System.setProperty( "log4j.root",
- launcherHome + sp + "lib" + sp + "log4j.jar" );
- System.setProperty( "vtalk.root",
- launcherHome + sp + "lib" + sp + "vt.jar" + p +
- launcherHome + sp + "lib" + sp + "userlib.jar" + p +
- launcherHome + sp + "lib" + sp + "comms.jar" + p +
- launcherHome + sp + "lib" + sp + "osgi.jar" );
+ System.setProperty( "log4j.root", launcherHome + sp + "lib" + sp + "log4j.jar" );
+ System.setProperty( "vtalk.root", launcherHome + sp + "lib" + sp + "vt.jar" + p + launcherHome + sp + "lib"
+ + sp + "userlib.jar" + p + launcherHome + sp + "lib" + sp + "comms.jar" + p + launcherHome + sp + "lib"
+ + sp + "osgi.jar" );
// Set the SAX driver property for XMLRPC to be the Piccolo driver.
// Its slightly more compliant than the default one (MinML) supplied
// with apache-xmlrpc but is slightly slower. Piccolo handles String
// that are set to all spaces, MinML compresses these to empty strings.
// Piccolo is available from http://piccolo.sourceforge.net/.
- String saxDriver = System.getProperty("sax.driver");
+ String saxDriver = System.getProperty( "sax.driver" );
if ( ( saxDriver != null ) && ( saxDriver.trim().length() > 0 ) )
{
// Property passed through to the XML-RPC code XMLRpc.java
@@ -90,41 +83,41 @@
else
{
// Set the driver to piccolo
- System.setProperty( "sax.driver","com.bluecast.xml.Piccolo" );
+ System.setProperty( "sax.driver", "com.bluecast.xml.Piccolo" );
}
-
+
// Strip off launch target name from args
String launchTarget = argv[ 0 ];
- String[] launchArgs = new String[ argv.length-1 ];
- System.arraycopy( argv, 1, launchArgs, 0, argv.length-1 );
-
+ String[] launchArgs = new String[ argv.length - 1 ];
+ System.arraycopy( argv, 1, launchArgs, 0, argv.length - 1 );
+
try
{
if ( launchTarget.equals( "launcher " ) )
{
launchVtmp( launchArgs );
}
- else if ( launchTarget.startsWith( "vwin" ) )
- {
- launchVwin( launchTarget, launchArgs );
- }
else
- {
- launchProg( launchTarget, launchArgs, null );
- }
+ if ( launchTarget.startsWith( "vwin" ) )
+ {
+ launchVwin( launchTarget, launchArgs );
+ }
+ else
+ {
+ launchProg( launchTarget, launchArgs, null );
+ }
}
- catch (Exception e)
+ catch ( Exception e )
{
System.err.println( "Error launching: " + launchTarget + "," + e );
e.printStackTrace( System.err );
}
}
-
- private static void addJarURLs( List list, File dir )
- throws Exception
+
+ private static void addJarURLs( List list, File dir ) throws Exception
{
File[] all = dir.listFiles();
-
+
for ( int ix = 0; ix < all.length; ix++ )
{
// ick, sure there's a better way to do this
@@ -134,33 +127,31 @@
}
}
}
-
- private static ClassLoader createClassLoader()
- throws Exception
+
+ private static ClassLoader createClassLoader() throws Exception
{
//TODO: consider making this use/load encrypted class files
List urlList = new ArrayList();
addJarURLs( urlList, new File( launcherHome + File.separator + "bin" ) );
addJarURLs( urlList, new File( launcherHome + File.separator + "lib" ) );
-
+
// see if we can find tools.jar (used by VCOMP)
File javaHome = new File( System.getProperty( "java.home" ) );
File toolsJar = new File( javaHome, "lib" + File.separator + "tools.jar" );
-
+
if ( !toolsJar.exists() )
{
toolsJar = new File( javaHome.getParent(), "lib" + File.separator + "tools.jar" );
}
//TODO: should we put out warning if not found?
urlList.add( toolsJar.toURL() );
-
+
URL[] urls = (URL[]) urlList.toArray( new URL[ 0 ] );
return new URLClassLoader( urls );
}
-
- private static void deleteOscarHome( String profile )
- throws IOException
+
+ private static void deleteOscarHome( String profile ) throws IOException
{
StringBuffer temp = new StringBuffer( 10 );
@@ -169,7 +160,7 @@
temp.append( ".oscar" + File.separator + profile );
File oscarHome = new File( home, temp.toString() );
-
+
Launcher.deleteFiles( oscarHome );
}
@@ -179,17 +170,16 @@
* @param file root of files to delete
* @exception IOException Exception on delete
*/
- private static void deleteFiles( File file )
- throws IOException
+ private static void deleteFiles( File file ) throws IOException
{
File[] list = null;
int idx = 0;
-
- if ( ! file.exists() )
+
+ if ( !file.exists() )
{
return;
}
-
+
if ( file.isDirectory() )
{
list = file.listFiles();
@@ -217,21 +207,20 @@
*
* @param argv The command line arguments
*/
- private static void launchVtmp( String[] argv )
- throws Exception
+ private static void launchVtmp( String[] argv ) throws Exception
{
String profile = DFLT_PROFILE;
if ( argv.length > 0 )
{
- profile = new String( argv[0] );
+ profile = new String( argv[ 0 ] );
}
-
+
// always assume coldstart for now
- try
+ try
{
Launcher.deleteOscarHome( profile );
- }
- catch (IOException e)
+ }
+ catch ( IOException e )
{
System.out.println( "Error removing bundle cache : " + e );
//System.exit(-1);
@@ -240,20 +229,19 @@
// use same name for properties files and oscar profile
launchOscar( profile, profile, true );
}
-
+
/**
* Launcher for the VWIN.
*
* @param argv The command line arguments
*/
- private static void launchVwin( String target, String[] argv )
- throws Exception
+ private static void launchVwin( String target, String[] argv ) throws Exception
{
boolean coldstart = true;
String clientConfig = null;
-
+
int i = 0;
-
+
while ( i < argv.length )
{
if ( argv[ i ].compareToIgnoreCase( "warmstart" ) == 0 )
@@ -264,23 +252,25 @@
{
clientConfig = argv[ i ];
File clientConfigFile = new File( clientConfig );
- try {
+ try
+ {
File dir = clientConfigFile.getParentFile();
- if ( dir != null && ! dir.exists() )
+ if ( dir != null && !dir.exists() )
{
dir.mkdirs();
}
-
+
clientConfigFile.createNewFile();
// Setup the property so that VWIN uses the
// specified client config
System.setProperty( "launcher.ui.vwin.property_file", clientConfigFile.getAbsolutePath() );
- } catch (Exception e)
+ }
+ catch ( Exception e )
{
System.err.println( "Error accessing client config file " + clientConfigFile + " : " + e );
return;
}
-
+
}
i++;
}
@@ -291,14 +281,14 @@
boolean profileInUse = false;
if ( coldstart )
{
- do
- {
- try
+ do
+ {
+ try
{
Launcher.deleteOscarHome( profile );
profileInUse = false;
- }
- catch (IOException e)
+ }
+ catch ( IOException e )
{
profileInUse = true;
profile = target + "o" + profileOccurence;
@@ -308,9 +298,10 @@
System.out.println( "Error starting profile: " + target + " : " + e );
return;
}
-
+
}
- } while ( profileInUse );
+ }
+ while ( profileInUse );
}
launchOscar( target, profile, false );
@@ -319,22 +310,19 @@
/**
* Launcher for Oscar
*/
- private static void launchOscar( String propsName, String profile, boolean embedded )
- throws Exception
+ private static void launchOscar( String propsName, String profile, boolean embedded ) throws Exception
{
- String sysProps = launcherHome + File.separator + "etc" + File.separator
- + propsName + ".system.properties";
- String bundleProps = launcherHome + File.separator + "etc" + File.separator
- + propsName + ".bundle.properties";
-
+ String sysProps = launcherHome + File.separator + "etc" + File.separator + propsName + ".system.properties";
+ String bundleProps = launcherHome + File.separator + "etc" + File.separator + propsName + ".bundle.properties";
+
// used for 1.0.2+ versions of Oscar
System.setProperty( "oscar.cache.profile", profile );
- System.setProperty( "oscar.system.properties", sysProps );
+ System.setProperty( "oscar.system.properties", sysProps );
System.setProperty( "oscar.bundle.properties", bundleProps );
- System.setProperty( "oscar.strict.osgi","false" );
+ System.setProperty( "oscar.strict.osgi", "false" );
System.setProperty( "oscar.embedded.execution", embedded ? "true" : "false" );
-
- Oscar main = new Oscar();
+
+ Oscar main = new Oscar();
}
/**
@@ -342,20 +330,19 @@
*
* @param argv The command line arguments
*/
- private static void launchProg( String target, String[] argv, ClassLoader loader )
- throws Exception
+ private static void launchProg( String target, String[] argv, ClassLoader loader ) throws Exception
{
//TODO: include debug detect/defeat code
if ( loader == null )
{
loader = createClassLoader();
}
-
+
// for sax, xerces etc.
Thread.currentThread().setContextClassLoader( loader );
-
+
Class cls = null;
-
+
if ( target.equals( "custom" ) )
{
// use -D specified main class
@@ -372,7 +359,7 @@
}
}
}
-
+
if ( cls != null )
{
// launch the program's main method
@@ -380,8 +367,7 @@
entry.invoke( null, new Object[] { argv } );
return;
}
-
+
throw new ClassNotFoundException( "main class for " + target );
}
}
-
Modified: directory/sandbox/trunk/osgi-core/trunk/loader/src/main/java/org/apache/ldap/server/loader/Activator.java
URL: http://svn.apache.org/viewcvs/directory/sandbox/trunk/osgi-core/trunk/loader/src/main/java/org/apache/ldap/server/loader/Activator.java?rev=265057&r1=265056&r2=265057&view=diff
==============================================================================
--- directory/sandbox/trunk/osgi-core/trunk/loader/src/main/java/org/apache/ldap/server/loader/Activator.java (original)
+++ directory/sandbox/trunk/osgi-core/trunk/loader/src/main/java/org/apache/ldap/server/loader/Activator.java Wed Aug 31 07:54:29 2005
@@ -35,7 +35,7 @@
{
private LdapContext ctx;
private LdifFileLoader loader;
-
+
/**
* Implements BundleActivator.start().
* Logs that this service is starting and starts this service.
@@ -44,26 +44,26 @@
public void start( BundleContext context ) throws BundleException
{
System.out.println( "Starting Apache Load Command." );
-
+
ServiceReference storeReference = context.getServiceReference( InitialContextFactory.class.getName() );
-
+
InitialContextFactory factory = (InitialContextFactory) context.getService( storeReference );
-
+
Hashtable env = new Hashtable( new LoaderConfiguration().toJndiEnvironment() );
loadEnvironment( env );
-
+
try
{
- ctx = ( LdapContext ) factory.getInitialContext( env );
+ ctx = (LdapContext) factory.getInitialContext( env );
}
- catch (NamingException ne)
+ catch ( NamingException ne )
{
throw new BundleException( "Unable to create initial context.", ne );
}
-
+
context.registerService( Command.class.getName(), this, new Properties() );
}
-
+
/**
* Implements BundleActivator.stop(). Logs that this service has stopped.
* @param context the framework context for the bundle.
@@ -71,32 +71,32 @@
public void stop( BundleContext context )
{
System.out.println( "Stopping Apache Load Command." );
-
+
loader = null;
}
-
- public String getName()
+
+ public String getName()
{
return "load";
}
-
- public String getUsage()
+
+ public String getUsage()
{
return "load <path>";
}
-
- public String getShortDescription()
+
+ public String getShortDescription()
{
return "Load LDIF entries into the embedded directory backing store.";
}
-
- public void execute( String line, PrintStream out, PrintStream err )
+
+ public void execute( String line, PrintStream out, PrintStream err )
{
String[] components = line.split( "\\s" );
-
+
if ( components.length > 1 )
{
- loader = new LdifFileLoader( ctx, components[1] );
+ loader = new LdifFileLoader( ctx, components[ 1 ] );
loader.execute();
}
else
@@ -104,7 +104,7 @@
System.out.println( "Incorrect number of arguments: load <path>" );
}
}
-
+
private void loadEnvironment( Hashtable env )
{
env.put( "java.naming.provider.url", "dc=example,dc=com" );
Modified: directory/sandbox/trunk/osgi-core/trunk/loader/src/main/java/org/apache/ldap/server/loader/LdifFileLoader.java
URL: http://svn.apache.org/viewcvs/directory/sandbox/trunk/osgi-core/trunk/loader/src/main/java/org/apache/ldap/server/loader/LdifFileLoader.java?rev=265057&r1=265056&r2=265057&view=diff
==============================================================================
--- directory/sandbox/trunk/osgi-core/trunk/loader/src/main/java/org/apache/ldap/server/loader/LdifFileLoader.java (original)
+++ directory/sandbox/trunk/osgi-core/trunk/loader/src/main/java/org/apache/ldap/server/loader/LdifFileLoader.java Wed Aug 31 07:54:29 2005
@@ -48,7 +48,7 @@
{
/** a handle on the top initial context: get new context from this */
protected LdapContext ctx;
-
+
protected String ldifPath;
/**
@@ -59,10 +59,10 @@
*/
public LdifFileLoader( LdapContext ctx, String ldifPath )
{
- this.ctx = ctx;
+ this.ctx = ctx;
this.ldifPath = ldifPath;
}
-
+
/**
* Opens the LDIF file and loads the entries into the context.
*/
@@ -80,23 +80,23 @@
while ( iterator.hasNext() )
{
- String ldif = ( String ) iterator.next();
+ String ldif = (String) iterator.next();
Attributes attributes = new LockableAttributesImpl();
ldifParser.parse( attributes, ldif );
- String dn = ( String ) attributes.remove( "dn" ).get();
+ String dn = (String) attributes.remove( "dn" ).get();
if ( attributes.get( "objectClass" ).contains( "krb5KDCEntry" ) )
{
- String pw = ( String ) attributes.get( "userpassword" ).get();
+ String pw = (String) attributes.get( "userpassword" ).get();
- String krbPrincipal = ( String ) attributes.get( KerberosAttribute.PRINCIPAL ).get();
+ String krbPrincipal = (String) attributes.get( KerberosAttribute.PRINCIPAL ).get();
KerberosPrincipal principal = new KerberosPrincipal( krbPrincipal );
- KerberosKey key = new KerberosKey( principal, pw.toCharArray(), "DES" ) ;
+ KerberosKey key = new KerberosKey( principal, pw.toCharArray(), "DES" );
byte[] encodedKey = key.getEncoded();
@@ -116,7 +116,7 @@
System.err.println( "succeeded on looked up of " + rdn + " will not create" );
}
- catch( Exception e )
+ catch ( Exception e )
{
System.err.println( "creating " + rdn );
@@ -126,10 +126,10 @@
}
}
}
- catch( Exception e )
+ catch ( Exception e )
{
String msg = "Failed to import LDIF into backing store.";
-
+
throw new NestableRuntimeException( msg, e );
}
@@ -143,13 +143,13 @@
while ( iterator.hasNext() )
{
- String ldif = ( String ) iterator.next();
+ String ldif = (String) iterator.next();
Attributes attributes = new LockableAttributesImpl();
ldifParser.parse( attributes, ldif );
- String dn = ( String ) attributes.remove( "dn" ).get();
+ String dn = (String) attributes.remove( "dn" ).get();
rdn = getRelativeName( ctx, dn );
@@ -157,7 +157,7 @@
Object stored = ctx.lookup( rdn );
- System.err.println( "looked up " + rdn + " and found " + stored );
+ System.err.println( "looked up " + rdn + " and found " + stored );
if ( stored == null )
{
@@ -167,14 +167,14 @@
}
}
}
- catch( Exception e )
+ catch ( Exception e )
{
e.printStackTrace();
System.err.println( "failed to find " + rdn );
String msg = "Failed to import LDIF into backing store.";
-
+
throw new NestableRuntimeException( msg, e );
}
}
@@ -199,7 +199,7 @@
return rdn;
}
-
+
/**
* Tries to find an LDIF file either on the file system or packaged within a jar.
*
Modified: directory/sandbox/trunk/osgi-core/trunk/network/src/main/java/org/apache/mina/Activator.java
URL: http://svn.apache.org/viewcvs/directory/sandbox/trunk/osgi-core/trunk/network/src/main/java/org/apache/mina/Activator.java?rev=265057&r1=265056&r2=265057&view=diff
==============================================================================
--- directory/sandbox/trunk/osgi-core/trunk/network/src/main/java/org/apache/mina/Activator.java (original)
+++ directory/sandbox/trunk/osgi-core/trunk/network/src/main/java/org/apache/mina/Activator.java Wed Aug 31 07:54:29 2005
@@ -43,8 +43,7 @@
registry = new SimpleServiceRegistry();
Dictionary parameters = new Hashtable();
- registration = context.registerService( ServiceRegistry.class.getName(), registry,
- parameters );
+ registration = context.registerService( ServiceRegistry.class.getName(), registry, parameters );
}
/**