summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristian Campo2008-02-12 08:09:44 (EST)
committerChristian Campo2008-02-12 08:09:44 (EST)
commitaf3ae7d5308b62ca262f7fcf9daf933d190e5295 (patch)
treede5518c7c98c23d1891635d1716d8230d2aca3d9
parent047b3d931cc60ceeac0c705ced6e7809235399fd (diff)
downloadorg.eclipse.riena-af3ae7d5308b62ca262f7fcf9daf933d190e5295.zip
org.eclipse.riena-af3ae7d5308b62ca262f7fcf9daf933d190e5295.tar.gz
org.eclipse.riena-af3ae7d5308b62ca262f7fcf9daf933d190e5295.tar.bz2
replaced System.out with Logging calls
-rw-r--r--org.eclipse.riena.core/src/org/eclipse/riena/internal/core/Activator.java12
-rw-r--r--org.eclipse.riena.core/src/org/eclipse/riena/internal/core/config/ConfigProxy.java131
-rw-r--r--org.eclipse.riena.security.common/src/org/eclipse/riena/security/common/authorization/RienaPolicy.java34
3 files changed, 97 insertions, 80 deletions
diff --git a/org.eclipse.riena.core/src/org/eclipse/riena/internal/core/Activator.java b/org.eclipse.riena.core/src/org/eclipse/riena/internal/core/Activator.java
index f1b7fe2..f1670d9 100644
--- a/org.eclipse.riena.core/src/org/eclipse/riena/internal/core/Activator.java
+++ b/org.eclipse.riena.core/src/org/eclipse/riena/internal/core/Activator.java
@@ -24,6 +24,7 @@ import org.osgi.framework.Constants;
import org.osgi.framework.ServiceRegistration;
import org.osgi.service.cm.ConfigurationPlugin;
import org.osgi.service.cm.ManagedService;
+import org.osgi.service.log.LogService;
public class Activator extends Plugin {
@@ -46,6 +47,7 @@ public class Activator extends Plugin {
super.start(context);
plugin = this;
CONTEXT = context;
+ Logger LOGGER = getLogger(Activator.class.getName());
Bundle[] bundles = context.getBundles();
for (Bundle bundle : bundles) {
@@ -59,18 +61,18 @@ public class Activator extends Plugin {
// TODO STARTING == LAZY, so start that also, STARTING is
// disabled, bundles with forceStart should not be LAZY
if (bundle.getState() == Bundle.RESOLVED/*
- * || bundle.getState() ==
- * Bundle.STARTING
- */) {
+ * || bundle.getState() ==
+ * Bundle.STARTING
+ */) {
bundle.start();
- System.out.println(bundle.getSymbolicName() + " forced autostart successfully");
+ LOGGER.log(LogService.LOG_INFO, bundle.getSymbolicName() + " forced autostart successfully");
} else {
if (bundle.getState() == Bundle.INSTALLED) {
System.err.println(bundle.getSymbolicName()
+ " has Riena-ForceStart but is only in state INSTALLED (not RESOLVED).");
} else {
if (bundle.getState() == Bundle.ACTIVE) {
- System.out.println(bundle.getSymbolicName()
+ LOGGER.log(LogService.LOG_INFO, bundle.getSymbolicName()
+ " no forced autostart. Bundle is already ACTIVE.");
}
}
diff --git a/org.eclipse.riena.core/src/org/eclipse/riena/internal/core/config/ConfigProxy.java b/org.eclipse.riena.core/src/org/eclipse/riena/internal/core/config/ConfigProxy.java
index 6ddf423..f61fb79 100644
--- a/org.eclipse.riena.core/src/org/eclipse/riena/internal/core/config/ConfigProxy.java
+++ b/org.eclipse.riena.core/src/org/eclipse/riena/internal/core/config/ConfigProxy.java
@@ -16,78 +16,83 @@ import java.util.Dictionary;
import java.util.Enumeration;
import java.util.HashMap;
+import org.eclipse.equinox.log.Logger;
+import org.eclipse.riena.internal.core.Activator;
import org.osgi.framework.Constants;
import org.osgi.service.cm.ConfigurationException;
import org.osgi.service.cm.ManagedService;
+import org.osgi.service.log.LogService;
/**
- * This class makes configuration a regular Java POJO easier. Its used by ConfigUtility and is instantiated for each
- * Java POJO instance that should be wrapped. It translates configuration properties from ConfigAdmin into setter calls
- * of the underlying Java POJO.
+ * This class makes configuration a regular Java POJO easier. Its used by
+ * ConfigUtility and is instantiated for each Java POJO instance that should be
+ * wrapped. It translates configuration properties from ConfigAdmin into setter
+ * calls of the underlying Java POJO.
*
*/
public class ConfigProxy implements ManagedService {
- private Object bObject;
- private HashMap<String, Method> methods;
+ private Object bObject;
+ private HashMap<String, Method> methods;
+ private Logger LOGGER = Activator.getDefault().getLogger(ConfigProxy.class.getName());
- /**
- * standard constructor that takes the object to wrap as parameter
- *
- * @param bObject
- */
- public ConfigProxy(Object bObject) {
- this.bObject = bObject;
- methods = new HashMap<String, Method>();
- for (Method method : bObject.getClass().getMethods()) {
- if (method.getName().startsWith("set")) {
- methods.put(method.getName(), method);
- }
- }
- }
+ /**
+ * standard constructor that takes the object to wrap as parameter
+ *
+ * @param bObject
+ */
+ public ConfigProxy(Object bObject) {
+ this.bObject = bObject;
+ methods = new HashMap<String, Method>();
+ for (Method method : bObject.getClass().getMethods()) {
+ if (method.getName().startsWith("set")) {
+ methods.put(method.getName(), method);
+ }
+ }
+ }
- /*
- * (non-Javadoc)
- *
- * @see org.osgi.service.cm.ManagedService#updated(java.util.Dictionary)
- */
- public void updated(Dictionary properties) throws ConfigurationException {
- if (properties == null) {
- return;
- }
- Enumeration<?> eKeys = properties.keys();
- while (eKeys.hasMoreElements()) {
- Object oKey = eKeys.nextElement();
- if (oKey instanceof String) {
- String key = (String) oKey;
- if (key.equals(Constants.SERVICE_PID)) {
- continue;
- }
- if (key.contains(".")) {
- System.out.println("skipping " + key);
- continue;
- }
- Object oValue = properties.get(key);
- String methodName = "set" + key.substring(0, 1).toUpperCase() + key.substring(1);
- Method m = methods.get(methodName);
- System.out.println(methodName + " :" + oValue + " ... " + System.currentTimeMillis());
- try {
- if (m != null) {
- m.invoke(bObject, oValue);
- } else {
- System.out.println("method does not exist");
- }
- } catch (IllegalArgumentException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- } catch (IllegalAccessException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- } catch (InvocationTargetException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- }
- }
- }
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.osgi.service.cm.ManagedService#updated(java.util.Dictionary)
+ */
+ public void updated(Dictionary properties) throws ConfigurationException {
+ if (properties == null) {
+ return;
+ }
+ Enumeration<?> eKeys = properties.keys();
+ while (eKeys.hasMoreElements()) {
+ Object oKey = eKeys.nextElement();
+ if (oKey instanceof String) {
+ String key = (String) oKey;
+ if (key.equals(Constants.SERVICE_PID)) {
+ continue;
+ }
+ if (key.contains(".")) {
+ LOGGER.log(LogService.LOG_WARNING, "skipping " + key);
+ continue;
+ }
+ Object oValue = properties.get(key);
+ String methodName = "set" + key.substring(0, 1).toUpperCase() + key.substring(1);
+ Method m = methods.get(methodName);
+ LOGGER.log(LogService.LOG_DEBUG, methodName + " :" + oValue + " ... " + System.currentTimeMillis());
+ try {
+ if (m != null) {
+ m.invoke(bObject, oValue);
+ } else {
+ LOGGER.log(LogService.LOG_WARNING, "method" + m.getName() + "does not exist");
+ }
+ } catch (IllegalArgumentException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ } catch (IllegalAccessException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ } catch (InvocationTargetException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ }
+ }
+ }
} \ No newline at end of file
diff --git a/org.eclipse.riena.security.common/src/org/eclipse/riena/security/common/authorization/RienaPolicy.java b/org.eclipse.riena.security.common/src/org/eclipse/riena/security/common/authorization/RienaPolicy.java
index 21a6876..c84c36e 100644
--- a/org.eclipse.riena.security.common/src/org/eclipse/riena/security/common/authorization/RienaPolicy.java
+++ b/org.eclipse.riena.security.common/src/org/eclipse/riena/security/common/authorization/RienaPolicy.java
@@ -20,8 +20,10 @@ import java.security.Policy;
import java.security.Principal;
import java.security.ProtectionDomain;
+import org.eclipse.equinox.log.Logger;
import org.eclipse.riena.core.service.ServiceInjector;
import org.eclipse.riena.internal.security.common.Activator;
+import org.osgi.service.log.LogService;
import sun.security.provider.PolicyFile;
@@ -32,10 +34,12 @@ public class RienaPolicy extends Policy {
private static Policy defaultPolicy;
private IPermissionCache permCache;
+ private Logger LOGGER = Activator.getDefault().getLogger(RienaPolicy.class.getName());
public RienaPolicy() {
super();
- new ServiceInjector(Activator.getContext(), IPermissionCache.ID, this, "bindPermCache", "unbindPermCache").start();
+ new ServiceInjector(Activator.getContext(), IPermissionCache.ID, this, "bindPermCache", "unbindPermCache")
+ .start();
}
public void bindPermCache(IPermissionCache permCache) {
@@ -58,7 +62,8 @@ public class RienaPolicy extends Policy {
if (true)
return;
try {
- Class<?> clz = RienaPolicy.class.getClassLoader().getSystemClassLoader().loadClass("org.eclipse.riena.security.common.policyproxy.PolicyProxy");
+ Class<?> clz = RienaPolicy.class.getClassLoader().getSystemClassLoader().loadClass(
+ "org.eclipse.riena.security.common.policyproxy.PolicyProxy");
Method method = clz.getMethod("setRealPolicy", Policy.class);
method.invoke(clz, rp);
} catch (ClassNotFoundException e) {
@@ -91,7 +96,8 @@ public class RienaPolicy extends Policy {
*/
@Override
public PermissionCollection getPermissions(CodeSource codesource) {
- System.out.println("rienapolicy: codesource: getPermissions codesource=" + codesource.getLocation());
+ LOGGER.log(LogService.LOG_DEBUG, "rienapolicy: codesource: getPermissions codesource="
+ + codesource.getLocation());
return null;
}
@@ -102,19 +108,21 @@ public class RienaPolicy extends Policy {
*/
@Override
public void refresh() {
- System.out.println("rienapolicy: refresh");
+ LOGGER.log(LogService.LOG_DEBUG, "rienapolicy: refresh");
}
@Override
public PermissionCollection getPermissions(ProtectionDomain domain) {
- System.out.println("rienapolicy: domain: getPermissions domain=" + domain.getCodeSource().getLocation());
+ LOGGER.log(LogService.LOG_DEBUG, "rienapolicy: domain: getPermissions domain="
+ + domain.getCodeSource().getLocation());
return super.getPermissions(domain);
}
@Override
public boolean implies(ProtectionDomain domain, Permission permission) {
- System.out.print("(Y)");
- if (/* permission instanceof AuthPermission && */domain.getCodeSource().getLocation().toString().contains("/org.eclipse.riena.security.common/")) {
+ // System.out.print("(Y)");
+ if (/* permission instanceof AuthPermission && */domain.getCodeSource().getLocation().toString().contains(
+ "/org.eclipse.riena.security.common/")) {
return true;
}
@@ -122,17 +130,18 @@ public class RienaPolicy extends Policy {
if (domain.getPrincipals() == null || domain.getPrincipals().length == 0) {
boolean result = defaultPolicy.implies(domain, permission);
if (!result) {
- System.err.println("no right to do " + permission + " for " + domain.getCodeSource().getLocation() + " no principal");
+ LOGGER.log(LogService.LOG_WARNING, "no right to do " + permission + " for "
+ + domain.getCodeSource().getLocation() + " no principal");
}
return result;
}
// this branch is entered if there is at least one principal
- System.out.print("rienapolicy: implies ");
+ LOGGER.log(LogService.LOG_DEBUG, "rienapolicy: implies ");
for (Principal p : domain.getPrincipals()) {
- System.out.print(p);
+ LOGGER.log(LogService.LOG_DEBUG, p.toString());
}
- System.out.println(" " + permission);
+ LOGGER.log(LogService.LOG_DEBUG, " " + permission);
boolean result;
if (permCache == null) {
result = defaultPolicy.implies(domain, permission);
@@ -145,7 +154,8 @@ public class RienaPolicy extends Policy {
}
}
if (!result) {
- System.err.println("no right to do " + permission + " for " + domain.getCodeSource().getLocation() + " with principal");
+ LOGGER.log(LogService.LOG_ERROR, "no right to do " + permission + " for "
+ + domain.getCodeSource().getLocation() + " with principal");
}
return result;
}